Index: src/x64/builtins-x64.cc |
diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc |
index ff0a349dbd2729de6f04979705a1e8f56f25dd2d..80a41dde16c6d06b570347c9d2772fb1795db1b3 100644 |
--- a/src/x64/builtins-x64.cc |
+++ b/src/x64/builtins-x64.cc |
@@ -498,6 +498,59 @@ void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { |
} |
+void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) { |
+ // ----------- S t a t e ------------- |
+ // -- rax: number of arguments |
+ // -- rdi: constructor function |
+ // -- rbx: allocation site or undefined |
+ // -- rdx: original constructor |
+ // ----------------------------------- |
+ // TODO(dslomov): support pretenuring |
+ CHECK(!FLAG_pretenuring_call_new); |
+ |
+ { |
+ FrameScope frame_scope(masm, StackFrame::CONSTRUCT); |
+ |
+ // Store a smi-tagged arguments count on the stack. |
+ __ Integer32ToSmi(rax, rax); |
+ __ Push(rax); |
+ __ SmiToInteger32(rax, rax); |
+ |
+ // receiver is the hole. |
+ __ Push(masm->isolate()->factory()->the_hole_value()); |
+ |
+ // Set up pointer to last argument. |
+ __ leap(rbx, Operand(rbp, StandardFrameConstants::kCallerSPOffset)); |
+ |
+ // Copy arguments and receiver to the expression stack. |
+ Label loop, entry; |
+ __ movp(rcx, rax); |
+ __ jmp(&entry); |
+ __ bind(&loop); |
+ __ Push(Operand(rbx, rcx, times_pointer_size, 0)); |
+ __ bind(&entry); |
+ __ decp(rcx); |
+ __ j(greater_equal, &loop); |
+ |
+ // Call the function. |
+ ParameterCount actual(rax); |
+ __ InvokeFunction(rdi, actual, CALL_FUNCTION, NullCallWrapper()); |
+ |
+ // Restore context from the frame. |
+ __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
+ |
+ __ movp(rbx, Operand(rsp, 0)); // Get arguments count. |
+ } // Leave construct frame. |
+ |
+ // Remove caller arguments from the stack and return. |
+ __ PopReturnAddressTo(rcx); |
+ SmiIndex index = masm->SmiToIndex(rbx, rbx, kPointerSizeLog2); |
+ __ leap(rsp, Operand(rsp, index.reg, index.scale, 1 * kPointerSize)); |
+ __ PushReturnAddressFrom(rcx); |
+ __ ret(0); |
+} |
+ |
+ |
static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, |
bool is_construct) { |
ProfileEntryHookStub::MaybeCallEntryHook(masm); |