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_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
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/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 2822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2833 __ li(a1, Operand(Handle<Name>(name))); | 2833 __ li(a1, Operand(Handle<Name>(name))); |
2834 NameDictionaryLookupStub stub(masm->isolate(), NEGATIVE_LOOKUP); | 2834 NameDictionaryLookupStub stub(masm->isolate(), NEGATIVE_LOOKUP); |
2835 __ CallStub(&stub); | 2835 __ CallStub(&stub); |
2836 __ mov(at, v0); | 2836 __ mov(at, v0); |
2837 __ MultiPop(spill_mask); | 2837 __ MultiPop(spill_mask); |
2838 | 2838 |
2839 __ Branch(done, eq, at, Operand(zero_reg)); | 2839 __ Branch(done, eq, at, Operand(zero_reg)); |
2840 __ Branch(miss, ne, at, Operand(zero_reg)); | 2840 __ Branch(miss, ne, at, Operand(zero_reg)); |
2841 } | 2841 } |
2842 | 2842 |
2843 | |
2844 // Probe the name dictionary in the |elements| register. Jump to the | |
2845 // |done| label if a property with the given name is found. Jump to | |
2846 // the |miss| label otherwise. | |
2847 // If lookup was successful |scratch2| will be equal to elements + 4 * index. | |
2848 void NameDictionaryLookupStub::GeneratePositiveLookup(MacroAssembler* masm, | |
2849 Label* miss, | |
2850 Label* done, | |
2851 Register elements, | |
2852 Register name, | |
2853 Register scratch1, | |
2854 Register scratch2) { | |
2855 DCHECK(!elements.is(scratch1)); | |
2856 DCHECK(!elements.is(scratch2)); | |
2857 DCHECK(!name.is(scratch1)); | |
2858 DCHECK(!name.is(scratch2)); | |
2859 | |
2860 __ AssertName(name); | |
2861 | |
2862 // Compute the capacity mask. | |
2863 __ ld(scratch1, FieldMemOperand(elements, kCapacityOffset)); | |
2864 __ SmiUntag(scratch1); | |
2865 __ Dsubu(scratch1, scratch1, Operand(1)); | |
2866 | |
2867 // Generate an unrolled loop that performs a few probes before | |
2868 // giving up. Measurements done on Gmail indicate that 2 probes | |
2869 // cover ~93% of loads from dictionaries. | |
2870 for (int i = 0; i < kInlinedProbes; i++) { | |
2871 // Compute the masked index: (hash + i + i * i) & mask. | |
2872 __ lwu(scratch2, FieldMemOperand(name, Name::kHashFieldOffset)); | |
2873 if (i > 0) { | |
2874 // Add the probe offset (i + i * i) left shifted to avoid right shifting | |
2875 // the hash in a separate instruction. The value hash + i + i * i is right | |
2876 // shifted in the following and instruction. | |
2877 DCHECK(NameDictionary::GetProbeOffset(i) < | |
2878 1 << (32 - Name::kHashFieldOffset)); | |
2879 __ Daddu(scratch2, scratch2, Operand( | |
2880 NameDictionary::GetProbeOffset(i) << Name::kHashShift)); | |
2881 } | |
2882 __ dsrl(scratch2, scratch2, Name::kHashShift); | |
2883 __ And(scratch2, scratch1, scratch2); | |
2884 | |
2885 // Scale the index by multiplying by the entry size. | |
2886 STATIC_ASSERT(NameDictionary::kEntrySize == 3); | |
2887 // scratch2 = scratch2 * 3. | |
2888 __ Dlsa(scratch2, scratch2, scratch2, 1); | |
2889 | |
2890 // Check if the key is identical to the name. | |
2891 __ Dlsa(scratch2, elements, scratch2, kPointerSizeLog2); | |
2892 __ ld(at, FieldMemOperand(scratch2, kElementsStartOffset)); | |
2893 __ Branch(done, eq, name, Operand(at)); | |
2894 } | |
2895 | |
2896 const int spill_mask = | |
2897 (ra.bit() | a6.bit() | a5.bit() | a4.bit() | | |
2898 a3.bit() | a2.bit() | a1.bit() | a0.bit() | v0.bit()) & | |
2899 ~(scratch1.bit() | scratch2.bit()); | |
2900 | |
2901 __ MultiPush(spill_mask); | |
2902 if (name.is(a0)) { | |
2903 DCHECK(!elements.is(a1)); | |
2904 __ Move(a1, name); | |
2905 __ Move(a0, elements); | |
2906 } else { | |
2907 __ Move(a0, elements); | |
2908 __ Move(a1, name); | |
2909 } | |
2910 NameDictionaryLookupStub stub(masm->isolate(), POSITIVE_LOOKUP); | |
2911 __ CallStub(&stub); | |
2912 __ mov(scratch2, a2); | |
2913 __ mov(at, v0); | |
2914 __ MultiPop(spill_mask); | |
2915 | |
2916 __ Branch(done, ne, at, Operand(zero_reg)); | |
2917 __ Branch(miss, eq, at, Operand(zero_reg)); | |
2918 } | |
2919 | |
2920 | |
2921 void NameDictionaryLookupStub::Generate(MacroAssembler* masm) { | 2843 void NameDictionaryLookupStub::Generate(MacroAssembler* masm) { |
2922 // This stub overrides SometimesSetsUpAFrame() to return false. That means | 2844 // This stub overrides SometimesSetsUpAFrame() to return false. That means |
2923 // we cannot call anything that could cause a GC from this stub. | 2845 // we cannot call anything that could cause a GC from this stub. |
2924 // Registers: | 2846 // Registers: |
2925 // result: NameDictionary to probe | 2847 // result: NameDictionary to probe |
2926 // a1: key | 2848 // a1: key |
2927 // dictionary: NameDictionary to probe. | 2849 // dictionary: NameDictionary to probe. |
2928 // index: will hold an index of entry if lookup is successful. | 2850 // index: will hold an index of entry if lookup is successful. |
2929 // might alias with result_. | 2851 // might alias with result_. |
2930 // Returns: | 2852 // Returns: |
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4389 kStackUnwindSpace, kInvalidStackOffset, | 4311 kStackUnwindSpace, kInvalidStackOffset, |
4390 return_value_operand, NULL); | 4312 return_value_operand, NULL); |
4391 } | 4313 } |
4392 | 4314 |
4393 #undef __ | 4315 #undef __ |
4394 | 4316 |
4395 } // namespace internal | 4317 } // namespace internal |
4396 } // namespace v8 | 4318 } // namespace v8 |
4397 | 4319 |
4398 #endif // V8_TARGET_ARCH_MIPS64 | 4320 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |