Chromium Code Reviews| Index: src/ia32/ic-ia32.cc |
| =================================================================== |
| --- src/ia32/ic-ia32.cc (revision 3428) |
| +++ src/ia32/ic-ia32.cc (working copy) |
| @@ -50,7 +50,7 @@ |
| // or if name is not a symbol, and will jump to the miss_label in that case. |
| static void GenerateDictionaryLoad(MacroAssembler* masm, Label* miss_label, |
| Register r0, Register r1, Register r2, |
| - Register name) { |
| + Register name, bool check_dictionary) { |
|
Erik Corry
2009/12/09 10:43:40
This should be an enum with CHECK_DICTIONARY and D
Mads Ager (chromium)
2009/12/10 09:18:18
Done.
|
| // Register use: |
| // |
| // r0 - used to hold the property dictionary. |
| @@ -86,12 +86,16 @@ |
| __ cmp(r0, JS_BUILTINS_OBJECT_TYPE); |
| __ j(equal, miss_label, not_taken); |
| - // Check that the properties array is a dictionary. |
| + // Load properties array. |
| __ mov(r0, FieldOperand(r1, JSObject::kPropertiesOffset)); |
| - __ cmp(FieldOperand(r0, HeapObject::kMapOffset), |
| - Immediate(Factory::hash_table_map())); |
| - __ j(not_equal, miss_label); |
| + // Check that the properties array is a dictionary. |
| + if (check_dictionary) { |
| + __ cmp(FieldOperand(r0, HeapObject::kMapOffset), |
| + Immediate(Factory::hash_table_map())); |
| + __ j(not_equal, miss_label); |
| + } |
| + |
| // Compute the capacity mask. |
| const int kCapacityOffset = |
| StringDictionary::kHeaderSize + |
| @@ -223,7 +227,8 @@ |
| // -- esp[4] : name |
| // -- esp[8] : receiver |
| // ----------------------------------- |
| - Label slow, check_string, index_int, index_string, check_pixel_array; |
| + Label slow, check_string, index_int, index_string; |
| + Label check_pixel_array, probe_dictionary; |
| // Load name and receiver. |
| __ mov(eax, Operand(esp, kPointerSize)); |
| @@ -302,17 +307,68 @@ |
| __ test(ebx, Immediate(String::kIsArrayIndexMask)); |
|
Erik Corry
2009/12/09 10:43:40
Can't we do this with a single test instruction in
Mads Ager (chromium)
2009/12/10 09:18:18
No. If we jump, we use the fact that the hash fiel
|
| __ j(not_zero, &index_string, not_taken); |
| - // If the string is a symbol, do a quick inline probe of the receiver's |
| - // dictionary, if it exists. |
| + // Is the string a symbol? |
| __ movzx_b(ebx, FieldOperand(edx, Map::kInstanceTypeOffset)); |
| __ test(ebx, Immediate(kIsSymbolMask)); |
|
Erik Corry
2009/12/09 10:43:40
And here?
Mads Ager (chromium)
2009/12/10 09:18:18
No, because we are not looking at a word, but only
|
| __ j(zero, &slow, not_taken); |
| - // Probe the dictionary leaving result in ecx. |
| - GenerateDictionaryLoad(masm, &slow, ebx, ecx, edx, eax); |
| + |
| + // If the receiver is a fast-case object, check the keyed lookup |
| + // cache. Otherwise probe the dictionary leaving result in ecx. |
| + __ mov(ebx, FieldOperand(ecx, JSObject::kPropertiesOffset)); |
| + __ cmp(FieldOperand(ebx, HeapObject::kMapOffset), |
| + Immediate(Factory::hash_table_map())); |
| + __ j(equal, &probe_dictionary); |
| + |
| + // Load the map of the receiver, compute the keyed lookup cache hash |
|
Erik Corry
2009/12/09 10:43:40
Don't we need to check the interceptor bit here or
Mads Ager (chromium)
2009/12/10 09:18:18
No. I those cases we will never put the map-name p
|
| + // based on 32 bits of the map pointer and the string hash. |
| + __ mov(ebx, FieldOperand(ecx, HeapObject::kMapOffset)); |
| + __ mov(edx, ebx); |
| + __ shr(edx, KeyedLookupCache::kMapHashShift); |
| + __ mov(eax, FieldOperand(eax, String::kHashFieldOffset)); |
| + __ shr(eax, String::kHashShift); |
| + __ xor_(edx, Operand(eax)); |
| + __ and_(edx, KeyedLookupCache::kCapacityMask); |
| + |
| + // Load the key (consisting of map and symbol) from the cache and |
| + // check for match. |
| + ExternalReference cache_keys |
| + = ExternalReference::keyed_lookup_cache_keys(); |
| + __ mov(edi, edx); |
| + __ shl(edi, kPointerSizeLog2 + 1); |
|
Erik Corry
2009/12/09 10:43:40
You can combine this mov-shl-mov-cmp combination i
Mads Ager (chromium)
2009/12/10 09:18:18
Done in the ia32 version. Can't do a times_16 sca
|
| + __ mov(eax, Operand::StaticArray(edi, times_1, cache_keys)); |
| + __ cmp(ebx, Operand(eax)); |
| + __ j(not_equal, &slow); |
| + __ mov(eax, Operand(esp, kPointerSize)); |
| + __ add(Operand(edi), Immediate(kPointerSize)); |
| + __ mov(edi, Operand::StaticArray(edi, times_1, cache_keys)); |
| + __ cmp(eax, Operand(edi)); |
|
Erik Corry
2009/12/09 10:43:40
And this cmp could just take the operand instead o
Mads Ager (chromium)
2009/12/10 09:18:18
Done.
|
| + __ j(not_equal, &slow); |
| + |
| + // Get field offset and check that it is an in-object property. |
|
Erik Corry
2009/12/09 10:43:40
In a later change we could handle out-of-object fa
Mads Ager (chromium)
2009/12/10 09:18:18
Yes, we can and we probably should.
|
| + ExternalReference cache_field_offsets |
| + = ExternalReference::keyed_lookup_cache_field_offsets(); |
| + __ mov(eax, |
| + Operand::StaticArray(edx, times_pointer_size, cache_field_offsets)); |
| + __ movzx_b(edx, FieldOperand(ebx, Map::kInObjectPropertiesOffset)); |
| + __ cmp(eax, Operand(edx)); |
| + __ j(above_equal, &slow); |
| + |
| + // Load in-object property. |
| + __ sub(eax, Operand(edx)); |
| + __ movzx_b(edx, FieldOperand(ebx, Map::kInstanceSizeOffset)); |
| + __ add(eax, Operand(edx)); |
| + __ mov(eax, FieldOperand(ecx, eax, times_pointer_size, 0)); |
| + __ ret(0); |
| + |
| + // Do a quick inline probe of the receiver's dictionary, if it |
| + // exists. |
| + __ bind(&probe_dictionary); |
| + GenerateDictionaryLoad(masm, &slow, ebx, ecx, edx, eax, false); |
| GenerateCheckNonObjectOrLoaded(masm, &slow, ecx, edx); |
| __ mov(eax, Operand(ecx)); |
| __ IncrementCounter(&Counters::keyed_load_generic_symbol, 1); |
| __ ret(0); |
| + |
| // If the hash field contains an array index pick it out. The assert checks |
| // that the constants for the maximum number of digits for an array index |
| // cached in the hash field and the number of bits reserved for it does not |
| @@ -885,7 +941,7 @@ |
| bool is_global_object, |
| Label* miss) { |
| // Search dictionary - put result in register edx. |
| - GenerateDictionaryLoad(masm, miss, eax, edx, ebx, ecx); |
| + GenerateDictionaryLoad(masm, miss, eax, edx, ebx, ecx, true); |
| // Move the result to register edi and check that it isn't a smi. |
| __ mov(edi, Operand(edx)); |
| @@ -1088,7 +1144,7 @@ |
| // Search the dictionary placing the result in eax. |
| __ bind(&probe); |
| - GenerateDictionaryLoad(masm, &miss, edx, eax, ebx, ecx); |
| + GenerateDictionaryLoad(masm, &miss, edx, eax, ebx, ecx, true); |
| GenerateCheckNonObjectOrLoaded(masm, &miss, eax, edx); |
| __ ret(0); |