diff --git a/src/x87/builtins-x87.cc b/src/x87/builtins-x87.cc index 11448e6fba..e4fe9f7080 100644 --- a/src/x87/builtins-x87.cc +++ b/src/x87/builtins-x87.cc @@ -60,39 +60,43 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, __ JumpToExternalReference(ExternalReference(id, masm->isolate())); } - -static void CallRuntimePassFunction( - MacroAssembler* masm, Runtime::FunctionId function_id) { +static void GenerateTailCallToReturnedCode(MacroAssembler* masm, + Runtime::FunctionId function_id) { // ----------- S t a t e ------------- + // -- eax : argument count (preserved for callee) // -- edx : new target (preserved for callee) // -- edi : target function (preserved for callee) // ----------------------------------- + { + FrameScope scope(masm, StackFrame::INTERNAL); + // Push the number of arguments to the callee. + __ SmiTag(eax); + __ push(eax); + // Push a copy of the target function and the new target. + __ push(edi); + __ push(edx); + // Function is also the parameter to the runtime call. + __ push(edi); - FrameScope scope(masm, StackFrame::INTERNAL); - // Push a copy of the target function and the new target. - __ push(edi); - __ push(edx); - // Function is also the parameter to the runtime call. - __ push(edi); + __ CallRuntime(function_id, 1); + __ mov(ebx, eax); - __ CallRuntime(function_id, 1); - // Restore target function and new target. - __ pop(edx); - __ pop(edi); + // Restore target function and new target. + __ pop(edx); + __ pop(edi); + __ pop(eax); + __ SmiUntag(eax); + } + + __ lea(ebx, FieldOperand(ebx, Code::kHeaderSize)); + __ jmp(ebx); } - static void GenerateTailCallToSharedCode(MacroAssembler* masm) { - __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); - __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kCodeOffset)); - __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); - __ jmp(eax); -} - - -static void GenerateTailCallToReturnedCode(MacroAssembler* masm) { - __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); - __ jmp(eax); + __ mov(ebx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); + __ mov(ebx, FieldOperand(ebx, SharedFunctionInfo::kCodeOffset)); + __ lea(ebx, FieldOperand(ebx, Code::kHeaderSize)); + __ jmp(ebx); } @@ -108,14 +112,12 @@ void Builtins::Generate_InOptimizationQueue(MacroAssembler* masm) { __ cmp(esp, Operand::StaticVariable(stack_limit)); __ j(above_equal, &ok, Label::kNear); - CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); - GenerateTailCallToReturnedCode(masm); + GenerateTailCallToReturnedCode(masm, Runtime::kTryInstallOptimizedCode); __ bind(&ok); GenerateTailCallToSharedCode(masm); } - static void Generate_JSConstructStubHelper(MacroAssembler* masm, bool is_api_function, bool create_implicit_receiver, @@ -852,20 +854,18 @@ void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { void Builtins::Generate_CompileLazy(MacroAssembler* masm) { - CallRuntimePassFunction(masm, Runtime::kCompileLazy); - GenerateTailCallToReturnedCode(masm); + GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); } void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { - CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); - GenerateTailCallToReturnedCode(masm); + GenerateTailCallToReturnedCode(masm, + Runtime::kCompileOptimized_NotConcurrent); } void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) { - CallRuntimePassFunction(masm, Runtime::kCompileOptimized_Concurrent); - GenerateTailCallToReturnedCode(masm); + GenerateTailCallToReturnedCode(masm, Runtime::kCompileOptimized_Concurrent); }