Index: src/ia32/code-stubs-ia32.cc |
diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc |
index 23dca4ec01506ea608d2c5c70dcb1d97a7055acc..c640a29c10db12c9959479b72d4b8f7afabeb89e 100644 |
--- a/src/ia32/code-stubs-ia32.cc |
+++ b/src/ia32/code-stubs-ia32.cc |
@@ -1913,6 +1913,30 @@ void CompareICStub::GenerateGeneric(MacroAssembler* masm) { |
} |
+static void CallStubInRecordCallTarget(MacroAssembler* masm, CodeStub* stub) { |
+ // eax : number of arguments to the construct function |
+ // ebx : Feedback vector |
+ // edx : slot in feedback vector (Smi) |
+ // edi : the function to call |
+ FrameScope scope(masm, StackFrame::INTERNAL); |
+ |
+ // Arguments register must be smi-tagged to call out. |
+ __ SmiTag(eax); |
+ __ push(eax); |
+ __ push(edi); |
+ __ push(edx); |
+ __ push(ebx); |
+ |
+ __ CallStub(stub); |
+ |
+ __ pop(ebx); |
+ __ pop(edx); |
+ __ pop(edi); |
+ __ pop(eax); |
+ __ SmiUntag(eax); |
+} |
+ |
+ |
static void GenerateRecordCallTarget(MacroAssembler* masm) { |
// Cache the called function in a feedback vector slot. Cache states |
// are uninitialized, monomorphic (indicated by a JSFunction), and |
@@ -1930,18 +1954,26 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) { |
// A monomorphic cache hit or an already megamorphic state: invoke the |
// function without changing the state. |
- __ cmp(ecx, edi); |
+ Label check_allocation_site; |
+ __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset)); |
__ j(equal, &done, Label::kFar); |
- __ cmp(ecx, Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); |
+ __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex); |
__ j(equal, &done, Label::kFar); |
+ __ CompareRoot(FieldOperand(ecx, 0), Heap::kWeakCellMapRootIndex); |
+ __ j(not_equal, FLAG_pretenuring_call_new ? &miss : &check_allocation_site); |
+ |
+ // If edi is not equal to the weak cell value, and the weak cell value is |
+ // cleared, we have a new chance to become monomorphic. |
+ __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize); |
+ __ jmp(&megamorphic); |
if (!FLAG_pretenuring_call_new) { |
+ __ bind(&check_allocation_site); |
// If we came here, we need to see if we are the array function. |
// If we didn't have a matching function, and we didn't find the megamorph |
// sentinel, then we have in the slot either some other function or an |
// AllocationSite. Do a map check on the object in ecx. |
- Handle<Map> allocation_site_map = isolate->factory()->allocation_site_map(); |
- __ cmp(FieldOperand(ecx, 0), Immediate(allocation_site_map)); |
+ __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex); |
__ j(not_equal, &miss); |
// Make sure the function is the Array() function |
@@ -1955,7 +1987,7 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) { |
// A monomorphic miss (i.e, here the cache is not uninitialized) goes |
// megamorphic. |
- __ cmp(ecx, Immediate(TypeFeedbackVector::UninitializedSentinel(isolate))); |
+ __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex); |
__ j(equal, &initialize); |
// MegamorphicSentinel is an immortal immovable object (undefined) so no |
// write-barrier is needed. |
@@ -1977,43 +2009,15 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) { |
// The target function is the Array constructor, |
// Create an AllocationSite if we don't already have it, store it in the |
// slot. |
- { |
- FrameScope scope(masm, StackFrame::INTERNAL); |
- |
- // Arguments register must be smi-tagged to call out. |
- __ SmiTag(eax); |
- __ push(eax); |
- __ push(edi); |
- __ push(edx); |
- __ push(ebx); |
- |
- CreateAllocationSiteStub create_stub(isolate); |
- __ CallStub(&create_stub); |
- |
- __ pop(ebx); |
- __ pop(edx); |
- __ pop(edi); |
- __ pop(eax); |
- __ SmiUntag(eax); |
- } |
+ CreateAllocationSiteStub create_stub(isolate); |
+ CallStubInRecordCallTarget(masm, &create_stub); |
__ jmp(&done); |
__ bind(¬_array_function); |
} |
- __ mov(FieldOperand(ebx, edx, times_half_pointer_size, |
- FixedArray::kHeaderSize), |
- edi); |
- // We won't need edx or ebx anymore, just save edi |
- __ push(edi); |
- __ push(ebx); |
- __ push(edx); |
- __ RecordWriteArray(ebx, edi, edx, kDontSaveFPRegs, |
- EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
- __ pop(edx); |
- __ pop(ebx); |
- __ pop(edi); |
- |
+ CreateWeakCellStub create_stub(isolate); |
+ CallStubInRecordCallTarget(masm, &create_stub); |
__ bind(&done); |
} |