Chromium Code Reviews| Index: src/ia32/builtins-ia32.cc |
| diff --git a/src/ia32/builtins-ia32.cc b/src/ia32/builtins-ia32.cc |
| index af591730d2f3f6e41708bdab567f23e2f880ef51..1320c592768476d3d940b7c1a06d2f5a1648902b 100644 |
| --- a/src/ia32/builtins-ia32.cc |
| +++ b/src/ia32/builtins-ia32.cc |
| @@ -60,15 +60,19 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, |
| __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
| } |
| - |
| -static void CallRuntimePassFunction( |
| - MacroAssembler* masm, Runtime::FunctionId function_id) { |
| +static void CallRuntimePassFunction(MacroAssembler* masm, |
| + Runtime::FunctionId function_id, |
| + Register output) { |
|
Michael Starzinger
2016/02/09 11:52:19
Instead of passing an output register this functio
mvstanton
2016/02/09 18:47:47
Most excellent idea, thanks!
|
| // ----------- S t a t e ------------- |
| + // -- eax : argument count (preserved for callee) |
| // -- edx : new target (preserved for callee) |
| // -- edi : target function (preserved for callee) |
| // ----------------------------------- |
| - |
| + DCHECK(!output.is(eax) && !output.is(edx) && !output.is(edi)); |
| 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); |
| @@ -76,23 +80,28 @@ static void CallRuntimePassFunction( |
| __ push(edi); |
| __ CallRuntime(function_id, 1); |
| + __ mov(output, eax); |
| + |
| // Restore target function and new target. |
| __ pop(edx); |
| __ pop(edi); |
| + __ pop(eax); |
| + __ SmiUntag(eax); |
| } |
| - |
| -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 GenerateTailCallToSharedCode(MacroAssembler* masm, |
| + Register scratch) { |
| + DCHECK(!scratch.is(eax) && !scratch.is(edi)); |
| + __ mov(scratch, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
| + __ mov(scratch, FieldOperand(scratch, SharedFunctionInfo::kCodeOffset)); |
| + __ lea(scratch, FieldOperand(scratch, Code::kHeaderSize)); |
| + __ jmp(scratch); |
| } |
| - |
| -static void GenerateTailCallToReturnedCode(MacroAssembler* masm) { |
| - __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); |
| - __ jmp(eax); |
| +static void GenerateTailCallToReturnedCode(MacroAssembler* masm, |
| + Register code) { |
| + __ lea(code, FieldOperand(code, Code::kHeaderSize)); |
| + __ jmp(code); |
| } |
| @@ -108,11 +117,11 @@ void Builtins::Generate_InOptimizationQueue(MacroAssembler* masm) { |
| __ cmp(esp, Operand::StaticVariable(stack_limit)); |
| __ j(above_equal, &ok, Label::kNear); |
| - CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); |
| - GenerateTailCallToReturnedCode(masm); |
| + CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode, ebx); |
| + GenerateTailCallToReturnedCode(masm, ebx); |
| __ bind(&ok); |
| - GenerateTailCallToSharedCode(masm); |
| + GenerateTailCallToSharedCode(masm, ebx); |
| } |
| @@ -848,20 +857,20 @@ void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { |
| void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
| - CallRuntimePassFunction(masm, Runtime::kCompileLazy); |
| - GenerateTailCallToReturnedCode(masm); |
| + CallRuntimePassFunction(masm, Runtime::kCompileLazy, ebx); |
| + GenerateTailCallToReturnedCode(masm, ebx); |
| } |
| void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { |
| - CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); |
| - GenerateTailCallToReturnedCode(masm); |
| + CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent, ebx); |
| + GenerateTailCallToReturnedCode(masm, ebx); |
| } |
| void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) { |
| - CallRuntimePassFunction(masm, Runtime::kCompileOptimized_Concurrent); |
| - GenerateTailCallToReturnedCode(masm); |
| + CallRuntimePassFunction(masm, Runtime::kCompileOptimized_Concurrent, ebx); |
| + GenerateTailCallToReturnedCode(masm, ebx); |
| } |