Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(706)

Side by Side Diff: src/ia32/ic-ia32.cc

Issue 491004: Reapply keyed load cache probing in generated code. I introduced a... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap.cc ('k') | src/ic.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 30 matching lines...) Expand all
41 // 41 //
42 42
43 #define __ ACCESS_MASM(masm) 43 #define __ ACCESS_MASM(masm)
44 44
45 45
46 // Helper function used to load a property from a dictionary backing storage. 46 // Helper function used to load a property from a dictionary backing storage.
47 // This function may return false negatives, so miss_label 47 // This function may return false negatives, so miss_label
48 // must always call a backup property load that is complete. 48 // must always call a backup property load that is complete.
49 // This function is safe to call if the receiver has fast properties, 49 // This function is safe to call if the receiver has fast properties,
50 // or if name is not a symbol, and will jump to the miss_label in that case. 50 // or if name is not a symbol, and will jump to the miss_label in that case.
51 static void GenerateDictionaryLoad(MacroAssembler* masm, Label* miss_label, 51 static void GenerateDictionaryLoad(MacroAssembler* masm,
52 Register r0, Register r1, Register r2, 52 Label* miss_label,
53 Register name) { 53 Register r0,
54 Register r1,
55 Register r2,
56 Register name,
57 DictionaryCheck check_dictionary) {
54 // Register use: 58 // Register use:
55 // 59 //
56 // r0 - used to hold the property dictionary. 60 // r0 - used to hold the property dictionary.
57 // 61 //
58 // r1 - initially the receiver 62 // r1 - initially the receiver
59 // - used for the index into the property dictionary 63 // - used for the index into the property dictionary
60 // - holds the result on exit. 64 // - holds the result on exit.
61 // 65 //
62 // r2 - used to hold the capacity of the property dictionary. 66 // r2 - used to hold the capacity of the property dictionary.
63 // 67 //
(...skipping 15 matching lines...) Expand all
79 __ movzx_b(r0, FieldOperand(r0, Map::kInstanceTypeOffset)); 83 __ movzx_b(r0, FieldOperand(r0, Map::kInstanceTypeOffset));
80 __ cmp(r0, JS_GLOBAL_PROXY_TYPE); 84 __ cmp(r0, JS_GLOBAL_PROXY_TYPE);
81 __ j(equal, miss_label, not_taken); 85 __ j(equal, miss_label, not_taken);
82 86
83 // Possible work-around for http://crbug.com/16276. 87 // Possible work-around for http://crbug.com/16276.
84 __ cmp(r0, JS_GLOBAL_OBJECT_TYPE); 88 __ cmp(r0, JS_GLOBAL_OBJECT_TYPE);
85 __ j(equal, miss_label, not_taken); 89 __ j(equal, miss_label, not_taken);
86 __ cmp(r0, JS_BUILTINS_OBJECT_TYPE); 90 __ cmp(r0, JS_BUILTINS_OBJECT_TYPE);
87 __ j(equal, miss_label, not_taken); 91 __ j(equal, miss_label, not_taken);
88 92
93 // Load properties array.
94 __ mov(r0, FieldOperand(r1, JSObject::kPropertiesOffset));
95
89 // Check that the properties array is a dictionary. 96 // Check that the properties array is a dictionary.
90 __ mov(r0, FieldOperand(r1, JSObject::kPropertiesOffset)); 97 if (check_dictionary == CHECK_DICTIONARY) {
91 __ cmp(FieldOperand(r0, HeapObject::kMapOffset), 98 __ cmp(FieldOperand(r0, HeapObject::kMapOffset),
92 Immediate(Factory::hash_table_map())); 99 Immediate(Factory::hash_table_map()));
93 __ j(not_equal, miss_label); 100 __ j(not_equal, miss_label);
101 }
94 102
95 // Compute the capacity mask. 103 // Compute the capacity mask.
96 const int kCapacityOffset = 104 const int kCapacityOffset =
97 StringDictionary::kHeaderSize + 105 StringDictionary::kHeaderSize +
98 StringDictionary::kCapacityIndex * kPointerSize; 106 StringDictionary::kCapacityIndex * kPointerSize;
99 __ mov(r2, FieldOperand(r0, kCapacityOffset)); 107 __ mov(r2, FieldOperand(r0, kCapacityOffset));
100 __ shr(r2, kSmiTagSize); // convert smi to int 108 __ shr(r2, kSmiTagSize); // convert smi to int
101 __ dec(r2); 109 __ dec(r2);
102 110
103 // Generate an unrolled loop that performs a few probes before 111 // Generate an unrolled loop that performs a few probes before
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC); 224 StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC);
217 } 225 }
218 226
219 227
220 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) { 228 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
221 // ----------- S t a t e ------------- 229 // ----------- S t a t e -------------
222 // -- esp[0] : return address 230 // -- esp[0] : return address
223 // -- esp[4] : name 231 // -- esp[4] : name
224 // -- esp[8] : receiver 232 // -- esp[8] : receiver
225 // ----------------------------------- 233 // -----------------------------------
226 Label slow, check_string, index_int, index_string, check_pixel_array; 234 Label slow, check_string, index_int, index_string;
235 Label check_pixel_array, probe_dictionary;
227 236
228 // Load name and receiver. 237 // Load name and receiver.
229 __ mov(eax, Operand(esp, kPointerSize)); 238 __ mov(eax, Operand(esp, kPointerSize));
230 __ mov(ecx, Operand(esp, 2 * kPointerSize)); 239 __ mov(ecx, Operand(esp, 2 * kPointerSize));
231 240
232 // Check that the object isn't a smi. 241 // Check that the object isn't a smi.
233 __ test(ecx, Immediate(kSmiTagMask)); 242 __ test(ecx, Immediate(kSmiTagMask));
234 __ j(zero, &slow, not_taken); 243 __ j(zero, &slow, not_taken);
235 244
236 // Get the map of the receiver. 245 // Get the map of the receiver.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 __ bind(&check_string); 304 __ bind(&check_string);
296 // The key is not a smi. 305 // The key is not a smi.
297 // Is it a string? 306 // Is it a string?
298 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edx); 307 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edx);
299 __ j(above_equal, &slow); 308 __ j(above_equal, &slow);
300 // Is the string an array index, with cached numeric value? 309 // Is the string an array index, with cached numeric value?
301 __ mov(ebx, FieldOperand(eax, String::kHashFieldOffset)); 310 __ mov(ebx, FieldOperand(eax, String::kHashFieldOffset));
302 __ test(ebx, Immediate(String::kIsArrayIndexMask)); 311 __ test(ebx, Immediate(String::kIsArrayIndexMask));
303 __ j(not_zero, &index_string, not_taken); 312 __ j(not_zero, &index_string, not_taken);
304 313
305 // If the string is a symbol, do a quick inline probe of the receiver's 314 // Is the string a symbol?
306 // dictionary, if it exists.
307 __ movzx_b(ebx, FieldOperand(edx, Map::kInstanceTypeOffset)); 315 __ movzx_b(ebx, FieldOperand(edx, Map::kInstanceTypeOffset));
308 __ test(ebx, Immediate(kIsSymbolMask)); 316 __ test(ebx, Immediate(kIsSymbolMask));
309 __ j(zero, &slow, not_taken); 317 __ j(zero, &slow, not_taken);
310 // Probe the dictionary leaving result in ecx. 318
311 GenerateDictionaryLoad(masm, &slow, ebx, ecx, edx, eax); 319 // If the receiver is a fast-case object, check the keyed lookup
320 // cache. Otherwise probe the dictionary leaving result in ecx.
321 __ mov(ebx, FieldOperand(ecx, JSObject::kPropertiesOffset));
322 __ cmp(FieldOperand(ebx, HeapObject::kMapOffset),
323 Immediate(Factory::hash_table_map()));
324 __ j(equal, &probe_dictionary);
325
326 // Load the map of the receiver, compute the keyed lookup cache hash
327 // based on 32 bits of the map pointer and the string hash.
328 __ mov(ebx, FieldOperand(ecx, HeapObject::kMapOffset));
329 __ mov(edx, ebx);
330 __ shr(edx, KeyedLookupCache::kMapHashShift);
331 __ mov(eax, FieldOperand(eax, String::kHashFieldOffset));
332 __ shr(eax, String::kHashShift);
333 __ xor_(edx, Operand(eax));
334 __ and_(edx, KeyedLookupCache::kCapacityMask);
335
336 // Load the key (consisting of map and symbol) from the cache and
337 // check for match.
338 ExternalReference cache_keys
339 = ExternalReference::keyed_lookup_cache_keys();
340 __ mov(edi, edx);
341 __ shl(edi, kPointerSizeLog2 + 1);
342 __ cmp(ebx, Operand::StaticArray(edi, times_1, cache_keys));
343 __ j(not_equal, &slow);
344 __ add(Operand(edi), Immediate(kPointerSize));
345 __ mov(edi, Operand::StaticArray(edi, times_1, cache_keys));
346 __ cmp(edi, Operand(esp, kPointerSize));
347 __ j(not_equal, &slow);
348
349 // Get field offset and check that it is an in-object property.
350 ExternalReference cache_field_offsets
351 = ExternalReference::keyed_lookup_cache_field_offsets();
352 __ mov(eax,
353 Operand::StaticArray(edx, times_pointer_size, cache_field_offsets));
354 __ movzx_b(edx, FieldOperand(ebx, Map::kInObjectPropertiesOffset));
355 __ cmp(eax, Operand(edx));
356 __ j(above_equal, &slow);
357
358 // Load in-object property.
359 __ sub(eax, Operand(edx));
360 __ movzx_b(edx, FieldOperand(ebx, Map::kInstanceSizeOffset));
361 __ add(eax, Operand(edx));
362 __ mov(eax, FieldOperand(ecx, eax, times_pointer_size, 0));
363 __ ret(0);
364
365 // Do a quick inline probe of the receiver's dictionary, if it
366 // exists.
367 __ bind(&probe_dictionary);
368 GenerateDictionaryLoad(masm,
369 &slow,
370 ebx,
371 ecx,
372 edx,
373 eax,
374 DICTIONARY_CHECK_DONE);
312 GenerateCheckNonObjectOrLoaded(masm, &slow, ecx, edx); 375 GenerateCheckNonObjectOrLoaded(masm, &slow, ecx, edx);
313 __ mov(eax, Operand(ecx)); 376 __ mov(eax, Operand(ecx));
314 __ IncrementCounter(&Counters::keyed_load_generic_symbol, 1); 377 __ IncrementCounter(&Counters::keyed_load_generic_symbol, 1);
315 __ ret(0); 378 __ ret(0);
379
316 // If the hash field contains an array index pick it out. The assert checks 380 // If the hash field contains an array index pick it out. The assert checks
317 // that the constants for the maximum number of digits for an array index 381 // that the constants for the maximum number of digits for an array index
318 // cached in the hash field and the number of bits reserved for it does not 382 // cached in the hash field and the number of bits reserved for it does not
319 // conflict. 383 // conflict.
320 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < 384 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) <
321 (1 << String::kArrayIndexValueBits)); 385 (1 << String::kArrayIndexValueBits));
322 __ bind(&index_string); 386 __ bind(&index_string);
323 __ mov(eax, Operand(ebx)); 387 __ mov(eax, Operand(ebx));
324 __ and_(eax, String::kArrayIndexHashMask); 388 __ and_(eax, String::kArrayIndexHashMask);
325 __ shr(eax, String::kHashShift); 389 __ shr(eax, String::kHashShift);
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 __ bind(&miss); 942 __ bind(&miss);
879 Generate(masm, argc, ExternalReference(IC_Utility(kCallIC_Miss))); 943 Generate(masm, argc, ExternalReference(IC_Utility(kCallIC_Miss)));
880 } 944 }
881 945
882 946
883 static void GenerateNormalHelper(MacroAssembler* masm, 947 static void GenerateNormalHelper(MacroAssembler* masm,
884 int argc, 948 int argc,
885 bool is_global_object, 949 bool is_global_object,
886 Label* miss) { 950 Label* miss) {
887 // Search dictionary - put result in register edx. 951 // Search dictionary - put result in register edx.
888 GenerateDictionaryLoad(masm, miss, eax, edx, ebx, ecx); 952 GenerateDictionaryLoad(masm, miss, eax, edx, ebx, ecx, CHECK_DICTIONARY);
889 953
890 // Move the result to register edi and check that it isn't a smi. 954 // Move the result to register edi and check that it isn't a smi.
891 __ mov(edi, Operand(edx)); 955 __ mov(edi, Operand(edx));
892 __ test(edx, Immediate(kSmiTagMask)); 956 __ test(edx, Immediate(kSmiTagMask));
893 __ j(zero, miss, not_taken); 957 __ j(zero, miss, not_taken);
894 958
895 // Check that the value is a JavaScript function. 959 // Check that the value is a JavaScript function.
896 __ CmpObjectType(edx, JS_FUNCTION_TYPE, edx); 960 __ CmpObjectType(edx, JS_FUNCTION_TYPE, edx);
897 __ j(not_equal, miss, not_taken); 961 __ j(not_equal, miss, not_taken);
898 962
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 __ cmp(edx, JS_GLOBAL_PROXY_TYPE); 1145 __ cmp(edx, JS_GLOBAL_PROXY_TYPE);
1082 __ j(equal, &global, not_taken); 1146 __ j(equal, &global, not_taken);
1083 1147
1084 // Check for non-global object that requires access check. 1148 // Check for non-global object that requires access check.
1085 __ movzx_b(ebx, FieldOperand(ebx, Map::kBitFieldOffset)); 1149 __ movzx_b(ebx, FieldOperand(ebx, Map::kBitFieldOffset));
1086 __ test(ebx, Immediate(1 << Map::kIsAccessCheckNeeded)); 1150 __ test(ebx, Immediate(1 << Map::kIsAccessCheckNeeded));
1087 __ j(not_zero, &miss, not_taken); 1151 __ j(not_zero, &miss, not_taken);
1088 1152
1089 // Search the dictionary placing the result in eax. 1153 // Search the dictionary placing the result in eax.
1090 __ bind(&probe); 1154 __ bind(&probe);
1091 GenerateDictionaryLoad(masm, &miss, edx, eax, ebx, ecx); 1155 GenerateDictionaryLoad(masm, &miss, edx, eax, ebx, ecx, CHECK_DICTIONARY);
1092 GenerateCheckNonObjectOrLoaded(masm, &miss, eax, edx); 1156 GenerateCheckNonObjectOrLoaded(masm, &miss, eax, edx);
1093 __ ret(0); 1157 __ ret(0);
1094 1158
1095 // Global object access: Check access rights. 1159 // Global object access: Check access rights.
1096 __ bind(&global); 1160 __ bind(&global);
1097 __ CheckAccessGlobalProxy(eax, edx, &miss); 1161 __ CheckAccessGlobalProxy(eax, edx, &miss);
1098 __ jmp(&probe); 1162 __ jmp(&probe);
1099 1163
1100 // Cache miss: Restore receiver from stack and jump to runtime. 1164 // Cache miss: Restore receiver from stack and jump to runtime.
1101 __ bind(&miss); 1165 __ bind(&miss);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 1426
1363 // Do tail-call to runtime routine. 1427 // Do tail-call to runtime routine.
1364 __ TailCallRuntime( 1428 __ TailCallRuntime(
1365 ExternalReference(IC_Utility(kSharedStoreIC_ExtendStorage)), 3, 1); 1429 ExternalReference(IC_Utility(kSharedStoreIC_ExtendStorage)), 3, 1);
1366 } 1430 }
1367 1431
1368 #undef __ 1432 #undef __
1369 1433
1370 1434
1371 } } // namespace v8::internal 1435 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/ic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698