OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
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 2818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2829 __ li(a1, Operand(Handle<Name>(name))); | 2829 __ li(a1, Operand(Handle<Name>(name))); |
2830 NameDictionaryLookupStub stub(masm->isolate(), NEGATIVE_LOOKUP); | 2830 NameDictionaryLookupStub stub(masm->isolate(), NEGATIVE_LOOKUP); |
2831 __ CallStub(&stub); | 2831 __ CallStub(&stub); |
2832 __ mov(at, v0); | 2832 __ mov(at, v0); |
2833 __ MultiPop(spill_mask); | 2833 __ MultiPop(spill_mask); |
2834 | 2834 |
2835 __ Branch(done, eq, at, Operand(zero_reg)); | 2835 __ Branch(done, eq, at, Operand(zero_reg)); |
2836 __ Branch(miss, ne, at, Operand(zero_reg)); | 2836 __ Branch(miss, ne, at, Operand(zero_reg)); |
2837 } | 2837 } |
2838 | 2838 |
2839 | |
2840 // Probe the name dictionary in the |elements| register. Jump to the | |
2841 // |done| label if a property with the given name is found. Jump to | |
2842 // the |miss| label otherwise. | |
2843 // If lookup was successful |scratch2| will be equal to elements + 4 * index. | |
2844 void NameDictionaryLookupStub::GeneratePositiveLookup(MacroAssembler* masm, | |
2845 Label* miss, | |
2846 Label* done, | |
2847 Register elements, | |
2848 Register name, | |
2849 Register scratch1, | |
2850 Register scratch2) { | |
2851 DCHECK(!elements.is(scratch1)); | |
2852 DCHECK(!elements.is(scratch2)); | |
2853 DCHECK(!name.is(scratch1)); | |
2854 DCHECK(!name.is(scratch2)); | |
2855 | |
2856 __ AssertName(name); | |
2857 | |
2858 // Compute the capacity mask. | |
2859 __ lw(scratch1, FieldMemOperand(elements, kCapacityOffset)); | |
2860 __ sra(scratch1, scratch1, kSmiTagSize); // convert smi to int | |
2861 __ Subu(scratch1, scratch1, Operand(1)); | |
2862 | |
2863 // Generate an unrolled loop that performs a few probes before | |
2864 // giving up. Measurements done on Gmail indicate that 2 probes | |
2865 // cover ~93% of loads from dictionaries. | |
2866 for (int i = 0; i < kInlinedProbes; i++) { | |
2867 // Compute the masked index: (hash + i + i * i) & mask. | |
2868 __ lw(scratch2, FieldMemOperand(name, Name::kHashFieldOffset)); | |
2869 if (i > 0) { | |
2870 // Add the probe offset (i + i * i) left shifted to avoid right shifting | |
2871 // the hash in a separate instruction. The value hash + i + i * i is right | |
2872 // shifted in the following and instruction. | |
2873 DCHECK(NameDictionary::GetProbeOffset(i) < | |
2874 1 << (32 - Name::kHashFieldOffset)); | |
2875 __ Addu(scratch2, scratch2, Operand( | |
2876 NameDictionary::GetProbeOffset(i) << Name::kHashShift)); | |
2877 } | |
2878 __ srl(scratch2, scratch2, Name::kHashShift); | |
2879 __ And(scratch2, scratch1, scratch2); | |
2880 | |
2881 // Scale the index by multiplying by the element size. | |
2882 STATIC_ASSERT(NameDictionary::kEntrySize == 3); | |
2883 // scratch2 = scratch2 * 3. | |
2884 | |
2885 __ Lsa(scratch2, scratch2, scratch2, 1); | |
2886 | |
2887 // Check if the key is identical to the name. | |
2888 __ Lsa(scratch2, elements, scratch2, 2); | |
2889 __ lw(at, FieldMemOperand(scratch2, kElementsStartOffset)); | |
2890 __ Branch(done, eq, name, Operand(at)); | |
2891 } | |
2892 | |
2893 const int spill_mask = | |
2894 (ra.bit() | t2.bit() | t1.bit() | t0.bit() | | |
2895 a3.bit() | a2.bit() | a1.bit() | a0.bit() | v0.bit()) & | |
2896 ~(scratch1.bit() | scratch2.bit()); | |
2897 | |
2898 __ MultiPush(spill_mask); | |
2899 if (name.is(a0)) { | |
2900 DCHECK(!elements.is(a1)); | |
2901 __ Move(a1, name); | |
2902 __ Move(a0, elements); | |
2903 } else { | |
2904 __ Move(a0, elements); | |
2905 __ Move(a1, name); | |
2906 } | |
2907 NameDictionaryLookupStub stub(masm->isolate(), POSITIVE_LOOKUP); | |
2908 __ CallStub(&stub); | |
2909 __ mov(scratch2, a2); | |
2910 __ mov(at, v0); | |
2911 __ MultiPop(spill_mask); | |
2912 | |
2913 __ Branch(done, ne, at, Operand(zero_reg)); | |
2914 __ Branch(miss, eq, at, Operand(zero_reg)); | |
2915 } | |
2916 | |
2917 | |
2918 void NameDictionaryLookupStub::Generate(MacroAssembler* masm) { | 2839 void NameDictionaryLookupStub::Generate(MacroAssembler* masm) { |
2919 // This stub overrides SometimesSetsUpAFrame() to return false. That means | 2840 // This stub overrides SometimesSetsUpAFrame() to return false. That means |
2920 // we cannot call anything that could cause a GC from this stub. | 2841 // we cannot call anything that could cause a GC from this stub. |
2921 // Registers: | 2842 // Registers: |
2922 // result: NameDictionary to probe | 2843 // result: NameDictionary to probe |
2923 // a1: key | 2844 // a1: key |
2924 // dictionary: NameDictionary to probe. | 2845 // dictionary: NameDictionary to probe. |
2925 // index: will hold an index of entry if lookup is successful. | 2846 // index: will hold an index of entry if lookup is successful. |
2926 // might alias with result_. | 2847 // might alias with result_. |
2927 // Returns: | 2848 // Returns: |
(...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4365 kStackUnwindSpace, kInvalidStackOffset, | 4286 kStackUnwindSpace, kInvalidStackOffset, |
4366 return_value_operand, NULL); | 4287 return_value_operand, NULL); |
4367 } | 4288 } |
4368 | 4289 |
4369 #undef __ | 4290 #undef __ |
4370 | 4291 |
4371 } // namespace internal | 4292 } // namespace internal |
4372 } // namespace v8 | 4293 } // namespace v8 |
4373 | 4294 |
4374 #endif // V8_TARGET_ARCH_MIPS | 4295 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |