Commit 3833fef5 authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

Refactor integer hashing function names

We now clearly differentiate between:
- unseeded hash for 32-bit integers
- unseeded hash for 64-bit integers
- seeded hash for 32-bit integers
- seeded hash for strings


R=bmeurer@chromium.org

Bug: chromium:680662
Change-Id: I7459958c4158ee3501c962943dff8f33258bb5ce
Reviewed-on: https://chromium-review.googlesource.com/1235973
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56068}
parent 2fde5433
...@@ -689,7 +689,7 @@ class CollectionsBuiltinsAssembler : public BaseCollectionsAssembler { ...@@ -689,7 +689,7 @@ class CollectionsBuiltinsAssembler : public BaseCollectionsAssembler {
Node* key_tagged, Variable* result, Node* key_tagged, Variable* result,
Label* entry_found, Label* entry_found,
Label* not_found); Label* not_found);
Node* ComputeIntegerHashForString(Node* context, Node* string_key); Node* ComputeStringHash(Node* context, Node* string_key);
void SameValueZeroString(Node* context, Node* key_string, Node* candidate_key, void SameValueZeroString(Node* context, Node* key_string, Node* candidate_key,
Label* if_same, Label* if_not_same); Label* if_same, Label* if_not_same);
...@@ -846,8 +846,7 @@ void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForSmiKey( ...@@ -846,8 +846,7 @@ void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForSmiKey(
Node* table, Node* smi_key, Variable* result, Label* entry_found, Node* table, Node* smi_key, Variable* result, Label* entry_found,
Label* not_found) { Label* not_found) {
Node* const key_untagged = SmiUntag(smi_key); Node* const key_untagged = SmiUntag(smi_key);
Node* const hash = Node* const hash = ChangeInt32ToIntPtr(ComputeUnseededHash(key_untagged));
ChangeInt32ToIntPtr(ComputeIntegerHash(key_untagged, Int32Constant(0)));
CSA_ASSERT(this, IntPtrGreaterThanOrEqual(hash, IntPtrConstant(0))); CSA_ASSERT(this, IntPtrGreaterThanOrEqual(hash, IntPtrConstant(0)));
result->Bind(hash); result->Bind(hash);
FindOrderedHashTableEntry<CollectionType>( FindOrderedHashTableEntry<CollectionType>(
...@@ -862,7 +861,7 @@ template <typename CollectionType> ...@@ -862,7 +861,7 @@ template <typename CollectionType>
void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForStringKey( void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForStringKey(
Node* context, Node* table, Node* key_tagged, Variable* result, Node* context, Node* table, Node* key_tagged, Variable* result,
Label* entry_found, Label* not_found) { Label* entry_found, Label* not_found) {
Node* const hash = ComputeIntegerHashForString(context, key_tagged); Node* const hash = ComputeStringHash(context, key_tagged);
CSA_ASSERT(this, IntPtrGreaterThanOrEqual(hash, IntPtrConstant(0))); CSA_ASSERT(this, IntPtrGreaterThanOrEqual(hash, IntPtrConstant(0)));
result->Bind(hash); result->Bind(hash);
FindOrderedHashTableEntry<CollectionType>( FindOrderedHashTableEntry<CollectionType>(
...@@ -920,8 +919,8 @@ void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForOtherKey( ...@@ -920,8 +919,8 @@ void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForOtherKey(
result, entry_found, not_found); result, entry_found, not_found);
} }
Node* CollectionsBuiltinsAssembler::ComputeIntegerHashForString( Node* CollectionsBuiltinsAssembler::ComputeStringHash(Node* context,
Node* context, Node* string_key) { Node* string_key) {
VARIABLE(var_result, MachineType::PointerRepresentation()); VARIABLE(var_result, MachineType::PointerRepresentation());
Label hash_not_computed(this), done(this, &var_result); Label hash_not_computed(this), done(this, &var_result);
......
...@@ -7766,14 +7766,28 @@ template void CodeStubAssembler::NameDictionaryLookup<GlobalDictionary>( ...@@ -7766,14 +7766,28 @@ template void CodeStubAssembler::NameDictionaryLookup<GlobalDictionary>(
TNode<GlobalDictionary>, TNode<Name>, Label*, TVariable<IntPtrT>*, Label*, TNode<GlobalDictionary>, TNode<Name>, Label*, TVariable<IntPtrT>*, Label*,
int, LookupMode); int, LookupMode);
Node* CodeStubAssembler::ComputeIntegerHash(Node* key) { Node* CodeStubAssembler::ComputeUnseededHash(Node* key) {
return ComputeIntegerHash(key, IntPtrConstant(kZeroHashSeed)); // See v8::internal::ComputeUnseededHash()
Node* hash = TruncateIntPtrToInt32(key);
hash = Int32Add(Word32Xor(hash, Int32Constant(0xFFFFFFFF)),
Word32Shl(hash, Int32Constant(15)));
hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(12)));
hash = Int32Add(hash, Word32Shl(hash, Int32Constant(2)));
hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(4)));
hash = Int32Mul(hash, Int32Constant(2057));
hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(16)));
return Word32And(hash, Int32Constant(0x3FFFFFFF));
} }
Node* CodeStubAssembler::ComputeIntegerHash(Node* key, Node* seed) { Node* CodeStubAssembler::ComputeSeededHash(Node* key) {
// See v8::internal::ComputeIntegerHash() // See v8::internal::ComputeIntegerHash()
Node* hash = TruncateIntPtrToInt32(key); Node* hash_seed;
hash = Word32Xor(hash, seed); if (Is64()) {
hash_seed = TruncateInt64ToInt32(HashSeed());
} else {
hash_seed = HashSeedLow();
}
Node* hash = Word32Xor(TruncateIntPtrToInt32(key), hash_seed);
hash = Int32Add(Word32Xor(hash, Int32Constant(0xFFFFFFFF)), hash = Int32Add(Word32Xor(hash, Int32Constant(0xFFFFFFFF)),
Word32Shl(hash, Int32Constant(15))); Word32Shl(hash, Int32Constant(15)));
hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(12))); hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(12)));
...@@ -7794,16 +7808,7 @@ void CodeStubAssembler::NumberDictionaryLookup( ...@@ -7794,16 +7808,7 @@ void CodeStubAssembler::NumberDictionaryLookup(
TNode<IntPtrT> capacity = SmiUntag(GetCapacity<NumberDictionary>(dictionary)); TNode<IntPtrT> capacity = SmiUntag(GetCapacity<NumberDictionary>(dictionary));
TNode<WordT> mask = IntPtrSub(capacity, IntPtrConstant(1)); TNode<WordT> mask = IntPtrSub(capacity, IntPtrConstant(1));
TNode<Int32T> int32_seed; TNode<WordT> hash = ChangeUint32ToWord(ComputeSeededHash(intptr_index));
if (Is64()) {
int32_seed = TruncateInt64ToInt32(HashSeed());
} else {
int32_seed = HashSeedLow();
}
TNode<WordT> hash =
ChangeUint32ToWord(ComputeIntegerHash(intptr_index, int32_seed));
Node* key_as_float64 = RoundIntPtrToFloat64(intptr_index); Node* key_as_float64 = RoundIntPtrToFloat64(intptr_index);
// See Dictionary::FirstProbe(). // See Dictionary::FirstProbe().
......
...@@ -2320,8 +2320,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -2320,8 +2320,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
int inlined_probes = kInlinedDictionaryProbes, int inlined_probes = kInlinedDictionaryProbes,
LookupMode mode = kFindExisting); LookupMode mode = kFindExisting);
Node* ComputeIntegerHash(Node* key); Node* ComputeUnseededHash(Node* key);
Node* ComputeIntegerHash(Node* key, Node* seed); Node* ComputeSeededHash(Node* key);
void NumberDictionaryLookup(TNode<NumberDictionary> dictionary, void NumberDictionaryLookup(TNode<NumberDictionary> dictionary,
TNode<IntPtrT> intptr_index, Label* if_found, TNode<IntPtrT> intptr_index, Label* if_found,
......
...@@ -4947,8 +4947,8 @@ Node* EffectControlLinearizer::LowerFindOrderedHashMapEntry(Node* node) { ...@@ -4947,8 +4947,8 @@ Node* EffectControlLinearizer::LowerFindOrderedHashMapEntry(Node* node) {
} }
} }
Node* EffectControlLinearizer::ComputeIntegerHash(Node* value) { Node* EffectControlLinearizer::ComputeUnseededHash(Node* value) {
// See v8::internal::ComputeIntegerHash() // See v8::internal::ComputeUnseededHash()
value = __ Int32Add(__ Word32Xor(value, __ Int32Constant(0xFFFFFFFF)), value = __ Int32Add(__ Word32Xor(value, __ Int32Constant(0xFFFFFFFF)),
__ Word32Shl(value, __ Int32Constant(15))); __ Word32Shl(value, __ Int32Constant(15)));
value = __ Word32Xor(value, __ Word32Shr(value, __ Int32Constant(12))); value = __ Word32Xor(value, __ Word32Shr(value, __ Int32Constant(12)));
...@@ -4966,7 +4966,7 @@ Node* EffectControlLinearizer::LowerFindOrderedHashMapEntryForInt32Key( ...@@ -4966,7 +4966,7 @@ Node* EffectControlLinearizer::LowerFindOrderedHashMapEntryForInt32Key(
Node* key = NodeProperties::GetValueInput(node, 1); Node* key = NodeProperties::GetValueInput(node, 1);
// Compute the integer hash code. // Compute the integer hash code.
Node* hash = ChangeUint32ToUintPtr(ComputeIntegerHash(key)); Node* hash = ChangeUint32ToUintPtr(ComputeUnseededHash(key));
Node* number_of_buckets = ChangeSmiToIntPtr(__ LoadField( Node* number_of_buckets = ChangeSmiToIntPtr(__ LoadField(
AccessBuilder::ForOrderedHashTableBaseNumberOfBuckets(), table)); AccessBuilder::ForOrderedHashTableBaseNumberOfBuckets(), table));
......
...@@ -190,7 +190,7 @@ class V8_EXPORT_PRIVATE EffectControlLinearizer { ...@@ -190,7 +190,7 @@ class V8_EXPORT_PRIVATE EffectControlLinearizer {
Node* BuildFloat64RoundDown(Node* value); Node* BuildFloat64RoundDown(Node* value);
Node* BuildFloat64RoundTruncate(Node* input); Node* BuildFloat64RoundTruncate(Node* input);
Node* BuildUint32Mod(Node* lhs, Node* rhs); Node* BuildUint32Mod(Node* lhs, Node* rhs);
Node* ComputeIntegerHash(Node* value); Node* ComputeUnseededHash(Node* value);
Node* LowerStringComparison(Callable const& callable, Node* node); Node* LowerStringComparison(Callable const& callable, Node* node);
Node* IsElementsKindGreaterThan(Node* kind, ElementsKind reference_kind); Node* IsElementsKindGreaterThan(Node* kind, ElementsKind reference_kind);
......
...@@ -2133,7 +2133,7 @@ InnerPointerToCodeCache::InnerPointerToCodeCacheEntry* ...@@ -2133,7 +2133,7 @@ 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::IsPowerOfTwo(kInnerPointerToCodeCacheSize)); DCHECK(base::bits::IsPowerOfTwo(kInnerPointerToCodeCacheSize));
uint32_t hash = ComputeIntegerHash( uint32_t hash = ComputeUnseededHash(
ObjectAddressForHashing(reinterpret_cast<void*>(inner_pointer))); ObjectAddressForHashing(reinterpret_cast<void*>(inner_pointer)));
uint32_t index = hash & (kInnerPointerToCodeCacheSize - 1); uint32_t index = hash & (kInnerPointerToCodeCacheSize - 1);
InnerPointerToCodeCacheEntry* entry = cache(index); InnerPointerToCodeCacheEntry* entry = cache(index);
......
...@@ -2800,14 +2800,14 @@ bool NumberDictionaryBaseShape::IsMatch(uint32_t key, Object* other) { ...@@ -2800,14 +2800,14 @@ bool NumberDictionaryBaseShape::IsMatch(uint32_t key, Object* other) {
} }
uint32_t NumberDictionaryBaseShape::Hash(Isolate* isolate, uint32_t key) { uint32_t NumberDictionaryBaseShape::Hash(Isolate* isolate, uint32_t key) {
return ComputeIntegerHash(key, isolate->heap()->HashSeed()); return ComputeSeededHash(key, isolate->heap()->HashSeed());
} }
uint32_t NumberDictionaryBaseShape::HashForObject(Isolate* isolate, uint32_t NumberDictionaryBaseShape::HashForObject(Isolate* isolate,
Object* other) { Object* other) {
DCHECK(other->IsNumber()); DCHECK(other->IsNumber());
return ComputeIntegerHash(static_cast<uint32_t>(other->Number()), return ComputeSeededHash(static_cast<uint32_t>(other->Number()),
isolate->heap()->HashSeed()); isolate->heap()->HashSeed());
} }
Handle<Object> NumberDictionaryBaseShape::AsHandle(Isolate* isolate, Handle<Object> NumberDictionaryBaseShape::AsHandle(Isolate* isolate,
...@@ -2887,18 +2887,18 @@ uint32_t ObjectHashTableShape::HashForObject(Isolate* isolate, Object* other) { ...@@ -2887,18 +2887,18 @@ uint32_t ObjectHashTableShape::HashForObject(Isolate* isolate, Object* other) {
Object* Object::GetSimpleHash(Object* object) { Object* Object::GetSimpleHash(Object* object) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
if (object->IsSmi()) { if (object->IsSmi()) {
uint32_t hash = ComputeIntegerHash(Smi::ToInt(object)); uint32_t hash = ComputeUnseededHash(Smi::ToInt(object));
return Smi::FromInt(hash & Smi::kMaxValue); return Smi::FromInt(hash & Smi::kMaxValue);
} }
if (object->IsHeapNumber()) { if (object->IsHeapNumber()) {
double num = HeapNumber::cast(object)->value(); double num = HeapNumber::cast(object)->value();
if (std::isnan(num)) return Smi::FromInt(Smi::kMaxValue); if (std::isnan(num)) return Smi::FromInt(Smi::kMaxValue);
// Use ComputeIntegerHash for all values in Signed32 range, including -0, // Use ComputeUnseededHash for all values in Signed32 range, including -0,
// which is considered equal to 0 because collections use SameValueZero. // which is considered equal to 0 because collections use SameValueZero.
uint32_t hash; uint32_t hash;
// Check range before conversion to avoid undefined behavior. // Check range before conversion to avoid undefined behavior.
if (num >= kMinInt && num <= kMaxInt && FastI2D(FastD2I(num)) == num) { if (num >= kMinInt && num <= kMaxInt && FastI2D(FastD2I(num)) == num) {
hash = ComputeIntegerHash(FastD2I(num)); hash = ComputeUnseededHash(FastD2I(num));
} else { } else {
hash = ComputeLongHash(double_to_uint64(num)); hash = ComputeLongHash(double_to_uint64(num));
} }
......
...@@ -137,7 +137,7 @@ class V8_EXPORT_PRIVATE BigInt : public BigIntBase { ...@@ -137,7 +137,7 @@ class V8_EXPORT_PRIVATE BigInt : public BigIntBase {
bool ToBoolean() { return !is_zero(); } bool ToBoolean() { return !is_zero(); }
uint32_t Hash() { uint32_t Hash() {
// TODO(jkummerow): Improve this. At least use length and sign. // TODO(jkummerow): Improve this. At least use length and sign.
return is_zero() ? 0 : ComputeIntegerHash(static_cast<uint32_t>(digit(0))); return is_zero() ? 0 : ComputeLongHash(static_cast<uint64_t>(digit(0)));
} }
static bool EqualToString(Isolate* isolate, Handle<BigInt> x, static bool EqualToString(Isolate* isolate, Handle<BigInt> x,
......
...@@ -144,7 +144,7 @@ class OrderedHashTable : public OrderedHashTableBase { ...@@ -144,7 +144,7 @@ class OrderedHashTable : public OrderedHashTableBase {
// This special cases for Smi, so that we avoid the HandleScope // This special cases for Smi, so that we avoid the HandleScope
// creation below. // creation below.
if (key->IsSmi()) { if (key->IsSmi()) {
uint32_t hash = ComputeIntegerHash(Smi::ToInt(key)); uint32_t hash = ComputeUnseededHash(Smi::ToInt(key));
return HashToEntry(hash & Smi::kMaxValue); return HashToEntry(hash & Smi::kMaxValue);
} }
HandleScope scope(isolate); HandleScope scope(isolate);
......
...@@ -234,7 +234,7 @@ void AllocationTracker::AllocationEvent(Address addr, int size) { ...@@ -234,7 +234,7 @@ void AllocationTracker::AllocationEvent(Address addr, int size) {
static uint32_t SnapshotObjectIdHash(SnapshotObjectId id) { static uint32_t SnapshotObjectIdHash(SnapshotObjectId id) {
return ComputeIntegerHash(static_cast<uint32_t>(id)); return ComputeUnseededHash(static_cast<uint32_t>(id));
} }
......
...@@ -535,7 +535,7 @@ SnapshotObjectId HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) { ...@@ -535,7 +535,7 @@ SnapshotObjectId HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) {
heap_->HashSeed()); heap_->HashSeed());
intptr_t element_count = info->GetElementCount(); intptr_t element_count = info->GetElementCount();
if (element_count != -1) { if (element_count != -1) {
id ^= ComputeIntegerHash(static_cast<uint32_t>(element_count)); id ^= ComputeUnseededHash(static_cast<uint32_t>(element_count));
} }
return id << 1; return id << 1;
} }
......
...@@ -480,7 +480,7 @@ class NativeObjectsExplorer { ...@@ -480,7 +480,7 @@ class NativeObjectsExplorer {
struct RetainedInfoHasher { struct RetainedInfoHasher {
std::size_t operator()(v8::RetainedObjectInfo* info) const { std::size_t operator()(v8::RetainedObjectInfo* info) const {
return ComputeIntegerHash(static_cast<uint32_t>(info->GetHash())); return ComputeUnseededHash(static_cast<uint32_t>(info->GetHash()));
} }
}; };
struct RetainedInfoEquals { struct RetainedInfoEquals {
......
...@@ -84,16 +84,16 @@ CodeEntry* CodeEntry::UnresolvedEntryCreateTrait::Create() { ...@@ -84,16 +84,16 @@ CodeEntry* CodeEntry::UnresolvedEntryCreateTrait::Create() {
} }
uint32_t CodeEntry::GetHash() const { uint32_t CodeEntry::GetHash() const {
uint32_t hash = ComputeIntegerHash(tag()); uint32_t hash = ComputeUnseededHash(tag());
if (script_id_ != v8::UnboundScript::kNoScriptId) { if (script_id_ != v8::UnboundScript::kNoScriptId) {
hash ^= ComputeIntegerHash(static_cast<uint32_t>(script_id_)); hash ^= ComputeUnseededHash(static_cast<uint32_t>(script_id_));
hash ^= ComputeIntegerHash(static_cast<uint32_t>(position_)); hash ^= ComputeUnseededHash(static_cast<uint32_t>(position_));
} else { } else {
hash ^= ComputeIntegerHash( hash ^= ComputeUnseededHash(
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name_))); static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name_)));
hash ^= ComputeIntegerHash( hash ^= ComputeUnseededHash(
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(resource_name_))); static_cast<uint32_t>(reinterpret_cast<uintptr_t>(resource_name_)));
hash ^= ComputeIntegerHash(line_number_); hash ^= ComputeUnseededHash(line_number_);
} }
return hash; return hash;
} }
......
...@@ -243,7 +243,7 @@ class ProfileNode { ...@@ -243,7 +243,7 @@ class ProfileNode {
}; };
struct Hasher { struct Hasher {
std::size_t operator()(CodeEntryAndLineNumber pair) const { std::size_t operator()(CodeEntryAndLineNumber pair) const {
return pair.code_entry->GetHash() ^ ComputeIntegerHash(pair.line_number); return pair.code_entry->GetHash() ^ ComputeUnseededHash(pair.line_number);
} }
}; };
......
...@@ -488,10 +488,9 @@ class BitSetComputer { ...@@ -488,10 +488,9 @@ class BitSetComputer {
static const uint64_t kZeroHashSeed = 0; static const uint64_t kZeroHashSeed = 0;
// Thomas Wang, Integer Hash Functions. // Thomas Wang, Integer Hash Functions.
// http://www.concentric.net/~Ttwang/tech/inthash.htm // http://www.concentric.net/~Ttwang/tech/inthash.htm`
inline uint32_t ComputeIntegerHash(uint32_t key, uint64_t seed) { inline uint32_t ComputeUnseededHash(uint32_t key) {
uint32_t hash = key; uint32_t hash = key;
hash = hash ^ static_cast<uint32_t>(seed);
hash = ~hash + (hash << 15); // hash = (hash << 15) - hash - 1; hash = ~hash + (hash << 15); // hash = (hash << 15) - hash - 1;
hash = hash ^ (hash >> 12); hash = hash ^ (hash >> 12);
hash = hash + (hash << 2); hash = hash + (hash << 2);
...@@ -501,10 +500,6 @@ inline uint32_t ComputeIntegerHash(uint32_t key, uint64_t seed) { ...@@ -501,10 +500,6 @@ inline uint32_t ComputeIntegerHash(uint32_t key, uint64_t seed) {
return hash & 0x3fffffff; return hash & 0x3fffffff;
} }
inline uint32_t ComputeIntegerHash(uint32_t key) {
return ComputeIntegerHash(key, kZeroHashSeed);
}
inline uint32_t ComputeLongHash(uint64_t key) { inline uint32_t ComputeLongHash(uint64_t key) {
uint64_t hash = key; uint64_t hash = key;
hash = ~hash + (hash << 18); // hash = (hash << 18) - hash - 1; hash = ~hash + (hash << 18); // hash = (hash << 18) - hash - 1;
...@@ -516,14 +511,17 @@ inline uint32_t ComputeLongHash(uint64_t key) { ...@@ -516,14 +511,17 @@ inline uint32_t ComputeLongHash(uint64_t key) {
return static_cast<uint32_t>(hash); return static_cast<uint32_t>(hash);
} }
inline uint32_t ComputeSeededHash(uint32_t key, uint64_t seed) {
return ComputeUnseededHash(key ^ static_cast<uint32_t>(seed));
}
inline uint32_t ComputePointerHash(void* ptr) { inline uint32_t ComputePointerHash(void* ptr) {
return ComputeIntegerHash( return ComputeUnseededHash(
static_cast<uint32_t>(reinterpret_cast<intptr_t>(ptr))); static_cast<uint32_t>(reinterpret_cast<intptr_t>(ptr)));
} }
inline uint32_t ComputeAddressHash(Address address) { inline uint32_t ComputeAddressHash(Address address) {
return ComputeIntegerHash(static_cast<uint32_t>(address & 0xFFFFFFFFul)); return ComputeUnseededHash(static_cast<uint32_t>(address & 0xFFFFFFFFul));
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
......
...@@ -332,15 +332,7 @@ TEST(ComputeIntegerHash) { ...@@ -332,15 +332,7 @@ TEST(ComputeIntegerHash) {
CodeAssemblerTester asm_tester(isolate, kNumParams); CodeAssemblerTester asm_tester(isolate, kNumParams);
CodeStubAssembler m(asm_tester.state()); CodeStubAssembler m(asm_tester.state());
TNode<Int32T> int32_seed; m.Return(m.SmiFromInt32(m.ComputeSeededHash(m.SmiUntag(m.Parameter(0)))));
if (m.Is64()) {
int32_seed = m.TruncateInt64ToInt32(m.HashSeed());
} else {
int32_seed = m.HashSeedLow();
}
m.Return(m.SmiFromInt32(
m.ComputeIntegerHash(m.SmiUntag(m.Parameter(0)), int32_seed)));
FunctionTester ft(asm_tester.GenerateCode(), kNumParams); FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
...@@ -352,7 +344,7 @@ TEST(ComputeIntegerHash) { ...@@ -352,7 +344,7 @@ TEST(ComputeIntegerHash) {
Handle<Smi> key(Smi::FromInt(k), isolate); Handle<Smi> key(Smi::FromInt(k), isolate);
Handle<Object> result = ft.Call(key).ToHandleChecked(); Handle<Object> result = ft.Call(key).ToHandleChecked();
uint32_t hash = ComputeIntegerHash(k, isolate->heap()->HashSeed()); uint32_t hash = ComputeSeededHash(k, isolate->heap()->HashSeed());
Smi* expected = Smi::FromInt(hash & Smi::kMaxValue); Smi* expected = Smi::FromInt(hash & Smi::kMaxValue);
CHECK_EQ(expected, Smi::cast(*result)); CHECK_EQ(expected, Smi::cast(*result));
} }
......
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