Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/ppc/code-stubs-ppc.cc

Issue 1059133005: PPC: Vector-ICs - speed towards the monomorphic exit as quickly as possible. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_PPC 7 #if V8_TARGET_ARCH_PPC
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 4583 matching lines...) Expand 10 before | Expand all | Expand 10 after
4594 } 4594 }
4595 4595
4596 4596
4597 void VectorRawLoadStub::GenerateForTrampoline(MacroAssembler* masm) { 4597 void VectorRawLoadStub::GenerateForTrampoline(MacroAssembler* masm) {
4598 GenerateImpl(masm, true); 4598 GenerateImpl(masm, true);
4599 } 4599 }
4600 4600
4601 4601
4602 static void HandleArrayCases(MacroAssembler* masm, Register receiver, 4602 static void HandleArrayCases(MacroAssembler* masm, Register receiver,
4603 Register key, Register vector, Register slot, 4603 Register key, Register vector, Register slot,
4604 Register feedback, Register scratch1, 4604 Register feedback, Register receiver_map,
4605 Register scratch2, Register scratch3, 4605 Register scratch1, Register scratch2,
4606 bool is_polymorphic, Label* miss) { 4606 bool is_polymorphic, Label* miss) {
4607 // feedback initially contains the feedback array 4607 // feedback initially contains the feedback array
4608 Label next_loop, prepare_next; 4608 Label next_loop, prepare_next;
4609 Label load_smi_map, compare_map;
4610 Label start_polymorphic; 4609 Label start_polymorphic;
4611 4610
4612 Register receiver_map = scratch1; 4611 Register cached_map = scratch1;
4613 Register cached_map = scratch2;
4614 4612
4615 // Receiver might not be a heap object.
4616 __ JumpIfSmi(receiver, &load_smi_map);
4617 __ LoadP(receiver_map, FieldMemOperand(receiver, HeapObject::kMapOffset));
4618 __ bind(&compare_map);
4619 __ LoadP(cached_map, 4613 __ LoadP(cached_map,
4620 FieldMemOperand(feedback, FixedArray::OffsetOfElementAt(0))); 4614 FieldMemOperand(feedback, FixedArray::OffsetOfElementAt(0)));
4621 __ LoadP(cached_map, FieldMemOperand(cached_map, WeakCell::kValueOffset)); 4615 __ LoadP(cached_map, FieldMemOperand(cached_map, WeakCell::kValueOffset));
4622 __ cmp(receiver_map, cached_map); 4616 __ cmp(receiver_map, cached_map);
4623 __ bne(&start_polymorphic); 4617 __ bne(&start_polymorphic);
4624 // found, now call handler. 4618 // found, now call handler.
4625 Register handler = feedback; 4619 Register handler = feedback;
4626 __ LoadP(handler, 4620 __ LoadP(handler,
4627 FieldMemOperand(feedback, FixedArray::OffsetOfElementAt(1))); 4621 FieldMemOperand(feedback, FixedArray::OffsetOfElementAt(1)));
4628 __ addi(ip, handler, Operand(Code::kHeaderSize - kHeapObjectTag)); 4622 __ addi(ip, handler, Operand(Code::kHeaderSize - kHeapObjectTag));
4629 __ Jump(ip); 4623 __ Jump(ip);
4630 4624
4631 4625
4632 Register length = scratch3; 4626 Register length = scratch2;
4633 __ bind(&start_polymorphic); 4627 __ bind(&start_polymorphic);
4634 __ LoadP(length, FieldMemOperand(feedback, FixedArray::kLengthOffset)); 4628 __ LoadP(length, FieldMemOperand(feedback, FixedArray::kLengthOffset));
4635 if (!is_polymorphic) { 4629 if (!is_polymorphic) {
4636 // If the IC could be monomorphic we have to make sure we don't go past the 4630 // If the IC could be monomorphic we have to make sure we don't go past the
4637 // end of the feedback array. 4631 // end of the feedback array.
4638 __ CmpSmiLiteral(length, Smi::FromInt(2), r0); 4632 __ CmpSmiLiteral(length, Smi::FromInt(2), r0);
4639 __ beq(miss); 4633 __ beq(miss);
4640 } 4634 }
4641 4635
4642 Register too_far = length; 4636 Register too_far = length;
4643 Register pointer_reg = feedback; 4637 Register pointer_reg = feedback;
4644 4638
4645 // +-----+------+------+-----+-----+ ... ----+ 4639 // +-----+------+------+-----+-----+ ... ----+
4646 // | map | len | wm0 | h0 | wm1 | hN | 4640 // | map | len | wm0 | h0 | wm1 | hN |
4647 // +-----+------+------+-----+-----+ ... ----+ 4641 // +-----+------+------+-----+-----+ ... ----+
4648 // 0 1 2 len-1 4642 // 0 1 2 len-1
4649 // ^ ^ 4643 // ^ ^
4650 // | | 4644 // | |
4651 // pointer_reg too_far 4645 // pointer_reg too_far
4652 // aka feedback scratch3 4646 // aka feedback scratch2
4653 // also need receiver_map (aka scratch1) 4647 // also need receiver_map
4654 // use cached_map (scratch2) to look in the weak map values. 4648 // use cached_map (scratch1) to look in the weak map values.
4655 __ SmiToPtrArrayOffset(r0, length); 4649 __ SmiToPtrArrayOffset(r0, length);
4656 __ add(too_far, feedback, r0); 4650 __ add(too_far, feedback, r0);
4657 __ addi(too_far, too_far, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); 4651 __ addi(too_far, too_far, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
4658 __ addi(pointer_reg, feedback, 4652 __ addi(pointer_reg, feedback,
4659 Operand(FixedArray::OffsetOfElementAt(2) - kHeapObjectTag)); 4653 Operand(FixedArray::OffsetOfElementAt(2) - kHeapObjectTag));
4660 4654
4661 __ bind(&next_loop); 4655 __ bind(&next_loop);
4662 __ LoadP(cached_map, MemOperand(pointer_reg)); 4656 __ LoadP(cached_map, MemOperand(pointer_reg));
4663 __ LoadP(cached_map, FieldMemOperand(cached_map, WeakCell::kValueOffset)); 4657 __ LoadP(cached_map, FieldMemOperand(cached_map, WeakCell::kValueOffset));
4664 __ cmp(receiver_map, cached_map); 4658 __ cmp(receiver_map, cached_map);
4665 __ bne(&prepare_next); 4659 __ bne(&prepare_next);
4666 __ LoadP(handler, MemOperand(pointer_reg, kPointerSize)); 4660 __ LoadP(handler, MemOperand(pointer_reg, kPointerSize));
4667 __ addi(ip, handler, Operand(Code::kHeaderSize - kHeapObjectTag)); 4661 __ addi(ip, handler, Operand(Code::kHeaderSize - kHeapObjectTag));
4668 __ Jump(ip); 4662 __ Jump(ip);
4669 4663
4670 __ bind(&prepare_next); 4664 __ bind(&prepare_next);
4671 __ addi(pointer_reg, pointer_reg, Operand(kPointerSize * 2)); 4665 __ addi(pointer_reg, pointer_reg, Operand(kPointerSize * 2));
4672 __ cmp(pointer_reg, too_far); 4666 __ cmp(pointer_reg, too_far);
4673 __ blt(&next_loop); 4667 __ blt(&next_loop);
4674 4668
4675 // We exhausted our array of map handler pairs. 4669 // We exhausted our array of map handler pairs.
4676 __ b(miss); 4670 __ b(miss);
4677
4678 __ bind(&load_smi_map);
4679 __ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex);
4680 __ b(&compare_map);
4681 } 4671 }
4682 4672
4683 4673
4684 static void HandleMonomorphicCase(MacroAssembler* masm, Register receiver, 4674 static void HandleMonomorphicCase(MacroAssembler* masm, Register receiver,
4685 Register key, Register vector, Register slot, 4675 Register receiver_map, Register feedback,
4686 Register weak_cell, Register scratch, 4676 Register vector, Register slot,
4687 Label* miss) { 4677 Register scratch, Label* compare_map,
4688 // feedback initially contains the feedback array 4678 Label* load_smi_map, Label* try_array) {
4689 Label compare_smi_map; 4679 __ JumpIfSmi(receiver, load_smi_map);
4690 Register receiver_map = scratch; 4680 __ LoadP(receiver_map, FieldMemOperand(receiver, HeapObject::kMapOffset));
4691 Register cached_map = weak_cell; 4681 __ bind(compare_map);
4692 4682 Register cached_map = scratch;
4693 // Move the weak map into the weak_cell register. 4683 // Move the weak map into the weak_cell register.
4694 __ LoadP(cached_map, FieldMemOperand(weak_cell, WeakCell::kValueOffset)); 4684 __ LoadP(cached_map, FieldMemOperand(feedback, WeakCell::kValueOffset));
4695
4696 // Receiver might not be a heap object.
4697 __ JumpIfSmi(receiver, &compare_smi_map);
4698 __ LoadP(receiver_map, FieldMemOperand(receiver, HeapObject::kMapOffset));
4699 __ cmp(cached_map, receiver_map); 4685 __ cmp(cached_map, receiver_map);
4700 __ bne(miss); 4686 __ bne(try_array);
4701 4687 Register handler = feedback;
4702 Register handler = weak_cell;
4703 __ SmiToPtrArrayOffset(r0, slot); 4688 __ SmiToPtrArrayOffset(r0, slot);
4704 __ add(handler, vector, r0); 4689 __ add(handler, vector, r0);
4705 __ LoadP(handler, 4690 __ LoadP(handler,
4706 FieldMemOperand(handler, FixedArray::kHeaderSize + kPointerSize));
4707 __ addi(ip, handler, Operand(Code::kHeaderSize - kHeapObjectTag));
4708 __ Jump(ip);
4709
4710 // In microbenchmarks, it made sense to unroll this code so that the call to
4711 // the handler is duplicated for a HeapObject receiver and a Smi receiver.
4712 __ bind(&compare_smi_map);
4713 __ CompareRoot(weak_cell, Heap::kHeapNumberMapRootIndex);
4714 __ bne(miss);
4715 __ SmiToPtrArrayOffset(r0, slot);
4716 __ add(handler, vector, r0);
4717 __ LoadP(handler,
4718 FieldMemOperand(handler, FixedArray::kHeaderSize + kPointerSize)); 4691 FieldMemOperand(handler, FixedArray::kHeaderSize + kPointerSize));
4719 __ addi(ip, handler, Operand(Code::kHeaderSize - kHeapObjectTag)); 4692 __ addi(ip, handler, Operand(Code::kHeaderSize - kHeapObjectTag));
4720 __ Jump(ip); 4693 __ Jump(ip);
4721 } 4694 }
4722 4695
4723 4696
4724 void VectorRawLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) { 4697 void VectorRawLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
4725 Register receiver = VectorLoadICDescriptor::ReceiverRegister(); // r4 4698 Register receiver = VectorLoadICDescriptor::ReceiverRegister(); // r4
4726 Register name = VectorLoadICDescriptor::NameRegister(); // r5 4699 Register name = VectorLoadICDescriptor::NameRegister(); // r5
4727 Register vector = VectorLoadICDescriptor::VectorRegister(); // r6 4700 Register vector = VectorLoadICDescriptor::VectorRegister(); // r6
4728 Register slot = VectorLoadICDescriptor::SlotRegister(); // r3 4701 Register slot = VectorLoadICDescriptor::SlotRegister(); // r3
4729 Register feedback = r7; 4702 Register feedback = r7;
4730 Register scratch1 = r8; 4703 Register receiver_map = r8;
4704 Register scratch1 = r9;
4731 4705
4732 __ SmiToPtrArrayOffset(r0, slot); 4706 __ SmiToPtrArrayOffset(r0, slot);
4733 __ add(feedback, vector, r0); 4707 __ add(feedback, vector, r0);
4734 __ LoadP(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize)); 4708 __ LoadP(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize));
4735 4709
4736 // Is it a weak cell? 4710 // Try to quickly handle the monomorphic case without knowing for sure
4737 Label try_array; 4711 // if we have a weak cell in feedback. We do know it's safe to look
4738 Label not_array, smi_key, key_okay, miss; 4712 // at WeakCell::kValueOffset.
4739 __ LoadP(scratch1, FieldMemOperand(feedback, HeapObject::kMapOffset)); 4713 Label try_array, load_smi_map, compare_map;
4740 __ CompareRoot(scratch1, Heap::kWeakCellMapRootIndex); 4714 Label not_array, miss;
4741 __ bne(&try_array); 4715 HandleMonomorphicCase(masm, receiver, receiver_map, feedback, vector, slot,
4742 HandleMonomorphicCase(masm, receiver, name, vector, slot, feedback, scratch1, 4716 scratch1, &compare_map, &load_smi_map, &try_array);
4743 &miss);
4744 4717
4745 // Is it a fixed array? 4718 // Is it a fixed array?
4746 __ bind(&try_array); 4719 __ bind(&try_array);
4720 __ LoadP(scratch1, FieldMemOperand(feedback, HeapObject::kMapOffset));
4747 __ CompareRoot(scratch1, Heap::kFixedArrayMapRootIndex); 4721 __ CompareRoot(scratch1, Heap::kFixedArrayMapRootIndex);
4748 __ bne(&not_array); 4722 __ bne(&not_array);
4749 HandleArrayCases(masm, receiver, name, vector, slot, feedback, scratch1, r9, 4723 HandleArrayCases(masm, receiver, name, vector, slot, feedback, receiver_map,
4750 r10, true, &miss); 4724 scratch1, r10, true, &miss);
4751 4725
4752 __ bind(&not_array); 4726 __ bind(&not_array);
4753 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex); 4727 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex);
4754 __ bne(&miss); 4728 __ bne(&miss);
4755 Code::Flags code_flags = Code::RemoveTypeAndHolderFromFlags( 4729 Code::Flags code_flags = Code::RemoveTypeAndHolderFromFlags(
4756 Code::ComputeHandlerFlags(Code::LOAD_IC)); 4730 Code::ComputeHandlerFlags(Code::LOAD_IC));
4757 masm->isolate()->stub_cache()->GenerateProbe(masm, Code::LOAD_IC, code_flags, 4731 masm->isolate()->stub_cache()->GenerateProbe(masm, Code::LOAD_IC, code_flags,
4758 false, receiver, name, feedback, 4732 false, receiver, name, feedback,
4759 scratch1, r9, r10); 4733 receiver_map, scratch1, r10);
4760 4734
4761 __ bind(&miss); 4735 __ bind(&miss);
4762 LoadIC::GenerateMiss(masm); 4736 LoadIC::GenerateMiss(masm);
4737
4738 __ bind(&load_smi_map);
4739 __ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex);
4740 __ b(&compare_map);
4763 } 4741 }
4764 4742
4765 4743
4766 void VectorRawKeyedLoadStub::Generate(MacroAssembler* masm) { 4744 void VectorRawKeyedLoadStub::Generate(MacroAssembler* masm) {
4767 GenerateImpl(masm, false); 4745 GenerateImpl(masm, false);
4768 } 4746 }
4769 4747
4770 4748
4771 void VectorRawKeyedLoadStub::GenerateForTrampoline(MacroAssembler* masm) { 4749 void VectorRawKeyedLoadStub::GenerateForTrampoline(MacroAssembler* masm) {
4772 GenerateImpl(masm, true); 4750 GenerateImpl(masm, true);
4773 } 4751 }
4774 4752
4775 4753
4776 void VectorRawKeyedLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) { 4754 void VectorRawKeyedLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
4777 Register receiver = VectorLoadICDescriptor::ReceiverRegister(); // r4 4755 Register receiver = VectorLoadICDescriptor::ReceiverRegister(); // r4
4778 Register key = VectorLoadICDescriptor::NameRegister(); // r5 4756 Register key = VectorLoadICDescriptor::NameRegister(); // r5
4779 Register vector = VectorLoadICDescriptor::VectorRegister(); // r6 4757 Register vector = VectorLoadICDescriptor::VectorRegister(); // r6
4780 Register slot = VectorLoadICDescriptor::SlotRegister(); // r3 4758 Register slot = VectorLoadICDescriptor::SlotRegister(); // r3
4781 Register feedback = r7; 4759 Register feedback = r7;
4782 Register scratch1 = r8; 4760 Register receiver_map = r8;
4761 Register scratch1 = r9;
4783 4762
4784 __ SmiToPtrArrayOffset(r0, slot); 4763 __ SmiToPtrArrayOffset(r0, slot);
4785 __ add(feedback, vector, r0); 4764 __ add(feedback, vector, r0);
4786 __ LoadP(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize)); 4765 __ LoadP(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize));
4787 4766
4788 // Is it a weak cell? 4767 // Try to quickly handle the monomorphic case without knowing for sure
4789 Label try_array; 4768 // if we have a weak cell in feedback. We do know it's safe to look
4790 Label not_array, smi_key, key_okay, miss; 4769 // at WeakCell::kValueOffset.
4791 __ LoadP(scratch1, FieldMemOperand(feedback, HeapObject::kMapOffset)); 4770 Label try_array, load_smi_map, compare_map;
4792 __ CompareRoot(scratch1, Heap::kWeakCellMapRootIndex); 4771 Label not_array, miss;
4793 __ bne(&try_array); 4772 HandleMonomorphicCase(masm, receiver, receiver_map, feedback, vector, slot,
4794 HandleMonomorphicCase(masm, receiver, key, vector, slot, feedback, scratch1, 4773 scratch1, &compare_map, &load_smi_map, &try_array);
4795 &miss);
4796 4774
4797 __ bind(&try_array); 4775 __ bind(&try_array);
4798 // Is it a fixed array? 4776 // Is it a fixed array?
4777 __ LoadP(scratch1, FieldMemOperand(feedback, HeapObject::kMapOffset));
4799 __ CompareRoot(scratch1, Heap::kFixedArrayMapRootIndex); 4778 __ CompareRoot(scratch1, Heap::kFixedArrayMapRootIndex);
4800 __ bne(&not_array); 4779 __ bne(&not_array);
4801 4780
4802 // We have a polymorphic element handler. 4781 // We have a polymorphic element handler.
4803 Label polymorphic, try_poly_name; 4782 Label polymorphic, try_poly_name;
4804 __ bind(&polymorphic); 4783 __ bind(&polymorphic);
4805 HandleArrayCases(masm, receiver, key, vector, slot, feedback, scratch1, r9, 4784 HandleArrayCases(masm, receiver, key, vector, slot, feedback, receiver_map,
4806 r10, true, &miss); 4785 scratch1, r10, true, &miss);
4807 4786
4808 __ bind(&not_array); 4787 __ bind(&not_array);
4809 // Is it generic? 4788 // Is it generic?
4810 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex); 4789 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex);
4811 __ bne(&try_poly_name); 4790 __ bne(&try_poly_name);
4812 Handle<Code> megamorphic_stub = 4791 Handle<Code> megamorphic_stub =
4813 KeyedLoadIC::ChooseMegamorphicStub(masm->isolate()); 4792 KeyedLoadIC::ChooseMegamorphicStub(masm->isolate());
4814 __ Jump(megamorphic_stub, RelocInfo::CODE_TARGET); 4793 __ Jump(megamorphic_stub, RelocInfo::CODE_TARGET);
4815 4794
4816 __ bind(&try_poly_name); 4795 __ bind(&try_poly_name);
4817 // We might have a name in feedback, and a fixed array in the next slot. 4796 // We might have a name in feedback, and a fixed array in the next slot.
4818 __ cmp(key, feedback); 4797 __ cmp(key, feedback);
4819 __ bne(&miss); 4798 __ bne(&miss);
4820 // If the name comparison succeeded, we know we have a fixed array with 4799 // If the name comparison succeeded, we know we have a fixed array with
4821 // at least one map/handler pair. 4800 // at least one map/handler pair.
4822 __ SmiToPtrArrayOffset(r0, slot); 4801 __ SmiToPtrArrayOffset(r0, slot);
4823 __ add(feedback, vector, r0); 4802 __ add(feedback, vector, r0);
4824 __ LoadP(feedback, 4803 __ LoadP(feedback,
4825 FieldMemOperand(feedback, FixedArray::kHeaderSize + kPointerSize)); 4804 FieldMemOperand(feedback, FixedArray::kHeaderSize + kPointerSize));
4826 HandleArrayCases(masm, receiver, key, vector, slot, feedback, scratch1, r9, 4805 HandleArrayCases(masm, receiver, key, vector, slot, feedback, receiver_map,
4827 r10, false, &miss); 4806 scratch1, r10, false, &miss);
4828 4807
4829 __ bind(&miss); 4808 __ bind(&miss);
4830 KeyedLoadIC::GenerateMiss(masm); 4809 KeyedLoadIC::GenerateMiss(masm);
4810
4811 __ bind(&load_smi_map);
4812 __ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex);
4813 __ b(&compare_map);
4831 } 4814 }
4832 4815
4833 4816
4834 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { 4817 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) {
4835 if (masm->isolate()->function_entry_hook() != NULL) { 4818 if (masm->isolate()->function_entry_hook() != NULL) {
4836 PredictableCodeSizeScope predictable(masm, 4819 PredictableCodeSizeScope predictable(masm,
4837 #if V8_TARGET_ARCH_PPC64 4820 #if V8_TARGET_ARCH_PPC64
4838 14 * Assembler::kInstrSize); 4821 14 * Assembler::kInstrSize);
4839 #else 4822 #else
4840 11 * Assembler::kInstrSize); 4823 11 * Assembler::kInstrSize);
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
5590 kStackUnwindSpace, NULL, 5573 kStackUnwindSpace, NULL,
5591 MemOperand(fp, 6 * kPointerSize), NULL); 5574 MemOperand(fp, 6 * kPointerSize), NULL);
5592 } 5575 }
5593 5576
5594 5577
5595 #undef __ 5578 #undef __
5596 } 5579 }
5597 } // namespace v8::internal 5580 } // namespace v8::internal
5598 5581
5599 #endif // V8_TARGET_ARCH_PPC 5582 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698