| Index: src/x64/builtins-x64.cc
|
| diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc
|
| index 7ec210ae8de4ceead2bdeaa9665ae07ebe8f3994..84b5caa8c14b7e39df3db3bd54761b402c691eb4 100644
|
| --- a/src/x64/builtins-x64.cc
|
| +++ b/src/x64/builtins-x64.cc
|
| @@ -136,6 +136,7 @@ static void Generate_Runtime_NewObject(MacroAssembler* masm,
|
|
|
| static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
| bool is_api_function,
|
| + bool use_new_target,
|
| bool create_memento) {
|
| // ----------- S t a t e -------------
|
| // -- rax: number of arguments
|
| @@ -163,6 +164,10 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
| // Push the function to invoke on the stack.
|
| __ Push(rdi);
|
|
|
| + if (use_new_target) {
|
| + __ Push(rdx);
|
| + }
|
| +
|
| Label rt_call, normal_new, allocated, count_incremented;
|
| __ cmpp(rdx, rdi);
|
| __ j(equal, &normal_new);
|
| @@ -410,6 +415,10 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
| // Retrieve the function from the stack.
|
| __ Pop(rdi);
|
|
|
| + if (use_new_target) {
|
| + __ Pop(rdx);
|
| + }
|
| +
|
| // Retrieve smi-tagged arguments count from the stack.
|
| __ movp(rax, Operand(rsp, 0));
|
| __ SmiToInteger32(rax, rax);
|
| @@ -418,6 +427,11 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
| // because we may have to return the original one and the calling
|
| // conventions dictate that the called function pops the receiver.
|
| __ Push(rbx);
|
| +
|
| + if (use_new_target) {
|
| + __ Push(rdx);
|
| + }
|
| +
|
| __ Push(rbx);
|
|
|
| // Set up pointer to last argument.
|
| @@ -433,6 +447,10 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
| __ decp(rcx);
|
| __ j(greater_equal, &loop);
|
|
|
| + if (use_new_target) {
|
| + __ incp(rax); // Pushed new.target
|
| + }
|
| +
|
| // Call the function.
|
| if (is_api_function) {
|
| __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
|
| @@ -445,7 +463,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
| }
|
|
|
| // Store offset of return address for deoptimizer.
|
| - if (!is_api_function) {
|
| + // TODO(adamk): Remove the "!use_new_target" before supporting optimization
|
| + // of functions that reference new.target
|
| + if (!is_api_function && !use_new_target) {
|
| masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset());
|
| }
|
|
|
| @@ -489,12 +509,17 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
|
|
|
|
|
| void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) {
|
| - Generate_JSConstructStubHelper(masm, false, FLAG_pretenuring_call_new);
|
| + Generate_JSConstructStubHelper(masm, false, false, FLAG_pretenuring_call_new);
|
| }
|
|
|
|
|
| void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) {
|
| - Generate_JSConstructStubHelper(masm, true, false);
|
| + Generate_JSConstructStubHelper(masm, true, false, false);
|
| +}
|
| +
|
| +
|
| +void Builtins::Generate_JSConstructStubNewTarget(MacroAssembler* masm) {
|
| + Generate_JSConstructStubHelper(masm, false, true, FLAG_pretenuring_call_new);
|
| }
|
|
|
|
|
|
|