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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 if (IsFull()) { | 179 if (IsFull()) { |
180 SetOverflowed(); | 180 SetOverflowed(); |
181 return false; | 181 return false; |
182 } else { | 182 } else { |
183 bottom_ = ((bottom_ - 1) & mask_); | 183 bottom_ = ((bottom_ - 1) & mask_); |
184 array_[bottom_] = object; | 184 array_[bottom_] = object; |
185 return true; | 185 return true; |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
| 189 template <typename Callback> |
| 190 void Iterate(Callback callback) { |
| 191 int i = bottom_; |
| 192 while (i != top_) { |
| 193 callback(array_[i]); |
| 194 i = (i + 1) & mask_; |
| 195 } |
| 196 } |
| 197 |
189 HeapObject** array() { return array_; } | 198 HeapObject** array() { return array_; } |
190 int bottom() { return bottom_; } | 199 int bottom() { return bottom_; } |
191 int top() { return top_; } | 200 int top() { return top_; } |
192 int mask() { return mask_; } | 201 int mask() { return mask_; } |
193 void set_top(int top) { top_ = top; } | 202 void set_top(int top) { top_ = top; } |
194 | 203 |
195 private: | 204 private: |
196 // This task uncommits the marking_deque backing store if | 205 // This task uncommits the marking_deque backing store if |
197 // markin_deque->in_use_ is false. | 206 // markin_deque->in_use_ is false. |
198 class UncommitTask : public CancelableTask { | 207 class UncommitTask : public CancelableTask { |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 | 870 |
862 private: | 871 private: |
863 MarkCompactCollector* collector_; | 872 MarkCompactCollector* collector_; |
864 }; | 873 }; |
865 | 874 |
866 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space); | 875 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space); |
867 } // namespace internal | 876 } // namespace internal |
868 } // namespace v8 | 877 } // namespace v8 |
869 | 878 |
870 #endif // V8_HEAP_MARK_COMPACT_H_ | 879 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |