Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 7691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7702 | 7702 |
| 7703 | 7703 |
| 7704 int KeyedLookupCache::Hash(Map* map, Name* name) { | 7704 int KeyedLookupCache::Hash(Map* map, Name* name) { |
| 7705 // Uses only lower 32 bits if pointers are larger. | 7705 // Uses only lower 32 bits if pointers are larger. |
| 7706 uintptr_t addr_hash = | 7706 uintptr_t addr_hash = |
| 7707 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(map)) >> kMapHashShift; | 7707 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(map)) >> kMapHashShift; |
| 7708 return static_cast<uint32_t>((addr_hash ^ name->Hash()) & kCapacityMask); | 7708 return static_cast<uint32_t>((addr_hash ^ name->Hash()) & kCapacityMask); |
| 7709 } | 7709 } |
| 7710 | 7710 |
| 7711 | 7711 |
| 7712 int KeyedLookupCache::ConvertToFastIndexForGeneratedCode(Map* map, int index) { | |
| 7713 if (FLAG_compiled_keyed_generic_loads) { | |
| 7714 if (index >= map->inobject_properties()) { | |
| 7715 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
| |
| 7716 } | |
| 7717 } | |
| 7718 return index; | |
| 7719 } | |
| 7720 | |
| 7721 | |
| 7722 int KeyedLookupCache::ConvertFromFastIndexForGeneratedCode(Map* map, | |
| 7723 int index) { | |
| 7724 if (FLAG_compiled_keyed_generic_loads) { | |
| 7725 if (index < 0) { | |
| 7726 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.
| |
| 7727 } | |
| 7728 } | |
| 7729 return index; | |
| 7730 } | |
| 7731 | |
| 7732 | |
| 7712 int KeyedLookupCache::Lookup(Map* map, Name* name) { | 7733 int KeyedLookupCache::Lookup(Map* map, Name* name) { |
| 7713 int index = (Hash(map, name) & kHashMask); | 7734 int index = (Hash(map, name) & kHashMask); |
| 7714 for (int i = 0; i < kEntriesPerBucket; i++) { | 7735 for (int i = 0; i < kEntriesPerBucket; i++) { |
| 7715 Key& key = keys_[index + i]; | 7736 Key& key = keys_[index + i]; |
| 7716 if ((key.map == map) && key.name->Equals(name)) { | 7737 if ((key.map == map) && key.name->Equals(name)) { |
| 7717 return field_offsets_[index + i]; | 7738 int result = field_offsets_[index + i]; |
| 7739 result = ConvertFromFastIndexForGeneratedCode(map, result); | |
| 7718 } | 7740 } |
| 7719 } | 7741 } |
| 7720 return kNotFound; | 7742 return kNotFound; |
| 7721 } | 7743 } |
| 7722 | 7744 |
| 7723 | 7745 |
| 7724 void KeyedLookupCache::Update(Map* map, Name* name, int field_offset) { | 7746 void KeyedLookupCache::Update(Map* map, Name* name, int field_offset) { |
| 7725 if (!name->IsUniqueName()) { | 7747 if (!name->IsUniqueName()) { |
| 7726 String* internalized_string; | 7748 String* internalized_string; |
| 7727 if (!map->GetIsolate()->heap()->InternalizeStringIfExists( | 7749 if (!map->GetIsolate()->heap()->InternalizeStringIfExists( |
| 7728 String::cast(name), &internalized_string)) { | 7750 String::cast(name), &internalized_string)) { |
| 7729 return; | 7751 return; |
| 7730 } | 7752 } |
| 7731 name = internalized_string; | 7753 name = internalized_string; |
| 7732 } | 7754 } |
| 7733 // This cache is cleared only between mark compact passes, so we expect the | 7755 // This cache is cleared only between mark compact passes, so we expect the |
| 7734 // cache to only contain old space names. | 7756 // cache to only contain old space names. |
| 7735 ASSERT(!map->GetIsolate()->heap()->InNewSpace(name)); | 7757 ASSERT(!map->GetIsolate()->heap()->InNewSpace(name)); |
| 7736 | 7758 |
| 7759 // Swizzle the field offset so that it's in the most efficient format to be | |
| 7760 // accessed in the cache from generated code: in-object properties are index | |
| 7761 // offsets and out-of-object are negative offsets. | |
| 7762 field_offset = ConvertToFastIndexForGeneratedCode(map, field_offset); | |
| 7763 | |
| 7737 int index = (Hash(map, name) & kHashMask); | 7764 int index = (Hash(map, name) & kHashMask); |
| 7738 // After a GC there will be free slots, so we use them in order (this may | 7765 // After a GC there will be free slots, so we use them in order (this may |
| 7739 // help to get the most frequently used one in position 0). | 7766 // help to get the most frequently used one in position 0). |
| 7740 for (int i = 0; i< kEntriesPerBucket; i++) { | 7767 for (int i = 0; i< kEntriesPerBucket; i++) { |
| 7741 Key& key = keys_[index]; | 7768 Key& key = keys_[index]; |
| 7742 Object* free_entry_indicator = NULL; | 7769 Object* free_entry_indicator = NULL; |
| 7743 if (key.map == free_entry_indicator) { | 7770 if (key.map == free_entry_indicator) { |
| 7744 key.map = map; | 7771 key.map = map; |
| 7745 key.name = name; | 7772 key.name = name; |
| 7746 field_offsets_[index + i] = field_offset; | 7773 field_offsets_[index + i] = field_offset; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7988 static_cast<int>(object_sizes_last_time_[index])); | 8015 static_cast<int>(object_sizes_last_time_[index])); |
| 7989 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 8016 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 7990 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 8017 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 7991 | 8018 |
| 7992 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 8019 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 7993 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 8020 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 7994 ClearObjectStats(); | 8021 ClearObjectStats(); |
| 7995 } | 8022 } |
| 7996 | 8023 |
| 7997 } } // namespace v8::internal | 8024 } } // namespace v8::internal |
| OLD | NEW |