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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 } | 173 } |
174 | 174 |
175 | 175 |
176 TEST_F(GCIdleTimeHandlerTest, DontDoMarkCompact) { | 176 TEST_F(GCIdleTimeHandlerTest, DontDoMarkCompact) { |
177 size_t idle_time_in_ms = 1; | 177 size_t idle_time_in_ms = 1; |
178 EXPECT_FALSE(GCIdleTimeHandler::ShouldDoMarkCompact( | 178 EXPECT_FALSE(GCIdleTimeHandler::ShouldDoMarkCompact( |
179 idle_time_in_ms, kSizeOfObjects, kMarkingSpeed)); | 179 idle_time_in_ms, kSizeOfObjects, kMarkingSpeed)); |
180 } | 180 } |
181 | 181 |
182 | 182 |
183 TEST_F(GCIdleTimeHandlerTest, ShouldDoFinalIncrementalMarkCompact) { | |
184 size_t idle_time_in_ms = 16; | |
185 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact( | |
186 idle_time_in_ms, 0, 0)); | |
187 } | |
188 | |
189 | |
190 TEST_F(GCIdleTimeHandlerTest, DontDoFinalIncrementalMarkCompact) { | |
191 size_t idle_time_in_ms = 1; | |
192 EXPECT_FALSE(GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact( | |
193 idle_time_in_ms, kSizeOfObjects, kMarkingSpeed)); | |
194 } | |
195 | |
196 | |
197 TEST_F(GCIdleTimeHandlerTest, ContextDisposeLowRate) { | 183 TEST_F(GCIdleTimeHandlerTest, ContextDisposeLowRate) { |
198 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 184 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
199 heap_state.contexts_disposed = 1; | 185 heap_state.contexts_disposed = 1; |
200 heap_state.incremental_marking_stopped = true; | 186 heap_state.incremental_marking_stopped = true; |
201 int idle_time_ms = 0; | 187 int idle_time_ms = 0; |
202 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 188 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
203 EXPECT_EQ(DO_NOTHING, action.type); | 189 EXPECT_EQ(DO_NOTHING, action.type); |
204 } | 190 } |
205 | 191 |
206 | 192 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 // Emulate mutator work. | 414 // Emulate mutator work. |
429 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { | 415 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { |
430 handler()->NotifyScavenge(); | 416 handler()->NotifyScavenge(); |
431 } | 417 } |
432 action = handler()->Compute(0, heap_state); | 418 action = handler()->Compute(0, heap_state); |
433 EXPECT_EQ(DO_NOTHING, action.type); | 419 EXPECT_EQ(DO_NOTHING, action.type); |
434 } | 420 } |
435 | 421 |
436 } // namespace internal | 422 } // namespace internal |
437 } // namespace v8 | 423 } // namespace v8 |
OLD | NEW |