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/heap.h" | 8 #include "src/heap/heap.h" |
9 #include "src/utils.h" | 9 #include "src/utils.h" |
10 #include "src/v8.h" | 10 #include "src/v8.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 | 88 |
89 | 89 |
90 void MemoryReducer::NotifyBackgroundIdleNotification(const Event& event) { | 90 void MemoryReducer::NotifyBackgroundIdleNotification(const Event& event) { |
91 DCHECK_EQ(kBackgroundIdleNotification, event.type); | 91 DCHECK_EQ(kBackgroundIdleNotification, event.type); |
92 Action old_action = state_.action; | 92 Action old_action = state_.action; |
93 int old_started_gcs = state_.started_gcs; | 93 int old_started_gcs = state_.started_gcs; |
94 state_ = Step(state_, event); | 94 state_ = Step(state_, event); |
95 if (old_action == kWait && state_.action == kWait && | 95 if (old_action == kWait && state_.action == kWait && |
96 old_started_gcs + 1 == state_.started_gcs) { | 96 old_started_gcs + 1 == state_.started_gcs) { |
97 DCHECK(heap()->incremental_marking()->IsStopped()); | 97 DCHECK(heap()->incremental_marking()->IsStopped()); |
98 DCHECK(FLAG_incremental_marking); | 98 heap()->CollectAllGarbage(Heap::kReduceMemoryFootprintMask, |
Hannes Payer (out of office)
2015/08/03 19:11:39
Let's leave a comment here why we do a full GCs. O
ulan
2015/08/04 11:26:21
Done.
| |
99 heap()->StartIdleIncrementalMarking(); | 99 "memory reducer background GC"); |
100 if (FLAG_trace_gc_verbose) { | |
101 PrintIsolate(heap()->isolate(), | |
102 "Memory reducer: started GC #%d" | |
103 " (background idle)\n", | |
104 state_.started_gcs); | |
105 } | |
106 } | 100 } |
107 } | 101 } |
108 | 102 |
109 | 103 |
110 bool MemoryReducer::WatchdogGC(const State& state, const Event& event) { | 104 bool MemoryReducer::WatchdogGC(const State& state, const Event& event) { |
111 return state.last_gc_time_ms != 0 && | 105 return state.last_gc_time_ms != 0 && |
112 event.time_ms > state.last_gc_time_ms + kWatchdogDelayMs; | 106 event.time_ms > state.last_gc_time_ms + kWatchdogDelayMs; |
113 } | 107 } |
114 | 108 |
115 | 109 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 auto timer_task = new MemoryReducer::TimerTask(this); | 180 auto timer_task = new MemoryReducer::TimerTask(this); |
187 V8::GetCurrentPlatform()->CallDelayedOnForegroundThread( | 181 V8::GetCurrentPlatform()->CallDelayedOnForegroundThread( |
188 isolate, timer_task, (delay_ms + kSlackMs) / 1000.0); | 182 isolate, timer_task, (delay_ms + kSlackMs) / 1000.0); |
189 } | 183 } |
190 | 184 |
191 | 185 |
192 void MemoryReducer::TearDown() { state_ = State(kDone, 0, 0, 0.0); } | 186 void MemoryReducer::TearDown() { state_ = State(kDone, 0, 0, 0.0); } |
193 | 187 |
194 } // internal | 188 } // internal |
195 } // v8 | 189 } // v8 |
OLD | NEW |