Index: src/ppc/code-stubs-ppc.cc |
diff --git a/src/ppc/code-stubs-ppc.cc b/src/ppc/code-stubs-ppc.cc |
index 4a6e7db5fa5fab1d8ea39495a990a676d2a48351..4b33cefcf4668fe9bdffe127afee857a84155daf 100644 |
--- a/src/ppc/code-stubs-ppc.cc |
+++ b/src/ppc/code-stubs-ppc.cc |
@@ -4780,11 +4780,52 @@ void VectorStoreICStub::GenerateForTrampoline(MacroAssembler* masm) { |
void VectorStoreICStub::GenerateImpl(MacroAssembler* masm, bool in_frame) { |
- Label miss; |
+ Register receiver = VectorStoreICDescriptor::ReceiverRegister(); // r4 |
+ Register key = VectorStoreICDescriptor::NameRegister(); // r5 |
+ Register vector = VectorStoreICDescriptor::VectorRegister(); // r6 |
+ Register slot = VectorStoreICDescriptor::SlotRegister(); // r7 |
+ DCHECK(VectorStoreICDescriptor::ValueRegister().is(r3)); // r3 |
+ Register feedback = r8; |
+ Register receiver_map = r9; |
+ Register scratch1 = r10; |
+ |
+ __ SmiToPtrArrayOffset(r0, slot); |
+ __ add(feedback, vector, r0); |
+ __ LoadP(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); |
+ __ LoadP(scratch1, FieldMemOperand(feedback, HeapObject::kMapOffset)); |
+ __ CompareRoot(scratch1, Heap::kFixedArrayMapRootIndex); |
+ __ bne(¬_array); |
+ |
+ Register scratch2 = r11; |
+ HandleArrayCases(masm, feedback, receiver_map, scratch1, scratch2, true, |
+ &miss); |
+ |
+ __ bind(¬_array); |
+ __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex); |
+ __ bne(&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); |
+ __ b(&compare_map); |
} |
@@ -4798,12 +4839,135 @@ 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; |
+ __ LoadP(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. |
+ __ SmiToPtrArrayOffset(r0, too_far); |
+ __ add(too_far, feedback, r0); |
+ __ addi(too_far, too_far, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
+ __ addi(pointer_reg, feedback, |
+ Operand(FixedArray::OffsetOfElementAt(0) - kHeapObjectTag)); |
+ |
+ __ bind(&next_loop); |
+ __ LoadP(cached_map, MemOperand(pointer_reg)); |
+ __ LoadP(cached_map, FieldMemOperand(cached_map, WeakCell::kValueOffset)); |
+ __ cmp(receiver_map, cached_map); |
+ __ bne(&prepare_next); |
+ // Is it a transitioning store? |
+ __ LoadP(too_far, MemOperand(pointer_reg, kPointerSize)); |
+ __ CompareRoot(too_far, Heap::kUndefinedValueRootIndex); |
+ __ bne(&transition_call); |
+ __ LoadP(pointer_reg, MemOperand(pointer_reg, kPointerSize * 2)); |
+ __ addi(ip, pointer_reg, Operand(Code::kHeaderSize - kHeapObjectTag)); |
+ __ Jump(ip); |
+ |
+ __ bind(&transition_call); |
+ __ LoadP(too_far, FieldMemOperand(too_far, WeakCell::kValueOffset)); |
+ __ JumpIfSmi(too_far, miss); |
+ |
+ __ LoadP(receiver_map, MemOperand(pointer_reg, kPointerSize * 2)); |
+ |
+ // Load the map into the correct register. |
+ DCHECK(feedback.is(VectorStoreTransitionDescriptor::MapRegister())); |
+ __ mr(feedback, too_far); |
+ |
+ __ addi(ip, receiver_map, Operand(Code::kHeaderSize - kHeapObjectTag)); |
+ __ Jump(ip); |
+ |
+ __ bind(&prepare_next); |
+ __ addi(pointer_reg, pointer_reg, Operand(kPointerSize * 3)); |
+ __ cmpl(pointer_reg, too_far); |
+ __ blt(&next_loop); |
+ |
+ // We exhausted our array of map handler pairs. |
+ __ b(miss); |
+} |
+ |
+ |
void VectorKeyedStoreICStub::GenerateImpl(MacroAssembler* masm, bool in_frame) { |
- Label miss; |
+ Register receiver = VectorStoreICDescriptor::ReceiverRegister(); // r4 |
+ Register key = VectorStoreICDescriptor::NameRegister(); // r5 |
+ Register vector = VectorStoreICDescriptor::VectorRegister(); // r6 |
+ Register slot = VectorStoreICDescriptor::SlotRegister(); // r7 |
+ DCHECK(VectorStoreICDescriptor::ValueRegister().is(r3)); // r3 |
+ Register feedback = r8; |
+ Register receiver_map = r9; |
+ Register scratch1 = r10; |
+ |
+ __ SmiToPtrArrayOffset(r0, slot); |
+ __ add(feedback, vector, r0); |
+ __ LoadP(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? |
+ __ LoadP(scratch1, FieldMemOperand(feedback, HeapObject::kMapOffset)); |
+ __ CompareRoot(scratch1, Heap::kFixedArrayMapRootIndex); |
+ __ bne(¬_array); |
+ |
+ // We have a polymorphic element handler. |
+ Label polymorphic, try_poly_name; |
+ __ bind(&polymorphic); |
+ |
+ Register scratch2 = r11; |
+ |
+ HandlePolymorphicStoreCase(masm, feedback, receiver_map, scratch1, scratch2, |
+ &miss); |
+ |
+ __ bind(¬_array); |
+ // Is it generic? |
+ __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex); |
+ __ bne(&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); |
+ __ bne(&miss); |
+ // If the name comparison succeeded, we know we have a fixed array with |
+ // at least one map/handler pair. |
+ __ SmiToPtrArrayOffset(r0, slot); |
+ __ add(feedback, vector, r0); |
+ __ LoadP(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); |
+ __ b(&compare_map); |
} |