OLD | NEW |
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 <deque> | 8 #include <deque> |
9 | 9 |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 if (IsFull()) { | 170 if (IsFull()) { |
171 SetOverflowed(); | 171 SetOverflowed(); |
172 return false; | 172 return false; |
173 } else { | 173 } else { |
174 bottom_ = ((bottom_ - 1) & mask_); | 174 bottom_ = ((bottom_ - 1) & mask_); |
175 array_[bottom_] = object; | 175 array_[bottom_] = object; |
176 return true; | 176 return true; |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
| 180 template <typename Callback> |
| 181 void Iterate(Callback callback) { |
| 182 int i = bottom_; |
| 183 while (i != top_) { |
| 184 callback(array_[i]); |
| 185 i = (i + 1) & mask_; |
| 186 } |
| 187 } |
| 188 |
180 HeapObject** array() { return array_; } | 189 HeapObject** array() { return array_; } |
181 int bottom() { return bottom_; } | 190 int bottom() { return bottom_; } |
182 int top() { return top_; } | 191 int top() { return top_; } |
183 int mask() { return mask_; } | 192 int mask() { return mask_; } |
184 void set_top(int top) { top_ = top; } | 193 void set_top(int top) { top_ = top; } |
185 | 194 |
186 private: | 195 private: |
187 // This task uncommits the marking_deque backing store if | 196 // This task uncommits the marking_deque backing store if |
188 // markin_deque->in_use_ is false. | 197 // markin_deque->in_use_ is false. |
189 class UncommitTask : public CancelableTask { | 198 class UncommitTask : public CancelableTask { |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 | 839 |
831 private: | 840 private: |
832 MarkCompactCollector* collector_; | 841 MarkCompactCollector* collector_; |
833 }; | 842 }; |
834 | 843 |
835 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space); | 844 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space); |
836 } // namespace internal | 845 } // namespace internal |
837 } // namespace v8 | 846 } // namespace v8 |
838 | 847 |
839 #endif // V8_HEAP_MARK_COMPACT_H_ | 848 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |