| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <limits> | 5 #include <limits> |
| 6 | 6 |
| 7 #include "src/heap/gc-idle-time-handler.h" | 7 #include "src/heap/gc-idle-time-handler.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 EXPECT_EQ(DONE, action.type); | 185 EXPECT_EQ(DONE, action.type); |
| 186 } | 186 } |
| 187 | 187 |
| 188 | 188 |
| 189 TEST_F(GCIdleTimeHandlerTest, StopEventually2) { | 189 TEST_F(GCIdleTimeHandlerTest, StopEventually2) { |
| 190 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 190 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
| 191 int idle_time_ms = 10; | 191 int idle_time_ms = 10; |
| 192 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { | 192 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { |
| 193 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 193 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
| 194 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); | 194 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); |
| 195 // In this case we emulate incremental marking steps that finish with a |
| 196 // full gc. |
| 195 handler()->NotifyIdleMarkCompact(); | 197 handler()->NotifyIdleMarkCompact(); |
| 196 } | 198 } |
| 199 heap_state.can_start_incremental_marking = false; |
| 197 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 200 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
| 198 EXPECT_EQ(DONE, action.type); | 201 EXPECT_EQ(DONE, action.type); |
| 199 } | 202 } |
| 200 | 203 |
| 201 | 204 |
| 202 TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop1) { | 205 TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop1) { |
| 203 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 206 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
| 204 heap_state.incremental_marking_stopped = true; | 207 heap_state.incremental_marking_stopped = true; |
| 205 heap_state.can_start_incremental_marking = false; | 208 heap_state.can_start_incremental_marking = false; |
| 206 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; | 209 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 221 } | 224 } |
| 222 | 225 |
| 223 | 226 |
| 224 TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop2) { | 227 TEST_F(GCIdleTimeHandlerTest, ContinueAfterStop2) { |
| 225 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 228 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
| 226 int idle_time_ms = 10; | 229 int idle_time_ms = 10; |
| 227 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { | 230 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { |
| 228 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 231 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
| 229 if (action.type == DONE) break; | 232 if (action.type == DONE) break; |
| 230 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); | 233 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); |
| 234 // In this case we try to emulate incremental marking steps the finish with |
| 235 // a full gc. |
| 231 handler()->NotifyIdleMarkCompact(); | 236 handler()->NotifyIdleMarkCompact(); |
| 232 } | 237 } |
| 238 heap_state.can_start_incremental_marking = false; |
| 233 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 239 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
| 234 EXPECT_EQ(DONE, action.type); | 240 EXPECT_EQ(DONE, action.type); |
| 235 // Emulate mutator work. | 241 // Emulate mutator work. |
| 236 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { | 242 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { |
| 237 handler()->NotifyScavenge(); | 243 handler()->NotifyScavenge(); |
| 238 } | 244 } |
| 245 heap_state.can_start_incremental_marking = true; |
| 239 action = handler()->Compute(idle_time_ms, heap_state); | 246 action = handler()->Compute(idle_time_ms, heap_state); |
| 240 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); | 247 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); |
| 241 } | 248 } |
| 242 | 249 |
| 243 } // namespace internal | 250 } // namespace internal |
| 244 } // namespace v8 | 251 } // namespace v8 |
| OLD | NEW |