long_idle_notifications_(0),
background_idle_notifications_(0),
idle_times_which_made_no_progress_per_mode_(0),
+ next_gc_likely_to_collect_more_(false),
mode_(kReduceLatency) {}
GCIdleTimeAction Compute(double idle_time_in_ms, HeapState heap_state);
void NotifyIdleMarkCompact() { ++idle_mark_compacts_; }
- void NotifyMarkCompact() { ++mark_compacts_; }
+ void NotifyMarkCompact(bool next_gc_likely_to_collect_more) {
+ next_gc_likely_to_collect_more_ = next_gc_likely_to_collect_more;
+ ++mark_compacts_;
+ }
void NotifyScavenge() { ++scavenges_; }
// Idle notifications with no progress in the current mode.
int idle_times_which_made_no_progress_per_mode_;
+ bool next_gc_likely_to_collect_more_;
+
Mode mode_;
DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler);
GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
EXPECT_EQ(expected, action.type);
EXPECT_TRUE(action.reduce_memory);
- handler()->NotifyMarkCompact();
+ handler()->NotifyMarkCompact(true);
handler()->NotifyIdleMarkCompact();
}
handler()->Compute(idle_time_ms, heap_state);
for (int i = 0; i < limit; i++) {
GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
EXPECT_EQ(DONE, action.type);
- handler()->NotifyMarkCompact();
+ handler()->NotifyMarkCompact(true);
}
handler()->Compute(idle_time_ms, heap_state);
EXPECT_EQ(GCIdleTimeHandler::kReduceLatency, handler()->mode());
for (int i = 0; i < kMaxNotifications && !stopped; i++) {
GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
if (action.type == DO_INCREMENTAL_MARKING || action.type == DO_FULL_GC) {
- handler()->NotifyMarkCompact();
+ handler()->NotifyMarkCompact(true);
handler()->NotifyIdleMarkCompact();
}
if (action.type == DONE) stopped = true;
for (int i = 0; i < kMaxNotifications; i++) {
GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
EXPECT_TRUE(DO_NOTHING == action.type || DONE == action.type);
- if ((i + 1) % limit == 0) handler()->NotifyMarkCompact();
+ if ((i + 1) % limit == 0) handler()->NotifyMarkCompact(true);
EXPECT_EQ(GCIdleTimeHandler::kReduceLatency, handler()->mode());
}
}
// ReduceMemory mode should tolerate one mutator GC per idle GC.
handler()->NotifyScavenge();
// Notify idle GC.
- handler()->NotifyMarkCompact();
+ handler()->NotifyMarkCompact(true);
handler()->NotifyIdleMarkCompact();
}
// Transition to ReduceLatency mode after doing |idle_gc| idle GCs.
// ReduceMemory mode should tolerate one mutator GC per idle GC.
handler()->NotifyScavenge();
// Notify idle GC.
- handler()->NotifyMarkCompact();
+ handler()->NotifyMarkCompact(true);
handler()->NotifyIdleMarkCompact();
}
action = handler()->Compute(idle_time_ms, heap_state);
EXPECT_EQ(GCIdleTimeHandler::kReduceMemory, handler()->mode());
}
+
+TEST_F(GCIdleTimeHandlerTest, SkipUselessGCs) {
+ GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
+ heap_state.incremental_marking_stopped = false;
+ heap_state.can_start_incremental_marking = true;
+ TransitionToReduceMemoryMode(heap_state);
+ EXPECT_EQ(GCIdleTimeHandler::kReduceMemory, handler()->mode());
+ double idle_time_ms = GCIdleTimeHandler::kMinLongIdleTime;
+ GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
+ EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type);
+ handler()->NotifyMarkCompact(false);
+ handler()->NotifyIdleMarkCompact();
+ action = handler()->Compute(idle_time_ms, heap_state);
+ EXPECT_EQ(DONE, action.type);
+}
+
} // namespace internal
} // namespace v8