Chromium Code Reviews| Index: src/x64/builtins-x64.cc |
| diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc |
| index 03f6fa2fd545ae565588ef65a76f7ef44ab47854..4efb6811519ee3810bb75aa01861174880be4585 100644 |
| --- a/src/x64/builtins-x64.cc |
| +++ b/src/x64/builtins-x64.cc |
| @@ -785,21 +785,21 @@ void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { |
| } |
| -// static |
| -void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) { |
| +static void Generate_InterpreterPushArgs(MacroAssembler* masm, |
| + bool push_receiver) { |
| // ----------- S t a t e ------------- |
| // -- rax : the number of arguments (not including the receiver) |
| // -- rbx : the address of the first argument to be pushed. Subsequent |
| // arguments should be consecutive above this, in the same order as |
| // they are to be pushed onto the stack. |
| - // -- rdi : the target to call (can be any Object). |
| - |
| - // Pop return address to allow tail-call after pushing arguments. |
| - __ Pop(rdx); |
| + // ----------------------------------- |
| // Find the address of the last argument. |
| __ movp(rcx, rax); |
| - __ addp(rcx, Immediate(1)); // Add one for receiver. |
| + if (push_receiver) { |
| + __ addp(rcx, Immediate(1)); // Add one for receiver. |
| + } |
| + |
| __ shlp(rcx, Immediate(kPointerSizeLog2)); |
| __ negp(rcx); |
| __ addp(rcx, rbx); |
| @@ -813,13 +813,58 @@ void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) { |
| __ bind(&loop_check); |
| __ cmpp(rbx, rcx); |
| __ j(greater, &loop_header, Label::kNear); |
| +} |
| + |
| + |
| +// static |
| +void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) { |
| + // ----------- S t a t e ------------- |
| + // -- rax : the number of arguments (not including the receiver) |
| + // -- rbx : the address of the first argument to be pushed. Subsequent |
| + // arguments should be consecutive above this, in the same order as |
| + // they are to be pushed onto the stack. |
| + // -- rdi : the target to call (can be any Object). |
| + // ----------------------------------- |
| + |
| + // Pop return address to allow tail-call after pushing arguments. |
| + __ PopReturnAddressTo(kScratchRegister); |
| + |
| + Generate_InterpreterPushArgs(masm, true); |
| // Call the target. |
| - __ Push(rdx); // Re-push return address. |
| + __ PushReturnAddressFrom(kScratchRegister); // Re-push return address. |
| __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| } |
| +// static |
| +void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { |
| + // ----------- S t a t e ------------- |
| + // -- rax : the number of arguments (not including the receiver) |
| + // -- rdx : the original constructor (either the same as the constructor or |
| + // the JSFunction on which new was invoked initially) |
| + // -- rdi : the constructor to call (can be any Object) |
| + // -- rbx : the address of the first argument to be pushed. Subsequent |
| + // arguments should be consecutive above this, in the same order as |
| + // they are to be pushed onto the stack. |
| + // ----------------------------------- |
| + |
| + // Pop return address to allow tail-call after pushing arguments. |
| + __ PopReturnAddressTo(kScratchRegister); |
| + |
| + // Push required padding. |
|
rmcilroy
2015/10/14 10:18:34
nit - Push padding required for receiver which is
oth
2015/10/14 16:02:19
Done.
|
| + __ Push(Immediate(0)); |
| + |
| + Generate_InterpreterPushArgs(masm, false); |
| + |
| + // Push return address in preparation for the tail-call. |
| + __ PushReturnAddressFrom(kScratchRegister); |
| + |
| + // Call the constructor (rax, rdx, rdi passed on). |
| + __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CONSTRUCT_CALL); |
| +} |
| + |
| + |
| void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
| CallRuntimePassFunction(masm, Runtime::kCompileLazy); |
| GenerateTailCallToReturnedCode(masm); |