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) { ...@@ -182,7 +182,7 @@ TEST_F(GCIdleTimeHandlerTest, StopEventually1) {
handler()->NotifyIdleMarkCompact(); handler()->NotifyIdleMarkCompact();
} }
GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); 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) { ...@@ -195,7 +195,7 @@ TEST_F(GCIdleTimeHandlerTest, StopEventually2) {
handler()->NotifyIdleMarkCompact(); handler()->NotifyIdleMarkCompact();
} }
GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); 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) { ...@@ -211,7 +211,7 @@ TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop1) {
handler()->NotifyIdleMarkCompact(); handler()->NotifyIdleMarkCompact();
} }
GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
EXPECT_EQ(DO_NOTHING, action.type); EXPECT_EQ(DONE, action.type);
// Emulate mutator work. // Emulate mutator work.
for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) {
handler()->NotifyScavenge(); handler()->NotifyScavenge();
...@@ -226,12 +226,12 @@ TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop2) { ...@@ -226,12 +226,12 @@ TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop2) {
int idle_time_ms = 10; int idle_time_ms = 10;
for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) {
GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); 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); EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type);
handler()->NotifyIdleMarkCompact(); handler()->NotifyIdleMarkCompact();
} }
GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
EXPECT_EQ(DO_NOTHING, action.type); EXPECT_EQ(DONE, action.type);
// Emulate mutator work. // Emulate mutator work.
for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) {
handler()->NotifyScavenge(); handler()->NotifyScavenge();
......
...@@ -18,6 +18,9 @@ const int GCIdleTimeHandler::kIdleScavengeThreshold = 5; ...@@ -18,6 +18,9 @@ const int GCIdleTimeHandler::kIdleScavengeThreshold = 5;
void GCIdleTimeAction::Print() { void GCIdleTimeAction::Print() {
switch (type) { switch (type) {
case DONE:
PrintF("done");
break;
case DO_NOTHING: case DO_NOTHING:
PrintF("no action"); PrintF("no action");
break; break;
...@@ -74,7 +77,7 @@ GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms, ...@@ -74,7 +77,7 @@ GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms,
if (EnoughGarbageSinceLastIdleRound() || heap_state.contexts_disposed > 0) { if (EnoughGarbageSinceLastIdleRound() || heap_state.contexts_disposed > 0) {
StartIdleRound(); StartIdleRound();
} else { } else {
return GCIdleTimeAction::Nothing(); return GCIdleTimeAction::Done();
} }
} }
if (heap_state.incremental_marking_stopped) { if (heap_state.incremental_marking_stopped) {
......
...@@ -11,6 +11,7 @@ namespace v8 { ...@@ -11,6 +11,7 @@ namespace v8 {
namespace internal { namespace internal {
enum GCIdleTimeActionType { enum GCIdleTimeActionType {
DONE,
DO_NOTHING, DO_NOTHING,
DO_INCREMENTAL_MARKING, DO_INCREMENTAL_MARKING,
DO_SCAVENGE, DO_SCAVENGE,
...@@ -21,6 +22,13 @@ enum GCIdleTimeActionType { ...@@ -21,6 +22,13 @@ enum GCIdleTimeActionType {
class GCIdleTimeAction { class GCIdleTimeAction {
public: public:
static GCIdleTimeAction Done() {
GCIdleTimeAction result;
result.type = DONE;
result.parameter = 0;
return result;
}
static GCIdleTimeAction Nothing() { static GCIdleTimeAction Nothing() {
GCIdleTimeAction result; GCIdleTimeAction result;
result.type = DO_NOTHING; result.type = DO_NOTHING;
......
...@@ -4318,6 +4318,9 @@ bool Heap::IdleNotification(int idle_time_in_ms) { ...@@ -4318,6 +4318,9 @@ bool Heap::IdleNotification(int idle_time_in_ms) {
bool result = false; bool result = false;
switch (action.type) { switch (action.type) {
case DONE:
result = true;
break;
case DO_INCREMENTAL_MARKING: case DO_INCREMENTAL_MARKING:
if (incremental_marking()->IsStopped()) { if (incremental_marking()->IsStopped()) {
incremental_marking()->Start(); incremental_marking()->Start();
...@@ -4340,7 +4343,6 @@ bool Heap::IdleNotification(int idle_time_in_ms) { ...@@ -4340,7 +4343,6 @@ bool Heap::IdleNotification(int idle_time_in_ms) {
mark_compact_collector()->EnsureSweepingCompleted(); mark_compact_collector()->EnsureSweepingCompleted();
break; break;
case DO_NOTHING: case DO_NOTHING:
result = true;
break; break;
} }
if (FLAG_trace_idle_notification) { 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