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.h

Issue 1230163002: Disable the pending task if the memory reducer is torn down. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix check 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/heap/heap.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 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 }; 94 };
95 95
96 struct Event { 96 struct Event {
97 EventType type; 97 EventType type;
98 double time_ms; 98 double time_ms;
99 bool low_allocation_rate; 99 bool low_allocation_rate;
100 bool next_gc_likely_to_collect_more; 100 bool next_gc_likely_to_collect_more;
101 bool can_start_incremental_gc; 101 bool can_start_incremental_gc;
102 }; 102 };
103 103
104 explicit MemoryReducer(Heap* heap) : heap_(heap), state_(kDone, 0, 0.0) {} 104 explicit MemoryReducer(Heap* heap)
105 : heap_(heap), state_(kDone, 0, 0.0), pending_task_(nullptr) {}
105 // Callbacks. 106 // Callbacks.
106 void NotifyTimer(const Event& event); 107 void NotifyTimer(const Event& event);
107 void NotifyMarkCompact(const Event& event); 108 void NotifyMarkCompact(const Event& event);
108 void NotifyContextDisposed(const Event& event); 109 void NotifyContextDisposed(const Event& event);
109 void NotifyBackgroundIdleNotification(const Event& event); 110 void NotifyBackgroundIdleNotification(const Event& event);
110 // The step function that computes the next state from the current state and 111 // The step function that computes the next state from the current state and
111 // the incoming event. 112 // the incoming event.
112 static State Step(const State& state, const Event& event); 113 static State Step(const State& state, const Event& event);
113 // Posts a timer task that will call NotifyTimer after the given delay. 114 // Posts a timer task that will call NotifyTimer after the given delay.
114 void ScheduleTimer(double delay_ms); 115 void ScheduleTimer(double delay_ms);
116 void TearDown();
115 117
116 static const int kLongDelayMs; 118 static const int kLongDelayMs;
117 static const int kShortDelayMs; 119 static const int kShortDelayMs;
118 static const int kMaxNumberOfGCs; 120 static const int kMaxNumberOfGCs;
119 121
120 Heap* heap() { return heap_; } 122 Heap* heap() { return heap_; }
121 123
122 private: 124 private:
123 class TimerTask : public v8::Task { 125 class TimerTask : public v8::Task {
124 public: 126 public:
125 explicit TimerTask(MemoryReducer* memory_reducer) 127 explicit TimerTask(MemoryReducer* memory_reducer)
126 : memory_reducer_(memory_reducer) {} 128 : memory_reducer_(memory_reducer), heap_is_torn_down_(false) {}
127 virtual ~TimerTask() {} 129 virtual ~TimerTask() {}
130 void NotifyHeapTearDown() { heap_is_torn_down_ = true; }
128 131
129 private: 132 private:
130 // v8::Task overrides. 133 // v8::Task overrides.
131 void Run() override; 134 void Run() override;
132 MemoryReducer* memory_reducer_; 135 MemoryReducer* memory_reducer_;
136 bool heap_is_torn_down_;
133 DISALLOW_COPY_AND_ASSIGN(TimerTask); 137 DISALLOW_COPY_AND_ASSIGN(TimerTask);
134 }; 138 };
135
136 Heap* heap_; 139 Heap* heap_;
137 State state_; 140 State state_;
141 TimerTask* pending_task_;
138 142
139 DISALLOW_COPY_AND_ASSIGN(MemoryReducer); 143 DISALLOW_COPY_AND_ASSIGN(MemoryReducer);
140 }; 144 };
141 145
142 } // namespace internal 146 } // namespace internal
143 } // namespace v8 147 } // namespace v8
144 148
145 #endif // V8_HEAP_memory_reducer_H 149 #endif // V8_HEAP_memory_reducer_H
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/memory-reducer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698