OLD | NEW |
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 #if V8_TARGET_ARCH_PPC | 5 #if V8_TARGET_ARCH_PPC |
6 | 6 |
7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 2777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2788 __ CallStub(&stub); | 2788 __ CallStub(&stub); |
2789 __ cmpi(r3, Operand::Zero()); | 2789 __ cmpi(r3, Operand::Zero()); |
2790 | 2790 |
2791 __ MultiPop(spill_mask); // MultiPop does not touch condition flags | 2791 __ MultiPop(spill_mask); // MultiPop does not touch condition flags |
2792 __ mtlr(r0); | 2792 __ mtlr(r0); |
2793 | 2793 |
2794 __ beq(done); | 2794 __ beq(done); |
2795 __ bne(miss); | 2795 __ bne(miss); |
2796 } | 2796 } |
2797 | 2797 |
2798 | |
2799 // Probe the name dictionary in the |elements| register. Jump to the | |
2800 // |done| label if a property with the given name is found. Jump to | |
2801 // the |miss| label otherwise. | |
2802 // If lookup was successful |scratch2| will be equal to elements + 4 * index. | |
2803 void NameDictionaryLookupStub::GeneratePositiveLookup( | |
2804 MacroAssembler* masm, Label* miss, Label* done, Register elements, | |
2805 Register name, Register scratch1, Register scratch2) { | |
2806 DCHECK(!elements.is(scratch1)); | |
2807 DCHECK(!elements.is(scratch2)); | |
2808 DCHECK(!name.is(scratch1)); | |
2809 DCHECK(!name.is(scratch2)); | |
2810 | |
2811 __ AssertName(name); | |
2812 | |
2813 // Compute the capacity mask. | |
2814 __ LoadP(scratch1, FieldMemOperand(elements, kCapacityOffset)); | |
2815 __ SmiUntag(scratch1); // convert smi to int | |
2816 __ subi(scratch1, scratch1, Operand(1)); | |
2817 | |
2818 // Generate an unrolled loop that performs a few probes before | |
2819 // giving up. Measurements done on Gmail indicate that 2 probes | |
2820 // cover ~93% of loads from dictionaries. | |
2821 for (int i = 0; i < kInlinedProbes; i++) { | |
2822 // Compute the masked index: (hash + i + i * i) & mask. | |
2823 __ lwz(scratch2, FieldMemOperand(name, Name::kHashFieldOffset)); | |
2824 if (i > 0) { | |
2825 // Add the probe offset (i + i * i) left shifted to avoid right shifting | |
2826 // the hash in a separate instruction. The value hash + i + i * i is right | |
2827 // shifted in the following and instruction. | |
2828 DCHECK(NameDictionary::GetProbeOffset(i) < | |
2829 1 << (32 - Name::kHashFieldOffset)); | |
2830 __ addi(scratch2, scratch2, | |
2831 Operand(NameDictionary::GetProbeOffset(i) << Name::kHashShift)); | |
2832 } | |
2833 __ srwi(scratch2, scratch2, Operand(Name::kHashShift)); | |
2834 __ and_(scratch2, scratch1, scratch2); | |
2835 | |
2836 // Scale the index by multiplying by the entry size. | |
2837 STATIC_ASSERT(NameDictionary::kEntrySize == 3); | |
2838 // scratch2 = scratch2 * 3. | |
2839 __ ShiftLeftImm(ip, scratch2, Operand(1)); | |
2840 __ add(scratch2, scratch2, ip); | |
2841 | |
2842 // Check if the key is identical to the name. | |
2843 __ ShiftLeftImm(ip, scratch2, Operand(kPointerSizeLog2)); | |
2844 __ add(scratch2, elements, ip); | |
2845 __ LoadP(ip, FieldMemOperand(scratch2, kElementsStartOffset)); | |
2846 __ cmp(name, ip); | |
2847 __ beq(done); | |
2848 } | |
2849 | |
2850 const int spill_mask = (r0.bit() | r9.bit() | r8.bit() | r7.bit() | r6.bit() | | |
2851 r5.bit() | r4.bit() | r3.bit()) & | |
2852 ~(scratch1.bit() | scratch2.bit()); | |
2853 | |
2854 __ mflr(r0); | |
2855 __ MultiPush(spill_mask); | |
2856 if (name.is(r3)) { | |
2857 DCHECK(!elements.is(r4)); | |
2858 __ mr(r4, name); | |
2859 __ mr(r3, elements); | |
2860 } else { | |
2861 __ mr(r3, elements); | |
2862 __ mr(r4, name); | |
2863 } | |
2864 NameDictionaryLookupStub stub(masm->isolate(), POSITIVE_LOOKUP); | |
2865 __ CallStub(&stub); | |
2866 __ cmpi(r3, Operand::Zero()); | |
2867 __ mr(scratch2, r5); | |
2868 __ MultiPop(spill_mask); | |
2869 __ mtlr(r0); | |
2870 | |
2871 __ bne(done); | |
2872 __ beq(miss); | |
2873 } | |
2874 | |
2875 | |
2876 void NameDictionaryLookupStub::Generate(MacroAssembler* masm) { | 2798 void NameDictionaryLookupStub::Generate(MacroAssembler* masm) { |
2877 // This stub overrides SometimesSetsUpAFrame() to return false. That means | 2799 // This stub overrides SometimesSetsUpAFrame() to return false. That means |
2878 // we cannot call anything that could cause a GC from this stub. | 2800 // we cannot call anything that could cause a GC from this stub. |
2879 // Registers: | 2801 // Registers: |
2880 // result: NameDictionary to probe | 2802 // result: NameDictionary to probe |
2881 // r4: key | 2803 // r4: key |
2882 // dictionary: NameDictionary to probe. | 2804 // dictionary: NameDictionary to probe. |
2883 // index: will hold an index of entry if lookup is successful. | 2805 // index: will hold an index of entry if lookup is successful. |
2884 // might alias with result_. | 2806 // might alias with result_. |
2885 // Returns: | 2807 // Returns: |
(...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4422 fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); | 4344 fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); |
4423 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 4345 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
4424 kStackUnwindSpace, NULL, return_value_operand, NULL); | 4346 kStackUnwindSpace, NULL, return_value_operand, NULL); |
4425 } | 4347 } |
4426 | 4348 |
4427 #undef __ | 4349 #undef __ |
4428 } // namespace internal | 4350 } // namespace internal |
4429 } // namespace v8 | 4351 } // namespace v8 |
4430 | 4352 |
4431 #endif // V8_TARGET_ARCH_PPC | 4353 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |