OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 (1 << Map::kHasNamedInterceptor))); | 90 (1 << Map::kHasNamedInterceptor))); |
91 __ j(not_zero, miss); | 91 __ j(not_zero, miss); |
92 | 92 |
93 __ movq(r0, FieldOperand(receiver, JSObject::kPropertiesOffset)); | 93 __ movq(r0, FieldOperand(receiver, JSObject::kPropertiesOffset)); |
94 __ CompareRoot(FieldOperand(r0, HeapObject::kMapOffset), | 94 __ CompareRoot(FieldOperand(r0, HeapObject::kMapOffset), |
95 Heap::kHashTableMapRootIndex); | 95 Heap::kHashTableMapRootIndex); |
96 __ j(not_equal, miss); | 96 __ j(not_equal, miss); |
97 } | 97 } |
98 | 98 |
99 | 99 |
100 // Probe the string dictionary in the |elements| register. Jump to the | |
101 // |done| label if a property with the given name is found leaving the | |
102 // index into the dictionary in |r1|. Jump to the |miss| label | |
103 // otherwise. | |
104 static void GenerateStringDictionaryProbes(MacroAssembler* masm, | |
105 Label* miss, | |
106 Label* done, | |
107 Register elements, | |
108 Register name, | |
109 Register r0, | |
110 Register r1) { | |
111 // Assert that name contains a string. | |
112 if (FLAG_debug_code) __ AbortIfNotString(name); | |
113 | |
114 // Compute the capacity mask. | |
115 const int kCapacityOffset = | |
116 StringDictionary::kHeaderSize + | |
117 StringDictionary::kCapacityIndex * kPointerSize; | |
118 __ SmiToInteger32(r0, FieldOperand(elements, kCapacityOffset)); | |
119 __ decl(r0); | |
120 | |
121 // Generate an unrolled loop that performs a few probes before | |
122 // giving up. Measurements done on Gmail indicate that 2 probes | |
123 // cover ~93% of loads from dictionaries. | |
124 static const int kProbes = 4; | |
125 const int kElementsStartOffset = | |
126 StringDictionary::kHeaderSize + | |
127 StringDictionary::kElementsStartIndex * kPointerSize; | |
128 for (int i = 0; i < kProbes; i++) { | |
129 // Compute the masked index: (hash + i + i * i) & mask. | |
130 __ movl(r1, FieldOperand(name, String::kHashFieldOffset)); | |
131 __ shrl(r1, Immediate(String::kHashShift)); | |
132 if (i > 0) { | |
133 __ addl(r1, Immediate(StringDictionary::GetProbeOffset(i))); | |
134 } | |
135 __ and_(r1, r0); | |
136 | |
137 // Scale the index by multiplying by the entry size. | |
138 ASSERT(StringDictionary::kEntrySize == 3); | |
139 __ lea(r1, Operand(r1, r1, times_2, 0)); // r1 = r1 * 3 | |
140 | |
141 // Check if the key is identical to the name. | |
142 __ cmpq(name, Operand(elements, r1, times_pointer_size, | |
143 kElementsStartOffset - kHeapObjectTag)); | |
144 if (i != kProbes - 1) { | |
145 __ j(equal, done); | |
146 } else { | |
147 __ j(not_equal, miss); | |
148 } | |
149 } | |
150 } | |
151 | |
152 | 100 |
153 // Helper function used to load a property from a dictionary backing storage. | 101 // Helper function used to load a property from a dictionary backing storage. |
154 // This function may return false negatives, so miss_label | 102 // This function may return false negatives, so miss_label |
155 // must always call a backup property load that is complete. | 103 // must always call a backup property load that is complete. |
156 // This function is safe to call if name is not a symbol, and will jump to | 104 // This function is safe to call if name is not a symbol, and will jump to |
157 // the miss_label in that case. | 105 // the miss_label in that case. |
158 // The generated code assumes that the receiver has slow properties, | 106 // The generated code assumes that the receiver has slow properties, |
159 // is not a global object and does not have interceptors. | 107 // is not a global object and does not have interceptors. |
160 static void GenerateDictionaryLoad(MacroAssembler* masm, | 108 static void GenerateDictionaryLoad(MacroAssembler* masm, |
161 Label* miss_label, | 109 Label* miss_label, |
(...skipping 10 matching lines...) Expand all Loading... |
172 // | 120 // |
173 // r0 - used to hold the capacity of the property dictionary. | 121 // r0 - used to hold the capacity of the property dictionary. |
174 // | 122 // |
175 // r1 - used to hold the index into the property dictionary. | 123 // r1 - used to hold the index into the property dictionary. |
176 // | 124 // |
177 // result - holds the result on exit if the load succeeded. | 125 // result - holds the result on exit if the load succeeded. |
178 | 126 |
179 Label done; | 127 Label done; |
180 | 128 |
181 // Probe the dictionary. | 129 // Probe the dictionary. |
182 GenerateStringDictionaryProbes(masm, | 130 StringDictionaryLookupStub::GeneratePositiveLookup(masm, |
183 miss_label, | 131 miss_label, |
184 &done, | 132 &done, |
185 elements, | 133 elements, |
186 name, | 134 name, |
187 r0, | 135 r0, |
188 r1); | 136 r1); |
189 | 137 |
190 // If probing finds an entry in the dictionary, r0 contains the | 138 // If probing finds an entry in the dictionary, r0 contains the |
191 // index into the dictionary. Check that the value is a normal | 139 // index into the dictionary. Check that the value is a normal |
192 // property. | 140 // property. |
193 __ bind(&done); | 141 __ bind(&done); |
194 const int kElementsStartOffset = | 142 const int kElementsStartOffset = |
195 StringDictionary::kHeaderSize + | 143 StringDictionary::kHeaderSize + |
196 StringDictionary::kElementsStartIndex * kPointerSize; | 144 StringDictionary::kElementsStartIndex * kPointerSize; |
197 const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize; | 145 const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize; |
198 __ Test(Operand(elements, r1, times_pointer_size, | 146 __ Test(Operand(elements, r1, times_pointer_size, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 // | 178 // |
231 // value - holds the value to store and is unchanged. | 179 // value - holds the value to store and is unchanged. |
232 // | 180 // |
233 // scratch0 - used for index into the property dictionary and is clobbered. | 181 // scratch0 - used for index into the property dictionary and is clobbered. |
234 // | 182 // |
235 // scratch1 - used to hold the capacity of the property dictionary and is | 183 // scratch1 - used to hold the capacity of the property dictionary and is |
236 // clobbered. | 184 // clobbered. |
237 Label done; | 185 Label done; |
238 | 186 |
239 // Probe the dictionary. | 187 // Probe the dictionary. |
240 GenerateStringDictionaryProbes(masm, | 188 StringDictionaryLookupStub::GeneratePositiveLookup(masm, |
241 miss_label, | 189 miss_label, |
242 &done, | 190 &done, |
243 elements, | 191 elements, |
244 name, | 192 name, |
245 scratch0, | 193 scratch0, |
246 scratch1); | 194 scratch1); |
247 | 195 |
248 // If probing finds an entry in the dictionary, scratch0 contains the | 196 // If probing finds an entry in the dictionary, scratch0 contains the |
249 // index into the dictionary. Check that the value is a normal | 197 // index into the dictionary. Check that the value is a normal |
250 // property that is not read only. | 198 // property that is not read only. |
251 __ bind(&done); | 199 __ bind(&done); |
252 const int kElementsStartOffset = | 200 const int kElementsStartOffset = |
253 StringDictionary::kHeaderSize + | 201 StringDictionary::kHeaderSize + |
254 StringDictionary::kElementsStartIndex * kPointerSize; | 202 StringDictionary::kElementsStartIndex * kPointerSize; |
255 const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize; | 203 const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize; |
256 const int kTypeAndReadOnlyMask | 204 const int kTypeAndReadOnlyMask |
(...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1609 Condition cc = *jmp_address == Assembler::kJncShortOpcode | 1557 Condition cc = *jmp_address == Assembler::kJncShortOpcode |
1610 ? not_zero | 1558 ? not_zero |
1611 : zero; | 1559 : zero; |
1612 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); | 1560 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); |
1613 } | 1561 } |
1614 | 1562 |
1615 | 1563 |
1616 } } // namespace v8::internal | 1564 } } // namespace v8::internal |
1617 | 1565 |
1618 #endif // V8_TARGET_ARCH_X64 | 1566 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |