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

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

Issue 2412043003: [ic] Support non-code handlers in megamorphic stub cache. (Closed)
Patch Set: Addressing comments Created 4 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/ic/stub-cache.h ('k') | src/type-feedback-vector.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 fe1adaaadbbfec248372a502bb685068d30c9a65..9655cc4bbc82dfea5b6501282b5b5b9c52edd4eb 100644
--- a/src/ic/stub-cache.cc
+++ b/src/ic/stub-cache.cc
@@ -6,13 +6,18 @@
#include "src/ast/ast.h"
#include "src/base/bits.h"
+#include "src/ic/ic-inl.h"
#include "src/type-info.h"
namespace v8 {
namespace internal {
StubCache::StubCache(Isolate* isolate, Code::Kind ic_kind)
- : isolate_(isolate), ic_kind_(ic_kind) {}
+ : isolate_(isolate), ic_kind_(ic_kind) {
+ // Ensure the nullptr (aka Smi::kZero) which StubCache::Get() returns
+ // when the entry is not found is not considered as a handler.
+ DCHECK(!IC::IsHandler(nullptr));
+}
void StubCache::Initialize() {
DCHECK(base::bits::IsPowerOfTwo32(kPrimaryTableSize));
@@ -24,18 +29,22 @@ void StubCache::Initialize() {
namespace {
bool CommonStubCacheChecks(StubCache* stub_cache, Name* name, Map* map,
- Code* code) {
+ Object* handler) {
// 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) {
- 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()));
+ if (handler) {
+ DCHECK(IC::IsHandler(handler));
+ if (handler->IsCode()) {
+ Code* code = Code::cast(handler);
+ 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;
}
@@ -43,17 +52,17 @@ bool CommonStubCacheChecks(StubCache* stub_cache, Name* name, Map* map,
} // namespace
#endif
-Code* StubCache::Set(Name* name, Map* map, Code* code) {
- DCHECK(CommonStubCacheChecks(this, name, map, code));
+Object* StubCache::Set(Name* name, Map* map, Object* handler) {
+ DCHECK(CommonStubCacheChecks(this, name, map, handler));
// Compute the primary entry.
int primary_offset = PrimaryOffset(name, map);
Entry* primary = entry(primary_, primary_offset);
- Code* old_code = primary->value;
+ Object* old_handler = primary->value;
// If the primary entry has useful data in it, we retire it to the
// secondary cache before overwriting it.
- if (old_code != isolate_->builtins()->builtin(Builtins::kIllegal)) {
+ if (old_handler != isolate_->builtins()->builtin(Builtins::kIllegal)) {
Map* old_map = primary->map;
int seed = PrimaryOffset(primary->key, old_map);
int secondary_offset = SecondaryOffset(primary->key, seed);
@@ -63,13 +72,13 @@ Code* StubCache::Set(Name* name, Map* map, Code* code) {
// Update primary cache.
primary->key = name;
- primary->value = code;
+ primary->value = handler;
primary->map = map;
isolate()->counters()->megamorphic_stub_cache_updates()->Increment();
- return code;
+ return handler;
}
-Code* StubCache::Get(Name* name, Map* map) {
+Object* StubCache::Get(Name* name, Map* map) {
DCHECK(CommonStubCacheChecks(this, name, map, nullptr));
int primary_offset = PrimaryOffset(name, map);
Entry* primary = entry(primary_, primary_offset);
@@ -81,7 +90,7 @@ Code* StubCache::Get(Name* name, Map* map) {
if (secondary->key == name && secondary->map == map) {
return secondary->value;
}
- return NULL;
+ return nullptr;
}
« no previous file with comments | « src/ic/stub-cache.h ('k') | src/type-feedback-vector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698