| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 | 68 |
| 69 TEST(GCIdleTimeHandler, EstimateMarkingStepSizeOverflow2) { | 69 TEST(GCIdleTimeHandler, EstimateMarkingStepSizeOverflow2) { |
| 70 size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize( | 70 size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize( |
| 71 std::numeric_limits<size_t>::max(), 10); | 71 std::numeric_limits<size_t>::max(), 10); |
| 72 EXPECT_EQ(static_cast<size_t>(GCIdleTimeHandler::kMaximumMarkingStepSize), | 72 EXPECT_EQ(static_cast<size_t>(GCIdleTimeHandler::kMaximumMarkingStepSize), |
| 73 step_size); | 73 step_size); |
| 74 } | 74 } |
| 75 | 75 |
| 76 | 76 |
| 77 TEST(GCIdleTimeHandler, EstimateMarkCompactTimeInitial) { | |
| 78 size_t size = 100 * MB; | |
| 79 size_t time = GCIdleTimeHandler::EstimateMarkCompactTime(size, 0); | |
| 80 EXPECT_EQ(size / GCIdleTimeHandler::kInitialConservativeMarkCompactSpeed, | |
| 81 time); | |
| 82 } | |
| 83 | |
| 84 | |
| 85 TEST(GCIdleTimeHandler, EstimateMarkCompactTimeNonZero) { | |
| 86 size_t size = 100 * MB; | |
| 87 size_t speed = 1 * MB; | |
| 88 size_t time = GCIdleTimeHandler::EstimateMarkCompactTime(size, speed); | |
| 89 EXPECT_EQ(size / speed, time); | |
| 90 } | |
| 91 | |
| 92 | |
| 93 TEST(GCIdleTimeHandler, EstimateMarkCompactTimeMax) { | |
| 94 size_t size = std::numeric_limits<size_t>::max(); | |
| 95 size_t speed = 1; | |
| 96 size_t time = GCIdleTimeHandler::EstimateMarkCompactTime(size, speed); | |
| 97 EXPECT_EQ(GCIdleTimeHandler::kMaxMarkCompactTimeInMs, time); | |
| 98 } | |
| 99 | |
| 100 | |
| 101 TEST_F(GCIdleTimeHandlerTest, ShouldDoMarkCompact) { | |
| 102 size_t idle_time_ms = GCIdleTimeHandler::kMaxScheduledIdleTime; | |
| 103 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoMarkCompact(idle_time_ms, 0, 0)); | |
| 104 } | |
| 105 | |
| 106 | |
| 107 TEST_F(GCIdleTimeHandlerTest, DontDoMarkCompact) { | |
| 108 size_t idle_time_ms = 1; | |
| 109 EXPECT_FALSE(GCIdleTimeHandler::ShouldDoMarkCompact( | |
| 110 idle_time_ms, kSizeOfObjects, kMarkingSpeed)); | |
| 111 } | |
| 112 | |
| 113 | |
| 114 TEST_F(GCIdleTimeHandlerTest, ShouldDoFinalIncrementalMarkCompact) { | 77 TEST_F(GCIdleTimeHandlerTest, ShouldDoFinalIncrementalMarkCompact) { |
| 115 size_t idle_time_ms = 16; | 78 size_t idle_time_ms = 16; |
| 116 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact( | 79 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact( |
| 117 idle_time_ms, 0, 0)); | 80 idle_time_ms, 0, 0)); |
| 118 } | 81 } |
| 119 | 82 |
| 120 | 83 |
| 121 TEST_F(GCIdleTimeHandlerTest, DontDoFinalIncrementalMarkCompact) { | 84 TEST_F(GCIdleTimeHandlerTest, DontDoFinalIncrementalMarkCompact) { |
| 122 size_t idle_time_ms = 1; | 85 size_t idle_time_ms = 1; |
| 123 EXPECT_FALSE(GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact( | 86 EXPECT_FALSE(GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact( |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 // Simulate incremental marking stopped and not eligible to start. | 210 // Simulate incremental marking stopped and not eligible to start. |
| 248 heap_state.incremental_marking_stopped = true; | 211 heap_state.incremental_marking_stopped = true; |
| 249 double idle_time_ms = 10.0; | 212 double idle_time_ms = 10.0; |
| 250 // We should return DONE if we cannot start incremental marking. | 213 // We should return DONE if we cannot start incremental marking. |
| 251 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 214 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
| 252 EXPECT_EQ(DONE, action.type); | 215 EXPECT_EQ(DONE, action.type); |
| 253 } | 216 } |
| 254 | 217 |
| 255 } // namespace internal | 218 } // namespace internal |
| 256 } // namespace v8 | 219 } // namespace v8 |
| OLD | NEW |