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 | 10 |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 | 510 |
511 void AddEvacuationCandidate(Page* p); | 511 void AddEvacuationCandidate(Page* p); |
512 | 512 |
513 // Prepares for GC by resetting relocation info in old and map spaces and | 513 // Prepares for GC by resetting relocation info in old and map spaces and |
514 // choosing spaces to compact. | 514 // choosing spaces to compact. |
515 void Prepare(); | 515 void Prepare(); |
516 | 516 |
517 // Performs a global garbage collection. | 517 // Performs a global garbage collection. |
518 void CollectGarbage(); | 518 void CollectGarbage(); |
519 | 519 |
520 enum CompactionMode { INCREMENTAL_COMPACTION, NON_INCREMENTAL_COMPACTION }; | 520 enum MarkingMode { INCREMENTAL, NON_INCREMENTAL }; |
521 | 521 |
522 bool StartCompaction(CompactionMode mode); | 522 bool StartCompaction(MarkingMode mode); |
523 | 523 |
524 void AbortCompaction(); | 524 void AbortCompaction(); |
525 | 525 |
526 #ifdef DEBUG | 526 #ifdef DEBUG |
527 // Checks whether performing mark-compact collection. | 527 // Checks whether performing mark-compact collection. |
528 bool in_use() { return state_ > PREPARE_GC; } | 528 bool in_use() { return state_ > PREPARE_GC; } |
529 bool are_map_pointers_encoded() { return state_ == UPDATE_POINTERS; } | 529 bool are_map_pointers_encoded() { return state_ == UPDATE_POINTERS; } |
530 #endif | 530 #endif |
531 | 531 |
532 // Determine type of object and emit deletion log event. | 532 // Determine type of object and emit deletion log event. |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 // - Processing of objects reachable through Harmony WeakMaps. | 764 // - Processing of objects reachable through Harmony WeakMaps. |
765 // - Objects reachable due to host application logic like object groups | 765 // - Objects reachable due to host application logic like object groups |
766 // or implicit references' groups. | 766 // or implicit references' groups. |
767 void ProcessEphemeralMarking(ObjectVisitor* visitor); | 767 void ProcessEphemeralMarking(ObjectVisitor* visitor); |
768 | 768 |
769 // If the call-site of the top optimized code was not prepared for | 769 // If the call-site of the top optimized code was not prepared for |
770 // deoptimization, then treat the maps in the code as strong pointers, | 770 // deoptimization, then treat the maps in the code as strong pointers, |
771 // otherwise a map can die and deoptimize the code. | 771 // otherwise a map can die and deoptimize the code. |
772 void ProcessTopOptimizedFrame(ObjectVisitor* visitor); | 772 void ProcessTopOptimizedFrame(ObjectVisitor* visitor); |
773 | 773 |
774 // Mark objects reachable (transitively) from objects in the marking | |
775 // stack. This function empties the marking stack, but may leave | |
776 // overflowed objects in the heap, in which case the marking stack's | |
777 // overflow flag will be set. | |
778 void EmptyMarkingDeque(); | |
779 | |
780 // Refill the marking stack with overflowed objects from the heap. This | 774 // Refill the marking stack with overflowed objects from the heap. This |
781 // function either leaves the marking stack full or clears the overflow | 775 // function either leaves the marking stack full or clears the overflow |
782 // flag on the marking stack. | 776 // flag on the marking stack. |
783 void RefillMarkingDeque(); | 777 void RefillMarkingDeque(); |
784 | 778 |
785 // Callback function for telling whether the object *p is an unmarked | 779 // Callback function for telling whether the object *p is an unmarked |
786 // heap object. | 780 // heap object. |
787 static bool IsUnmarkedHeapObject(Object** p); | 781 static bool IsUnmarkedHeapObject(Object** p); |
788 static bool IsUnmarkedHeapObjectWithHeap(Heap* heap, Object** p); | 782 static bool IsUnmarkedHeapObjectWithHeap(Heap* heap, Object** p); |
789 | 783 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 | 853 |
860 // Finalizes the parallel sweeping phase. Marks all the pages that were | 854 // Finalizes the parallel sweeping phase. Marks all the pages that were |
861 // swept in parallel. | 855 // swept in parallel. |
862 void ParallelSweepSpacesComplete(); | 856 void ParallelSweepSpacesComplete(); |
863 | 857 |
864 void ParallelSweepSpaceComplete(PagedSpace* space); | 858 void ParallelSweepSpaceComplete(PagedSpace* space); |
865 | 859 |
866 // Updates store buffer and slot buffer for a pointer in a migrating object. | 860 // Updates store buffer and slot buffer for a pointer in a migrating object. |
867 void RecordMigratedSlot(Object* value, Address slot); | 861 void RecordMigratedSlot(Object* value, Address slot); |
868 | 862 |
| 863 MarkingDeque* marking_deque() { return &marking_deque_; } |
| 864 |
| 865 void EnsureMarkingDequeIsCommittedAndInitialize(); |
| 866 |
| 867 void InitializeMarkingDeque(); |
| 868 |
| 869 void UncommitMarkingDeque(); |
| 870 |
| 871 // Mark objects reachable (transitively) from objects in the marking |
| 872 // stack. This function empties the marking stack, but may leave |
| 873 // overflowed objects in the heap, in which case the marking stack's |
| 874 // overflow flag will be set. |
| 875 template <MarkingMode mode> |
| 876 void EmptyMarkingDeque(); |
| 877 |
869 #ifdef DEBUG | 878 #ifdef DEBUG |
870 friend class MarkObjectVisitor; | 879 friend class MarkObjectVisitor; |
871 static void VisitObject(HeapObject* obj); | 880 static void VisitObject(HeapObject* obj); |
872 | 881 |
873 friend class UnmarkObjectVisitor; | 882 friend class UnmarkObjectVisitor; |
874 static void UnmarkObject(HeapObject* obj); | 883 static void UnmarkObject(HeapObject* obj); |
875 #endif | 884 #endif |
876 | 885 |
877 Heap* heap_; | 886 Heap* heap_; |
| 887 base::VirtualMemory* marking_deque_memory_; |
| 888 bool marking_deque_memory_committed_; |
878 MarkingDeque marking_deque_; | 889 MarkingDeque marking_deque_; |
879 CodeFlusher* code_flusher_; | 890 CodeFlusher* code_flusher_; |
880 bool have_code_to_deoptimize_; | 891 bool have_code_to_deoptimize_; |
881 | 892 |
882 List<Page*> evacuation_candidates_; | 893 List<Page*> evacuation_candidates_; |
883 List<Code*> invalidated_code_; | 894 List<Code*> invalidated_code_; |
884 | 895 |
885 SmartPointer<FreeList> free_list_old_data_space_; | 896 SmartPointer<FreeList> free_list_old_data_space_; |
886 SmartPointer<FreeList> free_list_old_pointer_space_; | 897 SmartPointer<FreeList> free_list_old_pointer_space_; |
887 | 898 |
| 899 friend class IncrementalMarking; |
| 900 friend class IncrementalMarkingMarkingVisitor; |
888 friend class Heap; | 901 friend class Heap; |
889 }; | 902 }; |
890 | 903 |
891 | 904 |
892 class MarkBitCellIterator BASE_EMBEDDED { | 905 class MarkBitCellIterator BASE_EMBEDDED { |
893 public: | 906 public: |
894 explicit MarkBitCellIterator(MemoryChunk* chunk) : chunk_(chunk) { | 907 explicit MarkBitCellIterator(MemoryChunk* chunk) : chunk_(chunk) { |
895 last_cell_index_ = Bitmap::IndexToCell(Bitmap::CellAlignIndex( | 908 last_cell_index_ = Bitmap::IndexToCell(Bitmap::CellAlignIndex( |
896 chunk_->AddressToMarkbitIndex(chunk_->area_end()))); | 909 chunk_->AddressToMarkbitIndex(chunk_->area_end()))); |
897 cell_base_ = chunk_->area_start(); | 910 cell_base_ = chunk_->area_start(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 private: | 955 private: |
943 MarkCompactCollector* collector_; | 956 MarkCompactCollector* collector_; |
944 }; | 957 }; |
945 | 958 |
946 | 959 |
947 const char* AllocationSpaceName(AllocationSpace space); | 960 const char* AllocationSpaceName(AllocationSpace space); |
948 } | 961 } |
949 } // namespace v8::internal | 962 } // namespace v8::internal |
950 | 963 |
951 #endif // V8_HEAP_MARK_COMPACT_H_ | 964 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |