OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 // | 65 // |
66 // r2 - used to hold the capacity of the property dictionary. | 66 // r2 - used to hold the capacity of the property dictionary. |
67 // | 67 // |
68 // name - holds the name of the property and is unchanged. | 68 // name - holds the name of the property and is unchanged. |
69 | 69 |
70 Label done; | 70 Label done; |
71 | 71 |
72 // Check for the absence of an interceptor. | 72 // Check for the absence of an interceptor. |
73 // Load the map into r0. | 73 // Load the map into r0. |
74 __ movq(r0, FieldOperand(r1, JSObject::kMapOffset)); | 74 __ movq(r0, FieldOperand(r1, JSObject::kMapOffset)); |
75 // Test the has_named_interceptor bit in the map. | |
76 __ testl(FieldOperand(r0, Map::kInstanceAttributesOffset), | |
77 Immediate(1 << (Map::kHasNamedInterceptor + (3 * 8)))); | |
78 | 75 |
79 // Jump to miss if the interceptor bit is set. | 76 // Bail out if the receiver has a named interceptor. |
77 __ testl(FieldOperand(r0, Map::kBitFieldOffset), | |
Vyacheslav Egorov (Chromium)
2010/03/26 09:00:28
Unaligned read. Is it good?
Version with tricky
| |
78 Immediate(1 << Map::kHasNamedInterceptor)); | |
80 __ j(not_zero, miss_label); | 79 __ j(not_zero, miss_label); |
81 | 80 |
82 // Bail out if we have a JS global proxy object. | 81 // Bail out if we have a JS global proxy object. |
83 __ movzxbq(r0, FieldOperand(r0, Map::kInstanceTypeOffset)); | 82 __ movzxbq(r0, FieldOperand(r0, Map::kInstanceTypeOffset)); |
84 __ cmpb(r0, Immediate(JS_GLOBAL_PROXY_TYPE)); | 83 __ cmpb(r0, Immediate(JS_GLOBAL_PROXY_TYPE)); |
85 __ j(equal, miss_label); | 84 __ j(equal, miss_label); |
86 | 85 |
87 // Possible work-around for http://crbug.com/16276. | 86 // Possible work-around for http://crbug.com/16276. |
88 __ cmpb(r0, Immediate(JS_GLOBAL_OBJECT_TYPE)); | 87 __ cmpb(r0, Immediate(JS_GLOBAL_OBJECT_TYPE)); |
89 __ j(equal, miss_label); | 88 __ j(equal, miss_label); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 __ shrl(r1, Immediate(4)); | 193 __ shrl(r1, Immediate(4)); |
195 __ xorl(r0, r1); | 194 __ xorl(r0, r1); |
196 // hash = hash * 2057; | 195 // hash = hash * 2057; |
197 __ imull(r0, r0, Immediate(2057)); | 196 __ imull(r0, r0, Immediate(2057)); |
198 // hash = hash ^ (hash >> 16); | 197 // hash = hash ^ (hash >> 16); |
199 __ movl(r1, r0); | 198 __ movl(r1, r0); |
200 __ shrl(r1, Immediate(16)); | 199 __ shrl(r1, Immediate(16)); |
201 __ xorl(r0, r1); | 200 __ xorl(r0, r1); |
202 | 201 |
203 // Compute capacity mask. | 202 // Compute capacity mask. |
204 const int kCapacityOffset = | 203 __ movq(r1, FieldOperand(elements, NumberDictionary::kCapacityOffset)); |
205 StringDictionary::kHeaderSize + | |
206 StringDictionary::kCapacityIndex * kPointerSize; | |
207 __ movq(r1, FieldOperand(elements, kCapacityOffset)); | |
208 __ SmiToInteger32(r1, r1); | 204 __ SmiToInteger32(r1, r1); |
209 __ decl(r1); | 205 __ decl(r1); |
210 | 206 |
211 const int kElementsStartOffset = | |
212 NumberDictionary::kHeaderSize + | |
213 NumberDictionary::kElementsStartIndex * kPointerSize; | |
214 | |
215 // Generate an unrolled loop that performs a few probes before giving up. | 207 // Generate an unrolled loop that performs a few probes before giving up. |
216 const int kProbes = 4; | 208 const int kProbes = 4; |
217 for (int i = 0; i < kProbes; i++) { | 209 for (int i = 0; i < kProbes; i++) { |
218 // Use r2 for index calculations and keep the hash intact in r0. | 210 // Use r2 for index calculations and keep the hash intact in r0. |
219 __ movq(r2, r0); | 211 __ movq(r2, r0); |
220 // Compute the masked index: (hash + i + i * i) & mask. | 212 // Compute the masked index: (hash + i + i * i) & mask. |
221 if (i > 0) { | 213 if (i > 0) { |
222 __ addl(r2, Immediate(NumberDictionary::GetProbeOffset(i))); | 214 __ addl(r2, Immediate(NumberDictionary::GetProbeOffset(i))); |
223 } | 215 } |
224 __ and_(r2, r1); | 216 __ and_(r2, r1); |
225 | 217 |
226 // Scale the index by multiplying by the entry size. | 218 // Scale the index by multiplying by the entry size. |
227 ASSERT(NumberDictionary::kEntrySize == 3); | 219 ASSERT(NumberDictionary::kEntrySize == 3); |
228 __ lea(r2, Operand(r2, r2, times_2, 0)); // r2 = r2 * 3 | 220 __ lea(r2, Operand(r2, r2, times_2, 0)); // r2 = r2 * 3 |
229 | 221 |
230 // Check if the key matches. | 222 // Check if the key matches. |
231 __ cmpq(key, FieldOperand(elements, | 223 __ cmpq(key, FieldOperand(elements, |
232 r2, | 224 r2, |
233 times_pointer_size, | 225 times_pointer_size, |
234 kElementsStartOffset)); | 226 NumberDictionary::kElementsStartOffset)); |
235 if (i != (kProbes - 1)) { | 227 if (i != (kProbes - 1)) { |
236 __ j(equal, &done); | 228 __ j(equal, &done); |
237 } else { | 229 } else { |
238 __ j(not_equal, miss); | 230 __ j(not_equal, miss); |
239 } | 231 } |
240 } | 232 } |
241 | 233 |
242 __ bind(&done); | 234 __ bind(&done); |
243 // Check that the value is a normal propety. | 235 // Check that the value is a normal propety. |
244 const int kDetailsOffset = kElementsStartOffset + 2 * kPointerSize; | 236 const int kDetailsOffset = |
237 NumberDictionary::kElementsStartOffset + 2 * kPointerSize; | |
245 ASSERT_EQ(NORMAL, 0); | 238 ASSERT_EQ(NORMAL, 0); |
246 __ Test(FieldOperand(elements, r2, times_pointer_size, kDetailsOffset), | 239 __ Test(FieldOperand(elements, r2, times_pointer_size, kDetailsOffset), |
247 Smi::FromInt(PropertyDetails::TypeField::mask())); | 240 Smi::FromInt(PropertyDetails::TypeField::mask())); |
248 __ j(not_zero, miss); | 241 __ j(not_zero, miss); |
249 | 242 |
250 // Get the value at the masked, scaled index. | 243 // Get the value at the masked, scaled index. |
251 const int kValueOffset = kElementsStartOffset + kPointerSize; | 244 const int kValueOffset = |
245 NumberDictionary::kElementsStartOffset + kPointerSize; | |
252 __ movq(r0, FieldOperand(elements, r2, times_pointer_size, kValueOffset)); | 246 __ movq(r0, FieldOperand(elements, r2, times_pointer_size, kValueOffset)); |
253 } | 247 } |
254 | 248 |
255 | 249 |
256 // One byte opcode for test eax,0xXXXXXXXX. | 250 // One byte opcode for test eax,0xXXXXXXXX. |
257 static const byte kTestEaxByte = 0xA9; | 251 static const byte kTestEaxByte = 0xA9; |
258 | 252 |
259 | 253 |
260 static bool PatchInlinedMapCheck(Address address, Object* map) { | 254 static bool PatchInlinedMapCheck(Address address, Object* map) { |
261 // Arguments are address of start of call sequence that called | 255 // Arguments are address of start of call sequence that called |
(...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1397 | 1391 |
1398 // If this assert fails, we have to check upper bound too. | 1392 // If this assert fails, we have to check upper bound too. |
1399 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); | 1393 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); |
1400 | 1394 |
1401 // Check for access to global object (unlikely). | 1395 // Check for access to global object (unlikely). |
1402 __ CmpInstanceType(rbx, JS_GLOBAL_PROXY_TYPE); | 1396 __ CmpInstanceType(rbx, JS_GLOBAL_PROXY_TYPE); |
1403 __ j(equal, &global); | 1397 __ j(equal, &global); |
1404 | 1398 |
1405 // Check for non-global object that requires access check. | 1399 // Check for non-global object that requires access check. |
1406 __ testl(FieldOperand(rbx, Map::kBitFieldOffset), | 1400 __ testl(FieldOperand(rbx, Map::kBitFieldOffset), |
1407 Immediate(1 << Map::kIsAccessCheckNeeded)); | 1401 Immediate(1 << Map::kIsAccessCheckNeeded)); |
1408 __ j(not_zero, &miss); | 1402 __ j(not_zero, &miss); |
1409 | 1403 |
1410 // Search the dictionary placing the result in rax. | 1404 // Search the dictionary placing the result in rax. |
1411 __ bind(&probe); | 1405 __ bind(&probe); |
1412 GenerateDictionaryLoad(masm, &miss, rdx, rax, rbx, rcx, CHECK_DICTIONARY); | 1406 GenerateDictionaryLoad(masm, &miss, rdx, rax, rbx, rcx, CHECK_DICTIONARY); |
1413 __ ret(0); | 1407 __ ret(0); |
1414 | 1408 |
1415 // Global object access: Check access rights. | 1409 // Global object access: Check access rights. |
1416 __ bind(&global); | 1410 __ bind(&global); |
1417 __ CheckAccessGlobalProxy(rax, rdx, &miss); | 1411 __ CheckAccessGlobalProxy(rax, rdx, &miss); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1554 __ bind(&miss); | 1548 __ bind(&miss); |
1555 | 1549 |
1556 GenerateMiss(masm); | 1550 GenerateMiss(masm); |
1557 } | 1551 } |
1558 | 1552 |
1559 | 1553 |
1560 #undef __ | 1554 #undef __ |
1561 | 1555 |
1562 | 1556 |
1563 } } // namespace v8::internal | 1557 } } // namespace v8::internal |
OLD | NEW |