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

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

Issue 816653002: Monomorphic and polymorphic ICs with cleared maps should not go megamorphic. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 2d15786f89ee03af59847a8e2687d3b5ef1f412d..e3fb806d3be5969934215f91372bbb22b0dab0e9 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -4639,6 +4639,94 @@ TEST(WeakMapInMonomorphicCompareNilIC) {
}
+Handle<JSFunction> GetFunctionByName(Isolate* isolate, const char* name) {
+ Handle<String> str = isolate->factory()->InternalizeUtf8String(name);
+ Handle<Object> obj =
+ Object::GetProperty(isolate->global_object(), str).ToHandleChecked();
+ return Handle<JSFunction>::cast(obj);
+}
+
+
+void CheckIC(Code* code, Code::Kind kind, InlineCacheState state) {
+ Code* ic = FindFirstIC(code, kind);
+ CHECK(ic->is_inline_cache_stub());
+ CHECK(ic->ic_state() == state);
+}
+
+
+TEST(MonomorphicStaysMonomorphicAfterGC) {
+ if (FLAG_always_opt) return;
+ // TODO(mvstanton): vector ics need weak support!
+ if (FLAG_vector_ics) return;
+ CcTest::InitializeVM();
+ Isolate* isolate = CcTest::i_isolate();
+ Heap* heap = isolate->heap();
+ v8::HandleScope scope(CcTest::isolate());
+ CompileRun(
+ "function loadIC(obj) {"
+ " return obj.name;"
+ "}"
+ "function testIC() {"
+ " var proto = {'name' : 'weak'};"
+ " var obj = Object.create(proto);"
+ " loadIC(obj);"
+ " loadIC(obj);"
+ " loadIC(obj);"
+ " return proto;"
+ "};");
+ Handle<JSFunction> loadIC = GetFunctionByName(isolate, "loadIC");
+ {
+ v8::HandleScope scope(CcTest::isolate());
+ CompileRun("(testIC())");
+ }
+ heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ CheckIC(loadIC->code(), Code::LOAD_IC, MONOMORPHIC);
+ {
+ v8::HandleScope scope(CcTest::isolate());
+ CompileRun("(testIC())");
+ }
+ CheckIC(loadIC->code(), Code::LOAD_IC, MONOMORPHIC);
+}
+
+
+TEST(PolymorphicStaysPolymorphicAfterGC) {
+ if (FLAG_always_opt) return;
+ // TODO(mvstanton): vector ics need weak support!
+ if (FLAG_vector_ics) return;
+ CcTest::InitializeVM();
+ Isolate* isolate = CcTest::i_isolate();
+ Heap* heap = isolate->heap();
+ v8::HandleScope scope(CcTest::isolate());
+ CompileRun(
+ "function loadIC(obj) {"
+ " return obj.name;"
+ "}"
+ "function testIC() {"
+ " var proto = {'name' : 'weak'};"
+ " var obj = Object.create(proto);"
+ " loadIC(obj);"
+ " loadIC(obj);"
+ " loadIC(obj);"
+ " var poly = Object.create(proto);"
+ " poly.x = true;"
+ " loadIC(poly);"
+ " return proto;"
+ "};");
+ Handle<JSFunction> loadIC = GetFunctionByName(isolate, "loadIC");
+ {
+ v8::HandleScope scope(CcTest::isolate());
+ CompileRun("(testIC())");
+ }
+ heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
+ CheckIC(loadIC->code(), Code::LOAD_IC, POLYMORPHIC);
+ {
+ v8::HandleScope scope(CcTest::isolate());
+ CompileRun("(testIC())");
+ }
+ CheckIC(loadIC->code(), Code::LOAD_IC, POLYMORPHIC);
+}
+
+
TEST(WeakCell) {
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
« no previous file with comments | « src/ic/ic.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698