Index: src/x64/builtins-x64.cc |
diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc |
index 858ee3372222b578e2e606a60d68827f7ce79b61..6876be71ddce78d4cd3b074f5cceb8109f757018 100644 |
--- a/src/x64/builtins-x64.cc |
+++ b/src/x64/builtins-x64.cc |
@@ -598,6 +598,27 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { |
} |
} |
+static void LeaveInterpreterFrame(MacroAssembler* masm, Register scratch1, |
+ Register scratch2) { |
+ Register args_count = scratch1; |
+ Register return_pc = scratch2; |
+ |
+ // Get the arguments + reciever count. |
+ __ movp(args_count, |
+ Operand(rbp, InterpreterFrameConstants::kBytecodeArrayFromFp)); |
+ __ movl(args_count, |
+ FieldOperand(args_count, BytecodeArray::kParameterSizeOffset)); |
+ |
+ // Leave the before recompiling for baseline so that we don't count as an |
+ // activation on the stack. |
Michael Starzinger
2016/05/13 09:01:40
nit: Can we keep the generic "Leave the frame (als
rmcilroy
2016/05/17 11:28:30
Done.
|
+ __ leave(); |
+ |
+ // Drop receiver + arguments and return. |
Michael Starzinger
2016/05/13 09:01:40
nit: The "and return" part of the comment no longe
rmcilroy
2016/05/17 11:28:30
Done.
|
+ __ PopReturnAddressTo(return_pc); |
+ __ addp(rsp, args_count); |
+ __ PushReturnAddressFrom(return_pc); |
+} |
+ |
// Generate code for entering a JS function with the interpreter. |
// On entry to the function the receiver and arguments have been pushed on the |
// stack left to right. The actual argument count matches the formal parameter |
@@ -703,18 +724,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { |
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); |
+ LeaveInterpreterFrame(masm, rbx, rcx); |
__ ret(0); |
// Load debug copy of the bytecode array. |
@@ -738,6 +748,31 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { |
__ jmp(rcx); |
} |
+void Builtins::Generate_InterpreterMarkBaselineOnReturn(MacroAssembler* masm) { |
+ // Save the function and context for call to CompileBaseline. |
+ __ movp(rdi, Operand(rbp, StandardFrameConstants::kFunctionOffset)); |
+ __ movp(kContextRegister, |
+ Operand(rbp, StandardFrameConstants::kContextOffset)); |
+ |
+ // Leave the frame before recompiling for baseline so that we don't count as |
+ // an activation on the stack. |
+ LeaveInterpreterFrame(masm, rbx, rcx); |
+ |
+ { |
+ FrameScope frame_scope(masm, StackFrame::INTERNAL); |
+ // Push return value. |
+ __ Push(rax); |
+ |
+ // Push function as argument and compile for baseline. |
+ __ Push(rdi); |
+ __ CallRuntime(Runtime::kCompileBaseline); |
+ |
+ // Restore return value. |
+ __ Pop(rax); |
+ } |
+ __ ret(0); |
+} |
+ |
static void Generate_InterpreterPushArgs(MacroAssembler* masm, |
bool push_receiver) { |
// ----------- S t a t e ------------- |