| 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/flags.h" | 7 #include "src/flags.h" |
| 8 #include "src/heap/memory-reducer.h" | 8 #include "src/heap/memory-reducer.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 TEST(MemoryReducer, FromWaitToDone) { | 232 TEST(MemoryReducer, FromWaitToDone) { |
| 233 if (!FLAG_incremental_marking) return; | 233 if (!FLAG_incremental_marking) return; |
| 234 | 234 |
| 235 MemoryReducer::State state0(WaitState(2, 0.0)), state1(DoneState()); | 235 MemoryReducer::State state0(WaitState(2, 0.0)), state1(DoneState()); |
| 236 | 236 |
| 237 state0.started_gcs = MemoryReducer::kMaxNumberOfGCs; | 237 state0.started_gcs = MemoryReducer::kMaxNumberOfGCs; |
| 238 | 238 |
| 239 state1 = MemoryReducer::Step(state0, TimerEventLowAllocationRate(2000)); | 239 state1 = MemoryReducer::Step(state0, TimerEventLowAllocationRate(2000)); |
| 240 EXPECT_EQ(MemoryReducer::kDone, state1.action); | 240 EXPECT_EQ(MemoryReducer::kDone, state1.action); |
| 241 EXPECT_EQ(0, state1.next_gc_start_ms); | 241 EXPECT_EQ(0, state1.next_gc_start_ms); |
| 242 EXPECT_EQ(0, state1.started_gcs); | 242 EXPECT_EQ(MemoryReducer::kMaxNumberOfGCs, state1.started_gcs); |
| 243 EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms); | 243 EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms); |
| 244 | 244 |
| 245 state1 = MemoryReducer::Step(state0, TimerEventHighAllocationRate(2000)); | 245 state1 = MemoryReducer::Step(state0, TimerEventHighAllocationRate(2000)); |
| 246 EXPECT_EQ(MemoryReducer::kDone, state1.action); | 246 EXPECT_EQ(MemoryReducer::kDone, state1.action); |
| 247 EXPECT_EQ(0, state1.next_gc_start_ms); | 247 EXPECT_EQ(0, state1.next_gc_start_ms); |
| 248 EXPECT_EQ(0, state1.started_gcs); | 248 EXPECT_EQ(MemoryReducer::kMaxNumberOfGCs, state1.started_gcs); |
| 249 EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms); | 249 EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms); |
| 250 | 250 |
| 251 state1 = MemoryReducer::Step(state0, TimerEventPendingGC(2000)); | 251 state1 = MemoryReducer::Step(state0, TimerEventPendingGC(2000)); |
| 252 EXPECT_EQ(MemoryReducer::kDone, state1.action); | 252 EXPECT_EQ(MemoryReducer::kDone, state1.action); |
| 253 EXPECT_EQ(0, state1.next_gc_start_ms); | 253 EXPECT_EQ(0, state1.next_gc_start_ms); |
| 254 EXPECT_EQ(0, state1.started_gcs); | 254 EXPECT_EQ(MemoryReducer::kMaxNumberOfGCs, state1.started_gcs); |
| 255 EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms); | 255 EXPECT_EQ(state0.last_gc_time_ms, state1.last_gc_time_ms); |
| 256 } | 256 } |
| 257 | 257 |
| 258 | 258 |
| 259 TEST(MemoryReducer, FromRunToRun) { | 259 TEST(MemoryReducer, FromRunToRun) { |
| 260 if (!FLAG_incremental_marking) return; | 260 if (!FLAG_incremental_marking) return; |
| 261 | 261 |
| 262 MemoryReducer::State state0(RunState(1, 0.0)), state1(DoneState()); | 262 MemoryReducer::State state0(RunState(1, 0.0)), state1(DoneState()); |
| 263 | 263 |
| 264 state1 = MemoryReducer::Step(state0, TimerEventLowAllocationRate(2000)); | 264 state1 = MemoryReducer::Step(state0, TimerEventLowAllocationRate(2000)); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 288 | 288 |
| 289 | 289 |
| 290 TEST(MemoryReducer, FromRunToDone) { | 290 TEST(MemoryReducer, FromRunToDone) { |
| 291 if (!FLAG_incremental_marking) return; | 291 if (!FLAG_incremental_marking) return; |
| 292 | 292 |
| 293 MemoryReducer::State state0(RunState(2, 0.0)), state1(DoneState()); | 293 MemoryReducer::State state0(RunState(2, 0.0)), state1(DoneState()); |
| 294 | 294 |
| 295 state1 = MemoryReducer::Step(state0, MarkCompactEventNoGarbageLeft(2000)); | 295 state1 = MemoryReducer::Step(state0, MarkCompactEventNoGarbageLeft(2000)); |
| 296 EXPECT_EQ(MemoryReducer::kDone, state1.action); | 296 EXPECT_EQ(MemoryReducer::kDone, state1.action); |
| 297 EXPECT_EQ(0, state1.next_gc_start_ms); | 297 EXPECT_EQ(0, state1.next_gc_start_ms); |
| 298 EXPECT_EQ(0, state1.started_gcs); | 298 EXPECT_EQ(MemoryReducer::kMaxNumberOfGCs, state1.started_gcs); |
| 299 EXPECT_EQ(2000, state1.last_gc_time_ms); | 299 EXPECT_EQ(2000, state1.last_gc_time_ms); |
| 300 | 300 |
| 301 state0.started_gcs = MemoryReducer::kMaxNumberOfGCs; | 301 state0.started_gcs = MemoryReducer::kMaxNumberOfGCs; |
| 302 | 302 |
| 303 state1 = MemoryReducer::Step(state0, MarkCompactEventGarbageLeft(2000)); | 303 state1 = MemoryReducer::Step(state0, MarkCompactEventGarbageLeft(2000)); |
| 304 EXPECT_EQ(MemoryReducer::kDone, state1.action); | 304 EXPECT_EQ(MemoryReducer::kDone, state1.action); |
| 305 EXPECT_EQ(0, state1.next_gc_start_ms); | 305 EXPECT_EQ(0, state1.next_gc_start_ms); |
| 306 EXPECT_EQ(2000, state1.last_gc_time_ms); | 306 EXPECT_EQ(2000, state1.last_gc_time_ms); |
| 307 } | 307 } |
| 308 | 308 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 322 | 322 |
| 323 state1 = MemoryReducer::Step(state0, MarkCompactEventNoGarbageLeft(2000)); | 323 state1 = MemoryReducer::Step(state0, MarkCompactEventNoGarbageLeft(2000)); |
| 324 EXPECT_EQ(MemoryReducer::kWait, state1.action); | 324 EXPECT_EQ(MemoryReducer::kWait, state1.action); |
| 325 EXPECT_EQ(2000 + MemoryReducer::kShortDelayMs, state1.next_gc_start_ms); | 325 EXPECT_EQ(2000 + MemoryReducer::kShortDelayMs, state1.next_gc_start_ms); |
| 326 EXPECT_EQ(state0.started_gcs, state1.started_gcs); | 326 EXPECT_EQ(state0.started_gcs, state1.started_gcs); |
| 327 EXPECT_EQ(2000, state1.last_gc_time_ms); | 327 EXPECT_EQ(2000, state1.last_gc_time_ms); |
| 328 } | 328 } |
| 329 | 329 |
| 330 } // namespace internal | 330 } // namespace internal |
| 331 } // namespace v8 | 331 } // namespace v8 |
| OLD | NEW |