Index: src/x64/builtins-x64.cc |
diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc |
index 03f6fa2fd545ae565588ef65a76f7ef44ab47854..8538ac596b978f483df27dd2960cc9a46bf9dd20 100644 |
--- a/src/x64/builtins-x64.cc |
+++ b/src/x64/builtins-x64.cc |
@@ -795,7 +795,7 @@ void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) { |
// -- rdi : the target to call (can be any Object). |
// Pop return address to allow tail-call after pushing arguments. |
- __ Pop(rdx); |
+ __ PopReturnAddressTo(kScratchRegister); |
// Find the address of the last argument. |
__ movp(rcx, rax); |
@@ -815,11 +815,51 @@ void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) { |
__ j(greater, &loop_header, Label::kNear); |
// 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); |
+ |
+ // Find the address of the last argument. |
+ __ movp(rcx, rax); |
+ __ addp(rcx, Immediate(1)); // Add one for receiver. |
+ __ shlp(rcx, Immediate(kPointerSizeLog2)); |
+ __ negp(rcx); |
+ __ addp(rcx, rbx); |
+ |
+ // Push the arguments. |
+ Label loop_header, loop_check; |
+ __ j(always, &loop_check); |
+ __ bind(&loop_header); |
+ __ Push(Operand(rbx, 0)); |
+ __ subp(rbx, Immediate(kPointerSize)); |
+ __ bind(&loop_check); |
+ __ cmpp(rbx, rcx); |
+ __ j(greater, &loop_header, Label::kNear); |
+ |
+ // Push return address in preparation for the tail-call. |
+ __ PushReturnAddressFrom(kScratchRegister); |
rmcilroy
2015/10/13 14:07:30
nit - could we create a helper function for the ar
oth
2015/10/14 08:40:09
Done.
|
+ |
+ // Call the target. |
+ __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CONSTRUCT_CALL); |
+} |
+ |
+ |
void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
CallRuntimePassFunction(masm, Runtime::kCompileLazy); |
GenerateTailCallToReturnedCode(masm); |