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

Unified Diff: test/cctest/heap/test-heap.cc

Issue 2663303003: Store correct String.prototype map on the context (Closed)
Patch Set: Created 3 years, 11 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/bootstrapper.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/heap/test-heap.cc
diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc
index 2183c8879b8065ce43612451850086bbead73801..da7becd9827f90db8d7e56eaba82c5f0356a6f2f 100644
--- a/test/cctest/heap/test-heap.cc
+++ b/test/cctest/heap/test-heap.cc
@@ -76,6 +76,37 @@ TEST(HeapMaps) {
CheckMap(heap->string_map(), STRING_TYPE, kVariableSizeSentinel);
}
+static void VerifyStoredPrototypeMap(Isolate* isolate,
+ int stored_map_context_index,
+ int stored_ctor_context_index) {
+ Handle<Context> context = isolate->native_context();
+
+ Handle<Map> this_map(Map::cast(context->get(stored_map_context_index)));
+
+ Handle<JSFunction> fun(
+ JSFunction::cast(context->get(stored_ctor_context_index)));
+ Handle<JSObject> proto(JSObject::cast(fun->initial_map()->prototype()));
+ Handle<Map> that_map(proto->map());
+
+ CHECK(proto->HasFastProperties());
+ CHECK_EQ(*this_map, *that_map);
+}
+
+// Checks that critical maps stored on the context (mostly used for fast-path
+// checks) are unchanged after initialization.
+TEST(ContextMaps) {
+ CcTest::InitializeVM();
+ Isolate* isolate = CcTest::i_isolate();
+ HandleScope handle_scope(isolate);
+
+ VerifyStoredPrototypeMap(isolate,
+ Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX,
+ Context::STRING_FUNCTION_INDEX);
+ VerifyStoredPrototypeMap(isolate, Context::REGEXP_PROTOTYPE_MAP_INDEX,
+ Context::REGEXP_FUNCTION_INDEX);
+ VerifyStoredPrototypeMap(isolate, Context::PROMISE_PROTOTYPE_MAP_INDEX,
+ Context::PROMISE_FUNCTION_INDEX);
+}
static void CheckOddball(Isolate* isolate, Object* obj, const char* string) {
CHECK(obj->IsOddball());
« no previous file with comments | « src/bootstrapper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698