Index: test/cctest/test-heap.cc |
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc |
index ee476db6cdc4729b1a65a560fe03734a65f2bfdb..969fd8824d2b20ed76bac324a4a91d8535af9b21 100644 |
--- a/test/cctest/test-heap.cc |
+++ b/test/cctest/test-heap.cc |
@@ -2183,6 +2183,48 @@ TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) { |
} |
+TEST(IdleNotificationFinishMarking) { |
+ i::FLAG_allow_natives_syntax = true; |
+ CcTest::InitializeVM(); |
+ SimulateFullSpace(CcTest::heap()->old_pointer_space()); |
+ IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
+ marking->Abort(); |
+ marking->Start(); |
+ |
+ CHECK_EQ(CcTest::heap()->gc_count(), 0); |
+ |
+ // TODO(hpayer): We cannot write proper unit test right now for heap. |
+ // The ideal test would call kMaxIdleMarkingDelayCounter to test the |
+ // marking delay counter. |
+ |
+ // Perform a huge incremental marking step but don't complete marking. |
+ intptr_t bytes_processed = 0; |
+ do { |
+ bytes_processed = |
+ marking->Step(1 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
+ IncrementalMarking::FORCE_MARKING, |
+ IncrementalMarking::DO_NOT_FORCE_COMPLETION); |
+ CHECK(!marking->IsIdleMarkingDelayCounterLimitReached()); |
+ } while (bytes_processed); |
+ |
+ // The next invocations of incremental marking are not going to complete |
+ // marking |
+ // since the completion threshold is not reached |
+ for (size_t i = 0; i < IncrementalMarking::kMaxIdleMarkingDelayCounter - 2; |
+ i++) { |
+ marking->Step(1 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
+ IncrementalMarking::FORCE_MARKING, |
+ IncrementalMarking::DO_NOT_FORCE_COMPLETION); |
+ CHECK(!marking->IsIdleMarkingDelayCounterLimitReached()); |
+ } |
+ |
+ // The next idle notification has to finish incremental marking. |
+ const int kShortIdleTimeInMs = 1; |
+ CcTest::isolate()->IdleNotification(kShortIdleTimeInMs); |
+ CHECK_EQ(CcTest::heap()->gc_count(), 1); |
+} |
+ |
+ |
// Test that HAllocateObject will always return an object in new-space. |
TEST(OptimizedAllocationAlwaysInNewSpace) { |
i::FLAG_allow_natives_syntax = true; |