Commit 8f0ab471 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[ia32,x64] Make more use of the 'leave' instruction

It is a little shorter and cheaper[1] than the equivalent
"mov sp,bp; pop bp".

Also remove support for the 'enter' instruction, since
- it is unused,
- it is neither shorter nor cheaper than the corresponding
  push and mov (in fact more expensive[1]), and
- our disassembler doesn't support it.

[1] See https://www.agner.org/optimize/instruction_tables.pdf

Change-Id: I6c99c2f3e53081aea55445a54e18eaf45baa79c2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2482822
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70660}
parent 949025df
......@@ -510,13 +510,6 @@ void Assembler::pop(Operand dst) {
emit_operand(eax, dst);
}
void Assembler::enter(const Immediate& size) {
EnsureSpace ensure_space(this);
EMIT(0xC8);
emit_w(size);
EMIT(0);
}
void Assembler::leave() {
EnsureSpace ensure_space(this);
EMIT(0xC9);
......
......@@ -474,7 +474,6 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
void pop(Register dst);
void pop(Operand dst);
void enter(const Immediate& size);
void leave();
// Moves
......
......@@ -975,9 +975,7 @@ void MacroAssembler::LeaveExitFrameEpilogue() {
}
void MacroAssembler::LeaveApiExitFrame() {
mov(esp, ebp);
pop(ebp);
leave();
LeaveExitFrameEpilogue();
}
......
......@@ -1207,13 +1207,6 @@ void Assembler::decb(Operand dst) {
emit_operand(1, dst);
}
void Assembler::enter(Immediate size) {
EnsureSpace ensure_space(this);
emit(0xC8);
emitw(size.value_); // 16 bit operand, always.
emit(0);
}
void Assembler::hlt() {
EnsureSpace ensure_space(this);
emit(0xF4);
......
......@@ -561,7 +561,6 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
void popq(Register dst);
void popq(Operand dst);
void enter(Immediate size);
void leave();
// Moves
......
......@@ -2488,8 +2488,7 @@ void TurboAssembler::LeaveFrame(StackFrame::Type type) {
Immediate(StackFrame::TypeToMarker(type)));
Check(equal, AbortReason::kStackFrameTypesMustMatch);
}
movq(rsp, rbp);
popq(rbp);
leave();
}
#ifdef V8_TARGET_OS_WIN
......@@ -2641,9 +2640,7 @@ void MacroAssembler::LeaveExitFrame(bool save_doubles, bool pop_arguments) {
}
void MacroAssembler::LeaveApiExitFrame() {
movq(rsp, rbp);
popq(rbp);
leave();
LeaveExitFrameEpilogue();
}
......
......@@ -509,10 +509,7 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
} \
} while (false)
void CodeGenerator::AssembleDeconstructFrame() {
__ mov(esp, ebp);
__ pop(ebp);
}
void CodeGenerator::AssembleDeconstructFrame() { __ leave(); }
void CodeGenerator::AssemblePrepareTailCall() {
if (frame_access_state()->has_frame()) {
......
......@@ -681,8 +681,7 @@ void EmitWordLoadPoisoningIfNeeded(CodeGenerator* codegen,
void CodeGenerator::AssembleDeconstructFrame() {
unwinding_info_writer_.MarkFrameDeconstructed(__ pc_offset());
__ movq(rsp, rbp);
__ popq(rbp);
__ leave();
}
void CodeGenerator::AssemblePrepareTailCall() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment