Commit 25510907 authored by mbrandy's avatar mbrandy Committed by Commit bot

PPC: Cleanup Generate_JSConstructStubHelper a bit.

Port 6ddcd327

R=mstarzinger@chromium.org, dstence@us.ibm.com, michael_dawson@ca.ibm.com
BUG=

Review URL: https://codereview.chromium.org/1234953002

Cr-Commit-Position: refs/heads/master@{#29623}
parent 2606538e
...@@ -307,34 +307,6 @@ void Builtins::Generate_InOptimizationQueue(MacroAssembler* masm) { ...@@ -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, static void Generate_JSConstructStubHelper(MacroAssembler* masm,
bool is_api_function, bool is_api_function,
bool create_memento) { bool create_memento) {
...@@ -365,17 +337,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, ...@@ -365,17 +337,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ SmiTag(r3); __ SmiTag(r3);
__ Push(r3, r4, r6); __ 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 // 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. // the preconditions is not met, the code bails out to the runtime call.
Label rt_call, allocated;
if (FLAG_inline_new) { if (FLAG_inline_new) {
ExternalReference debug_step_in_fp = ExternalReference debug_step_in_fp =
ExternalReference::debug_step_in_fp_address(isolate); ExternalReference::debug_step_in_fp_address(isolate);
...@@ -384,12 +348,16 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, ...@@ -384,12 +348,16 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
__ cmpi(r5, Operand::Zero()); __ cmpi(r5, Operand::Zero());
__ bne(&rt_call); __ 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. // Load the initial map and verify that it is in fact a map.
// r4: constructor function // r4: constructor function
__ LoadP(r5, __ LoadP(r5,
FieldMemOperand(r4, JSFunction::kPrototypeOrInitialMapOffset)); FieldMemOperand(r4, JSFunction::kPrototypeOrInitialMapOffset));
__ JumpIfSmi(r5, &rt_call); __ JumpIfSmi(r5, &rt_call);
__ CompareObjectType(r5, r6, r7, MAP_TYPE); __ CompareObjectType(r5, r8, r7, MAP_TYPE);
__ bne(&rt_call); __ bne(&rt_call);
// Check that the constructor is not constructing a JSFunction (see // Check that the constructor is not constructing a JSFunction (see
...@@ -397,7 +365,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, ...@@ -397,7 +365,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// initial map's instance type would be JS_FUNCTION_TYPE. // initial map's instance type would be JS_FUNCTION_TYPE.
// r4: constructor function // r4: constructor function
// r5: initial map // r5: initial map
__ CompareInstanceType(r5, r6, JS_FUNCTION_TYPE); __ CompareInstanceType(r5, r8, JS_FUNCTION_TYPE);
__ beq(&rt_call); __ beq(&rt_call);
if (!is_api_function) { if (!is_api_function) {
...@@ -427,12 +395,13 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, ...@@ -427,12 +395,13 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// Now allocate the JSObject on the heap. // Now allocate the JSObject on the heap.
// r4: constructor function // r4: constructor function
// r5: initial map // r5: initial map
Label rt_call_reload_new_target;
__ lbz(r6, FieldMemOperand(r5, Map::kInstanceSizeOffset)); __ lbz(r6, FieldMemOperand(r5, Map::kInstanceSizeOffset));
if (create_memento) { if (create_memento) {
__ addi(r6, r6, Operand(AllocationMemento::kSize / kPointerSize)); __ 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 // Allocated the JSObject, now initialize the fields. Map is set to
// initial map and properties and elements are set to empty fixed array. // initial map and properties and elements are set to empty fixed array.
...@@ -517,13 +486,33 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, ...@@ -517,13 +486,33 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
// Continue with JSObject being successfully allocated // Continue with JSObject being successfully allocated
// r7: JSObject // r7: JSObject
__ b(&allocated); __ 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. // Allocate the new receiver object using the runtime call.
// r4: constructor function // r4: constructor function
// r6: original constructor
__ bind(&rt_call); __ bind(&rt_call);
Generate_Runtime_NewObject(masm, create_memento, r4, &count_incremented, if (create_memento) {
&allocated); // 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. // Receiver for constructor call allocated.
// r7: JSObject // r7: JSObject
...@@ -610,7 +599,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, ...@@ -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. // If the result is a smi, it is *not* an object in the ECMA sense.
// r3: result // r3: result
// sp[0]: receiver (newly allocated object) // sp[0]: receiver
// sp[1]: new.target // sp[1]: new.target
// sp[2]: number of arguments (smi-tagged) // sp[2]: number of arguments (smi-tagged)
__ JumpIfSmi(r3, &use_receiver); __ JumpIfSmi(r3, &use_receiver);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment