| Index: test/cctest/test-heap.cc
|
| ===================================================================
|
| --- test/cctest/test-heap.cc (revision 12520)
|
| +++ test/cctest/test-heap.cc (working copy)
|
| @@ -1941,6 +1941,57 @@
|
| }
|
|
|
|
|
| +// Tests the FlushEagerly class from heap.h
|
| +TEST(ReleaseUnoptimizedCode) {
|
| + i::FLAG_trace_gc = true;
|
| + // The optimizer can allocate stuff, messing up the test.
|
| + i::FLAG_crankshaft = false;
|
| + if (i::FLAG_always_opt) return;
|
| + InitializeVM();
|
| + v8::HandleScope scope;
|
| +
|
| + PagedSpace* code_space = HEAP->code_space();
|
| + CompileRun("var a = [];"
|
| + "var sum = 0;"
|
| + "for (var j = 0; j < 1e4; j++) {"
|
| + " var fn = new Function("
|
| + " 'var k; var o = {}; for (k in o) { } return ' + j + ';');"
|
| + " sum += fn();"
|
| + "}");
|
| + HEAP->CollectAllGarbage(Heap::kNoGCFlags, "triggered for preparation");
|
| + printf("%d\n", code_space->CountTotalPages());
|
| + CHECK_GE(5, code_space->CountTotalPages());
|
| + HEAP->CollectAllAvailableGarbage("triggered really hard");
|
| + printf("%d\n", code_space->CountTotalPages());
|
| + CHECK_LE(2, code_space->CountTotalPages());
|
| +}
|
| +
|
| +
|
| +// Tests the FlushEagerly class from heap.h
|
| +TEST(ReleaseRegexpCode) {
|
| + i::FLAG_trace_gc = true;
|
| + // The optimizer can allocate stuff, messing up the test.
|
| + i::FLAG_crankshaft = false;
|
| + if (i::FLAG_always_opt) return;
|
| + InitializeVM();
|
| + v8::HandleScope scope;
|
| +
|
| + PagedSpace* code_space = HEAP->code_space();
|
| + CompileRun("var a = [];"
|
| + "for (var j = 0; j < 2e4; j++) {"
|
| + " var re = RegExp(j + '?');"
|
| + " a.push(re);"
|
| + " re.test('foo');"
|
| + "}");
|
| + HEAP->CollectAllGarbage(Heap::kNoGCFlags, "triggered for preparation");
|
| + printf("%d\n", code_space->CountTotalPages());
|
| + CHECK_GT(15, code_space->CountTotalPages());
|
| + HEAP->CollectAllAvailableGarbage("triggered really hard");
|
| + printf("%d\n", code_space->CountTotalPages());
|
| + CHECK_LE(2, code_space->CountTotalPages());
|
| +}
|
| +
|
| +
|
| TEST(Regress2237) {
|
| InitializeVM();
|
| v8::HandleScope scope;
|
|
|