Author: l...@chromium.org Date: Wed May 6 01:42:36 2009 New Revision: 1876
Modified: branches/bleeding_edge/src/stub-cache.h Log: X64: Changed hash computations to only use lower 32 bits of pointers. Review URL: http://codereview.chromium.org/115017 Modified: branches/bleeding_edge/src/stub-cache.h ============================================================================== --- branches/bleeding_edge/src/stub-cache.h (original) +++ branches/bleeding_edge/src/stub-cache.h Wed May 6 01:42:36 2009 @@ -203,14 +203,21 @@ // Compute the hash of the name (use entire length field). ASSERT(name->HasHashCode()); 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. - uint32_t key = (reinterpret_cast<uint32_t>(map) + field) ^ flags; + uint32_t key = (map_low32bits + field) ^ flags; return key & ((kPrimaryTableSize - 1) << kHeapObjectTagSize); } static int SecondaryOffset(String* name, Code::Flags flags, int seed) { // 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); } --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list v8-dev@googlegroups.com http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---