Index: src/x64/builtins-x64.cc |
diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc |
index 419ee0fa5c9b547098b732f743402a8865fae6b9..517be34d8504425b3ed29d1ca24c840f76d05119 100644 |
--- a/src/x64/builtins-x64.cc |
+++ b/src/x64/builtins-x64.cc |
@@ -598,6 +598,26 @@ 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 + receiver count. |
+ __ movp(args_count, |
+ Operand(rbp, InterpreterFrameConstants::kBytecodeArrayFromFp)); |
+ __ movl(args_count, |
+ FieldOperand(args_count, BytecodeArray::kParameterSizeOffset)); |
+ |
+ // Leave the frame (also dropping the register file). |
+ __ leave(); |
+ |
+ // Drop receiver + arguments. |
+ __ 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 |
@@ -702,18 +722,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. |
@@ -737,6 +746,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 ------------- |