Index: src/ppc/builtins-ppc.cc |
diff --git a/src/ppc/builtins-ppc.cc b/src/ppc/builtins-ppc.cc |
index 1c4f10b15a55cc6f4de1cd1617f107cdcfc658e5..20d9b57e190fb0fa6680c88966e99b744bcb68f2 100644 |
--- a/src/ppc/builtins-ppc.cc |
+++ b/src/ppc/builtins-ppc.cc |
@@ -307,34 +307,6 @@ void Builtins::Generate_InOptimizationQueue(MacroAssembler* masm) { |
} |
-static void Generate_Runtime_NewObject(MacroAssembler* masm, |
- bool create_memento, |
- Register original_constructor, |
- Label* count_incremented, |
- Label* allocated) { |
- // ----------- S t a t e ------------- |
- // -- r4: argument for Runtime_NewObject |
- // ----------------------------------- |
- Register result = r7; |
- |
- if (create_memento) { |
- // Get the cell or allocation site. |
- __ LoadP(r5, MemOperand(sp, 3 * kPointerSize)); |
- __ Push(r5, r4, original_constructor); |
- __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3); |
- __ mr(result, r3); |
- // Runtime_NewObjectWithAllocationSite increments allocation count. |
- // Skip the increment. |
- __ b(count_incremented); |
- } else { |
- __ Push(r4, original_constructor); |
- __ CallRuntime(Runtime::kNewObject, 2); |
- __ mr(result, r3); |
- __ b(allocated); |
- } |
-} |
- |
- |
static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
bool is_api_function, |
bool create_memento) { |
@@ -365,17 +337,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
__ SmiTag(r3); |
__ Push(r3, r4, r6); |
- Label rt_call, allocated, normal_new, count_incremented; |
- __ cmp(r4, r6); |
- __ beq(&normal_new); |
- |
- // Original constructor and function are different. |
- Generate_Runtime_NewObject(masm, create_memento, r6, &count_incremented, |
- &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) { |
ExternalReference debug_step_in_fp = |
ExternalReference::debug_step_in_fp_address(isolate); |
@@ -384,12 +348,16 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
__ cmpi(r5, Operand::Zero()); |
__ bne(&rt_call); |
+ // Fall back to runtime if the original constructor and function differ. |
+ __ cmp(r4, r6); |
+ __ bne(&rt_call); |
+ |
// Load the initial map and verify that it is in fact a map. |
// r4: constructor function |
__ LoadP(r5, |
FieldMemOperand(r4, JSFunction::kPrototypeOrInitialMapOffset)); |
__ JumpIfSmi(r5, &rt_call); |
- __ CompareObjectType(r5, r6, r7, MAP_TYPE); |
+ __ CompareObjectType(r5, r8, r7, MAP_TYPE); |
__ bne(&rt_call); |
// Check that the constructor is not constructing a JSFunction (see |
@@ -397,7 +365,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
// initial map's instance type would be JS_FUNCTION_TYPE. |
// r4: constructor function |
// r5: initial map |
- __ CompareInstanceType(r5, r6, JS_FUNCTION_TYPE); |
+ __ CompareInstanceType(r5, r8, JS_FUNCTION_TYPE); |
__ beq(&rt_call); |
if (!is_api_function) { |
@@ -427,12 +395,13 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
// Now allocate the JSObject on the heap. |
// r4: constructor function |
// r5: initial map |
+ Label rt_call_reload_new_target; |
__ lbz(r6, FieldMemOperand(r5, Map::kInstanceSizeOffset)); |
if (create_memento) { |
__ addi(r6, r6, Operand(AllocationMemento::kSize / kPointerSize)); |
} |
- __ Allocate(r6, r7, r8, r9, &rt_call, SIZE_IN_WORDS); |
+ __ Allocate(r6, r7, r8, r9, &rt_call_reload_new_target, SIZE_IN_WORDS); |
// Allocated the JSObject, now initialize the fields. Map is set to |
// initial map and properties and elements are set to empty fixed array. |
@@ -517,13 +486,33 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
// Continue with JSObject being successfully allocated |
// r7: JSObject |
__ b(&allocated); |
+ |
+ // Reload the original constructor and fall-through. |
+ __ bind(&rt_call_reload_new_target); |
+ __ LoadP(r6, MemOperand(sp, 0 * kPointerSize)); |
} |
// Allocate the new receiver object using the runtime call. |
// r4: constructor function |
+ // r6: original constructor |
__ bind(&rt_call); |
- Generate_Runtime_NewObject(masm, create_memento, r4, &count_incremented, |
- &allocated); |
+ if (create_memento) { |
+ // Get the cell or allocation site. |
+ __ LoadP(r5, MemOperand(sp, 3 * kPointerSize)); |
+ __ Push(r5, r4, r6); |
+ __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3); |
+ } else { |
+ __ Push(r4, r6); |
+ __ CallRuntime(Runtime::kNewObject, 2); |
+ } |
+ __ mr(r7, r3); |
+ |
+ // Runtime_NewObjectWithAllocationSite increments allocation count. |
+ // Skip the increment. |
+ Label count_incremented; |
+ if (create_memento) { |
+ __ b(&count_incremented); |
+ } |
// Receiver for constructor call allocated. |
// r7: JSObject |
@@ -610,7 +599,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
// If the result is a smi, it is *not* an object in the ECMA sense. |
// r3: result |
- // sp[0]: receiver (newly allocated object) |
+ // sp[0]: receiver |
// sp[1]: new.target |
// sp[2]: number of arguments (smi-tagged) |
__ JumpIfSmi(r3, &use_receiver); |