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.h" | 9 #include "src/heap/heap.h" |
10 #include "src/objects-inl.h" // TODO(mstarzinger): Temporary cycle breaker! | 10 #include "src/objects-inl.h" // TODO(mstarzinger): Temporary cycle breaker! |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 DCHECK_EQ(kBackgroundIdleNotification, event.type); | 96 DCHECK_EQ(kBackgroundIdleNotification, event.type); |
97 Action old_action = state_.action; | 97 Action old_action = state_.action; |
98 int old_started_gcs = state_.started_gcs; | 98 int old_started_gcs = state_.started_gcs; |
99 state_ = Step(state_, event); | 99 state_ = Step(state_, event); |
100 if (old_action == kWait && state_.action == kWait && | 100 if (old_action == kWait && state_.action == kWait && |
101 old_started_gcs + 1 == state_.started_gcs) { | 101 old_started_gcs + 1 == state_.started_gcs) { |
102 DCHECK(heap()->incremental_marking()->IsStopped()); | 102 DCHECK(heap()->incremental_marking()->IsStopped()); |
103 // TODO(ulan): Replace it with incremental marking GC once | 103 // TODO(ulan): Replace it with incremental marking GC once |
104 // chromium:490559 is fixed. | 104 // chromium:490559 is fixed. |
105 if (event.time_ms > state_.last_gc_time_ms + kLongDelayMs) { | 105 if (event.time_ms > state_.last_gc_time_ms + kLongDelayMs) { |
106 heap()->CollectAllGarbage(Heap::kReduceMemoryFootprintMask, | 106 heap()->CollectAllGarbage("memory reducer background GC", |
107 "memory reducer background GC"); | 107 Heap::kReduceMemoryFootprintMask); |
108 } else { | 108 } else { |
109 DCHECK(FLAG_incremental_marking); | 109 DCHECK(FLAG_incremental_marking); |
110 heap()->StartIdleIncrementalMarking(); | 110 heap()->StartIdleIncrementalMarking(); |
111 if (FLAG_trace_gc_verbose) { | 111 if (FLAG_trace_gc_verbose) { |
112 PrintIsolate(heap()->isolate(), | 112 PrintIsolate(heap()->isolate(), |
113 "Memory reducer: started GC #%d" | 113 "Memory reducer: started GC #%d" |
114 " (background idle)\n", | 114 " (background idle)\n", |
115 state_.started_gcs); | 115 state_.started_gcs); |
116 } | 116 } |
117 } | 117 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 auto timer_task = new MemoryReducer::TimerTask(this); | 198 auto timer_task = new MemoryReducer::TimerTask(this); |
199 V8::GetCurrentPlatform()->CallDelayedOnForegroundThread( | 199 V8::GetCurrentPlatform()->CallDelayedOnForegroundThread( |
200 isolate, timer_task, (delay_ms + kSlackMs) / 1000.0); | 200 isolate, timer_task, (delay_ms + kSlackMs) / 1000.0); |
201 } | 201 } |
202 | 202 |
203 | 203 |
204 void MemoryReducer::TearDown() { state_ = State(kDone, 0, 0, 0.0); } | 204 void MemoryReducer::TearDown() { state_ = State(kDone, 0, 0, 0.0); } |
205 | 205 |
206 } // internal | 206 } // internal |
207 } // v8 | 207 } // v8 |
OLD | NEW |