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

Unified Diff: src/ic/ic.cc

Issue 2405213002: V8 support for cached accessors. (Closed)
Patch Set: Toon's feedback. Created 4 years, 1 month 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/ic.h ('k') | src/lookup.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ic/ic.cc
diff --git a/src/ic/ic.cc b/src/ic/ic.cc
index dd310a9c201c5357a8f6915dd3dc406eb55c240e..0d342cff8832f68f9e4b97bd138113ddd1dd6350 100644
--- a/src/ic/ic.cc
+++ b/src/ic/ic.cc
@@ -1175,10 +1175,10 @@ void IC::TraceHandlerCacheHitStats(LookupIterator* lookup) {
Handle<Object> IC::ComputeHandler(LookupIterator* lookup,
Handle<Object> value) {
// Try to find a globally shared handler stub.
- Handle<Object> handler = GetMapIndependentHandler(lookup);
- if (!handler.is_null()) {
- DCHECK(IC::IsHandler(*handler));
- return handler;
+ Handle<Object> shared_handler = GetMapIndependentHandler(lookup);
+ if (!shared_handler.is_null()) {
+ DCHECK(IC::IsHandler(*shared_handler));
+ return shared_handler;
}
// Otherwise check the map's handler cache for a map-specific handler, and
@@ -1198,16 +1198,16 @@ Handle<Object> IC::ComputeHandler(LookupIterator* lookup,
stub_holder_map = receiver_map();
}
- Handle<Code> code = PropertyHandlerCompiler::Find(
+ Handle<Object> handler = PropertyHandlerCompiler::Find(
lookup->name(), stub_holder_map, kind(), flag);
// Use the cached value if it exists, and if it is different from the
// handler that just missed.
- if (!code.is_null()) {
- Handle<Object> handler;
- if (maybe_handler_.ToHandle(&handler)) {
- if (!handler.is_identical_to(code)) {
+ if (!handler.is_null()) {
+ Handle<Object> current_handler;
+ if (maybe_handler_.ToHandle(&current_handler)) {
+ if (!current_handler.is_identical_to(handler)) {
TraceHandlerCacheHitStats(lookup);
- return code;
+ return handler;
}
} else {
// maybe_handler_ is only populated for MONOMORPHIC and POLYMORPHIC ICs.
@@ -1217,23 +1217,25 @@ Handle<Object> IC::ComputeHandler(LookupIterator* lookup,
Map* map = Handle<HeapObject>::cast(lookup->GetReceiver())->map();
Object* megamorphic_cached_handler =
stub_cache()->Get(*lookup->name(), map);
- if (megamorphic_cached_handler != *code) {
+ if (megamorphic_cached_handler != *handler) {
TraceHandlerCacheHitStats(lookup);
- return code;
+ return handler;
}
} else {
TraceHandlerCacheHitStats(lookup);
- return code;
+ return handler;
}
}
}
- code = CompileHandler(lookup, value, flag);
- DCHECK(code->is_handler());
- DCHECK(Code::ExtractCacheHolderFromFlags(code->flags()) == flag);
- Map::UpdateCodeCache(stub_holder_map, lookup->name(), code);
-
- return code;
+ handler = CompileHandler(lookup, value, flag);
+ DCHECK(IC::IsHandler(*handler));
+ if (handler->IsCode()) {
+ Handle<Code> code = Handle<Code>::cast(handler);
+ DCHECK_EQ(Code::ExtractCacheHolderFromFlags(code->flags()), flag);
+ Map::UpdateCodeCache(stub_holder_map, lookup->name(), code);
+ }
+ return handler;
}
Handle<Object> LoadIC::GetMapIndependentHandler(LookupIterator* lookup) {
@@ -1394,9 +1396,9 @@ Handle<Object> LoadIC::GetMapIndependentHandler(LookupIterator* lookup) {
return Handle<Code>::null();
}
-Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup,
- Handle<Object> unused,
- CacheHolderFlag cache_holder) {
+Handle<Object> LoadIC::CompileHandler(LookupIterator* lookup,
+ Handle<Object> unused,
+ CacheHolderFlag cache_holder) {
Handle<JSObject> holder = lookup->GetHolder<JSObject>();
#ifdef DEBUG
// Only used by DCHECKs below.
@@ -1441,6 +1443,10 @@ Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup,
DCHECK(IsCompatibleReceiver(lookup, map));
Handle<Object> accessors = lookup->GetAccessors();
if (accessors->IsAccessorPair()) {
+ if (lookup->TryLookupCachedProperty()) {
+ DCHECK_EQ(LookupIterator::DATA, lookup->state());
+ return ComputeHandler(lookup);
+ }
DCHECK(holder->HasFastProperties());
DCHECK(!GetSharedFunctionInfo()->HasDebugInfo());
Handle<Object> getter(Handle<AccessorPair>::cast(accessors)->getter(),
@@ -1963,9 +1969,9 @@ Handle<Object> StoreIC::GetMapIndependentHandler(LookupIterator* lookup) {
return Handle<Code>::null();
}
-Handle<Code> StoreIC::CompileHandler(LookupIterator* lookup,
- Handle<Object> value,
- CacheHolderFlag cache_holder) {
+Handle<Object> StoreIC::CompileHandler(LookupIterator* lookup,
+ Handle<Object> value,
+ CacheHolderFlag cache_holder) {
DCHECK_NE(LookupIterator::JSPROXY, lookup->state());
// This is currently guaranteed by checks in StoreIC::Store.
« no previous file with comments | « src/ic/ic.h ('k') | src/lookup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698