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