Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(774)

Unified Diff: src/stub-cache.h

Issue 6489: Exclude the bit-field bits from string hash codes. String hash codes... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects-inl.h ('k') | src/stub-cache-arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/stub-cache.h
===================================================================
--- src/stub-cache.h (revision 435)
+++ src/stub-cache.h (working copy)
@@ -198,11 +198,16 @@
// Computes the hashed offsets for primary and secondary caches.
static int PrimaryOffset(String* name, Code::Flags flags, Map* map) {
+ // This works well because the heap object tag size and the hash
+ // shift are equal. Shifting down the length field to get the
+ // hash code would effectively throw away two bits of the hash
+ // code.
+ ASSERT(kHeapObjectTagSize == kHashShift);
// Compute the hash of the name (use entire length field).
- uint32_t name_hash = name->length_field();
- ASSERT(name_hash & String::kHashComputedMask);
+ ASSERT(name->HasHashCode());
+ uint32_t field = name->length_field();
// Base the offset on a simple combination of name, flags, and map.
- uint32_t key = (reinterpret_cast<uint32_t>(map) + name_hash) ^ flags;
+ uint32_t key = (reinterpret_cast<uint32_t>(map) + field) ^ flags;
return key & ((kPrimaryTableSize - 1) << kHeapObjectTagSize);
}
« no previous file with comments | « src/objects-inl.h ('k') | src/stub-cache-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698