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

Side by Side Diff: src/heap/mark-compact.h

Issue 890663005: Introduce a flag for tracing retaining path in GC. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_MARK_COMPACT_H_ 5 #ifndef V8_HEAP_MARK_COMPACT_H_
6 #define V8_HEAP_MARK_COMPACT_H_ 6 #define V8_HEAP_MARK_COMPACT_H_
7 7
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/heap/spaces.h" 9 #include "src/heap/spaces.h"
10 10
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 to_mark_bit.Next().Set(); 128 to_mark_bit.Next().Set();
129 is_black = false; // Was actually gray. 129 is_black = false; // Was actually gray.
130 } 130 }
131 return is_black; 131 return is_black;
132 } 132 }
133 133
134 private: 134 private:
135 Heap* heap_; 135 Heap* heap_;
136 }; 136 };
137 137
138
138 // ---------------------------------------------------------------------------- 139 // ----------------------------------------------------------------------------
139 // Marking deque for tracing live objects. 140 // Marking deque for tracing live objects.
140 class MarkingDeque { 141 class MarkingDeque {
141 public: 142 public:
142 MarkingDeque() 143 MarkingDeque()
143 : array_(NULL), top_(0), bottom_(0), mask_(0), overflowed_(false) {} 144 : array_(NULL), top_(0), bottom_(0), mask_(0), overflowed_(false) {}
144 145
145 void Initialize(Address low, Address high) { 146 void Initialize(Address low, Address high) {
146 HeapObject** obj_low = reinterpret_cast<HeapObject**>(low); 147 HeapObject** obj_low = reinterpret_cast<HeapObject**>(low);
147 HeapObject** obj_high = reinterpret_cast<HeapObject**>(high); 148 HeapObject** obj_high = reinterpret_cast<HeapObject**>(high);
(...skipping 12 matching lines...) Expand all
160 bool overflowed() const { return overflowed_; } 161 bool overflowed() const { return overflowed_; }
161 162
162 void ClearOverflowed() { overflowed_ = false; } 163 void ClearOverflowed() { overflowed_ = false; }
163 164
164 void SetOverflowed() { overflowed_ = true; } 165 void SetOverflowed() { overflowed_ = true; }
165 166
166 // Push the (marked) object on the marking stack if there is room, 167 // Push the (marked) object on the marking stack if there is room,
167 // otherwise mark the object as overflowed and wait for a rescan of the 168 // otherwise mark the object as overflowed and wait for a rescan of the
168 // heap. 169 // heap.
169 INLINE(void PushBlack(HeapObject* object)) { 170 INLINE(void PushBlack(HeapObject* object)) {
171 #ifdef TRACE_RETAINING_PATH
172 AddRetainedObject(object);
173 #endif
170 DCHECK(object->IsHeapObject()); 174 DCHECK(object->IsHeapObject());
171 // TODO(jochen): Remove again before we branch for 4.2. 175 // TODO(jochen): Remove again before we branch for 4.2.
172 CHECK(object->IsHeapObject() && object->map()->IsMap()); 176 CHECK(object->IsHeapObject() && object->map()->IsMap());
173 if (IsFull()) { 177 if (IsFull()) {
174 Marking::BlackToGrey(object); 178 Marking::BlackToGrey(object);
175 MemoryChunk::IncrementLiveBytesFromGC(object->address(), -object->Size()); 179 MemoryChunk::IncrementLiveBytesFromGC(object->address(), -object->Size());
176 SetOverflowed(); 180 SetOverflowed();
177 } else { 181 } else {
178 array_[top_] = object; 182 array_[top_] = object;
179 top_ = ((top_ + 1) & mask_); 183 top_ = ((top_ + 1) & mask_);
180 } 184 }
181 } 185 }
182 186
183 INLINE(void PushGrey(HeapObject* object)) { 187 INLINE(void PushGrey(HeapObject* object)) {
188 #ifdef TRACE_RETAINING_PATH
189 AddRetainedObject(object);
190 #endif
184 DCHECK(object->IsHeapObject()); 191 DCHECK(object->IsHeapObject());
185 // TODO(jochen): Remove again before we branch for 4.2. 192 // TODO(jochen): Remove again before we branch for 4.2.
186 CHECK(object->IsHeapObject() && object->map()->IsMap()); 193 CHECK(object->IsHeapObject() && object->map()->IsMap());
187 if (IsFull()) { 194 if (IsFull()) {
188 SetOverflowed(); 195 SetOverflowed();
189 } else { 196 } else {
190 array_[top_] = object; 197 array_[top_] = object;
191 top_ = ((top_ + 1) & mask_); 198 top_ = ((top_ + 1) & mask_);
192 } 199 }
193 } 200 }
(...skipping 16 matching lines...) Expand all
210 } 217 }
211 } 218 }
212 219
213 HeapObject** array() { return array_; } 220 HeapObject** array() { return array_; }
214 int bottom() { return bottom_; } 221 int bottom() { return bottom_; }
215 int top() { return top_; } 222 int top() { return top_; }
216 int mask() { return mask_; } 223 int mask() { return mask_; }
217 void set_top(int top) { top_ = top; } 224 void set_top(int top) { top_ = top; }
218 225
219 private: 226 private:
227 #ifdef TRACE_RETAINING_PATH
228 static void AddRetainedObject(HeapObject* obj);
229 #endif
230
220 HeapObject** array_; 231 HeapObject** array_;
221 // array_[(top - 1) & mask_] is the top element in the deque. The Deque is 232 // array_[(top - 1) & mask_] is the top element in the deque. The Deque is
222 // empty when top_ == bottom_. It is full when top_ + 1 == bottom 233 // empty when top_ == bottom_. It is full when top_ + 1 == bottom
223 // (mod mask + 1). 234 // (mod mask + 1).
224 int top_; 235 int top_;
225 int bottom_; 236 int bottom_;
226 int mask_; 237 int mask_;
227 bool overflowed_; 238 bool overflowed_;
228 239
229 DISALLOW_COPY_AND_ASSIGN(MarkingDeque); 240 DISALLOW_COPY_AND_ASSIGN(MarkingDeque);
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 private: 972 private:
962 MarkCompactCollector* collector_; 973 MarkCompactCollector* collector_;
963 }; 974 };
964 975
965 976
966 const char* AllocationSpaceName(AllocationSpace space); 977 const char* AllocationSpaceName(AllocationSpace space);
967 } 978 }
968 } // namespace v8::internal 979 } // namespace v8::internal
969 980
970 #endif // V8_HEAP_MARK_COMPACT_H_ 981 #endif // V8_HEAP_MARK_COMPACT_H_
OLDNEW
« src/heap/heap.cc ('K') | « src/heap/heap.cc ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698