Commit 07c52763 authored by ishell's avatar ishell Committed by Commit bot

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}
parent f5828cb4
......@@ -1509,9 +1509,8 @@ InnerPointerToCodeCache::InnerPointerToCodeCacheEntry*
InnerPointerToCodeCache::GetCacheEntry(Address inner_pointer) {
isolate_->counters()->pc_to_code()->Increment();
DCHECK(base::bits::IsPowerOfTwo32(kInnerPointerToCodeCacheSize));
uint32_t hash = ComputeIntegerHash(
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(inner_pointer)),
v8::internal::kZeroHashSeed);
uint32_t hash = ComputeIntegerHash(ObjectAddressForHashing(inner_pointer),
v8::internal::kZeroHashSeed);
uint32_t index = hash & (kInnerPointerToCodeCacheSize - 1);
InnerPointerToCodeCacheEntry* entry = cache(index);
if (entry->inner_pointer == inner_pointer) {
......
......@@ -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 CAST_ACCESSOR
#undef INT_ACCESSORS
......
......@@ -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() {
// For performance reasons we only hash the 3 most variable fields of a map:
// constructor, prototype and bit_field2. For predictability reasons we
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment