Index: test/unittests/heap/gc-idle-time-handler-unittest.cc |
diff --git a/test/unittests/heap/gc-idle-time-handler-unittest.cc b/test/unittests/heap/gc-idle-time-handler-unittest.cc |
index 66b022c36020519be27d9a8993bf521b3da86fb6..868262bcb38152d4bdffbf84f83dbe820ce2a926 100644 |
--- a/test/unittests/heap/gc-idle-time-handler-unittest.cc |
+++ b/test/unittests/heap/gc-idle-time-handler-unittest.cc |
@@ -465,5 +465,56 @@ TEST_F(GCIdleTimeHandlerTest, ZeroIdleTimeDoNothingButStartIdleRound) { |
EXPECT_EQ(DO_NOTHING, action.type); |
} |
+ |
+TEST_F(GCIdleTimeHandlerTest, KeepDoingDoNothingWithZeroIdleTime) { |
+ GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
+ for (int i = 0; i < GCIdleTimeHandler::kMaxNoProgressIdleTimesPerIdleRound; |
+ i++) { |
+ GCIdleTimeAction action = handler()->Compute(0, heap_state); |
+ EXPECT_EQ(DO_NOTHING, action.type); |
+ } |
+ // Should still return DO_NOTHING if we have been given 0 deadline yet. |
+ GCIdleTimeAction action = handler()->Compute(0, heap_state); |
+ EXPECT_EQ(DO_NOTHING, action.type); |
+} |
+ |
+ |
+TEST_F(GCIdleTimeHandlerTest, DoneIfNotMakingProgressOnSweeping) { |
+ GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
+ |
+ // Simulate sweeping being in-progress but not complete. |
+ heap_state.incremental_marking_stopped = true; |
+ heap_state.can_start_incremental_marking = false; |
+ heap_state.sweeping_in_progress = true; |
+ heap_state.sweeping_completed = false; |
+ double idle_time_ms = 10.0; |
+ for (int i = 0; i < GCIdleTimeHandler::kMaxNoProgressIdleTimesPerIdleRound; |
+ i++) { |
+ GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
+ EXPECT_EQ(DO_NOTHING, action.type); |
+ } |
+ // We should return DONE after not making progress for some time. |
+ GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
+ EXPECT_EQ(DONE, action.type); |
+} |
+ |
+ |
+TEST_F(GCIdleTimeHandlerTest, DoneIfNotMakingProgressOnIncrementalMarking) { |
+ GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
+ |
+ // Simulate incremental marking stopped and not eligible to start. |
+ heap_state.incremental_marking_stopped = true; |
+ heap_state.can_start_incremental_marking = false; |
+ double idle_time_ms = 10.0; |
+ for (int i = 0; i < GCIdleTimeHandler::kMaxNoProgressIdleTimesPerIdleRound; |
+ i++) { |
+ GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
+ EXPECT_EQ(DO_NOTHING, action.type); |
+ } |
+ // We should return DONE after not making progress for some time. |
+ GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
+ EXPECT_EQ(DONE, action.type); |
+} |
+ |
} // namespace internal |
} // namespace v8 |