| 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 heap_state.incremental_marking_stopped = true; | 321 heap_state.incremental_marking_stopped = true; |
| 322 heap_state.can_start_incremental_marking = false; | 322 heap_state.can_start_incremental_marking = false; |
| 323 heap_state.sweeping_in_progress = true; | 323 heap_state.sweeping_in_progress = true; |
| 324 heap_state.sweeping_completed = false; | 324 heap_state.sweeping_completed = false; |
| 325 double idle_time_ms = 10.0; | 325 double idle_time_ms = 10.0; |
| 326 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 326 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
| 327 EXPECT_EQ(DO_NOTHING, action.type); | 327 EXPECT_EQ(DO_NOTHING, action.type); |
| 328 } | 328 } |
| 329 | 329 |
| 330 | 330 |
| 331 TEST_F(GCIdleTimeHandlerTest, NoIncrementalMarkingWhileSweeping) { |
| 332 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
| 333 heap_state.incremental_marking_stopped = false; |
| 334 heap_state.can_start_incremental_marking = false; |
| 335 heap_state.sweeping_in_progress = true; |
| 336 heap_state.sweeping_completed = false; |
| 337 double idle_time_ms = 10.0; |
| 338 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
| 339 EXPECT_EQ(DO_NOTHING, action.type); |
| 340 } |
| 341 |
| 342 |
| 331 TEST_F(GCIdleTimeHandlerTest, StopEventually1) { | 343 TEST_F(GCIdleTimeHandlerTest, StopEventually1) { |
| 332 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 344 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
| 333 heap_state.incremental_marking_stopped = true; | 345 heap_state.incremental_marking_stopped = true; |
| 334 heap_state.can_start_incremental_marking = false; | 346 heap_state.can_start_incremental_marking = false; |
| 335 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; | 347 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; |
| 336 double idle_time_ms = | 348 double idle_time_ms = |
| 337 static_cast<double>(heap_state.size_of_objects / speed + 1); | 349 static_cast<double>(heap_state.size_of_objects / speed + 1); |
| 338 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { | 350 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { |
| 339 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 351 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
| 340 EXPECT_EQ(DO_FULL_GC, action.type); | 352 EXPECT_EQ(DO_FULL_GC, action.type); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 // Emulate mutator work. | 472 // Emulate mutator work. |
| 461 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { | 473 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { |
| 462 handler()->NotifyScavenge(); | 474 handler()->NotifyScavenge(); |
| 463 } | 475 } |
| 464 action = handler()->Compute(0, heap_state); | 476 action = handler()->Compute(0, heap_state); |
| 465 EXPECT_EQ(DO_NOTHING, action.type); | 477 EXPECT_EQ(DO_NOTHING, action.type); |
| 466 } | 478 } |
| 467 | 479 |
| 468 } // namespace internal | 480 } // namespace internal |
| 469 } // namespace v8 | 481 } // namespace v8 |
| OLD | NEW |