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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 for (int i = 0; i < GCIdleTimeHandler::kMaxNoProgressIdleTimesPerIdleRound; | 509 for (int i = 0; i < GCIdleTimeHandler::kMaxNoProgressIdleTimesPerIdleRound; |
510 i++) { | 510 i++) { |
511 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 511 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
512 EXPECT_EQ(DO_NOTHING, action.type); | 512 EXPECT_EQ(DO_NOTHING, action.type); |
513 } | 513 } |
514 // We should return DONE after not making progress for some time. | 514 // We should return DONE after not making progress for some time. |
515 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 515 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
516 EXPECT_EQ(DONE, action.type); | 516 EXPECT_EQ(DONE, action.type); |
517 } | 517 } |
518 | 518 |
| 519 |
| 520 TEST_F(GCIdleTimeHandlerTest, ReduceMemory) { |
| 521 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
| 522 double idle_time = GCIdleTimeHandler::kMinTimeForReduceMemory; |
| 523 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) { |
| 524 GCIdleTimeAction action = handler()->Compute(idle_time, heap_state); |
| 525 EXPECT_EQ(DO_FULL_GC_COMPACT, action.type); |
| 526 handler()->NotifyIdleMarkCompact(); |
| 527 } |
| 528 GCIdleTimeAction action = handler()->Compute(idle_time, heap_state); |
| 529 EXPECT_EQ(DONE, action.type); |
| 530 } |
| 531 |
519 } // namespace internal | 532 } // namespace internal |
520 } // namespace v8 | 533 } // namespace v8 |
OLD | NEW |