Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index bea27922c73d72b37b57e46e0f242c623e903f63..e37d1f339f98b25fb70559d6700eaeec65b1b56e 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -8999,19 +8999,23 @@ 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. |
// Shift away the tag. |
- int hash = (static_cast<uint32_t>( |
- reinterpret_cast<uintptr_t>(constructor())) >> 2); |
+ int hash = ObjectAddressForHashing(constructor()) >> 2; |
// XOR-ing the prototype and constructor directly yields too many zero bits |
// when the two pointers are close (which is fairly common). |
// To avoid this we shift the prototype 4 bits relatively to the constructor. |
- hash ^= (static_cast<uint32_t>( |
- reinterpret_cast<uintptr_t>(prototype())) << 2); |
+ hash ^= ObjectAddressForHashing(prototype()) << 2; |
Jakob Kummerow
2014/09/29 10:38:21
To document our offline discussion for posterity:
|
return hash ^ (hash >> 16) ^ bit_field2(); |
} |