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

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

Issue 1019003002: PPC: Use platform specific stubs for vector-based Load/KeyedLoad. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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"
11 #include "src/code-stubs.h" 11 #include "src/code-stubs.h"
12 #include "src/codegen.h" 12 #include "src/codegen.h"
13 #include "src/ic/handler-compiler.h" 13 #include "src/ic/handler-compiler.h"
14 #include "src/ic/ic.h" 14 #include "src/ic/ic.h"
15 #include "src/ic/stub-cache.h"
15 #include "src/isolate.h" 16 #include "src/isolate.h"
16 #include "src/jsregexp.h" 17 #include "src/jsregexp.h"
17 #include "src/regexp-macro-assembler.h" 18 #include "src/regexp-macro-assembler.h"
18 #include "src/runtime/runtime.h" 19 #include "src/runtime/runtime.h"
19 20
20 namespace v8 { 21 namespace v8 {
21 namespace internal { 22 namespace internal {
22 23
23 24
24 static void InitializeArrayConstructorDescriptor( 25 static void InitializeArrayConstructorDescriptor(
(...skipping 4517 matching lines...) Expand 10 before | Expand all | Expand 10 after
4542 } 4543 }
4543 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE); 4544 masm->LeaveFrame(StackFrame::STUB_FAILURE_TRAMPOLINE);
4544 __ slwi(r4, r4, Operand(kPointerSizeLog2)); 4545 __ slwi(r4, r4, Operand(kPointerSizeLog2));
4545 __ add(sp, sp, r4); 4546 __ add(sp, sp, r4);
4546 __ Ret(); 4547 __ Ret();
4547 } 4548 }
4548 4549
4549 4550
4550 void LoadICTrampolineStub::Generate(MacroAssembler* masm) { 4551 void LoadICTrampolineStub::Generate(MacroAssembler* masm) {
4551 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister()); 4552 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister());
4552 VectorLoadStub stub(isolate(), state()); 4553 VectorRawLoadStub stub(isolate(), state());
4553 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); 4554 stub.GenerateForTrampoline(masm);
4554 } 4555 }
4555 4556
4556 4557
4557 void KeyedLoadICTrampolineStub::Generate(MacroAssembler* masm) { 4558 void KeyedLoadICTrampolineStub::Generate(MacroAssembler* masm) {
4558 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister()); 4559 EmitLoadTypeFeedbackVector(masm, VectorLoadICDescriptor::VectorRegister());
4559 VectorKeyedLoadStub stub(isolate()); 4560 VectorRawKeyedLoadStub stub(isolate());
4560 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); 4561 stub.GenerateForTrampoline(masm);
4561 } 4562 }
4562 4563
4563 4564
4564 void CallICTrampolineStub::Generate(MacroAssembler* masm) { 4565 void CallICTrampolineStub::Generate(MacroAssembler* masm) {
4565 EmitLoadTypeFeedbackVector(masm, r5); 4566 EmitLoadTypeFeedbackVector(masm, r5);
4566 CallICStub stub(isolate(), state()); 4567 CallICStub stub(isolate(), state());
4567 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); 4568 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET);
4568 } 4569 }
4569 4570
4570 4571
4571 void CallIC_ArrayTrampolineStub::Generate(MacroAssembler* masm) { 4572 void CallIC_ArrayTrampolineStub::Generate(MacroAssembler* masm) {
4572 EmitLoadTypeFeedbackVector(masm, r5); 4573 EmitLoadTypeFeedbackVector(masm, r5);
4573 CallIC_ArrayStub stub(isolate(), state()); 4574 CallIC_ArrayStub stub(isolate(), state());
4574 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); 4575 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET);
4575 } 4576 }
4576 4577
4577 4578
4579 void VectorRawLoadStub::Generate(MacroAssembler* masm) {
4580 GenerateImpl(masm, false);
4581 }
4582
4583
4584 void VectorRawLoadStub::GenerateForTrampoline(MacroAssembler* masm) {
4585 GenerateImpl(masm, true);
4586 }
4587
4588
4589 static void HandleArrayCases(MacroAssembler* masm, Register receiver,
4590 Register key, Register vector, Register slot,
4591 Register feedback, Register scratch1,
4592 Register scratch2, Register scratch3,
4593 bool is_polymorphic, Label* miss) {
4594 // feedback initially contains the feedback array
4595 Label next_loop, prepare_next;
4596 Label load_smi_map, compare_map;
4597 Label start_polymorphic;
4598
4599 Register receiver_map = scratch1;
4600 Register cached_map = scratch2;
4601
4602 // Receiver might not be a heap object.
4603 __ JumpIfSmi(receiver, &load_smi_map);
4604 __ LoadP(receiver_map, FieldMemOperand(receiver, HeapObject::kMapOffset));
4605 __ bind(&compare_map);
4606 __ LoadP(cached_map,
4607 FieldMemOperand(feedback, FixedArray::OffsetOfElementAt(0)));
4608 __ LoadP(cached_map, FieldMemOperand(cached_map, WeakCell::kValueOffset));
4609 __ cmp(receiver_map, cached_map);
4610 __ bne(&start_polymorphic);
4611 // found, now call handler.
4612 Register handler = feedback;
4613 __ LoadP(handler,
4614 FieldMemOperand(feedback, FixedArray::OffsetOfElementAt(1)));
4615 __ addi(ip, handler, Operand(Code::kHeaderSize - kHeapObjectTag));
4616 __ Jump(ip);
4617
4618
4619 Register length = scratch3;
4620 __ bind(&start_polymorphic);
4621 __ LoadP(length, FieldMemOperand(feedback, FixedArray::kLengthOffset));
4622 if (!is_polymorphic) {
4623 // If the IC could be monomorphic we have to make sure we don't go past the
4624 // end of the feedback array.
4625 __ CmpSmiLiteral(length, Smi::FromInt(2), r0);
4626 __ beq(miss);
4627 }
4628
4629 Register too_far = length;
4630 Register pointer_reg = feedback;
4631
4632 // +-----+------+------+-----+-----+ ... ----+
4633 // | map | len | wm0 | h0 | wm1 | hN |
4634 // +-----+------+------+-----+-----+ ... ----+
4635 // 0 1 2 len-1
4636 // ^ ^
4637 // | |
4638 // pointer_reg too_far
4639 // aka feedback scratch3
4640 // also need receiver_map (aka scratch1)
4641 // use cached_map (scratch2) to look in the weak map values.
4642 __ SmiToPtrArrayOffset(r0, length);
4643 __ add(too_far, feedback, r0);
4644 __ addi(too_far, too_far, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
4645 __ addi(pointer_reg, feedback,
4646 Operand(FixedArray::OffsetOfElementAt(2) - kHeapObjectTag));
4647
4648 __ bind(&next_loop);
4649 __ LoadP(cached_map, MemOperand(pointer_reg));
4650 __ LoadP(cached_map, FieldMemOperand(cached_map, WeakCell::kValueOffset));
4651 __ cmp(receiver_map, cached_map);
4652 __ bne(&prepare_next);
4653 __ LoadP(handler, MemOperand(pointer_reg, kPointerSize));
4654 __ addi(ip, handler, Operand(Code::kHeaderSize - kHeapObjectTag));
4655 __ Jump(ip);
4656
4657 __ bind(&prepare_next);
4658 __ addi(pointer_reg, pointer_reg, Operand(kPointerSize * 2));
4659 __ cmp(pointer_reg, too_far);
4660 __ blt(&next_loop);
4661
4662 // We exhausted our array of map handler pairs.
4663 __ b(miss);
4664
4665 __ bind(&load_smi_map);
4666 __ LoadRoot(receiver_map, Heap::kHeapNumberMapRootIndex);
4667 __ b(&compare_map);
4668 }
4669
4670
4671 static void HandleMonomorphicCase(MacroAssembler* masm, Register receiver,
4672 Register key, Register vector, Register slot,
4673 Register weak_cell, Register scratch,
4674 Label* miss) {
4675 // feedback initially contains the feedback array
4676 Label compare_smi_map;
4677 Register receiver_map = scratch;
4678 Register cached_map = weak_cell;
4679
4680 // Move the weak map into the weak_cell register.
4681 __ LoadP(cached_map, FieldMemOperand(weak_cell, WeakCell::kValueOffset));
4682
4683 // Receiver might not be a heap object.
4684 __ JumpIfSmi(receiver, &compare_smi_map);
4685 __ LoadP(receiver_map, FieldMemOperand(receiver, HeapObject::kMapOffset));
4686 __ cmp(cached_map, receiver_map);
4687 __ bne(miss);
4688
4689 Register handler = weak_cell;
4690 __ SmiToPtrArrayOffset(r0, slot);
4691 __ add(handler, vector, r0);
4692 __ LoadP(handler,
4693 FieldMemOperand(handler, FixedArray::kHeaderSize + kPointerSize));
4694 __ addi(ip, handler, Operand(Code::kHeaderSize - kHeapObjectTag));
4695 __ Jump(ip);
4696
4697 // In microbenchmarks, it made sense to unroll this code so that the call to
4698 // the handler is duplicated for a HeapObject receiver and a Smi receiver.
4699 __ bind(&compare_smi_map);
4700 __ CompareRoot(weak_cell, Heap::kHeapNumberMapRootIndex);
4701 __ bne(miss);
4702 __ SmiToPtrArrayOffset(r0, slot);
4703 __ add(handler, vector, r0);
4704 __ LoadP(handler,
4705 FieldMemOperand(handler, FixedArray::kHeaderSize + kPointerSize));
4706 __ addi(ip, handler, Operand(Code::kHeaderSize - kHeapObjectTag));
4707 __ Jump(ip);
4708 }
4709
4710
4711 void VectorRawLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
4712 Register receiver = VectorLoadICDescriptor::ReceiverRegister(); // r4
4713 Register name = VectorLoadICDescriptor::NameRegister(); // r5
4714 Register vector = VectorLoadICDescriptor::VectorRegister(); // r6
4715 Register slot = VectorLoadICDescriptor::SlotRegister(); // r3
4716 Register feedback = r7;
4717 Register scratch1 = r8;
4718
4719 __ SmiToPtrArrayOffset(r0, slot);
4720 __ add(feedback, vector, r0);
4721 __ LoadP(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize));
4722
4723 // Is it a weak cell?
4724 Label try_array;
4725 Label not_array, smi_key, key_okay, miss;
4726 __ LoadP(scratch1, FieldMemOperand(feedback, HeapObject::kMapOffset));
4727 __ CompareRoot(scratch1, Heap::kWeakCellMapRootIndex);
4728 __ bne(&try_array);
4729 HandleMonomorphicCase(masm, receiver, name, vector, slot, feedback, scratch1,
4730 &miss);
4731
4732 // Is it a fixed array?
4733 __ bind(&try_array);
4734 __ CompareRoot(scratch1, Heap::kFixedArrayMapRootIndex);
4735 __ bne(&not_array);
4736 HandleArrayCases(masm, receiver, name, vector, slot, feedback, scratch1, r9,
4737 r10, true, &miss);
4738
4739 __ bind(&not_array);
4740 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex);
4741 __ bne(&miss);
4742 Code::Flags code_flags = Code::RemoveTypeAndHolderFromFlags(
4743 Code::ComputeHandlerFlags(Code::LOAD_IC));
4744 masm->isolate()->stub_cache()->GenerateProbe(masm, Code::LOAD_IC, code_flags,
4745 false, receiver, name, feedback,
4746 scratch1, r9, r10);
4747
4748 __ bind(&miss);
4749 LoadIC::GenerateMiss(masm);
4750 }
4751
4752
4753 void VectorRawKeyedLoadStub::Generate(MacroAssembler* masm) {
4754 GenerateImpl(masm, false);
4755 }
4756
4757
4758 void VectorRawKeyedLoadStub::GenerateForTrampoline(MacroAssembler* masm) {
4759 GenerateImpl(masm, true);
4760 }
4761
4762
4763 void VectorRawKeyedLoadStub::GenerateImpl(MacroAssembler* masm, bool in_frame) {
4764 Register receiver = VectorLoadICDescriptor::ReceiverRegister(); // r4
4765 Register key = VectorLoadICDescriptor::NameRegister(); // r5
4766 Register vector = VectorLoadICDescriptor::VectorRegister(); // r6
4767 Register slot = VectorLoadICDescriptor::SlotRegister(); // r3
4768 Register feedback = r7;
4769 Register scratch1 = r8;
4770
4771 __ SmiToPtrArrayOffset(r0, slot);
4772 __ add(feedback, vector, r0);
4773 __ LoadP(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize));
4774
4775 // Is it a weak cell?
4776 Label try_array;
4777 Label not_array, smi_key, key_okay, miss;
4778 __ LoadP(scratch1, FieldMemOperand(feedback, HeapObject::kMapOffset));
4779 __ CompareRoot(scratch1, Heap::kWeakCellMapRootIndex);
4780 __ bne(&try_array);
4781 __ JumpIfNotSmi(key, &miss);
4782 HandleMonomorphicCase(masm, receiver, key, vector, slot, feedback, scratch1,
4783 &miss);
4784
4785 __ bind(&try_array);
4786 // Is it a fixed array?
4787 __ CompareRoot(scratch1, Heap::kFixedArrayMapRootIndex);
4788 __ bne(&not_array);
4789 // We have a polymorphic element handler.
4790 __ JumpIfNotSmi(key, &miss);
4791
4792 Label polymorphic, try_poly_name;
4793 __ bind(&polymorphic);
4794 HandleArrayCases(masm, receiver, key, vector, slot, feedback, scratch1, r9,
4795 r10, true, &miss);
4796
4797 __ bind(&not_array);
4798 // Is it generic?
4799 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex);
4800 __ bne(&try_poly_name);
4801 Handle<Code> megamorphic_stub =
4802 KeyedLoadIC::ChooseMegamorphicStub(masm->isolate());
4803 __ Jump(megamorphic_stub, RelocInfo::CODE_TARGET);
4804
4805 __ bind(&try_poly_name);
4806 // We might have a name in feedback, and a fixed array in the next slot.
4807 __ cmp(key, feedback);
4808 __ bne(&miss);
4809 // If the name comparison succeeded, we know we have a fixed array with
4810 // at least one map/handler pair.
4811 __ SmiToPtrArrayOffset(r0, slot);
4812 __ add(feedback, vector, r0);
4813 __ LoadP(feedback,
4814 FieldMemOperand(feedback, FixedArray::kHeaderSize + kPointerSize));
4815 HandleArrayCases(masm, receiver, key, vector, slot, feedback, scratch1, r9,
4816 r10, false, &miss);
4817
4818 __ bind(&miss);
4819 KeyedLoadIC::GenerateMiss(masm);
4820 }
4821
4822
4578 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { 4823 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) {
4579 if (masm->isolate()->function_entry_hook() != NULL) { 4824 if (masm->isolate()->function_entry_hook() != NULL) {
4580 PredictableCodeSizeScope predictable(masm, 4825 PredictableCodeSizeScope predictable(masm,
4581 #if V8_TARGET_ARCH_PPC64 4826 #if V8_TARGET_ARCH_PPC64
4582 14 * Assembler::kInstrSize); 4827 14 * Assembler::kInstrSize);
4583 #else 4828 #else
4584 11 * Assembler::kInstrSize); 4829 11 * Assembler::kInstrSize);
4585 #endif 4830 #endif
4586 ProfileEntryHookStub stub(masm->isolate()); 4831 ProfileEntryHookStub stub(masm->isolate());
4587 __ mflr(r0); 4832 __ mflr(r0);
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
5334 kStackUnwindSpace, NULL, 5579 kStackUnwindSpace, NULL,
5335 MemOperand(fp, 6 * kPointerSize), NULL); 5580 MemOperand(fp, 6 * kPointerSize), NULL);
5336 } 5581 }
5337 5582
5338 5583
5339 #undef __ 5584 #undef __
5340 } 5585 }
5341 } // namespace v8::internal 5586 } // namespace v8::internal
5342 5587
5343 #endif // V8_TARGET_ARCH_PPC 5588 #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