From 8516076a6c18c4e51be57c477c5c34b0ea864b24 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 29 Jun 2017 16:59:34 +0200 Subject: [PATCH] [cleanup] Add kZeroSeed default parameter to ComputeIntegerHash Change-Id: I46ac3b82a37c7044d5ce5eb3c0378e354ef13c52 Reviewed-on: https://chromium-review.googlesource.com/552538 Reviewed-by: Jaroslav Sevcik Commit-Queue: Camillo Bruni Cr-Commit-Position: refs/heads/master@{#46330} --- src/code-stub-assembler.cc | 4 ++++ src/code-stub-assembler.h | 1 + src/frames.cc | 3 +-- src/objects-inl.h | 4 ++-- src/objects.cc | 3 +-- src/objects/hash-table.h | 3 +-- src/profiler/allocation-tracker.cc | 3 +-- src/profiler/heap-snapshot-generator.cc | 6 +++--- src/profiler/heap-snapshot-generator.h | 6 ++---- src/profiler/profile-generator.cc | 19 +++++++------------ src/utils.h | 6 ++++-- 11 files changed, 27 insertions(+), 31 deletions(-) diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc index e4df4890a6..a2b78c4b82 100644 --- a/src/code-stub-assembler.cc +++ b/src/code-stub-assembler.cc @@ -5060,6 +5060,10 @@ template void CodeStubAssembler::NameDictionaryLookup( template void CodeStubAssembler::NameDictionaryLookup( 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); diff --git a/src/code-stub-assembler.h b/src/code-stub-assembler.h index 683e242756..589021d4f6 100644 --- a/src/code-stub-assembler.h +++ b/src/code-stub-assembler.h @@ -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 diff --git a/src/frames.cc b/src/frames.cc index 3dab640232..00c4500b3c 100644 --- a/src/frames.cc +++ b/src/frames.cc @@ -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) { diff --git a/src/objects-inl.h b/src/objects-inl.h index 82a9cf1d66..b401bcd93e 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -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(other->Number()), 0); + return ComputeIntegerHash(static_cast(other->Number())); } Map* UnseededNumberDictionaryShape::GetMap(Isolate* isolate) { diff --git a/src/objects.cc b/src/objects.cc index 3e85c1d2ec..d56475c9ec 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -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()) { diff --git a/src/objects/hash-table.h b/src/objects/hash-table.h index 71cc371442..aba7a9511e 100644 --- a/src/objects/hash-table.h +++ b/src/objects/hash-table.h @@ -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); diff --git a/src/profiler/allocation-tracker.cc b/src/profiler/allocation-tracker.cc index e2ed7f7817..8d8a3c7e1d 100644 --- a/src/profiler/allocation-tracker.cc +++ b/src/profiler/allocation-tracker.cc @@ -252,8 +252,7 @@ void AllocationTracker::AllocationEvent(Address addr, int size) { static uint32_t SnapshotObjectIdHash(SnapshotObjectId id) { - return ComputeIntegerHash(static_cast(id), - v8::internal::kZeroHashSeed); + return ComputeIntegerHash(static_cast(id)); } diff --git a/src/profiler/heap-snapshot-generator.cc b/src/profiler/heap-snapshot-generator.cc index dfdd0cb771..b94e576963 100644 --- a/src/profiler/heap-snapshot-generator.cc +++ b/src/profiler/heap-snapshot-generator.cc @@ -677,9 +677,9 @@ SnapshotObjectId HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) { static_cast(strlen(label)), heap_->HashSeed()); intptr_t element_count = info->GetElementCount(); - if (element_count != -1) - id ^= ComputeIntegerHash(static_cast(element_count), - v8::internal::kZeroHashSeed); + if (element_count != -1) { + id ^= ComputeIntegerHash(static_cast(element_count)); + } return id << 1; } diff --git a/src/profiler/heap-snapshot-generator.h b/src/profiler/heap-snapshot-generator.h index 84a23e4c0d..897d4a3069 100644 --- a/src/profiler/heap-snapshot-generator.h +++ b/src/profiler/heap-snapshot-generator.h @@ -297,8 +297,7 @@ class HeapEntriesMap { private: static uint32_t Hash(HeapThing thing) { return ComputeIntegerHash( - static_cast(reinterpret_cast(thing)), - v8::internal::kZeroHashSeed); + static_cast(reinterpret_cast(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(info->GetHash()), - v8::internal::kZeroHashSeed); + return ComputeIntegerHash(static_cast(info->GetHash())); } static bool RetainedInfosMatch(void* key1, void* key2) { return key1 == key2 || diff --git a/src/profiler/profile-generator.cc b/src/profiler/profile-generator.cc index 742d368390..75377f0f2d 100644 --- a/src/profiler/profile-generator.cc +++ b/src/profiler/profile-generator.cc @@ -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(script_id_), - v8::internal::kZeroHashSeed); - hash ^= ComputeIntegerHash(static_cast(position_), - v8::internal::kZeroHashSeed); + hash ^= ComputeIntegerHash(static_cast(script_id_)); + hash ^= ComputeIntegerHash(static_cast(position_)); } else { hash ^= ComputeIntegerHash( - static_cast(reinterpret_cast(name_prefix_)), - v8::internal::kZeroHashSeed); + static_cast(reinterpret_cast(name_prefix_))); hash ^= ComputeIntegerHash( - static_cast(reinterpret_cast(name_)), - v8::internal::kZeroHashSeed); + static_cast(reinterpret_cast(name_))); hash ^= ComputeIntegerHash( - static_cast(reinterpret_cast(resource_name_)), - v8::internal::kZeroHashSeed); - hash ^= ComputeIntegerHash(line_number_, v8::internal::kZeroHashSeed); + static_cast(reinterpret_cast(resource_name_))); + hash ^= ComputeIntegerHash(line_number_); } return hash; } diff --git a/src/utils.h b/src/utils.h index 786d2cd472..3f99499563 100644 --- a/src/utils.h +++ b/src/utils.h @@ -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(reinterpret_cast(ptr)), - v8::internal::kZeroHashSeed); + static_cast(reinterpret_cast(ptr))); }