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

Unified Diff: src/ic/stub-cache.cc

Issue 2147213004: Revert of [ic] [stubs] Don't use Code::flags in megamorphic stub cache hash computations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@split-stub-cache
Patch Set: Created 4 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/ic/stub-cache.h ('k') | src/ic/x64/stub-cache-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ic/stub-cache.cc
diff --git a/src/ic/stub-cache.cc b/src/ic/stub-cache.cc
index 02a8b0ad3403f5e5e030d688e8a3734d191834a5..4a834b82ba6f7603befe46eed7f1a811cf0d560a 100644
--- a/src/ic/stub-cache.cc
+++ b/src/ic/stub-cache.cc
@@ -19,23 +19,33 @@
Clear();
}
-static void CommonStubCacheChecks(Name* name, Map* map, Code* code) {
+
+static Code::Flags CommonStubCacheChecks(Name* name, Map* map,
+ Code::Flags flags) {
+ flags = Code::RemoveHolderFromFlags(flags);
+
// Validate that the name does not move on scavenge, and that we
// can use identity checks instead of structural equality checks.
DCHECK(!name->GetHeap()->InNewSpace(name));
DCHECK(name->IsUniqueName());
- DCHECK(name->HasHashCode());
- if (code) {
- DCHECK_EQ(Code::HANDLER, Code::ExtractKindFromFlags(code->flags()));
- }
+
+ // The state bits are not important to the hash function because the stub
+ // cache only contains handlers. Make sure that the bits are the least
+ // significant so they will be the ones masked out.
+ DCHECK_EQ(Code::HANDLER, Code::ExtractKindFromFlags(flags));
+
+ // Make sure that the cache holder are not included in the hash.
+ DCHECK(Code::ExtractCacheHolderFromFlags(flags) == 0);
+
+ return flags;
}
Code* StubCache::Set(Name* name, Map* map, Code* code) {
- CommonStubCacheChecks(name, map, code);
+ Code::Flags flags = CommonStubCacheChecks(name, map, code->flags());
// Compute the primary entry.
- int primary_offset = PrimaryOffset(name, map);
+ int primary_offset = PrimaryOffset(name, flags, map);
Entry* primary = entry(primary_, primary_offset);
Code* old_code = primary->value;
@@ -43,8 +53,9 @@
// secondary cache before overwriting it.
if (old_code != isolate_->builtins()->builtin(Builtins::kIllegal)) {
Map* old_map = primary->map;
- int seed = PrimaryOffset(primary->key, old_map);
- int secondary_offset = SecondaryOffset(primary->key, seed);
+ Code::Flags old_flags = Code::RemoveHolderFromFlags(old_code->flags());
+ int seed = PrimaryOffset(primary->key, old_flags, old_map);
+ int secondary_offset = SecondaryOffset(primary->key, old_flags, seed);
Entry* secondary = entry(secondary_, secondary_offset);
*secondary = *primary;
}
@@ -57,16 +68,19 @@
return code;
}
-Code* StubCache::Get(Name* name, Map* map) {
- CommonStubCacheChecks(name, map, nullptr);
- int primary_offset = PrimaryOffset(name, map);
+
+Code* StubCache::Get(Name* name, Map* map, Code::Flags flags) {
+ flags = CommonStubCacheChecks(name, map, flags);
+ int primary_offset = PrimaryOffset(name, flags, map);
Entry* primary = entry(primary_, primary_offset);
- if (primary->key == name && primary->map == map) {
+ if (primary->key == name && primary->map == map &&
+ flags == Code::RemoveHolderFromFlags(primary->value->flags())) {
return primary->value;
}
- int secondary_offset = SecondaryOffset(name, primary_offset);
+ int secondary_offset = SecondaryOffset(name, flags, primary_offset);
Entry* secondary = entry(secondary_, secondary_offset);
- if (secondary->key == name && secondary->map == map) {
+ if (secondary->key == name && secondary->map == map &&
+ flags == Code::RemoveHolderFromFlags(secondary->value->flags())) {
return secondary->value;
}
return NULL;
@@ -89,6 +103,7 @@
void StubCache::CollectMatchingMaps(SmallMapList* types, Handle<Name> name,
+ Code::Flags flags,
Handle<Context> native_context,
Zone* zone) {
for (int i = 0; i < kPrimaryTableSize; i++) {
@@ -98,7 +113,7 @@
// with a primitive receiver.
if (map == NULL) continue;
- int offset = PrimaryOffset(*name, map);
+ int offset = PrimaryOffset(*name, flags, map);
if (entry(primary_, offset) == &primary_[i] &&
TypeFeedbackOracle::IsRelevantFeedback(map, *native_context)) {
types->AddMapIfMissing(Handle<Map>(map), zone);
@@ -114,10 +129,10 @@
if (map == NULL) continue;
// Lookup in primary table and skip duplicates.
- int primary_offset = PrimaryOffset(*name, map);
+ int primary_offset = PrimaryOffset(*name, flags, map);
// Lookup in secondary table and add matches.
- int offset = SecondaryOffset(*name, primary_offset);
+ int offset = SecondaryOffset(*name, flags, primary_offset);
if (entry(secondary_, offset) == &secondary_[i] &&
TypeFeedbackOracle::IsRelevantFeedback(map, *native_context)) {
types->AddMapIfMissing(Handle<Map>(map), zone);
« no previous file with comments | « src/ic/stub-cache.h ('k') | src/ic/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698