Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: src/heap/memory-reducer.cc

Issue 1303333005: Revert "Make sure that memory reducer makes progress in incremental marking" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/heap.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 29 matching lines...) Expand all
40 } 40 }
41 41
42 42
43 void MemoryReducer::NotifyTimer(const Event& event) { 43 void MemoryReducer::NotifyTimer(const Event& event) {
44 DCHECK_EQ(kTimer, event.type); 44 DCHECK_EQ(kTimer, event.type);
45 DCHECK_EQ(kWait, state_.action); 45 DCHECK_EQ(kWait, state_.action);
46 state_ = Step(state_, event); 46 state_ = Step(state_, event);
47 if (state_.action == kRun) { 47 if (state_.action == kRun) {
48 DCHECK(heap()->incremental_marking()->IsStopped()); 48 DCHECK(heap()->incremental_marking()->IsStopped());
49 DCHECK(FLAG_incremental_marking); 49 DCHECK(FLAG_incremental_marking);
50 heap()->StartIdleIncrementalMarking();
50 if (FLAG_trace_gc_verbose) { 51 if (FLAG_trace_gc_verbose) {
51 PrintIsolate(heap()->isolate(), "Memory reducer: started GC #%d\n", 52 PrintIsolate(heap()->isolate(), "Memory reducer: started GC #%d\n",
52 state_.started_gcs); 53 state_.started_gcs);
53 } 54 }
54 if (heap()->ShouldOptimizeForMemoryUsage()) {
55 // Do full GC if memory usage has higher priority than latency. This is
56 // important for background tabs that do not send idle notifications.
57 heap()->CollectAllGarbage(Heap::kReduceMemoryFootprintMask,
58 "memory reducer");
59 } else {
60 heap()->StartIdleIncrementalMarking();
61 }
62 } else if (state_.action == kWait) { 55 } else if (state_.action == kWait) {
63 if (!heap()->incremental_marking()->IsStopped() &&
64 heap()->ShouldOptimizeForMemoryUsage()) {
65 // Make progress with pending incremental marking if memory usage has
66 // higher priority than latency. This is important for background tabs
67 // that do not send idle notifications.
68 const int kIncrementalMarkingDelayMs = 500;
69 double deadline = heap()->MonotonicallyIncreasingTimeInMs() +
70 kIncrementalMarkingDelayMs;
71 heap()->AdvanceIncrementalMarking(
72 0, deadline, i::IncrementalMarking::StepActions(
73 i::IncrementalMarking::NO_GC_VIA_STACK_GUARD,
74 i::IncrementalMarking::FORCE_MARKING,
75 i::IncrementalMarking::FORCE_COMPLETION));
76 heap()->FinalizeIncrementalMarkingIfComplete(
77 "Memory reducer: finalize incremental marking");
78 }
79 // Re-schedule the timer. 56 // Re-schedule the timer.
80 ScheduleTimer(state_.next_gc_start_ms - event.time_ms); 57 ScheduleTimer(state_.next_gc_start_ms - event.time_ms);
81 if (FLAG_trace_gc_verbose) { 58 if (FLAG_trace_gc_verbose) {
82 PrintIsolate(heap()->isolate(), "Memory reducer: waiting for %.f ms\n", 59 PrintIsolate(heap()->isolate(), "Memory reducer: waiting for %.f ms\n",
83 state_.next_gc_start_ms - event.time_ms); 60 state_.next_gc_start_ms - event.time_ms);
84 } 61 }
85 } 62 }
86 } 63 }
87 64
88 65
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 auto timer_task = new MemoryReducer::TimerTask(this); 198 auto timer_task = new MemoryReducer::TimerTask(this);
222 V8::GetCurrentPlatform()->CallDelayedOnForegroundThread( 199 V8::GetCurrentPlatform()->CallDelayedOnForegroundThread(
223 isolate, timer_task, (delay_ms + kSlackMs) / 1000.0); 200 isolate, timer_task, (delay_ms + kSlackMs) / 1000.0);
224 } 201 }
225 202
226 203
227 void MemoryReducer::TearDown() { state_ = State(kDone, 0, 0, 0.0); } 204 void MemoryReducer::TearDown() { state_ = State(kDone, 0, 0, 0.0); }
228 205
229 } // internal 206 } // internal
230 } // v8 207 } // v8
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698