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

Unified Diff: src/ic/ic.cc

Issue 1312693004: Vector ICs: Ensure KeyedAccessStore mode is encoded in all handlers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: A few nits. Created 5 years, 4 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/ic.h ('k') | src/ic/ic-compiler.cc » ('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 373aec718f4bc85335d6c1a105de4212957ec91a..b35c2a8aa39ac7989a515789ef985915e42f5f66 100644
--- a/src/ic/ic.cc
+++ b/src/ic/ic.cc
@@ -2059,6 +2059,44 @@ static KeyedAccessStoreMode GetStoreMode(Handle<JSObject> receiver,
}
+void KeyedStoreIC::ValidateStoreMode(Handle<Code> stub) {
+#ifdef DEBUG
+ DCHECK(!FLAG_vector_stores);
+ if (stub.is_null() || *stub == *megamorphic_stub() || *stub == *slow_stub()) {
+ return;
+ }
+
+ // Query the keyed store mode.
+ ExtraICState state = stub->extra_ic_state();
+ KeyedAccessStoreMode stub_mode = GetKeyedAccessStoreMode(state);
+
+ MapHandleList map_list;
+ stub->FindAllMaps(&map_list);
+ CodeHandleList list;
+ stub->FindHandlers(&list, map_list.length());
+ for (int i = 0; i < list.length(); i++) {
+ Handle<Code> handler = list.at(i);
+ CHECK(handler->is_handler());
+ CodeStub::Major major_key = CodeStub::MajorKeyFromKey(handler->stub_key());
+ uint32_t minor_key = CodeStub::MinorKeyFromKey(handler->stub_key());
+ // Ensure that we only see handlers we know have the store mode embedded.
+ CHECK(major_key == CodeStub::KeyedStoreSloppyArguments ||
+ major_key == CodeStub::StoreFastElement ||
+ major_key == CodeStub::StoreElement ||
+ major_key == CodeStub::ElementsTransitionAndStore ||
+ *handler == *isolate()->builtins()->KeyedStoreIC_Slow());
+ // Ensure that the store mode matches that of the IC.
+ CHECK(major_key == CodeStub::NoCache ||
+ stub_mode == CommonStoreModeBits::decode(minor_key));
+ // The one exception is the keyed store slow builtin, which doesn't include
+ // store mode.
+ CHECK(major_key != CodeStub::NoCache ||
+ *handler == *isolate()->builtins()->KeyedStoreIC_Slow());
+ }
+#endif // DEBUG
+}
+
+
MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object,
Handle<Object> key,
Handle<Object> value) {
@@ -2139,6 +2177,10 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object,
KeyedAccessStoreMode store_mode =
GetStoreMode(receiver, index, value);
stub = StoreElementStub(receiver, store_mode);
+
+ // Validate that the store_mode in the stub can also be derived
+ // from peeking in the code bits of the handlers.
+ ValidateStoreMode(stub);
} else {
TRACE_GENERIC_IC(isolate(), "KeyedStoreIC", "dictionary prototype");
}
« no previous file with comments | « src/ic/ic.h ('k') | src/ic/ic-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698