Index: src/x64/builtins-x64.cc |
diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc |
index 59811cf9d11c99c7f6058f0619968e10d4b0f4f9..9fbade7733a6a33af5dfde09bac750d1662a1dfd 100644 |
--- a/src/x64/builtins-x64.cc |
+++ b/src/x64/builtins-x64.cc |
@@ -699,22 +699,9 @@ |
__ movp(rbx, Operand(kInterpreterDispatchTableRegister, rbx, |
times_pointer_size, 0)); |
__ call(rbx); |
- masm->isolate()->heap()->SetInterpreterEntryReturnPCOffset(masm->pc_offset()); |
- |
- // The return value is in rax. |
- |
- // Get the arguments + reciever count. |
- __ movp(rbx, Operand(rbp, InterpreterFrameConstants::kBytecodeArrayFromFp)); |
- __ movl(rbx, FieldOperand(rbx, BytecodeArray::kParameterSizeOffset)); |
- |
- // Leave the frame (also dropping the register file). |
- __ leave(); |
- |
- // Drop receiver + arguments and return. |
- __ PopReturnAddressTo(rcx); |
- __ addp(rsp, rbx); |
- __ PushReturnAddressFrom(rcx); |
- __ ret(0); |
+ |
+ // Even though the first bytecode handler was called, we will never return. |
+ __ Abort(kUnexpectedReturnFromBytecodeHandler); |
// Load debug copy of the bytecode array. |
__ bind(&load_debug_bytecode_array); |
@@ -737,6 +724,23 @@ |
__ jmp(rcx); |
} |
+ |
+void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { |
+ // The return value is in accumulator, which is already in rax. |
+ |
+ // Leave the frame (also dropping the register file). |
+ __ leave(); |
+ |
+ // Drop receiver + arguments and return. |
+ __ movl(rbx, FieldOperand(kInterpreterBytecodeArrayRegister, |
+ BytecodeArray::kParameterSizeOffset)); |
+ __ PopReturnAddressTo(rcx); |
+ __ addp(rsp, rbx); |
+ __ PushReturnAddressFrom(rcx); |
+ __ ret(0); |
+} |
+ |
+ |
static void Generate_InterpreterPushArgs(MacroAssembler* masm, |
bool push_receiver) { |
// ----------- S t a t e ------------- |
@@ -767,6 +771,7 @@ |
__ j(greater, &loop_header, Label::kNear); |
} |
+ |
// static |
void Builtins::Generate_InterpreterPushArgsAndCallImpl( |
MacroAssembler* masm, TailCallMode tail_call_mode) { |
@@ -789,6 +794,7 @@ |
tail_call_mode), |
RelocInfo::CODE_TARGET); |
} |
+ |
// static |
void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { |
@@ -817,17 +823,8 @@ |
__ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
} |
-void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { |
- // Set the return address to the correct point in the interpreter entry |
- // trampoline. |
- Smi* interpreter_entry_return_pc_offset( |
- masm->isolate()->heap()->interpreter_entry_return_pc_offset()); |
- DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); |
- __ Move(rbx, masm->isolate()->builtins()->InterpreterEntryTrampoline()); |
- __ addp(rbx, Immediate(interpreter_entry_return_pc_offset->value() + |
- Code::kHeaderSize - kHeapObjectTag)); |
- __ Push(rbx); |
- |
+ |
+static void Generate_EnterBytecodeDispatch(MacroAssembler* masm) { |
// Initialize dispatch table register. |
__ Move( |
kInterpreterDispatchTableRegister, |
@@ -858,6 +855,58 @@ |
times_pointer_size, 0)); |
__ jmp(rbx); |
} |
+ |
+ |
+static void Generate_InterpreterNotifyDeoptimizedHelper( |
+ MacroAssembler* masm, Deoptimizer::BailoutType type) { |
+ // Enter an internal frame. |
+ { |
+ FrameScope scope(masm, StackFrame::INTERNAL); |
+ |
+ // Pass the deoptimization type to the runtime system. |
+ __ Push(Smi::FromInt(static_cast<int>(type))); |
+ __ CallRuntime(Runtime::kNotifyDeoptimized); |
+ // Tear down internal frame. |
+ } |
+ |
+ // Drop state (we don't use these for interpreter deopts) and and pop the |
+ // accumulator value into the accumulator register and push PC at top |
+ // of stack (to simulate initial call to bytecode handler in interpreter entry |
+ // trampoline). |
+ __ Pop(rbx); |
+ __ Drop(1); |
+ __ Pop(kInterpreterAccumulatorRegister); |
+ __ Push(rbx); |
+ |
+ // Enter the bytecode dispatch. |
+ Generate_EnterBytecodeDispatch(masm); |
+} |
+ |
+ |
+void Builtins::Generate_InterpreterNotifyDeoptimized(MacroAssembler* masm) { |
+ Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::EAGER); |
+} |
+ |
+ |
+void Builtins::Generate_InterpreterNotifySoftDeoptimized(MacroAssembler* masm) { |
+ Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); |
+} |
+ |
+ |
+void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) { |
+ Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); |
+} |
+ |
+void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { |
+ // Set the address of the interpreter entry trampoline as a return address. |
+ // This simulates the initial call to bytecode handlers in interpreter entry |
+ // trampoline. The return will never actually be taken, but our stack walker |
+ // uses this address to determine whether a frame is interpreted. |
+ __ Push(masm->isolate()->builtins()->InterpreterEntryTrampoline()); |
+ |
+ Generate_EnterBytecodeDispatch(masm); |
+} |
+ |
void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
// ----------- S t a t e ------------- |
@@ -1132,16 +1181,13 @@ |
// Switch on the state. |
Label not_no_registers, not_tos_rax; |
- __ cmpp(kScratchRegister, |
- Immediate(static_cast<int>(Deoptimizer::BailoutState::NO_REGISTERS))); |
+ __ cmpp(kScratchRegister, Immediate(FullCodeGenerator::NO_REGISTERS)); |
__ j(not_equal, ¬_no_registers, Label::kNear); |
__ ret(1 * kPointerSize); // Remove state. |
__ bind(¬_no_registers); |
- DCHECK_EQ(kInterpreterAccumulatorRegister.code(), rax.code()); |
__ movp(rax, Operand(rsp, kPCOnStackSize + kPointerSize)); |
- __ cmpp(kScratchRegister, |
- Immediate(static_cast<int>(Deoptimizer::BailoutState::TOS_REGISTER))); |
+ __ cmpp(kScratchRegister, Immediate(FullCodeGenerator::TOS_REG)); |
__ j(not_equal, ¬_tos_rax, Label::kNear); |
__ ret(2 * kPointerSize); // Remove state, rax. |