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

Unified Diff: test/cctest/test-feedback-vector.cc

Issue 1262803002: Stop overallocating feedback vector slots. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed nit. Created 5 years, 5 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/type-info.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-feedback-vector.cc
diff --git a/test/cctest/test-feedback-vector.cc b/test/cctest/test-feedback-vector.cc
index cf8a730fb71c8c5fcc4d2e8763a737098e6b29e6..2995fb9730eeec0172f2772344dc688abc66852e 100644
--- a/test/cctest/test-feedback-vector.cc
+++ b/test/cctest/test-feedback-vector.cc
@@ -385,4 +385,101 @@ TEST(VectorLoadICOnSmi) {
nexus.FindAllMaps(&maps2);
CHECK_EQ(2, maps2.length());
}
+
+
+static Handle<JSFunction> GetFunction(const char* name) {
+ Handle<JSFunction> f = v8::Utils::OpenHandle(
+ *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str(name))));
+ return f;
+}
+
+
+TEST(ReferenceContextAllocatesNoSlots) {
+ if (i::FLAG_always_opt) return;
+ CcTest::InitializeVM();
+ LocalContext context;
+ v8::HandleScope scope(context->GetIsolate());
+ Isolate* isolate = CcTest::i_isolate();
+
+ CompileRun(
+ "function testvar(x) {"
+ " y = x;"
+ " y = a;"
+ " return y;"
+ "}"
+ "a = 3;"
+ "testvar({});");
+
+ Handle<JSFunction> f = GetFunction("testvar");
+
+ // There should be two LOAD_ICs, one for a and one for y at the end.
+ Handle<TypeFeedbackVector> feedback_vector =
+ handle(f->shared()->feedback_vector(), isolate);
+ CHECK_EQ(2, feedback_vector->ICSlots());
+ CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::LOAD_IC);
+ CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) == Code::LOAD_IC);
+
+ CompileRun(
+ "function testprop(x) {"
+ " x.blue = a;"
+ "}"
+ "testprop({ blue: 3 });");
+
+ f = GetFunction("testprop");
+
+ // There should be one LOAD_IC, for the load of a.
+ feedback_vector = handle(f->shared()->feedback_vector(), isolate);
+ CHECK_EQ(1, feedback_vector->ICSlots());
+
+ CompileRun(
+ "function testpropfunc(x) {"
+ " x().blue = a;"
+ " return x().blue;"
+ "}"
+ "function makeresult() { return { blue: 3 }; }"
+ "testpropfunc(makeresult);");
+
+ f = GetFunction("testpropfunc");
+
+ // There should be 2 LOAD_ICs and 2 CALL_ICs.
+ feedback_vector = handle(f->shared()->feedback_vector(), isolate);
+ CHECK_EQ(4, feedback_vector->ICSlots());
+ CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::CALL_IC);
+ CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) == Code::LOAD_IC);
+ CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(2)) == Code::CALL_IC);
+ CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(3)) == Code::LOAD_IC);
+
+ CompileRun(
+ "function testkeyedprop(x) {"
+ " x[0] = a;"
+ " return x[0];"
+ "}"
+ "testkeyedprop([0, 1, 2]);");
+
+ f = GetFunction("testkeyedprop");
+
+ // There should be 1 LOAD_ICs for the load of a, and one KEYED_LOAD_IC for the
+ // load of x[0] in the return statement.
+ feedback_vector = handle(f->shared()->feedback_vector(), isolate);
+ CHECK_EQ(2, feedback_vector->ICSlots());
+ CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::LOAD_IC);
+ CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) ==
+ Code::KEYED_LOAD_IC);
+
+ CompileRun(
+ "function testcompound(x) {"
+ " x.old = x.young = x.in_between = a;"
+ " return x.old + x.young;"
+ "}"
+ "testcompound({ old: 3, young: 3, in_between: 3 });");
+
+ f = GetFunction("testcompound");
+
+ // There should be 3 LOAD_ICs, for load of a and load of x.old and x.young.
+ feedback_vector = handle(f->shared()->feedback_vector(), isolate);
+ CHECK_EQ(3, feedback_vector->ICSlots());
+ CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(0)) == Code::LOAD_IC);
+ CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(1)) == Code::LOAD_IC);
+ CHECK(feedback_vector->GetKind(FeedbackVectorICSlot(2)) == Code::LOAD_IC);
+}
}
« no previous file with comments | « src/type-info.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698