Index: src/arm64/builtins-arm64.cc |
diff --git a/src/arm64/builtins-arm64.cc b/src/arm64/builtins-arm64.cc |
index 9f140c2f7de72999c2167702f37fbd26342fed15..9930be7627d8b103b71c52e05722d2883451c360 100644 |
--- a/src/arm64/builtins-arm64.cc |
+++ b/src/arm64/builtins-arm64.cc |
@@ -308,6 +308,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
// -- x0 : number of arguments |
// -- x1 : constructor function |
// -- x2 : allocation site or undefined |
+ // -- x3 : original constructor |
// -- lr : return address |
// -- sp[...]: constructor arguments |
// ----------------------------------- |
@@ -330,15 +331,42 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
Register argc = x0; |
Register constructor = x1; |
+ Register original_constructor = x3; |
// x1: constructor function |
__ SmiTag(argc); |
__ Push(argc, constructor); |
// sp[0] : Constructor function. |
// sp[1]: number of arguments (smi-tagged) |
+ Label rt_call, count_incremented, allocated, normal_new; |
+ __ Cmp(constructor, original_constructor); |
+ __ B(eq, &normal_new); |
+ { |
+ if (create_memento) { |
+ // Get the cell or allocation site. |
+ __ Peek(x4, 2 * kXRegSize); |
+ __ Push(x4); |
+ __ Push(constructor); // Argument for Runtime_NewObject. |
+ __ Push(original_constructor); |
+ __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3); |
+ __ Mov(x4, x0); |
+ // If we ended up using the runtime, and we want a memento, then the |
+ // runtime call made it for us, and we shouldn't do create count |
+ // increment. |
+ __ jmp(&count_incremented); |
+ } else { |
+ __ Push(constructor); // Argument for Runtime_NewObject. |
+ __ Push(original_constructor); |
+ __ CallRuntime(Runtime::kNewObject, 2); |
+ __ Mov(x4, x0); |
+ __ jmp(&allocated); |
+ } |
+ } |
+ |
+ __ Bind(&normal_new); |
+ |
// Try to allocate the object without transitioning into C code. If any of |
// the preconditions is not met, the code bails out to the runtime call. |
- Label rt_call, allocated; |
if (FLAG_inline_new) { |
Label undo_allocation; |
ExternalReference debug_step_in_fp = |
@@ -535,13 +563,13 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
// Allocate the new receiver object using the runtime call. |
__ Bind(&rt_call); |
- Label count_incremented; |
if (create_memento) { |
// Get the cell or allocation site. |
__ Peek(x4, 2 * kXRegSize); |
__ Push(x4); |
__ Push(constructor); // Argument for Runtime_NewObject. |
- __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 2); |
+ __ Push(constructor); |
+ __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3); |
__ Mov(x4, x0); |
// If we ended up using the runtime, and we want a memento, then the |
// runtime call made it for us, and we shouldn't do create count |
@@ -549,7 +577,8 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
__ jmp(&count_incremented); |
} else { |
__ Push(constructor); // Argument for Runtime_NewObject. |
- __ CallRuntime(Runtime::kNewObject, 1); |
+ __ Push(constructor); |
+ __ CallRuntime(Runtime::kNewObject, 2); |
__ Mov(x4, x0); |
} |