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

Side by Side Diff: src/x64/ic-x64.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/serialize.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 __ movzxbq(r0, FieldOperand(r0, Map::kInstanceTypeOffset)); 83 __ movzxbq(r0, FieldOperand(r0, Map::kInstanceTypeOffset));
80 __ cmpb(r0, Immediate(JS_GLOBAL_PROXY_TYPE)); 84 __ cmpb(r0, Immediate(JS_GLOBAL_PROXY_TYPE));
81 __ j(equal, miss_label); 85 __ j(equal, miss_label);
82 86
83 // Possible work-around for http://crbug.com/16276. 87 // Possible work-around for http://crbug.com/16276.
84 __ cmpb(r0, Immediate(JS_GLOBAL_OBJECT_TYPE)); 88 __ cmpb(r0, Immediate(JS_GLOBAL_OBJECT_TYPE));
85 __ j(equal, miss_label); 89 __ j(equal, miss_label);
86 __ cmpb(r0, Immediate(JS_BUILTINS_OBJECT_TYPE)); 90 __ cmpb(r0, Immediate(JS_BUILTINS_OBJECT_TYPE));
87 __ j(equal, miss_label); 91 __ j(equal, miss_label);
88 92
89 // Check that the properties array is a dictionary. 93 // Load properties array.
90 __ movq(r0, FieldOperand(r1, JSObject::kPropertiesOffset)); 94 __ movq(r0, FieldOperand(r1, JSObject::kPropertiesOffset));
91 __ Cmp(FieldOperand(r0, HeapObject::kMapOffset), Factory::hash_table_map()); 95
92 __ j(not_equal, miss_label); 96 if (check_dictionary == CHECK_DICTIONARY) {
97 // Check that the properties array is a dictionary.
98 __ Cmp(FieldOperand(r0, HeapObject::kMapOffset), Factory::hash_table_map());
99 __ j(not_equal, miss_label);
100 }
93 101
94 // Compute the capacity mask. 102 // Compute the capacity mask.
95 const int kCapacityOffset = 103 const int kCapacityOffset =
96 StringDictionary::kHeaderSize + 104 StringDictionary::kHeaderSize +
97 StringDictionary::kCapacityIndex * kPointerSize; 105 StringDictionary::kCapacityIndex * kPointerSize;
98 __ movq(r2, FieldOperand(r0, kCapacityOffset)); 106 __ movq(r2, FieldOperand(r0, kCapacityOffset));
99 __ SmiToInteger32(r2, r2); 107 __ SmiToInteger32(r2, r2);
100 __ decl(r2); 108 __ decl(r2);
101 109
102 // Generate an unrolled loop that performs a few probes before 110 // Generate an unrolled loop that performs a few probes before
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 __ TailCallRuntime(f, 2, 1); 247 __ TailCallRuntime(f, 2, 1);
240 } 248 }
241 249
242 250
243 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) { 251 void KeyedLoadIC::GenerateGeneric(MacroAssembler* masm) {
244 // ----------- S t a t e ------------- 252 // ----------- S t a t e -------------
245 // -- rsp[0] : return address 253 // -- rsp[0] : return address
246 // -- rsp[8] : name 254 // -- rsp[8] : name
247 // -- rsp[16] : receiver 255 // -- rsp[16] : receiver
248 // ----------------------------------- 256 // -----------------------------------
249 Label slow, check_string, index_int, index_string, check_pixel_array; 257 Label slow, check_string, index_int, index_string;
258 Label check_pixel_array, probe_dictionary;
250 259
251 // Load name and receiver. 260 // Load name and receiver.
252 __ movq(rax, Operand(rsp, kPointerSize)); 261 __ movq(rax, Operand(rsp, kPointerSize));
253 __ movq(rcx, Operand(rsp, 2 * kPointerSize)); 262 __ movq(rcx, Operand(rsp, 2 * kPointerSize));
254 263
255 // Check that the object isn't a smi. 264 // Check that the object isn't a smi.
256 __ JumpIfSmi(rcx, &slow); 265 __ JumpIfSmi(rcx, &slow);
257 266
258 // Check that the object is some kind of JS object EXCEPT JS Value type. 267 // Check that the object is some kind of JS object EXCEPT JS Value type.
259 // In the case that the object is a value-wrapper object, 268 // In the case that the object is a value-wrapper object,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 Generate(masm, ExternalReference(Runtime::kKeyedGetProperty)); 321 Generate(masm, ExternalReference(Runtime::kKeyedGetProperty));
313 __ bind(&check_string); 322 __ bind(&check_string);
314 // The key is not a smi. 323 // The key is not a smi.
315 // Is it a string? 324 // Is it a string?
316 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdx); 325 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdx);
317 __ j(above_equal, &slow); 326 __ j(above_equal, &slow);
318 // Is the string an array index, with cached numeric value? 327 // Is the string an array index, with cached numeric value?
319 __ movl(rbx, FieldOperand(rax, String::kHashFieldOffset)); 328 __ movl(rbx, FieldOperand(rax, String::kHashFieldOffset));
320 __ testl(rbx, Immediate(String::kIsArrayIndexMask)); 329 __ testl(rbx, Immediate(String::kIsArrayIndexMask));
321 330
322 // If the string is a symbol, do a quick inline probe of the receiver's 331 // Is the string a symbol?
323 // dictionary, if it exists.
324 __ j(not_zero, &index_string); // The value in rbx is used at jump target. 332 __ j(not_zero, &index_string); // The value in rbx is used at jump target.
325 __ testb(FieldOperand(rdx, Map::kInstanceTypeOffset), 333 __ testb(FieldOperand(rdx, Map::kInstanceTypeOffset),
326 Immediate(kIsSymbolMask)); 334 Immediate(kIsSymbolMask));
327 __ j(zero, &slow); 335 __ j(zero, &slow);
328 // Probe the dictionary leaving result in rcx. 336
329 GenerateDictionaryLoad(masm, &slow, rbx, rcx, rdx, rax); 337 // If the receiver is a fast-case object, check the keyed lookup
338 // cache. Otherwise probe the dictionary leaving result in rcx.
339 __ movq(rbx, FieldOperand(rcx, JSObject::kPropertiesOffset));
340 __ Cmp(FieldOperand(rbx, HeapObject::kMapOffset), Factory::hash_table_map());
341 __ j(equal, &probe_dictionary);
342
343 // Load the map of the receiver, compute the keyed lookup cache hash
344 // based on 32 bits of the map pointer and the string hash.
345 __ movq(rbx, FieldOperand(rcx, HeapObject::kMapOffset));
346 __ movl(rdx, rbx);
347 __ shr(rdx, Immediate(KeyedLookupCache::kMapHashShift));
348 __ movl(rax, FieldOperand(rax, String::kHashFieldOffset));
349 __ shr(rax, Immediate(String::kHashShift));
350 __ xor_(rdx, rax);
351 __ and_(rdx, Immediate(KeyedLookupCache::kCapacityMask));
352
353 // Load the key (consisting of map and symbol) from the cache and
354 // check for match.
355 ExternalReference cache_keys
356 = ExternalReference::keyed_lookup_cache_keys();
357 __ movq(rdi, rdx);
358 __ shl(rdi, Immediate(kPointerSizeLog2 + 1));
359 __ movq(kScratchRegister, cache_keys);
360 __ cmpq(rbx, Operand(kScratchRegister, rdi, times_1, 0));
361 __ j(not_equal, &slow);
362 __ movq(rdi, Operand(kScratchRegister, rdi, times_1, kPointerSize));
363 __ cmpq(Operand(rsp, kPointerSize), rdi);
364 __ j(not_equal, &slow);
365
366 // Get field offset which is a 32-bit integer and check that it is
367 // an in-object property.
368 ExternalReference cache_field_offsets
369 = ExternalReference::keyed_lookup_cache_field_offsets();
370 __ movq(kScratchRegister, cache_field_offsets);
371 __ movl(rax, Operand(kScratchRegister, rdx, times_4, 0));
372 __ movzxbq(rdx, FieldOperand(rbx, Map::kInObjectPropertiesOffset));
373 __ cmpq(rax, rdx);
374 __ j(above_equal, &slow);
375
376 // Load in-object property.
377 __ subq(rax, rdx);
378 __ movzxbq(rdx, FieldOperand(rbx, Map::kInstanceSizeOffset));
379 __ addq(rax, rdx);
380 __ movq(rax, FieldOperand(rcx, rax, times_pointer_size, 0));
381 __ ret(0);
382
383 // Do a quick inline probe of the receiver's dictionary, if it
384 // exists.
385 __ bind(&probe_dictionary);
386 GenerateDictionaryLoad(masm,
387 &slow,
388 rbx,
389 rcx,
390 rdx,
391 rax,
392 DICTIONARY_CHECK_DONE);
330 GenerateCheckNonObjectOrLoaded(masm, &slow, rcx); 393 GenerateCheckNonObjectOrLoaded(masm, &slow, rcx);
331 __ movq(rax, rcx); 394 __ movq(rax, rcx);
332 __ IncrementCounter(&Counters::keyed_load_generic_symbol, 1); 395 __ IncrementCounter(&Counters::keyed_load_generic_symbol, 1);
333 __ ret(0); 396 __ ret(0);
334 // If the hash field contains an array index pick it out. The assert checks 397 // If the hash field contains an array index pick it out. The assert checks
335 // that the constants for the maximum number of digits for an array index 398 // that the constants for the maximum number of digits for an array index
336 // cached in the hash field and the number of bits reserved for it does not 399 // cached in the hash field and the number of bits reserved for it does not
337 // conflict. 400 // conflict.
338 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < 401 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) <
339 (1 << String::kArrayIndexValueBits)); 402 (1 << String::kArrayIndexValueBits));
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 // Cache miss: Jump to runtime. 1027 // Cache miss: Jump to runtime.
965 __ bind(&miss); 1028 __ bind(&miss);
966 Generate(masm, argc, ExternalReference(IC_Utility(kCallIC_Miss))); 1029 Generate(masm, argc, ExternalReference(IC_Utility(kCallIC_Miss)));
967 } 1030 }
968 1031
969 1032
970 static void GenerateNormalHelper(MacroAssembler* masm, 1033 static void GenerateNormalHelper(MacroAssembler* masm,
971 int argc, 1034 int argc,
972 bool is_global_object, 1035 bool is_global_object,
973 Label* miss) { 1036 Label* miss) {
974 // Search dictionary - put result in register edx. 1037 // Search dictionary - put result in register rdx.
975 GenerateDictionaryLoad(masm, miss, rax, rdx, rbx, rcx); 1038 GenerateDictionaryLoad(masm, miss, rax, rdx, rbx, rcx, CHECK_DICTIONARY);
976 1039
977 // Move the result to register rdi and check that it isn't a smi. 1040 // Move the result to register rdi and check that it isn't a smi.
978 __ movq(rdi, rdx); 1041 __ movq(rdi, rdx);
979 __ JumpIfSmi(rdx, miss); 1042 __ JumpIfSmi(rdx, miss);
980 1043
981 // Check that the value is a JavaScript function. 1044 // Check that the value is a JavaScript function.
982 __ CmpObjectType(rdx, JS_FUNCTION_TYPE, rdx); 1045 __ CmpObjectType(rdx, JS_FUNCTION_TYPE, rdx);
983 __ j(not_equal, miss); 1046 __ j(not_equal, miss);
984 // Check that the function has been loaded. 1047 // Check that the function has been loaded.
985 __ testb(FieldOperand(rdx, Map::kBitField2Offset), 1048 __ testb(FieldOperand(rdx, Map::kBitField2Offset),
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 1252
1190 // Check for access to global object (unlikely). 1253 // Check for access to global object (unlikely).
1191 __ CmpInstanceType(rbx, JS_GLOBAL_PROXY_TYPE); 1254 __ CmpInstanceType(rbx, JS_GLOBAL_PROXY_TYPE);
1192 __ j(equal, &global); 1255 __ j(equal, &global);
1193 1256
1194 // Check for non-global object that requires access check. 1257 // Check for non-global object that requires access check.
1195 __ testl(FieldOperand(rbx, Map::kBitFieldOffset), 1258 __ testl(FieldOperand(rbx, Map::kBitFieldOffset),
1196 Immediate(1 << Map::kIsAccessCheckNeeded)); 1259 Immediate(1 << Map::kIsAccessCheckNeeded));
1197 __ j(not_zero, &miss); 1260 __ j(not_zero, &miss);
1198 1261
1199 // Search the dictionary placing the result in eax. 1262 // Search the dictionary placing the result in rax.
1200 __ bind(&probe); 1263 __ bind(&probe);
1201 GenerateDictionaryLoad(masm, &miss, rdx, rax, rbx, rcx); 1264 GenerateDictionaryLoad(masm, &miss, rdx, rax, rbx, rcx, CHECK_DICTIONARY);
1202 GenerateCheckNonObjectOrLoaded(masm, &miss, rax); 1265 GenerateCheckNonObjectOrLoaded(masm, &miss, rax);
1203 __ ret(0); 1266 __ ret(0);
1204 1267
1205 // Global object access: Check access rights. 1268 // Global object access: Check access rights.
1206 __ bind(&global); 1269 __ bind(&global);
1207 __ CheckAccessGlobalProxy(rax, rdx, &miss); 1270 __ CheckAccessGlobalProxy(rax, rdx, &miss);
1208 __ jmp(&probe); 1271 __ jmp(&probe);
1209 1272
1210 // Cache miss: Restore receiver from stack and jump to runtime. 1273 // Cache miss: Restore receiver from stack and jump to runtime.
1211 __ bind(&miss); 1274 __ bind(&miss);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 1375
1313 // Cache miss: Jump to runtime. 1376 // Cache miss: Jump to runtime.
1314 Generate(masm, ExternalReference(IC_Utility(kStoreIC_Miss))); 1377 Generate(masm, ExternalReference(IC_Utility(kStoreIC_Miss)));
1315 } 1378 }
1316 1379
1317 1380
1318 #undef __ 1381 #undef __
1319 1382
1320 1383
1321 } } // namespace v8::internal 1384 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/serialize.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698