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

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

Issue 1246603002: Don't run the second pass of the pending phantom callbacks if the heap has been torn down. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: update Created 5 years, 5 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/global-handles.cc ('k') | src/heap/memory-reducer.cc » ('j') | 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 #ifndef V8_HEAP_memory_reducer_H 5 #ifndef V8_HEAP_memory_reducer_H
6 #define V8_HEAP_memory_reducer_H 6 #define V8_HEAP_memory_reducer_H
7 7
8 #include "include/v8-platform.h" 8 #include "include/v8-platform.h"
9 #include "src/base/macros.h" 9 #include "src/base/macros.h"
10 #include "src/cancelable-task.h"
10 11
11 namespace v8 { 12 namespace v8 {
12 namespace internal { 13 namespace internal {
13 14
14 class Heap; 15 class Heap;
15 16
16 17
17 // The goal of the MemoryReducer class is to detect transition of the mutator 18 // The goal of the MemoryReducer class is to detect transition of the mutator
18 // from high allocation phase to low allocation phase and to collect potential 19 // from high allocation phase to low allocation phase and to collect potential
19 // garbage created in the high allocation phase. 20 // garbage created in the high allocation phase.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 }; 95 };
95 96
96 struct Event { 97 struct Event {
97 EventType type; 98 EventType type;
98 double time_ms; 99 double time_ms;
99 bool low_allocation_rate; 100 bool low_allocation_rate;
100 bool next_gc_likely_to_collect_more; 101 bool next_gc_likely_to_collect_more;
101 bool can_start_incremental_gc; 102 bool can_start_incremental_gc;
102 }; 103 };
103 104
104 explicit MemoryReducer(Heap* heap) 105 explicit MemoryReducer(Heap* heap) : heap_(heap), state_(kDone, 0, 0.0) {}
105 : heap_(heap), state_(kDone, 0, 0.0), pending_task_(nullptr) {}
106 // Callbacks. 106 // Callbacks.
107 void NotifyTimer(const Event& event);
108 void NotifyMarkCompact(const Event& event); 107 void NotifyMarkCompact(const Event& event);
109 void NotifyContextDisposed(const Event& event); 108 void NotifyContextDisposed(const Event& event);
110 void NotifyBackgroundIdleNotification(const Event& event); 109 void NotifyBackgroundIdleNotification(const Event& event);
111 // The step function that computes the next state from the current state and 110 // The step function that computes the next state from the current state and
112 // the incoming event. 111 // the incoming event.
113 static State Step(const State& state, const Event& event); 112 static State Step(const State& state, const Event& event);
114 // Posts a timer task that will call NotifyTimer after the given delay. 113 // Posts a timer task that will call NotifyTimer after the given delay.
115 void ScheduleTimer(double delay_ms); 114 void ScheduleTimer(double delay_ms);
116 void TearDown(); 115 void TearDown();
117 void ClearTask(v8::Task* task);
118 static const int kLongDelayMs; 116 static const int kLongDelayMs;
119 static const int kShortDelayMs; 117 static const int kShortDelayMs;
120 static const int kMaxNumberOfGCs; 118 static const int kMaxNumberOfGCs;
121 119
122 Heap* heap() { return heap_; } 120 Heap* heap() { return heap_; }
123 121
124 private: 122 private:
125 class TimerTask : public v8::Task { 123 class TimerTask : public v8::internal::CancelableTask {
126 public: 124 public:
127 explicit TimerTask(MemoryReducer* memory_reducer) 125 explicit TimerTask(MemoryReducer* memory_reducer);
128 : memory_reducer_(memory_reducer), heap_is_torn_down_(false) {}
129 virtual ~TimerTask() {
130 if (!heap_is_torn_down_) {
131 memory_reducer_->ClearTask(this);
132 }
133 }
134 void NotifyHeapTearDown() { heap_is_torn_down_ = true; }
135 126
136 private: 127 private:
137 // v8::Task overrides. 128 // v8::internal::CancelableTask overrides.
138 void Run() override; 129 void RunInternal() override;
139 MemoryReducer* memory_reducer_; 130 MemoryReducer* memory_reducer_;
140 bool heap_is_torn_down_;
141 DISALLOW_COPY_AND_ASSIGN(TimerTask); 131 DISALLOW_COPY_AND_ASSIGN(TimerTask);
142 }; 132 };
133
134 void NotifyTimer(const Event& event);
135
143 Heap* heap_; 136 Heap* heap_;
144 State state_; 137 State state_;
145 TimerTask* pending_task_;
146 138
147 DISALLOW_COPY_AND_ASSIGN(MemoryReducer); 139 DISALLOW_COPY_AND_ASSIGN(MemoryReducer);
148 }; 140 };
149 141
150 } // namespace internal 142 } // namespace internal
151 } // namespace v8 143 } // namespace v8
152 144
153 #endif // V8_HEAP_memory_reducer_H 145 #endif // V8_HEAP_memory_reducer_H
OLDNEW
« no previous file with comments | « src/global-handles.cc ('k') | src/heap/memory-reducer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698