Commit 4412cdde authored by hpayer@chromium.org's avatar hpayer@chromium.org

Introduce DONE state in idle notification handler.

BUG=
R=ulan@chromium.org

Review URL: https://codereview.chromium.org/577573002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23965 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 069a9c75
......@@ -182,7 +182,7 @@ TEST_F(GCIdleTimeHandlerTest, StopEventually1) {
handler()->NotifyIdleMarkCompact();
}
GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
EXPECT_EQ(DO_NOTHING, action.type);
EXPECT_EQ(DONE, action.type);
}
......@@ -195,7 +195,7 @@ TEST_F(GCIdleTimeHandlerTest, StopEventually2) {
handler()->NotifyIdleMarkCompact();
}
GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
EXPECT_EQ(DO_NOTHING, action.type);
EXPECT_EQ(DONE, action.type);
}
......@@ -211,7 +211,7 @@ TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop1) {
handler()->NotifyIdleMarkCompact();
}
GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
EXPECT_EQ(DO_NOTHING, action.type);
EXPECT_EQ(DONE, action.type);
// Emulate mutator work.
for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) {
handler()->NotifyScavenge();
......@@ -226,12 +226,12 @@ TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop2) {
int idle_time_ms = 10;
for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) {
GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
if (action.type == DO_NOTHING) break;
if (action.type == DONE) break;
EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type);
handler()->NotifyIdleMarkCompact();
}
GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
EXPECT_EQ(DO_NOTHING, action.type);
EXPECT_EQ(DONE, action.type);
// Emulate mutator work.
for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) {
handler()->NotifyScavenge();
......
......@@ -18,6 +18,9 @@ const int GCIdleTimeHandler::kIdleScavengeThreshold = 5;
void GCIdleTimeAction::Print() {
switch (type) {
case DONE:
PrintF("done");
break;
case DO_NOTHING:
PrintF("no action");
break;
......@@ -74,7 +77,7 @@ GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms,
if (EnoughGarbageSinceLastIdleRound() || heap_state.contexts_disposed > 0) {
StartIdleRound();
} else {
return GCIdleTimeAction::Nothing();
return GCIdleTimeAction::Done();
}
}
if (heap_state.incremental_marking_stopped) {
......
......@@ -11,6 +11,7 @@ namespace v8 {
namespace internal {
enum GCIdleTimeActionType {
DONE,
DO_NOTHING,
DO_INCREMENTAL_MARKING,
DO_SCAVENGE,
......@@ -21,6 +22,13 @@ enum GCIdleTimeActionType {
class GCIdleTimeAction {
public:
static GCIdleTimeAction Done() {
GCIdleTimeAction result;
result.type = DONE;
result.parameter = 0;
return result;
}
static GCIdleTimeAction Nothing() {
GCIdleTimeAction result;
result.type = DO_NOTHING;
......
......@@ -4318,6 +4318,9 @@ bool Heap::IdleNotification(int idle_time_in_ms) {
bool result = false;
switch (action.type) {
case DONE:
result = true;
break;
case DO_INCREMENTAL_MARKING:
if (incremental_marking()->IsStopped()) {
incremental_marking()->Start();
......@@ -4340,7 +4343,6 @@ bool Heap::IdleNotification(int idle_time_in_ms) {
mark_compact_collector()->EnsureSweepingCompleted();
break;
case DO_NOTHING:
result = true;
break;
}
if (FLAG_trace_idle_notification) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment