| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 "src/heap/memory-reducer.h" | 5 #include "src/heap/memory-reducer.h" |
| 6 | 6 |
| 7 #include "src/flags.h" | 7 #include "src/flags.h" |
| 8 #include "src/heap/gc-tracer.h" | 8 #include "src/heap/gc-tracer.h" |
| 9 #include "src/heap/heap-inl.h" | 9 #include "src/heap/heap-inl.h" |
| 10 #include "src/utils.h" | 10 #include "src/utils.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } else if (state_.action == kWait) { | 77 } else if (state_.action == kWait) { |
| 78 if (!heap()->incremental_marking()->IsStopped() && | 78 if (!heap()->incremental_marking()->IsStopped() && |
| 79 heap()->ShouldOptimizeForMemoryUsage()) { | 79 heap()->ShouldOptimizeForMemoryUsage()) { |
| 80 // Make progress with pending incremental marking if memory usage has | 80 // Make progress with pending incremental marking if memory usage has |
| 81 // higher priority than latency. This is important for background tabs | 81 // higher priority than latency. This is important for background tabs |
| 82 // that do not send idle notifications. | 82 // that do not send idle notifications. |
| 83 const int kIncrementalMarkingDelayMs = 500; | 83 const int kIncrementalMarkingDelayMs = 500; |
| 84 double deadline = heap()->MonotonicallyIncreasingTimeInMs() + | 84 double deadline = heap()->MonotonicallyIncreasingTimeInMs() + |
| 85 kIncrementalMarkingDelayMs; | 85 kIncrementalMarkingDelayMs; |
| 86 heap()->incremental_marking()->AdvanceIncrementalMarking( | 86 heap()->incremental_marking()->AdvanceIncrementalMarking( |
| 87 0, deadline, i::IncrementalMarking::StepActions( | 87 deadline, i::IncrementalMarking::StepActions( |
| 88 i::IncrementalMarking::NO_GC_VIA_STACK_GUARD, | 88 i::IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
| 89 i::IncrementalMarking::FORCE_MARKING, | 89 i::IncrementalMarking::FORCE_MARKING, |
| 90 i::IncrementalMarking::FORCE_COMPLETION)); | 90 i::IncrementalMarking::FORCE_COMPLETION)); |
| 91 heap()->FinalizeIncrementalMarkingIfComplete( | 91 heap()->FinalizeIncrementalMarkingIfComplete( |
| 92 "Memory reducer: finalize incremental marking"); | 92 "Memory reducer: finalize incremental marking"); |
| 93 } | 93 } |
| 94 // Re-schedule the timer. | 94 // Re-schedule the timer. |
| 95 ScheduleTimer(event.time_ms, state_.next_gc_start_ms - event.time_ms); | 95 ScheduleTimer(event.time_ms, state_.next_gc_start_ms - event.time_ms); |
| 96 if (FLAG_trace_gc_verbose) { | 96 if (FLAG_trace_gc_verbose) { |
| 97 PrintIsolate(heap()->isolate(), "Memory reducer: waiting for %.f ms\n", | 97 PrintIsolate(heap()->isolate(), "Memory reducer: waiting for %.f ms\n", |
| 98 state_.next_gc_start_ms - event.time_ms); | 98 state_.next_gc_start_ms - event.time_ms); |
| 99 } | 99 } |
| 100 } | 100 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 auto timer_task = new MemoryReducer::TimerTask(this); | 203 auto timer_task = new MemoryReducer::TimerTask(this); |
| 204 V8::GetCurrentPlatform()->CallDelayedOnForegroundThread( | 204 V8::GetCurrentPlatform()->CallDelayedOnForegroundThread( |
| 205 isolate, timer_task, (delay_ms + kSlackMs) / 1000.0); | 205 isolate, timer_task, (delay_ms + kSlackMs) / 1000.0); |
| 206 } | 206 } |
| 207 | 207 |
| 208 | 208 |
| 209 void MemoryReducer::TearDown() { state_ = State(kDone, 0, 0, 0.0); } | 209 void MemoryReducer::TearDown() { state_ = State(kDone, 0, 0, 0.0); } |
| 210 | 210 |
| 211 } // namespace internal | 211 } // namespace internal |
| 212 } // namespace v8 | 212 } // namespace v8 |
| OLD | NEW |