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

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

Issue 410153002: Make --always-opt also optimize toplevel code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Jacob Bramley. Created 6 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 | « test/cctest/test-decls.cc ('k') | test/cctest/test-parsing.cc » ('j') | 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 22335071389bec3993d9a6ac57fd47282612d2fa..3ca9dc471085c2f76eb829cbc248981336e6a809 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -1380,16 +1380,21 @@ static int CountOptimizedUserFunctions(v8::Handle<v8::Context> context) {
TEST(TestInternalWeakLists) {
+ FLAG_allow_natives_syntax = true;
v8::V8::Initialize();
+ Isolate* isolate = CcTest::i_isolate();
+
+ // TODO(mstarzinger): Test should be resilient against optimization decisions.
+ if (i::FLAG_always_opt) return;
+ if (!isolate->use_crankshaft()) return;
// Some flags turn Scavenge collections into Mark-sweep collections
// and hence are incompatible with this test case.
if (FLAG_gc_global || FLAG_stress_compaction) return;
- static const int kNumTestContexts = 10;
+ static const int kNumTestContexts = 5;
+ static const int kNumTestCollections = 3;
- Isolate* isolate = CcTest::i_isolate();
- Heap* heap = isolate->heap();
HandleScope scope(isolate);
v8::Handle<v8::Context> ctx[kNumTestContexts];
@@ -1402,9 +1407,7 @@ TEST(TestInternalWeakLists) {
// Collect garbage that might have been created by one of the
// installed extensions.
isolate->compilation_cache()->Clear();
- heap->CollectAllGarbage(Heap::kNoGCFlags);
-
- bool opt = (FLAG_always_opt && isolate->use_crankshaft());
+ CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
CHECK_EQ(i + 1, CountNativeContexts());
@@ -1420,46 +1423,46 @@ TEST(TestInternalWeakLists) {
"function f5() { };";
CompileRun(source);
CHECK_EQ(0, CountOptimizedUserFunctions(ctx[i]));
- CompileRun("f1()");
- CHECK_EQ(opt ? 1 : 0, CountOptimizedUserFunctions(ctx[i]));
- CompileRun("f2()");
- CHECK_EQ(opt ? 2 : 0, CountOptimizedUserFunctions(ctx[i]));
- CompileRun("f3()");
- CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[i]));
- CompileRun("f4()");
- CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i]));
- CompileRun("f5()");
- CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[i]));
+ CompileRun("f1(); %OptimizeFunctionOnNextCall(f1); f1()");
+ CHECK_EQ(1, CountOptimizedUserFunctions(ctx[i]));
+ CompileRun("f2(); %OptimizeFunctionOnNextCall(f2); f2()");
+ CHECK_EQ(2, CountOptimizedUserFunctions(ctx[i]));
+ CompileRun("f3(); %OptimizeFunctionOnNextCall(f3); f3()");
+ CHECK_EQ(3, CountOptimizedUserFunctions(ctx[i]));
+ CompileRun("f4(); %OptimizeFunctionOnNextCall(f4); f4()");
+ CHECK_EQ(4, CountOptimizedUserFunctions(ctx[i]));
+ CompileRun("f5(); %OptimizeFunctionOnNextCall(f5); f5()");
+ CHECK_EQ(5, CountOptimizedUserFunctions(ctx[i]));
// Remove function f1, and
CompileRun("f1=null");
// Scavenge treats these references as strong.
- for (int j = 0; j < 10; j++) {
+ for (int j = 0; j < kNumTestCollections; j++) {
CcTest::heap()->CollectGarbage(NEW_SPACE);
- CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[i]));
+ CHECK_EQ(5, CountOptimizedUserFunctions(ctx[i]));
}
// Mark compact handles the weak references.
isolate->compilation_cache()->Clear();
- heap->CollectAllGarbage(Heap::kNoGCFlags);
- CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i]));
+ CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
+ CHECK_EQ(4, CountOptimizedUserFunctions(ctx[i]));
// Get rid of f3 and f5 in the same way.
CompileRun("f3=null");
- for (int j = 0; j < 10; j++) {
+ for (int j = 0; j < kNumTestCollections; j++) {
CcTest::heap()->CollectGarbage(NEW_SPACE);
- CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i]));
+ CHECK_EQ(4, CountOptimizedUserFunctions(ctx[i]));
}
CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
- CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[i]));
+ CHECK_EQ(3, CountOptimizedUserFunctions(ctx[i]));
CompileRun("f5=null");
- for (int j = 0; j < 10; j++) {
+ for (int j = 0; j < kNumTestCollections; j++) {
CcTest::heap()->CollectGarbage(NEW_SPACE);
- CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[i]));
+ CHECK_EQ(3, CountOptimizedUserFunctions(ctx[i]));
}
CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
- CHECK_EQ(opt ? 2 : 0, CountOptimizedUserFunctions(ctx[i]));
+ CHECK_EQ(2, CountOptimizedUserFunctions(ctx[i]));
ctx[i]->Exit();
}
@@ -1476,7 +1479,7 @@ TEST(TestInternalWeakLists) {
ctx[i].Clear();
// Scavenge treats these references as strong.
- for (int j = 0; j < 10; j++) {
+ for (int j = 0; j < kNumTestCollections; j++) {
CcTest::heap()->CollectGarbage(i::NEW_SPACE);
CHECK_EQ(kNumTestContexts - i, CountNativeContexts());
}
@@ -1530,10 +1533,15 @@ static int CountOptimizedUserFunctionsWithGC(v8::Handle<v8::Context> context,
TEST(TestInternalWeakListsTraverseWithGC) {
+ FLAG_allow_natives_syntax = true;
v8::V8::Initialize();
Isolate* isolate = CcTest::i_isolate();
- static const int kNumTestContexts = 10;
+ // TODO(mstarzinger): Test should be resilient against optimization decisions.
+ if (i::FLAG_always_opt) return;
+ if (!isolate->use_crankshaft()) return;
+
+ static const int kNumTestContexts = 5;
HandleScope scope(isolate);
v8::Handle<v8::Context> ctx[kNumTestContexts];
@@ -1548,8 +1556,6 @@ TEST(TestInternalWeakListsTraverseWithGC) {
CHECK_EQ(i + 1, CountNativeContextsWithGC(isolate, i / 2 + 1));
}
- bool opt = (FLAG_always_opt && isolate->use_crankshaft());
-
// Compile a number of functions the length of the weak list of optimized
// functions both with and without GCs while iterating the list.
ctx[0]->Enter();
@@ -1560,21 +1566,21 @@ TEST(TestInternalWeakListsTraverseWithGC) {
"function f5() { };";
CompileRun(source);
CHECK_EQ(0, CountOptimizedUserFunctions(ctx[0]));
- CompileRun("f1()");
- CHECK_EQ(opt ? 1 : 0, CountOptimizedUserFunctions(ctx[0]));
- CHECK_EQ(opt ? 1 : 0, CountOptimizedUserFunctionsWithGC(ctx[0], 1));
- CompileRun("f2()");
- CHECK_EQ(opt ? 2 : 0, CountOptimizedUserFunctions(ctx[0]));
- CHECK_EQ(opt ? 2 : 0, CountOptimizedUserFunctionsWithGC(ctx[0], 1));
- CompileRun("f3()");
- CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[0]));
- CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctionsWithGC(ctx[0], 1));
- CompileRun("f4()");
- CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[0]));
- CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctionsWithGC(ctx[0], 2));
- CompileRun("f5()");
- CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[0]));
- CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctionsWithGC(ctx[0], 4));
+ CompileRun("f1(); %OptimizeFunctionOnNextCall(f1); f1()");
+ CHECK_EQ(1, CountOptimizedUserFunctions(ctx[0]));
+ CHECK_EQ(1, CountOptimizedUserFunctionsWithGC(ctx[0], 1));
+ CompileRun("f2(); %OptimizeFunctionOnNextCall(f2); f2()");
+ CHECK_EQ(2, CountOptimizedUserFunctions(ctx[0]));
+ CHECK_EQ(2, CountOptimizedUserFunctionsWithGC(ctx[0], 1));
+ CompileRun("f3(); %OptimizeFunctionOnNextCall(f3); f3()");
+ CHECK_EQ(3, CountOptimizedUserFunctions(ctx[0]));
+ CHECK_EQ(3, CountOptimizedUserFunctionsWithGC(ctx[0], 1));
+ CompileRun("f4(); %OptimizeFunctionOnNextCall(f4); f4()");
+ CHECK_EQ(4, CountOptimizedUserFunctions(ctx[0]));
+ CHECK_EQ(4, CountOptimizedUserFunctionsWithGC(ctx[0], 2));
+ CompileRun("f5(); %OptimizeFunctionOnNextCall(f5); f5()");
+ CHECK_EQ(5, CountOptimizedUserFunctions(ctx[0]));
+ CHECK_EQ(5, CountOptimizedUserFunctionsWithGC(ctx[0], 4));
ctx[0]->Exit();
}
@@ -4036,7 +4042,10 @@ TEST(NextCodeLinkIsWeak) {
Isolate* isolate = CcTest::i_isolate();
v8::internal::Heap* heap = CcTest::heap();
+ // TODO(titzer): Test should be resilient against optimization decisions.
+ if (i::FLAG_always_opt) return;
if (!isolate->use_crankshaft()) return;
+
HandleScope outer_scope(heap->isolate());
Handle<Code> code;
heap->CollectAllAvailableGarbage();
« no previous file with comments | « test/cctest/test-decls.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698