Chromium Code Reviews| Index: src/heap.cc |
| diff --git a/src/heap.cc b/src/heap.cc |
| index d5c40ad154ad0e8de49a1ba86de2a659c352dbb7..b46ddfa89f4d9e4905dd5c21af60ff3f739dc2f5 100644 |
| --- a/src/heap.cc |
| +++ b/src/heap.cc |
| @@ -7709,12 +7709,34 @@ int KeyedLookupCache::Hash(Map* map, Name* name) { |
| } |
| +int KeyedLookupCache::ConvertToFastIndexForGeneratedCode(Map* map, int index) { |
| + if (FLAG_compiled_keyed_generic_loads) { |
| + if (index >= map->inobject_properties()) { |
| + return -(index - map->inobject_properties() + 1); |
|
Toon Verwaest
2013/12/04 17:29:26
Seems like this should be combined with the code i
danno
2014/06/06 15:43:50
Well, essentially because they are are not the sam
|
| + } |
| + } |
| + return index; |
| +} |
| + |
| + |
| +int KeyedLookupCache::ConvertFromFastIndexForGeneratedCode(Map* map, |
| + int index) { |
| + if (FLAG_compiled_keyed_generic_loads) { |
| + if (index < 0) { |
| + return -index + map->inobject_properties() - 1; |
|
Toon Verwaest
2013/12/04 17:29:26
Same as above.
danno
2014/06/06 15:43:50
See my comment above.
|
| + } |
| + } |
| + return index; |
| +} |
| + |
| + |
| int KeyedLookupCache::Lookup(Map* map, Name* name) { |
| int index = (Hash(map, name) & kHashMask); |
| for (int i = 0; i < kEntriesPerBucket; i++) { |
| Key& key = keys_[index + i]; |
| if ((key.map == map) && key.name->Equals(name)) { |
| - return field_offsets_[index + i]; |
| + int result = field_offsets_[index + i]; |
| + result = ConvertFromFastIndexForGeneratedCode(map, result); |
| } |
| } |
| return kNotFound; |
| @@ -7734,6 +7756,11 @@ void KeyedLookupCache::Update(Map* map, Name* name, int field_offset) { |
| // cache to only contain old space names. |
| ASSERT(!map->GetIsolate()->heap()->InNewSpace(name)); |
| + // Swizzle the field offset so that it's in the most efficient format to be |
| + // accessed in the cache from generated code: in-object properties are index |
| + // offsets and out-of-object are negative offsets. |
| + field_offset = ConvertToFastIndexForGeneratedCode(map, field_offset); |
| + |
| int index = (Hash(map, name) & kHashMask); |
| // After a GC there will be free slots, so we use them in order (this may |
| // help to get the most frequently used one in position 0). |