Index: src/arm/builtins-arm.cc |
diff --git a/src/arm/builtins-arm.cc b/src/arm/builtins-arm.cc |
index 2e5cc7398c7e70bdba5d984e07435a358e317d0b..a73613f534007e8b015a5d9bca92b8be9a098a06 100644 |
--- a/src/arm/builtins-arm.cc |
+++ b/src/arm/builtins-arm.cc |
@@ -313,7 +313,6 @@ void Builtins::Generate_InOptimizationQueue(MacroAssembler* masm) { |
static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
bool is_api_function, |
- bool count_constructions, |
bool create_memento) { |
// ----------- S t a t e ------------- |
// -- r0 : number of arguments |
@@ -323,15 +322,9 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
// -- sp[...]: constructor arguments |
// ----------------------------------- |
- // Should never count constructions for api objects. |
- ASSERT(!is_api_function || !count_constructions); |
- |
// Should never create mementos for api functions. |
ASSERT(!is_api_function || !create_memento); |
- // Should never create mementos before slack tracking is finished. |
- ASSERT(!count_constructions || !create_memento); |
- |
Isolate* isolate = masm->isolate(); |
// Enter a construct frame. |
@@ -375,21 +368,24 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
__ CompareInstanceType(r2, r3, JS_FUNCTION_TYPE); |
__ b(eq, &rt_call); |
- if (count_constructions) { |
+ if (!is_api_function) { |
Label allocate; |
+ MemOperand bit_field3 = FieldMemOperand(r2, Map::kBitField3Offset); |
+ // Check if slack tracking is enabled. |
+ __ ldr(r4, bit_field3); |
+ __ DecodeField<Map::ConstructionCount>(r3, r4); |
+ __ cmp(r3, Operand(static_cast<int32_t>(JSFunction::kNoSlackTracking))); |
+ __ b(eq, &allocate); |
// Decrease generous allocation count. |
- __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
- MemOperand constructor_count = |
- FieldMemOperand(r3, SharedFunctionInfo::kConstructionCountOffset); |
- __ ldrb(r4, constructor_count); |
- __ sub(r4, r4, Operand(1), SetCC); |
- __ strb(r4, constructor_count); |
+ __ sub(r4, r4, Operand(1 << Map::ConstructionCount::kShift)); |
+ __ str(r4, bit_field3); |
+ __ cmp(r3, |
+ Operand(static_cast<int32_t>(JSFunction::kFinishSlackTracking))); |
__ b(ne, &allocate); |
__ push(r1); |
__ Push(r2, r1); // r1 = constructor |
- // The call will replace the stub, so the countdown is only done once. |
__ CallRuntime(Runtime::kHiddenFinalizeInstanceSize, 1); |
__ pop(r2); |
@@ -431,7 +427,20 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
// r5: First in-object property of JSObject (not tagged) |
ASSERT_EQ(3 * kPointerSize, JSObject::kHeaderSize); |
- if (count_constructions) { |
+ if (is_api_function) { |
+ __ LoadRoot(r6, Heap::kUndefinedValueRootIndex); |
+ __ add(r0, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. |
+ __ InitializeFieldsWithFiller(r5, r0, r6); |
+ } else { |
+ Label no_inobject_slack_tracking, done_field_initialization; |
+ |
+ // Check if slack tracking is enabled. |
+ __ ldr(r6, FieldMemOperand(r2, Map::kBitField3Offset)); |
+ __ DecodeField<Map::ConstructionCount>(r6); |
+ __ cmp(r6, Operand(static_cast<int32_t>(JSFunction::kNoSlackTracking))); |
+ __ b(eq, &no_inobject_slack_tracking); |
+ |
+ // Allocate object with a slack. |
__ LoadRoot(r6, Heap::kUndefinedValueRootIndex); |
__ ldr(r0, FieldMemOperand(r2, Map::kInstanceSizesOffset)); |
__ Ubfx(r0, r0, Map::kPreAllocatedPropertyFieldsByte * kBitsPerByte, |
@@ -448,25 +457,31 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
__ LoadRoot(r6, Heap::kOnePointerFillerMapRootIndex); |
__ add(r0, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. |
__ InitializeFieldsWithFiller(r5, r0, r6); |
- } else if (create_memento) { |
- __ sub(r6, r3, Operand(AllocationMemento::kSize / kPointerSize)); |
- __ add(r0, r4, Operand(r6, LSL, kPointerSizeLog2)); // End of object. |
- __ LoadRoot(r6, Heap::kUndefinedValueRootIndex); |
- __ InitializeFieldsWithFiller(r5, r0, r6); |
- |
- // Fill in memento fields. |
- // r5: points to the allocated but uninitialized memento. |
- __ LoadRoot(r6, Heap::kAllocationMementoMapRootIndex); |
- ASSERT_EQ(0 * kPointerSize, AllocationMemento::kMapOffset); |
- __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); |
- // Load the AllocationSite |
- __ ldr(r6, MemOperand(sp, 2 * kPointerSize)); |
- ASSERT_EQ(1 * kPointerSize, AllocationMemento::kAllocationSiteOffset); |
- __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); |
- } else { |
- __ LoadRoot(r6, Heap::kUndefinedValueRootIndex); |
- __ add(r0, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. |
- __ InitializeFieldsWithFiller(r5, r0, r6); |
+ __ b(&done_field_initialization); |
+ |
+ __ bind(&no_inobject_slack_tracking); |
+ |
+ if (create_memento) { |
+ __ sub(r6, r3, Operand(AllocationMemento::kSize / kPointerSize)); |
+ __ add(r0, r4, Operand(r6, LSL, kPointerSizeLog2)); // End of object. |
+ __ LoadRoot(r6, Heap::kUndefinedValueRootIndex); |
+ __ InitializeFieldsWithFiller(r5, r0, r6); |
+ |
+ // Fill in memento fields. |
+ // r5: points to the allocated but uninitialized memento. |
+ __ LoadRoot(r6, Heap::kAllocationMementoMapRootIndex); |
+ ASSERT_EQ(0 * kPointerSize, AllocationMemento::kMapOffset); |
+ __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); |
+ // Load the AllocationSite |
+ __ ldr(r6, MemOperand(sp, 2 * kPointerSize)); |
+ ASSERT_EQ(1 * kPointerSize, AllocationMemento::kAllocationSiteOffset); |
+ __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); |
+ } else { |
+ __ LoadRoot(r6, Heap::kUndefinedValueRootIndex); |
+ __ add(r0, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. |
+ __ InitializeFieldsWithFiller(r5, r0, r6); |
+ } |
+ __ bind(&done_field_initialization); |
} |
// Add the object tag to make the JSObject real, so that we can continue |
@@ -655,7 +670,7 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
} |
// Store offset of return address for deoptimizer. |
- if (!is_api_function && !count_constructions) { |
+ if (!is_api_function) { |
masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); |
} |
@@ -707,18 +722,13 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
} |
-void Builtins::Generate_JSConstructStubCountdown(MacroAssembler* masm) { |
- Generate_JSConstructStubHelper(masm, false, true, false); |
-} |
- |
- |
void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { |
- Generate_JSConstructStubHelper(masm, false, false, FLAG_pretenuring_call_new); |
+ Generate_JSConstructStubHelper(masm, false, FLAG_pretenuring_call_new); |
} |
void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { |
- Generate_JSConstructStubHelper(masm, true, false, false); |
+ Generate_JSConstructStubHelper(masm, true, false); |
} |