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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 } | 211 } |
212 | 212 |
213 inline Address CurrentCellBase() { | 213 inline Address CurrentCellBase() { |
214 DCHECK(cell_index_ == Bitmap::IndexToCell(Bitmap::CellAlignIndex( | 214 DCHECK(cell_index_ == Bitmap::IndexToCell(Bitmap::CellAlignIndex( |
215 chunk_->AddressToMarkbitIndex(cell_base_)))); | 215 chunk_->AddressToMarkbitIndex(cell_base_)))); |
216 return cell_base_; | 216 return cell_base_; |
217 } | 217 } |
218 | 218 |
219 inline void Advance() { | 219 inline void Advance() { |
220 cell_index_++; | 220 cell_index_++; |
221 cell_base_ += 32 * kPointerSize; | 221 cell_base_ += Bitmap::kBitsPerCell * kPointerSize; |
| 222 } |
| 223 |
| 224 inline bool Advance(unsigned int new_cell_index) { |
| 225 if (new_cell_index != cell_index_) { |
| 226 DCHECK_GT(new_cell_index, cell_index_); |
| 227 DCHECK_LE(new_cell_index, last_cell_index_); |
| 228 unsigned int diff = new_cell_index - cell_index_; |
| 229 cell_index_ = new_cell_index; |
| 230 cell_base_ += diff * (Bitmap::kBitsPerCell * kPointerSize); |
| 231 return true; |
| 232 } |
| 233 return false; |
222 } | 234 } |
223 | 235 |
224 // Return the next mark bit cell. If there is no next it returns 0; | 236 // Return the next mark bit cell. If there is no next it returns 0; |
225 inline MarkBit::CellType PeekNext() { | 237 inline MarkBit::CellType PeekNext() { |
226 if (HasNext()) { | 238 if (HasNext()) { |
227 return cells_[cell_index_ + 1]; | 239 return cells_[cell_index_ + 1]; |
228 } | 240 } |
229 return 0; | 241 return 0; |
230 } | 242 } |
231 | 243 |
(...skipping 14 matching lines...) Expand all Loading... |
246 }; | 258 }; |
247 | 259 |
248 template <LiveObjectIterationMode T> | 260 template <LiveObjectIterationMode T> |
249 class LiveObjectIterator BASE_EMBEDDED { | 261 class LiveObjectIterator BASE_EMBEDDED { |
250 public: | 262 public: |
251 explicit LiveObjectIterator(MemoryChunk* chunk) | 263 explicit LiveObjectIterator(MemoryChunk* chunk) |
252 : chunk_(chunk), | 264 : chunk_(chunk), |
253 it_(chunk_), | 265 it_(chunk_), |
254 cell_base_(it_.CurrentCellBase()), | 266 cell_base_(it_.CurrentCellBase()), |
255 current_cell_(*it_.CurrentCell()) { | 267 current_cell_(*it_.CurrentCell()) { |
256 // Black pages can not be iterated. | |
257 DCHECK(!chunk->IsFlagSet(Page::BLACK_PAGE)); | |
258 } | 268 } |
259 | 269 |
260 HeapObject* Next(); | 270 HeapObject* Next(); |
261 | 271 |
262 private: | 272 private: |
263 MemoryChunk* chunk_; | 273 MemoryChunk* chunk_; |
264 MarkBitCellIterator it_; | 274 MarkBitCellIterator it_; |
265 Address cell_base_; | 275 Address cell_base_; |
266 MarkBit::CellType current_cell_; | 276 MarkBit::CellType current_cell_; |
267 }; | 277 }; |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 private: | 771 private: |
762 MarkCompactCollector* collector_; | 772 MarkCompactCollector* collector_; |
763 }; | 773 }; |
764 | 774 |
765 | 775 |
766 const char* AllocationSpaceName(AllocationSpace space); | 776 const char* AllocationSpaceName(AllocationSpace space); |
767 } // namespace internal | 777 } // namespace internal |
768 } // namespace v8 | 778 } // namespace v8 |
769 | 779 |
770 #endif // V8_HEAP_MARK_COMPACT_H_ | 780 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |