Index: test/cctest/test-heap.cc |
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc |
index e3ce37d4acbb2f98f5567750258f4b514a3747c4..17932d1847f4b85ed63520931c7cc45e6e1ccd1f 100644 |
--- a/test/cctest/test-heap.cc |
+++ b/test/cctest/test-heap.cc |
@@ -1029,6 +1029,7 @@ TEST(TestCodeFlushing) { |
// If we do not flush code this test is invalid. |
if (!FLAG_flush_code) return; |
i::FLAG_allow_natives_syntax = true; |
+ i::FLAG_optimize_for_size = false; |
CcTest::InitializeVM(); |
Isolate* isolate = Isolate::Current(); |
Factory* factory = isolate->factory(); |
@@ -1074,10 +1075,76 @@ TEST(TestCodeFlushing) { |
} |
+TEST(TestCodeFlushingPreAged) { |
+ // If we do not flush code this test is invalid. |
+ if (!FLAG_flush_code) return; |
+ i::FLAG_allow_natives_syntax = true; |
+ i::FLAG_optimize_for_size = true; |
+ CcTest::InitializeVM(); |
+ Isolate* isolate = Isolate::Current(); |
+ Factory* factory = isolate->factory(); |
+ v8::HandleScope scope(CcTest::isolate()); |
+ const char* source = "function foo() {" |
+ " var x = 42;" |
+ " var y = 42;" |
+ " var z = x + y;" |
+ "};" |
+ "foo()"; |
+ Handle<String> foo_name = factory->InternalizeUtf8String("foo"); |
+ |
+ // Compile foo, but don't run it. |
+ { v8::HandleScope scope(CcTest::isolate()); |
+ CompileRun(source); |
+ } |
rmcilroy
2013/09/23 12:58:34
I would like to test the immediate GCing of code t
|
+ |
+ // Check function is compiled. |
+ Object* func_value = Isolate::Current()->context()->global_object()-> |
+ GetProperty(*foo_name)->ToObjectChecked(); |
+ CHECK(func_value->IsJSFunction()); |
+ Handle<JSFunction> function(JSFunction::cast(func_value)); |
+ CHECK(function->shared()->is_compiled()); |
+ |
+ // The code has been run so will survive at least one GC. |
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
+ CHECK(function->shared()->is_compiled()); |
+ |
+ // The code was only run once, so it should be pre-aged and collected on the |
+ // next GC. |
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
+ CHECK(!function->shared()->is_compiled()); |
+ |
+ // Execute the function again twice, and ensure it is reset to the young age. |
+ { v8::HandleScope scope(CcTest::isolate()); |
+ CompileRun("foo();" |
+ "foo();"); |
+ } |
+ |
+ // The code will survive at least two GC now that it is young again. |
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
+ CHECK(function->shared()->is_compiled()); |
+ |
+ // Simulate several GCs that use full marking. |
+ const int kAgingThreshold = 6; |
+ for (int i = 0; i < kAgingThreshold; i++) { |
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
+ } |
+ |
+ // foo should no longer be in the compilation cache |
+ CHECK(!function->shared()->is_compiled() || function->IsOptimized()); |
+ CHECK(!function->is_compiled() || function->IsOptimized()); |
+ // Call foo to get it recompiled. |
+ CompileRun("foo()"); |
+ CHECK(function->shared()->is_compiled()); |
+ CHECK(function->is_compiled()); |
+} |
+ |
+ |
TEST(TestCodeFlushingIncremental) { |
// If we do not flush code this test is invalid. |
if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; |
i::FLAG_allow_natives_syntax = true; |
+ i::FLAG_optimize_for_size = false; |
CcTest::InitializeVM(); |
Isolate* isolate = Isolate::Current(); |
Factory* factory = isolate->factory(); |
@@ -1146,6 +1213,7 @@ TEST(TestCodeFlushingIncrementalScavenge) { |
// If we do not flush code this test is invalid. |
if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; |
i::FLAG_allow_natives_syntax = true; |
+ i::FLAG_optimize_for_size = false; |
CcTest::InitializeVM(); |
Isolate* isolate = Isolate::Current(); |
Factory* factory = isolate->factory(); |
@@ -1214,6 +1282,7 @@ TEST(TestCodeFlushingIncrementalAbort) { |
// If we do not flush code this test is invalid. |
if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; |
i::FLAG_allow_natives_syntax = true; |
+ i::FLAG_optimize_for_size = false; |
CcTest::InitializeVM(); |
Isolate* isolate = Isolate::Current(); |
Factory* factory = isolate->factory(); |