Commit f1e1b39e authored by lrn@chromium.org's avatar lrn@chromium.org

X64: Changed hash computations to only use lower 32 bits of pointers.

Review URL: http://codereview.chromium.org/115017


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1876 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0e76f83b
...@@ -203,14 +203,21 @@ class StubCache : public AllStatic { ...@@ -203,14 +203,21 @@ class StubCache : public AllStatic {
// Compute the hash of the name (use entire length field). // Compute the hash of the name (use entire length field).
ASSERT(name->HasHashCode()); ASSERT(name->HasHashCode());
uint32_t field = name->length_field(); uint32_t field = name->length_field();
// Using only the low bits in 64-bit mode is unlikely to increase the
// risk of collision even if the heap is spread over an area larger than
// 4Gb (and not at all if it isn't).
uint32_t map_low32bits =
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(map));
// Base the offset on a simple combination of name, flags, and map. // Base the offset on a simple combination of name, flags, and map.
uint32_t key = (reinterpret_cast<uint32_t>(map) + field) ^ flags; uint32_t key = (map_low32bits + field) ^ flags;
return key & ((kPrimaryTableSize - 1) << kHeapObjectTagSize); return key & ((kPrimaryTableSize - 1) << kHeapObjectTagSize);
} }
static int SecondaryOffset(String* name, Code::Flags flags, int seed) { static int SecondaryOffset(String* name, Code::Flags flags, int seed) {
// Use the seed from the primary cache in the secondary cache. // Use the seed from the primary cache in the secondary cache.
uint32_t key = seed - reinterpret_cast<uint32_t>(name) + flags; uint32_t string_low32bits =
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name));
uint32_t key = seed - string_low32bits + flags;
return key & ((kSecondaryTableSize - 1) << kHeapObjectTagSize); return key & ((kSecondaryTableSize - 1) << kHeapObjectTagSize);
} }
......
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