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

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

Issue 1297153002: Version 4.5.103.23 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@4.5
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
« src/heap/gc-tracer.h ('K') | « src/heap/incremental-marking.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/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 26 matching lines...) Expand all
37 37
38 void MemoryReducer::NotifyTimer(const Event& event) { 38 void MemoryReducer::NotifyTimer(const Event& event) {
39 DCHECK(nullptr != pending_task_); 39 DCHECK(nullptr != pending_task_);
40 DCHECK_EQ(kTimer, event.type); 40 DCHECK_EQ(kTimer, event.type);
41 DCHECK_EQ(kWait, state_.action); 41 DCHECK_EQ(kWait, state_.action);
42 pending_task_ = nullptr; 42 pending_task_ = nullptr;
43 state_ = Step(state_, event); 43 state_ = Step(state_, event);
44 if (state_.action == kRun) { 44 if (state_.action == kRun) {
45 DCHECK(heap()->incremental_marking()->IsStopped()); 45 DCHECK(heap()->incremental_marking()->IsStopped());
46 DCHECK(FLAG_incremental_marking); 46 DCHECK(FLAG_incremental_marking);
47 heap()->StartIdleIncrementalMarking();
48 if (FLAG_trace_gc_verbose) { 47 if (FLAG_trace_gc_verbose) {
49 PrintIsolate(heap()->isolate(), "Memory reducer: started GC #%d\n", 48 PrintIsolate(heap()->isolate(), "Memory reducer: started GC #%d\n",
50 state_.started_gcs); 49 state_.started_gcs);
51 } 50 }
51 if (heap()->ShouldOptimizeForMemoryUsage()) {
52 // Do full GC if memory usage has higher priority than latency. This is
53 // important for background tabs that do not send idle notifications.
54 heap()->CollectAllGarbage(Heap::kReduceMemoryFootprintMask,
55 "memory reducer");
56 } else {
57 heap()->StartIdleIncrementalMarking();
58 }
52 } else if (state_.action == kWait) { 59 } else if (state_.action == kWait) {
60 if (!heap()->incremental_marking()->IsStopped() &&
61 heap()->ShouldOptimizeForMemoryUsage()) {
62 // Make progress with pending incremental marking if memory usage has
63 // higher priority than latency. This is important for background tabs
64 // that do not send idle notifications.
65 const int kIncrementalMarkingDelayMs = 500;
66 double deadline = heap()->MonotonicallyIncreasingTimeInMs() +
67 kIncrementalMarkingDelayMs;
68 heap()->AdvanceIncrementalMarking(
69 0, deadline, i::IncrementalMarking::StepActions(
70 i::IncrementalMarking::NO_GC_VIA_STACK_GUARD,
71 i::IncrementalMarking::FORCE_MARKING,
72 i::IncrementalMarking::FORCE_COMPLETION));
73 heap()->FinalizeIncrementalMarkingIfComplete(
74 "Memory reducer: finalize incremental marking");
75 }
53 // Re-schedule the timer. 76 // Re-schedule the timer.
54 ScheduleTimer(state_.next_gc_start_ms - event.time_ms); 77 ScheduleTimer(state_.next_gc_start_ms - event.time_ms);
55 if (FLAG_trace_gc_verbose) { 78 if (FLAG_trace_gc_verbose) {
56 PrintIsolate(heap()->isolate(), "Memory reducer: waiting for %.f ms\n", 79 PrintIsolate(heap()->isolate(), "Memory reducer: waiting for %.f ms\n",
57 state_.next_gc_start_ms - event.time_ms); 80 state_.next_gc_start_ms - event.time_ms);
58 } 81 }
59 } 82 }
60 } 83 }
61 84
62 85
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 void MemoryReducer::TearDown() { 232 void MemoryReducer::TearDown() {
210 if (pending_task_ != nullptr) { 233 if (pending_task_ != nullptr) {
211 pending_task_->NotifyHeapTearDown(); 234 pending_task_->NotifyHeapTearDown();
212 pending_task_ = nullptr; 235 pending_task_ = nullptr;
213 } 236 }
214 state_ = State(kDone, 0, 0, 0.0); 237 state_ = State(kDone, 0, 0, 0.0);
215 } 238 }
216 239
217 } // internal 240 } // internal
218 } // v8 241 } // v8
OLDNEW
« src/heap/gc-tracer.h ('K') | « src/heap/incremental-marking.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698