| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 heap_state.contexts_disposed = 1; | 184 heap_state.contexts_disposed = 1; |
| 185 heap_state.incremental_marking_stopped = true; | 185 heap_state.incremental_marking_stopped = true; |
| 186 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; | 186 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; |
| 187 int idle_time_ms = | 187 int idle_time_ms = |
| 188 static_cast<int>((heap_state.size_of_objects + speed - 1) / speed); | 188 static_cast<int>((heap_state.size_of_objects + speed - 1) / speed); |
| 189 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 189 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
| 190 EXPECT_EQ(DO_FULL_GC, action.type); | 190 EXPECT_EQ(DO_FULL_GC, action.type); |
| 191 } | 191 } |
| 192 | 192 |
| 193 | 193 |
| 194 TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeZeroIdleTime) { |
| 195 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
| 196 heap_state.contexts_disposed = 1; |
| 197 heap_state.incremental_marking_stopped = true; |
| 198 heap_state.size_of_objects = GCIdleTimeHandler::kSmallHeapSize / 2; |
| 199 int idle_time_ms = 0; |
| 200 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
| 201 EXPECT_EQ(DO_FULL_GC, action.type); |
| 202 } |
| 203 |
| 204 |
| 194 TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime1) { | 205 TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime1) { |
| 195 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 206 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
| 196 heap_state.contexts_disposed = 1; | 207 heap_state.contexts_disposed = 1; |
| 197 heap_state.incremental_marking_stopped = true; | 208 heap_state.incremental_marking_stopped = true; |
| 198 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; |
| 199 int idle_time_ms = static_cast<int>(heap_state.size_of_objects / speed - 1); | 210 int idle_time_ms = static_cast<int>(heap_state.size_of_objects / speed - 1); |
| 200 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 211 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
| 201 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); | 212 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); |
| 202 } | 213 } |
| 203 | 214 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 // Emulate mutator work. | 387 // Emulate mutator work. |
| 377 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { | 388 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { |
| 378 handler()->NotifyScavenge(); | 389 handler()->NotifyScavenge(); |
| 379 } | 390 } |
| 380 action = handler()->Compute(0, heap_state); | 391 action = handler()->Compute(0, heap_state); |
| 381 EXPECT_EQ(DO_NOTHING, action.type); | 392 EXPECT_EQ(DO_NOTHING, action.type); |
| 382 } | 393 } |
| 383 | 394 |
| 384 } // namespace internal | 395 } // namespace internal |
| 385 } // namespace v8 | 396 } // namespace v8 |
| OLD | NEW |