[cleanup] Add kZeroSeed default parameter to ComputeIntegerHash

Change-Id: I46ac3b82a37c7044d5ce5eb3c0378e354ef13c52
Reviewed-on: https://chromium-review.googlesource.com/552538
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46330}
This commit is contained in:
Camillo Bruni 2017-06-29 16:59:34 +02:00 committed by Commit Bot
parent 3a9cd45423
commit 8516076a6c
11 changed files with 27 additions and 31 deletions

View File

@ -5060,6 +5060,10 @@ template void CodeStubAssembler::NameDictionaryLookup<NameDictionary>(
template void CodeStubAssembler::NameDictionaryLookup<GlobalDictionary>(
Node*, Node*, Label*, Variable*, Label*, int, LookupMode);
Node* CodeStubAssembler::ComputeIntegerHash(Node* key) {
return ComputeIntegerHash(key, IntPtrConstant(kZeroHashSeed));
}
Node* CodeStubAssembler::ComputeIntegerHash(Node* key, Node* seed) {
// See v8::internal::ComputeIntegerHash()
Node* hash = TruncateWordToWord32(key);

View File

@ -1148,6 +1148,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
int inlined_probes = kInlinedDictionaryProbes,
LookupMode mode = kFindExisting);
Node* ComputeIntegerHash(Node* key);
Node* ComputeIntegerHash(Node* key, Node* seed);
template <typename Dictionary>

View File

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

View File

@ -6015,13 +6015,13 @@ bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) {
}
uint32_t UnseededNumberDictionaryShape::Hash(Isolate* isolate, uint32_t key) {
return ComputeIntegerHash(key, 0);
return ComputeIntegerHash(key);
}
uint32_t UnseededNumberDictionaryShape::HashForObject(Isolate* isolate,
Object* other) {
DCHECK(other->IsNumber());
return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), 0);
return ComputeIntegerHash(static_cast<uint32_t>(other->Number()));
}
Map* UnseededNumberDictionaryShape::GetMap(Isolate* isolate) {

View File

@ -2180,8 +2180,7 @@ Object* GetSimpleHash(Object* object) {
// The object is either a Smi, a HeapNumber, a name, an odd-ball, a real JS
// object, or a Harmony proxy.
if (object->IsSmi()) {
uint32_t hash =
ComputeIntegerHash(Smi::cast(object)->value(), kZeroHashSeed);
uint32_t hash = ComputeIntegerHash(Smi::cast(object)->value());
return Smi::FromInt(hash & Smi::kMaxValue);
}
if (object->IsHeapNumber()) {

View File

@ -435,8 +435,7 @@ class OrderedHashTable : public FixedArray {
// This special cases for Smi, so that we avoid the HandleScope
// creation below.
if (key->IsSmi()) {
uint32_t hash =
ComputeIntegerHash(Smi::cast(key)->value(), kZeroHashSeed);
uint32_t hash = ComputeIntegerHash(Smi::cast(key)->value());
return HashToEntry(hash & Smi::kMaxValue);
}
HandleScope scope(isolate);

View File

@ -252,8 +252,7 @@ void AllocationTracker::AllocationEvent(Address addr, int size) {
static uint32_t SnapshotObjectIdHash(SnapshotObjectId id) {
return ComputeIntegerHash(static_cast<uint32_t>(id),
v8::internal::kZeroHashSeed);
return ComputeIntegerHash(static_cast<uint32_t>(id));
}

View File

@ -677,9 +677,9 @@ SnapshotObjectId HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) {
static_cast<int>(strlen(label)),
heap_->HashSeed());
intptr_t element_count = info->GetElementCount();
if (element_count != -1)
id ^= ComputeIntegerHash(static_cast<uint32_t>(element_count),
v8::internal::kZeroHashSeed);
if (element_count != -1) {
id ^= ComputeIntegerHash(static_cast<uint32_t>(element_count));
}
return id << 1;
}

View File

@ -297,8 +297,7 @@ class HeapEntriesMap {
private:
static uint32_t Hash(HeapThing thing) {
return ComputeIntegerHash(
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(thing)),
v8::internal::kZeroHashSeed);
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(thing)));
}
base::HashMap entries_;
@ -505,8 +504,7 @@ class NativeObjectsExplorer {
void VisitSubtreeWrapper(Object** p, uint16_t class_id);
static uint32_t InfoHash(v8::RetainedObjectInfo* info) {
return ComputeIntegerHash(static_cast<uint32_t>(info->GetHash()),
v8::internal::kZeroHashSeed);
return ComputeIntegerHash(static_cast<uint32_t>(info->GetHash()));
}
static bool RetainedInfosMatch(void* key1, void* key2) {
return key1 == key2 ||

View File

@ -96,23 +96,18 @@ CodeEntry::~CodeEntry() {
uint32_t CodeEntry::GetHash() const {
uint32_t hash = ComputeIntegerHash(tag(), v8::internal::kZeroHashSeed);
uint32_t hash = ComputeIntegerHash(tag());
if (script_id_ != v8::UnboundScript::kNoScriptId) {
hash ^= ComputeIntegerHash(static_cast<uint32_t>(script_id_),
v8::internal::kZeroHashSeed);
hash ^= ComputeIntegerHash(static_cast<uint32_t>(position_),
v8::internal::kZeroHashSeed);
hash ^= ComputeIntegerHash(static_cast<uint32_t>(script_id_));
hash ^= ComputeIntegerHash(static_cast<uint32_t>(position_));
} else {
hash ^= ComputeIntegerHash(
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name_prefix_)),
v8::internal::kZeroHashSeed);
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name_prefix_)));
hash ^= ComputeIntegerHash(
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name_)),
v8::internal::kZeroHashSeed);
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name_)));
hash ^= ComputeIntegerHash(
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(resource_name_)),
v8::internal::kZeroHashSeed);
hash ^= ComputeIntegerHash(line_number_, v8::internal::kZeroHashSeed);
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(resource_name_)));
hash ^= ComputeIntegerHash(line_number_);
}
return hash;
}

View File

@ -442,6 +442,9 @@ inline uint32_t ComputeIntegerHash(uint32_t key, uint32_t seed) {
return hash & 0x3fffffff;
}
inline uint32_t ComputeIntegerHash(uint32_t key) {
return ComputeIntegerHash(key, kZeroHashSeed);
}
inline uint32_t ComputeLongHash(uint64_t key) {
uint64_t hash = key;
@ -457,8 +460,7 @@ inline uint32_t ComputeLongHash(uint64_t key) {
inline uint32_t ComputePointerHash(void* ptr) {
return ComputeIntegerHash(
static_cast<uint32_t>(reinterpret_cast<intptr_t>(ptr)),
v8::internal::kZeroHashSeed);
static_cast<uint32_t>(reinterpret_cast<intptr_t>(ptr)));
}