diff options
Diffstat (limited to 'deps/v8/src/utils.h')
-rw-r--r-- | deps/v8/src/utils.h | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/deps/v8/src/utils.h b/deps/v8/src/utils.h index 9f4bb08614..f4669524a7 100644 --- a/deps/v8/src/utils.h +++ b/deps/v8/src/utils.h @@ -476,10 +476,9 @@ class BitSetComputer { static const uint64_t kZeroHashSeed = 0; // Thomas Wang, Integer Hash Functions. -// http://www.concentric.net/~Ttwang/tech/inthash.htm -inline uint32_t ComputeIntegerHash(uint32_t key, uint64_t seed) { +// http://www.concentric.net/~Ttwang/tech/inthash.htm` +inline uint32_t ComputeUnseededHash(uint32_t key) { uint32_t hash = key; - hash = hash ^ static_cast<uint32_t>(seed); hash = ~hash + (hash << 15); // hash = (hash << 15) - hash - 1; hash = hash ^ (hash >> 12); hash = hash + (hash << 2); @@ -489,10 +488,6 @@ inline uint32_t ComputeIntegerHash(uint32_t key, uint64_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; hash = ~hash + (hash << 18); // hash = (hash << 18) - hash - 1; @@ -501,17 +496,20 @@ inline uint32_t ComputeLongHash(uint64_t key) { hash = hash ^ (hash >> 11); hash = hash + (hash << 6); hash = hash ^ (hash >> 22); - return static_cast<uint32_t>(hash); + return static_cast<uint32_t>(hash & 0x3fffffff); } +inline uint32_t ComputeSeededHash(uint32_t key, uint64_t seed) { + return ComputeLongHash(static_cast<uint64_t>(key) ^ seed); +} inline uint32_t ComputePointerHash(void* ptr) { - return ComputeIntegerHash( + return ComputeUnseededHash( static_cast<uint32_t>(reinterpret_cast<intptr_t>(ptr))); } inline uint32_t ComputeAddressHash(Address address) { - return ComputeIntegerHash(static_cast<uint32_t>(address & 0xFFFFFFFFul)); + return ComputeUnseededHash(static_cast<uint32_t>(address & 0xFFFFFFFFul)); } // ---------------------------------------------------------------------------- |