Commit 45005083 authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: [Interpreter] Support compiling for baseline on return from interpreted function.

  port f241a61a (r36360)

  original commit message:
  We cannot tier up from interpreted to baseline code when there is an
  activation of the function on the stack. This significantly regresses
  the performance of recursive functions since they are unlikely to get
  tiered up.

  This CL adds the ability for a function to be marked for baseline
  compilation when it returns. To do this we patch the
  InterpreterEntryTrampoline return address to point to
  InterpreterMarkBaselineOnReturn, which leaves the
  interpreted frame and recompile the function for
  baseline.

  This improves the score of EarlyBoyer by ~8x for Ignition.

BUG=

Review-Url: https://codereview.chromium.org/1998153002
Cr-Commit-Position: refs/heads/master@{#36396}
parent 29f3e668
......@@ -521,6 +521,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 + reciever count.
__ mov(args_count,
Operand(ebp, InterpreterFrameConstants::kBytecodeArrayFromFp));
__ mov(args_count,
FieldOperand(args_count, BytecodeArray::kParameterSizeOffset));
// Leave the frame (also dropping the register file).
__ leave();
// Drop receiver + arguments.
__ pop(return_pc);
__ add(esp, args_count);
__ push(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
......@@ -624,18 +644,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
masm->isolate()->heap()->SetInterpreterEntryReturnPCOffset(masm->pc_offset());
// The return value is in eax.
// Get the arguments + reciever count.
__ mov(ebx, Operand(ebp, InterpreterFrameConstants::kBytecodeArrayFromFp));
__ mov(ebx, FieldOperand(ebx, BytecodeArray::kParameterSizeOffset));
// Leave the frame (also dropping the register file).
__ leave();
// Drop receiver + arguments and return.
__ pop(ecx);
__ add(esp, ebx);
__ push(ecx);
LeaveInterpreterFrame(masm, ebx, ecx);
__ ret(0);
// Load debug copy of the bytecode array.
......@@ -662,6 +671,31 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ jmp(ecx);
}
void Builtins::Generate_InterpreterMarkBaselineOnReturn(MacroAssembler* masm) {
// Save the function and context for call to CompileBaseline.
__ mov(edi, Operand(ebp, StandardFrameConstants::kFunctionOffset));
__ mov(kContextRegister,
Operand(ebp, StandardFrameConstants::kContextOffset));
// Leave the frame before recompiling for baseline so that we don't count as
// an activation on the stack.
LeaveInterpreterFrame(masm, ebx, ecx);
{
FrameScope frame_scope(masm, StackFrame::INTERNAL);
// Push return value.
__ push(eax);
// Push function as argument and compile for baseline.
__ push(edi);
__ CallRuntime(Runtime::kCompileBaseline);
// Restore return value.
__ pop(eax);
}
__ ret(0);
}
static void Generate_InterpreterPushArgs(MacroAssembler* masm,
Register array_limit) {
// ----------- S t a t e -------------
......
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