InnerPointerToCodeCache::GetCacheEntry() made deterministic in predictable mode.

The hash calculation was dependent on upper part of |inner_pointer| and caused non-deterministic cache miss events which in turn caused non-deterministic progress of pages sweeping (see GcSafeFindCodeForInnerPointer()).

Review URL: https://codereview.chromium.org/1582573002

Cr-Commit-Position: refs/heads/master@{#33246}
This commit is contained in:
ishell 2016-01-12 10:09:50 -08:00 committed by Commit bot
parent f5828cb4db
commit 07c52763bb
3 changed files with 10 additions and 9 deletions

View File

@ -1509,9 +1509,8 @@ InnerPointerToCodeCache::InnerPointerToCodeCacheEntry*
InnerPointerToCodeCache::GetCacheEntry(Address inner_pointer) { InnerPointerToCodeCache::GetCacheEntry(Address inner_pointer) {
isolate_->counters()->pc_to_code()->Increment(); isolate_->counters()->pc_to_code()->Increment();
DCHECK(base::bits::IsPowerOfTwo32(kInnerPointerToCodeCacheSize)); DCHECK(base::bits::IsPowerOfTwo32(kInnerPointerToCodeCacheSize));
uint32_t hash = ComputeIntegerHash( uint32_t hash = ComputeIntegerHash(ObjectAddressForHashing(inner_pointer),
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(inner_pointer)), v8::internal::kZeroHashSeed);
v8::internal::kZeroHashSeed);
uint32_t index = hash & (kInnerPointerToCodeCacheSize - 1); uint32_t index = hash & (kInnerPointerToCodeCacheSize - 1);
InnerPointerToCodeCacheEntry* entry = cache(index); InnerPointerToCodeCacheEntry* entry = cache(index);
if (entry->inner_pointer == inner_pointer) { if (entry->inner_pointer == inner_pointer) {

View File

@ -7753,6 +7753,14 @@ String::SubStringRange::iterator String::SubStringRange::end() {
} }
// Predictably converts HeapObject* or Address to uint32 by calculating
// offset of the address in respective MemoryChunk.
static inline uint32_t ObjectAddressForHashing(void* object) {
uint32_t value = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(object));
return value & MemoryChunk::kAlignmentMask;
}
#undef TYPE_CHECKER #undef TYPE_CHECKER
#undef CAST_ACCESSOR #undef CAST_ACCESSOR
#undef INT_ACCESSORS #undef INT_ACCESSORS

View File

@ -12171,12 +12171,6 @@ void String::PrintOn(FILE* file) {
} }
inline static uint32_t ObjectAddressForHashing(Object* object) {
uint32_t value = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(object));
return value & MemoryChunk::kAlignmentMask;
}
int Map::Hash() { int Map::Hash() {
// For performance reasons we only hash the 3 most variable fields of a map: // For performance reasons we only hash the 3 most variable fields of a map:
// constructor, prototype and bit_field2. For predictability reasons we // constructor, prototype and bit_field2. For predictability reasons we