Index: src/ic/stub-cache.cc |
diff --git a/src/ic/stub-cache.cc b/src/ic/stub-cache.cc |
index 4a834b82ba6f7603befe46eed7f1a811cf0d560a..31d7e2e0a81cc905629225a703ee1bd2ca8e3ee2 100644 |
--- a/src/ic/stub-cache.cc |
+++ b/src/ic/stub-cache.cc |
@@ -19,33 +19,34 @@ void StubCache::Initialize() { |
Clear(); |
} |
+#ifdef DEBUG |
+namespace { |
-static Code::Flags CommonStubCacheChecks(Name* name, Map* map, |
- Code::Flags flags) { |
- flags = Code::RemoveHolderFromFlags(flags); |
- |
+bool CommonStubCacheChecks(StubCache* stub_cache, Name* name, Map* map, |
+ Code* code) { |
// 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()); |
- |
- // 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; |
+ DCHECK(name->HasHashCode()); |
+ if (code) { |
+ Code::Flags expected_flags = Code::RemoveHolderFromFlags( |
+ Code::ComputeHandlerFlags(stub_cache->ic_kind())); |
+ Code::Flags flags = Code::RemoveHolderFromFlags(code->flags()); |
+ DCHECK_EQ(expected_flags, flags); |
+ DCHECK_EQ(Code::HANDLER, Code::ExtractKindFromFlags(code->flags())); |
+ } |
+ return true; |
} |
+} // namespace |
+#endif |
Code* StubCache::Set(Name* name, Map* map, Code* code) { |
- Code::Flags flags = CommonStubCacheChecks(name, map, code->flags()); |
+ DCHECK(CommonStubCacheChecks(this, name, map, code)); |
// Compute the primary entry. |
- int primary_offset = PrimaryOffset(name, flags, map); |
+ int primary_offset = PrimaryOffset(name, map); |
Entry* primary = entry(primary_, primary_offset); |
Code* old_code = primary->value; |
@@ -53,9 +54,8 @@ Code* StubCache::Set(Name* name, Map* map, Code* code) { |
// secondary cache before overwriting it. |
if (old_code != isolate_->builtins()->builtin(Builtins::kIllegal)) { |
Map* old_map = primary->map; |
- 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); |
+ int seed = PrimaryOffset(primary->key, old_map); |
+ int secondary_offset = SecondaryOffset(primary->key, seed); |
Entry* secondary = entry(secondary_, secondary_offset); |
*secondary = *primary; |
} |
@@ -68,19 +68,16 @@ Code* StubCache::Set(Name* name, Map* map, Code* code) { |
return code; |
} |
- |
-Code* StubCache::Get(Name* name, Map* map, Code::Flags flags) { |
- flags = CommonStubCacheChecks(name, map, flags); |
- int primary_offset = PrimaryOffset(name, flags, map); |
+Code* StubCache::Get(Name* name, Map* map) { |
+ DCHECK(CommonStubCacheChecks(this, name, map, nullptr)); |
+ int primary_offset = PrimaryOffset(name, map); |
Entry* primary = entry(primary_, primary_offset); |
- if (primary->key == name && primary->map == map && |
- flags == Code::RemoveHolderFromFlags(primary->value->flags())) { |
+ if (primary->key == name && primary->map == map) { |
return primary->value; |
} |
- int secondary_offset = SecondaryOffset(name, flags, primary_offset); |
+ int secondary_offset = SecondaryOffset(name, primary_offset); |
Entry* secondary = entry(secondary_, secondary_offset); |
- if (secondary->key == name && secondary->map == map && |
- flags == Code::RemoveHolderFromFlags(secondary->value->flags())) { |
+ if (secondary->key == name && secondary->map == map) { |
return secondary->value; |
} |
return NULL; |
@@ -103,7 +100,6 @@ void StubCache::Clear() { |
void StubCache::CollectMatchingMaps(SmallMapList* types, Handle<Name> name, |
- Code::Flags flags, |
Handle<Context> native_context, |
Zone* zone) { |
for (int i = 0; i < kPrimaryTableSize; i++) { |
@@ -113,7 +109,7 @@ void StubCache::CollectMatchingMaps(SmallMapList* types, Handle<Name> name, |
// with a primitive receiver. |
if (map == NULL) continue; |
- int offset = PrimaryOffset(*name, flags, map); |
+ int offset = PrimaryOffset(*name, map); |
if (entry(primary_, offset) == &primary_[i] && |
TypeFeedbackOracle::IsRelevantFeedback(map, *native_context)) { |
types->AddMapIfMissing(Handle<Map>(map), zone); |
@@ -129,10 +125,10 @@ void StubCache::CollectMatchingMaps(SmallMapList* types, Handle<Name> name, |
if (map == NULL) continue; |
// Lookup in primary table and skip duplicates. |
- int primary_offset = PrimaryOffset(*name, flags, map); |
+ int primary_offset = PrimaryOffset(*name, map); |
// Lookup in secondary table and add matches. |
- int offset = SecondaryOffset(*name, flags, primary_offset); |
+ int offset = SecondaryOffset(*name, primary_offset); |
if (entry(secondary_, offset) == &secondary_[i] && |
TypeFeedbackOracle::IsRelevantFeedback(map, *native_context)) { |
types->AddMapIfMissing(Handle<Map>(map), zone); |