| 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 "src/base/bits.h" | 8 #include "src/base/bits.h" |
| 9 #include "src/heap/spaces.h" | 9 #include "src/heap/spaces.h" |
| 10 #include "src/heap/store-buffer.h" | 10 #include "src/heap/store-buffer.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 unsigned int last_cell_index_; | 363 unsigned int last_cell_index_; |
| 364 unsigned int cell_index_; | 364 unsigned int cell_index_; |
| 365 Address cell_base_; | 365 Address cell_base_; |
| 366 }; | 366 }; |
| 367 | 367 |
| 368 // Grey objects can happen on black pages when black objects transition to | 368 // Grey objects can happen on black pages when black objects transition to |
| 369 // grey e.g. when calling RecordWrites on them. | 369 // grey e.g. when calling RecordWrites on them. |
| 370 enum LiveObjectIterationMode { | 370 enum LiveObjectIterationMode { |
| 371 kBlackObjects, | 371 kBlackObjects, |
| 372 kGreyObjects, | 372 kGreyObjects, |
| 373 kGreyObjectsOnBlackPage, | |
| 374 kAllLiveObjects | 373 kAllLiveObjects |
| 375 }; | 374 }; |
| 376 | 375 |
| 377 template <LiveObjectIterationMode T> | 376 template <LiveObjectIterationMode T> |
| 378 class LiveObjectIterator BASE_EMBEDDED { | 377 class LiveObjectIterator BASE_EMBEDDED { |
| 379 public: | 378 public: |
| 380 explicit LiveObjectIterator(MemoryChunk* chunk) | 379 explicit LiveObjectIterator(MemoryChunk* chunk) |
| 381 : chunk_(chunk), | 380 : chunk_(chunk), |
| 382 it_(chunk_), | 381 it_(chunk_), |
| 383 cell_base_(it_.CurrentCellBase()), | 382 cell_base_(it_.CurrentCellBase()), |
| 384 current_cell_(*it_.CurrentCell()) { | 383 current_cell_(*it_.CurrentCell()) { |
| 385 // Black pages can only be iterated with kGreyObjectsOnBlackPage mode. | 384 // Black pages can not be iterated. |
| 386 if (T != kGreyObjectsOnBlackPage) { | 385 DCHECK(!chunk->IsFlagSet(Page::BLACK_PAGE)); |
| 387 DCHECK(!chunk->IsFlagSet(Page::BLACK_PAGE)); | |
| 388 } | |
| 389 } | 386 } |
| 390 | 387 |
| 391 HeapObject* Next(); | 388 HeapObject* Next(); |
| 392 | 389 |
| 393 private: | 390 private: |
| 394 MemoryChunk* chunk_; | 391 MemoryChunk* chunk_; |
| 395 MarkBitCellIterator it_; | 392 MarkBitCellIterator it_; |
| 396 Address cell_base_; | 393 Address cell_base_; |
| 397 MarkBit::CellType current_cell_; | 394 MarkBit::CellType current_cell_; |
| 398 }; | 395 }; |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 | 699 |
| 703 // Refill the marking stack with overflowed objects from the heap. This | 700 // Refill the marking stack with overflowed objects from the heap. This |
| 704 // function either leaves the marking stack full or clears the overflow | 701 // function either leaves the marking stack full or clears the overflow |
| 705 // flag on the marking stack. | 702 // flag on the marking stack. |
| 706 void RefillMarkingDeque(); | 703 void RefillMarkingDeque(); |
| 707 | 704 |
| 708 // Helper methods for refilling the marking stack by discovering grey objects | 705 // Helper methods for refilling the marking stack by discovering grey objects |
| 709 // on various pages of the heap. Used by {RefillMarkingDeque} only. | 706 // on various pages of the heap. Used by {RefillMarkingDeque} only. |
| 710 template <class T> | 707 template <class T> |
| 711 void DiscoverGreyObjectsWithIterator(T* it); | 708 void DiscoverGreyObjectsWithIterator(T* it); |
| 712 template <LiveObjectIterationMode T> | |
| 713 void DiscoverGreyObjectsOnPage(MemoryChunk* p); | 709 void DiscoverGreyObjectsOnPage(MemoryChunk* p); |
| 714 void DiscoverGreyObjectsInSpace(PagedSpace* space); | 710 void DiscoverGreyObjectsInSpace(PagedSpace* space); |
| 715 void DiscoverGreyObjectsInNewSpace(); | 711 void DiscoverGreyObjectsInNewSpace(); |
| 716 | 712 |
| 717 // Callback function for telling whether the object *p is an unmarked | 713 // Callback function for telling whether the object *p is an unmarked |
| 718 // heap object. | 714 // heap object. |
| 719 static bool IsUnmarkedHeapObject(Object** p); | 715 static bool IsUnmarkedHeapObject(Object** p); |
| 720 | 716 |
| 721 // Clear non-live references in weak cells, transition and descriptor arrays, | 717 // Clear non-live references in weak cells, transition and descriptor arrays, |
| 722 // and deoptimize dependent code of non-live maps. | 718 // and deoptimize dependent code of non-live maps. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 private: | 860 private: |
| 865 MarkCompactCollector* collector_; | 861 MarkCompactCollector* collector_; |
| 866 }; | 862 }; |
| 867 | 863 |
| 868 | 864 |
| 869 const char* AllocationSpaceName(AllocationSpace space); | 865 const char* AllocationSpaceName(AllocationSpace space); |
| 870 } // namespace internal | 866 } // namespace internal |
| 871 } // namespace v8 | 867 } // namespace v8 |
| 872 | 868 |
| 873 #endif // V8_HEAP_MARK_COMPACT_H_ | 869 #endif // V8_HEAP_MARK_COMPACT_H_ |
| OLD | NEW |