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

Unified Diff: src/stub-cache.h

Issue 401613003: Unravel kHeapObjectTagSize from the stub cache. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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/mips64/stub-cache-mips64.cc ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/stub-cache.h
diff --git a/src/stub-cache.h b/src/stub-cache.h
index 8c863e1bd895eb8e46c4896336393483248f40fa..4687c1cb2baf5992886d0cb500d42dd627f2686c 100644
--- a/src/stub-cache.h
+++ b/src/stub-cache.h
@@ -183,6 +183,11 @@ class StubCache {
static const int kInterceptorArgsHolderIndex = 3;
static const int kInterceptorArgsLength = 4;
+ // Setting the entry size such that the index is shifted by Name::kHashShift
+ // is convenient; shifting down the length field (to extract the hash code)
+ // automatically discards the hash bit field.
+ static const int kCacheIndexShift = Name::kHashShift;
+
private:
explicit StubCache(Isolate* isolate);
@@ -195,13 +200,9 @@ class StubCache {
// Hash algorithm for the primary table. This algorithm is replicated in
// assembler for every architecture. Returns an index into the table that
- // is scaled by 1 << kHeapObjectTagSize.
+ // is scaled by 1 << kCacheIndexShift.
static int PrimaryOffset(Name* 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.
- STATIC_ASSERT(kHeapObjectTagSize == Name::kHashShift);
+ STATIC_ASSERT(kCacheIndexShift == Name::kHashShift);
// Compute the hash of the name (use entire hash field).
ASSERT(name->HasHashCode());
uint32_t field = name->hash_field();
@@ -216,12 +217,12 @@ class StubCache {
(static_cast<uint32_t>(flags) & ~Code::kFlagsNotUsedInLookup);
// Base the offset on a simple combination of name, flags, and map.
uint32_t key = (map_low32bits + field) ^ iflags;
- return key & ((kPrimaryTableSize - 1) << kHeapObjectTagSize);
+ return key & ((kPrimaryTableSize - 1) << kCacheIndexShift);
}
// Hash algorithm for the secondary table. This algorithm is replicated in
// assembler for every architecture. Returns an index into the table that
- // is scaled by 1 << kHeapObjectTagSize.
+ // is scaled by 1 << kCacheIndexShift.
static int SecondaryOffset(Name* name, Code::Flags flags, int seed) {
// Use the seed from the primary cache in the secondary cache.
uint32_t name_low32bits =
@@ -231,7 +232,7 @@ class StubCache {
uint32_t iflags =
(static_cast<uint32_t>(flags) & ~Code::kFlagsNotUsedInLookup);
uint32_t key = (seed - name_low32bits) + iflags;
- return key & ((kSecondaryTableSize - 1) << kHeapObjectTagSize);
+ return key & ((kSecondaryTableSize - 1) << kCacheIndexShift);
}
// Compute the entry for a given offset in exactly the same way as
« no previous file with comments | « src/mips64/stub-cache-mips64.cc ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698