Chromium Code Reviews| Index: src/ic/stub-cache.cc |
| diff --git a/src/ic/stub-cache.cc b/src/ic/stub-cache.cc |
| index 4a834b82ba6f7603befe46eed7f1a811cf0d560a..bead318cff15c741c8e7e69fb81fd6b9f88bf04a 100644 |
| --- a/src/ic/stub-cache.cc |
| +++ b/src/ic/stub-cache.cc |
| @@ -19,33 +19,27 @@ void StubCache::Initialize() { |
| Clear(); |
| } |
| - |
| -static Code::Flags CommonStubCacheChecks(Name* name, Map* map, |
| - Code::Flags flags) { |
| - flags = Code::RemoveHolderFromFlags(flags); |
| - |
| +static void CommonStubCacheChecks(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 flags = code->flags(); |
|
Jakob Kummerow
2016/07/12 12:55:50
Just inline this variable into the DCHECK to make
Igor Sheludko
2016/07/12 13:06:55
Done.
|
| + // 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)); |
| + } |
| } |
| Code* StubCache::Set(Name* name, Map* map, Code* code) { |
| - Code::Flags flags = CommonStubCacheChecks(name, map, code->flags()); |
| + CommonStubCacheChecks(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 +47,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 +61,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) { |
| + CommonStubCacheChecks(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 +93,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 +102,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 +118,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); |