Index: src/arm/code-stubs-arm.cc |
diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc |
index 6b0ae54aa3c7d22a265b21cfda587098ed5f4db9..f504b72fef7a3791c5ad590ddd25dbfc28fade25 100644 |
--- a/src/arm/code-stubs-arm.cc |
+++ b/src/arm/code-stubs-arm.cc |
@@ -4445,7 +4445,6 @@ void LoadICStub::GenerateImpl(MacroAssembler* masm, bool in_frame) { |
__ bind(&miss); |
LoadIC::GenerateMiss(masm); |
- |
__ bind(&load_smi_map); |
__ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex); |
__ jmp(&compare_map); |
@@ -4546,11 +4545,54 @@ void VectorStoreICStub::GenerateForTrampoline(MacroAssembler* masm) { |
void VectorStoreICStub::GenerateImpl(MacroAssembler* masm, bool in_frame) { |
- Label miss; |
+ Register receiver = VectorStoreICDescriptor::ReceiverRegister(); // r1 |
+ Register key = VectorStoreICDescriptor::NameRegister(); // r2 |
+ Register vector = VectorStoreICDescriptor::VectorRegister(); // r3 |
+ Register slot = VectorStoreICDescriptor::SlotRegister(); // r4 |
+ DCHECK(VectorStoreICDescriptor::ValueRegister().is(r0)); // r0 |
+ Register feedback = r5; |
+ Register receiver_map = r6; |
+ Register scratch1 = r9; |
+ |
+ __ add(feedback, vector, Operand::PointerOffsetFromSmiKey(slot)); |
+ __ ldr(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize)); |
+ |
+ // Try to quickly handle the monomorphic case without knowing for sure |
+ // if we have a weak cell in feedback. We do know it's safe to look |
+ // at WeakCell::kValueOffset. |
+ Label try_array, load_smi_map, compare_map; |
+ Label not_array, miss; |
+ HandleMonomorphicCase(masm, receiver, receiver_map, feedback, vector, slot, |
+ scratch1, &compare_map, &load_smi_map, &try_array); |
+ |
+ // Is it a fixed array? |
+ __ bind(&try_array); |
+ __ ldr(scratch1, FieldMemOperand(feedback, HeapObject::kMapOffset)); |
+ __ CompareRoot(scratch1, Heap::kFixedArrayMapRootIndex); |
+ __ b(ne, ¬_array); |
+ |
+ // We are using register r8, which is used for the embedded constant pool |
+ // when FLAG_enable_embedded_constant_pool is true. |
+ DCHECK(!FLAG_enable_embedded_constant_pool); |
+ Register scratch2 = r8; |
+ HandleArrayCases(masm, feedback, receiver_map, scratch1, scratch2, true, |
+ &miss); |
+ |
+ __ bind(¬_array); |
+ __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex); |
+ __ b(ne, &miss); |
+ Code::Flags code_flags = Code::RemoveTypeAndHolderFromFlags( |
+ Code::ComputeHandlerFlags(Code::STORE_IC)); |
+ masm->isolate()->stub_cache()->GenerateProbe( |
+ masm, Code::STORE_IC, code_flags, receiver, key, feedback, receiver_map, |
+ scratch1, scratch2); |
- // TODO(mvstanton): Implement. |
__ bind(&miss); |
StoreIC::GenerateMiss(masm); |
+ |
+ __ bind(&load_smi_map); |
+ __ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex); |
+ __ jmp(&compare_map); |
} |
@@ -4564,12 +4606,133 @@ void VectorKeyedStoreICStub::GenerateForTrampoline(MacroAssembler* masm) { |
} |
+static void HandlePolymorphicStoreCase(MacroAssembler* masm, Register feedback, |
+ Register receiver_map, Register scratch1, |
+ Register scratch2, Label* miss) { |
+ // feedback initially contains the feedback array |
+ Label next_loop, prepare_next; |
+ Label start_polymorphic; |
+ Label transition_call; |
+ |
+ Register cached_map = scratch1; |
+ Register too_far = scratch2; |
+ Register pointer_reg = feedback; |
+ __ ldr(too_far, FieldMemOperand(feedback, FixedArray::kLengthOffset)); |
+ |
+ // +-----+------+------+-----+-----+-----+ ... ----+ |
+ // | map | len | wm0 | wt0 | h0 | wm1 | hN | |
+ // +-----+------+------+-----+-----+ ----+ ... ----+ |
+ // 0 1 2 len-1 |
+ // ^ ^ |
+ // | | |
+ // pointer_reg too_far |
+ // aka feedback scratch2 |
+ // also need receiver_map |
+ // use cached_map (scratch1) to look in the weak map values. |
+ __ add(too_far, feedback, Operand::PointerOffsetFromSmiKey(too_far)); |
+ __ add(too_far, too_far, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
+ __ add(pointer_reg, feedback, |
+ Operand(FixedArray::OffsetOfElementAt(0) - kHeapObjectTag)); |
+ |
+ __ bind(&next_loop); |
+ __ ldr(cached_map, MemOperand(pointer_reg)); |
+ __ ldr(cached_map, FieldMemOperand(cached_map, WeakCell::kValueOffset)); |
+ __ cmp(receiver_map, cached_map); |
+ __ b(ne, &prepare_next); |
+ // Is it a transitioning store? |
+ __ ldr(too_far, MemOperand(pointer_reg, kPointerSize)); |
+ __ CompareRoot(too_far, Heap::kUndefinedValueRootIndex); |
+ __ b(ne, &transition_call); |
+ __ ldr(pointer_reg, MemOperand(pointer_reg, kPointerSize * 2)); |
+ __ add(pc, pointer_reg, Operand(Code::kHeaderSize - kHeapObjectTag)); |
+ |
+ __ bind(&transition_call); |
+ __ ldr(too_far, FieldMemOperand(too_far, WeakCell::kValueOffset)); |
+ __ JumpIfSmi(too_far, miss); |
+ |
+ __ ldr(receiver_map, MemOperand(pointer_reg, kPointerSize * 2)); |
+ |
+ // Load the map into the correct register. |
+ DCHECK(feedback.is(VectorStoreTransitionDescriptor::MapRegister())); |
+ __ mov(feedback, too_far); |
+ |
+ __ add(pc, receiver_map, Operand(Code::kHeaderSize - kHeapObjectTag)); |
+ |
+ __ bind(&prepare_next); |
+ __ add(pointer_reg, pointer_reg, Operand(kPointerSize * 3)); |
+ __ cmp(pointer_reg, too_far); |
+ __ b(lt, &next_loop); |
+ |
+ // We exhausted our array of map handler pairs. |
+ __ jmp(miss); |
+} |
+ |
+ |
void VectorKeyedStoreICStub::GenerateImpl(MacroAssembler* masm, bool in_frame) { |
- Label miss; |
+ Register receiver = VectorStoreICDescriptor::ReceiverRegister(); // r1 |
+ Register key = VectorStoreICDescriptor::NameRegister(); // r2 |
+ Register vector = VectorStoreICDescriptor::VectorRegister(); // r3 |
+ Register slot = VectorStoreICDescriptor::SlotRegister(); // r4 |
+ DCHECK(VectorStoreICDescriptor::ValueRegister().is(r0)); // r0 |
+ Register feedback = r5; |
+ Register receiver_map = r6; |
+ Register scratch1 = r9; |
+ |
+ __ add(feedback, vector, Operand::PointerOffsetFromSmiKey(slot)); |
+ __ ldr(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize)); |
+ |
+ // Try to quickly handle the monomorphic case without knowing for sure |
+ // if we have a weak cell in feedback. We do know it's safe to look |
+ // at WeakCell::kValueOffset. |
+ Label try_array, load_smi_map, compare_map; |
+ Label not_array, miss; |
+ HandleMonomorphicCase(masm, receiver, receiver_map, feedback, vector, slot, |
+ scratch1, &compare_map, &load_smi_map, &try_array); |
+ |
+ __ bind(&try_array); |
+ // Is it a fixed array? |
+ __ ldr(scratch1, FieldMemOperand(feedback, HeapObject::kMapOffset)); |
+ __ CompareRoot(scratch1, Heap::kFixedArrayMapRootIndex); |
+ __ b(ne, ¬_array); |
+ |
+ // We have a polymorphic element handler. |
+ Label polymorphic, try_poly_name; |
+ __ bind(&polymorphic); |
+ |
+ // We are using register r8, which is used for the embedded constant pool |
+ // when FLAG_enable_embedded_constant_pool is true. |
+ DCHECK(!FLAG_enable_embedded_constant_pool); |
+ Register scratch2 = r8; |
+ |
+ HandlePolymorphicStoreCase(masm, feedback, receiver_map, scratch1, scratch2, |
+ &miss); |
+ |
+ __ bind(¬_array); |
+ // Is it generic? |
+ __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex); |
+ __ b(ne, &try_poly_name); |
+ Handle<Code> megamorphic_stub = |
+ KeyedStoreIC::ChooseMegamorphicStub(masm->isolate(), GetExtraICState()); |
+ __ Jump(megamorphic_stub, RelocInfo::CODE_TARGET); |
+ |
+ __ bind(&try_poly_name); |
+ // We might have a name in feedback, and a fixed array in the next slot. |
+ __ cmp(key, feedback); |
+ __ b(ne, &miss); |
+ // If the name comparison succeeded, we know we have a fixed array with |
+ // at least one map/handler pair. |
+ __ add(feedback, vector, Operand::PointerOffsetFromSmiKey(slot)); |
+ __ ldr(feedback, |
+ FieldMemOperand(feedback, FixedArray::kHeaderSize + kPointerSize)); |
+ HandleArrayCases(masm, feedback, receiver_map, scratch1, scratch2, false, |
+ &miss); |
- // TODO(mvstanton): Implement. |
__ bind(&miss); |
KeyedStoreIC::GenerateMiss(masm); |
+ |
+ __ bind(&load_smi_map); |
+ __ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex); |
+ __ jmp(&compare_map); |
} |