Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: test/unittests/heap/memory-reducer-unittest.cc

Issue 1213313004: Start incremental marking in long idle notification for background tab (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/memory-reducer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/heap/memory-reducer-unittest.cc
diff --git a/test/unittests/heap/memory-reducer-unittest.cc b/test/unittests/heap/memory-reducer-unittest.cc
index 7f6785d5093ea8e85a6d8f48f3c45de40653e756..6a2bf2a87f327a2317160fa82c398e452f1b9d6d 100644
--- a/test/unittests/heap/memory-reducer-unittest.cc
+++ b/test/unittests/heap/memory-reducer-unittest.cc
@@ -82,6 +82,16 @@ MemoryReducer::Event ContextDisposedEvent(double time_ms) {
}
+MemoryReducer::Event BackgroundIdleNotificationEvent(
+ double time_ms, bool can_start_incremental_gc = true) {
+ MemoryReducer::Event event;
+ event.type = MemoryReducer::kBackgroundIdleNotification;
+ event.time_ms = time_ms;
+ event.can_start_incremental_gc = can_start_incremental_gc;
+ return event;
+}
+
+
TEST(MemoryReducer, FromDoneToDone) {
MemoryReducer::State state0(DoneState()), state1(DoneState());
@@ -93,6 +103,9 @@ TEST(MemoryReducer, FromDoneToDone) {
state1 = MemoryReducer::Step(state0, TimerEventPendingGC(0));
EXPECT_EQ(MemoryReducer::kDone, state1.action);
+
+ state1 = MemoryReducer::Step(state0, BackgroundIdleNotificationEvent(0));
+ EXPECT_EQ(MemoryReducer::kDone, state1.action);
}
@@ -153,6 +166,23 @@ TEST(MemoryReducer, FromWaitToWait) {
EXPECT_EQ(MemoryReducer::kWait, state1.action);
EXPECT_EQ(2000 + MemoryReducer::kLongDelayMs, state1.next_gc_start_ms);
EXPECT_EQ(state0.started_gcs, state1.started_gcs);
+
+ state1 = MemoryReducer::Step(state0, BackgroundIdleNotificationEvent(2000));
+ EXPECT_EQ(MemoryReducer::kWait, state1.action);
+ EXPECT_EQ(2000 + MemoryReducer::kLongDelayMs, state1.next_gc_start_ms);
+ EXPECT_EQ(state0.started_gcs + 1, state1.started_gcs);
+
+ state1 =
+ MemoryReducer::Step(state0, BackgroundIdleNotificationEvent(2000, false));
+ EXPECT_EQ(MemoryReducer::kWait, state1.action);
+ EXPECT_EQ(state0.next_gc_start_ms, state1.next_gc_start_ms);
+ EXPECT_EQ(state0.started_gcs, state1.started_gcs);
+
+ state0.started_gcs = MemoryReducer::kMaxNumberOfGCs;
+ state1 = MemoryReducer::Step(state0, BackgroundIdleNotificationEvent(2000));
+ EXPECT_EQ(MemoryReducer::kWait, state1.action);
+ EXPECT_EQ(state0.next_gc_start_ms, state1.next_gc_start_ms);
+ EXPECT_EQ(state0.started_gcs, state1.started_gcs);
}
@@ -169,6 +199,30 @@ TEST(MemoryReducer, FromWaitToRun) {
}
+TEST(MemoryReducer, FromWaitToDone) {
+ if (!FLAG_incremental_marking) return;
+
+ MemoryReducer::State state0(WaitState(2, 0.0)), state1(DoneState());
+
+ state0.started_gcs = MemoryReducer::kMaxNumberOfGCs;
+
+ state1 = MemoryReducer::Step(state0, TimerEventLowAllocationRate(2000));
+ EXPECT_EQ(MemoryReducer::kDone, state1.action);
+ EXPECT_EQ(0, state1.next_gc_start_ms);
+ EXPECT_EQ(0, state1.started_gcs);
+
+ state1 = MemoryReducer::Step(state0, TimerEventHighAllocationRate(2000));
+ EXPECT_EQ(MemoryReducer::kDone, state1.action);
+ EXPECT_EQ(0, state1.next_gc_start_ms);
+ EXPECT_EQ(0, state1.started_gcs);
+
+ state1 = MemoryReducer::Step(state0, TimerEventPendingGC(2000));
+ EXPECT_EQ(MemoryReducer::kDone, state1.action);
+ EXPECT_EQ(0, state1.next_gc_start_ms);
+ EXPECT_EQ(0, state1.started_gcs);
+}
+
+
TEST(MemoryReducer, FromRunToRun) {
if (!FLAG_incremental_marking) return;
« no previous file with comments | « src/heap/memory-reducer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698