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