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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
637 | 637 |
638 explicit MarkCompactCollector(Heap* heap); | 638 explicit MarkCompactCollector(Heap* heap); |
639 | 639 |
640 bool WillBeDeoptimized(Code* code); | 640 bool WillBeDeoptimized(Code* code); |
641 void ClearInvalidRememberedSetSlots(); | 641 void ClearInvalidRememberedSetSlots(); |
642 | 642 |
643 void ComputeEvacuationHeuristics(int area_size, | 643 void ComputeEvacuationHeuristics(int area_size, |
644 int* target_fragmentation_percent, | 644 int* target_fragmentation_percent, |
645 int* max_evacuated_bytes); | 645 int* max_evacuated_bytes); |
646 | 646 |
647 #ifdef DEBUG | |
ulan
2016/05/20 11:28:24
I moved this down.
| |
648 enum CollectorState { | |
649 IDLE, | |
650 PREPARE_GC, | |
651 MARK_LIVE_OBJECTS, | |
652 SWEEP_SPACES, | |
653 ENCODE_FORWARDING_ADDRESSES, | |
654 UPDATE_POINTERS, | |
655 RELOCATE_OBJECTS | |
656 }; | |
657 | |
658 // The current stage of the collector. | |
659 CollectorState state_; | |
660 #endif | |
661 | |
662 MarkingParity marking_parity_; | |
663 | |
664 bool was_marked_incrementally_; | |
665 | |
666 bool evacuation_; | |
667 | |
668 // Finishes GC, performs heap verification if enabled. | 647 // Finishes GC, performs heap verification if enabled. |
669 void Finish(); | 648 void Finish(); |
670 | 649 |
671 // ----------------------------------------------------------------------- | 650 // ----------------------------------------------------------------------- |
672 // Phase 1: Marking live objects. | 651 // Phase 1: Marking live objects. |
673 // | 652 // |
674 // Before: The heap has been prepared for garbage collection by | 653 // Before: The heap has been prepared for garbage collection by |
675 // MarkCompactCollector::Prepare() and is otherwise in its | 654 // MarkCompactCollector::Prepare() and is otherwise in its |
676 // normal state. | 655 // normal state. |
677 // | 656 // |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
843 | 822 |
844 #ifdef DEBUG | 823 #ifdef DEBUG |
845 friend class MarkObjectVisitor; | 824 friend class MarkObjectVisitor; |
846 static void VisitObject(HeapObject* obj); | 825 static void VisitObject(HeapObject* obj); |
847 | 826 |
848 friend class UnmarkObjectVisitor; | 827 friend class UnmarkObjectVisitor; |
849 static void UnmarkObject(HeapObject* obj); | 828 static void UnmarkObject(HeapObject* obj); |
850 #endif | 829 #endif |
851 | 830 |
852 Heap* heap_; | 831 Heap* heap_; |
832 | |
833 base::Semaphore page_parallel_job_semaphore_; | |
834 | |
835 #ifdef DEBUG | |
836 enum CollectorState { | |
837 IDLE, | |
838 PREPARE_GC, | |
839 MARK_LIVE_OBJECTS, | |
840 SWEEP_SPACES, | |
841 ENCODE_FORWARDING_ADDRESSES, | |
842 UPDATE_POINTERS, | |
843 RELOCATE_OBJECTS | |
844 }; | |
845 | |
846 // The current stage of the collector. | |
847 CollectorState state_; | |
848 #endif | |
849 | |
850 MarkingParity marking_parity_; | |
851 | |
852 bool was_marked_incrementally_; | |
853 | |
854 bool evacuation_; | |
855 | |
856 // True if we are collecting slots to perform evacuation from evacuation | |
857 // candidates. | |
858 bool compacting_; | |
859 | |
860 bool black_allocation_; | |
861 | |
862 bool have_code_to_deoptimize_; | |
863 | |
853 base::VirtualMemory* marking_deque_memory_; | 864 base::VirtualMemory* marking_deque_memory_; |
854 size_t marking_deque_memory_committed_; | 865 size_t marking_deque_memory_committed_; |
855 MarkingDeque marking_deque_; | 866 MarkingDeque marking_deque_; |
856 std::vector<std::pair<void*, void*>> wrappers_to_trace_; | 867 std::vector<std::pair<void*, void*>> wrappers_to_trace_; |
857 | 868 |
858 CodeFlusher* code_flusher_; | 869 CodeFlusher* code_flusher_; |
859 | 870 |
860 EmbedderHeapTracer* embedder_heap_tracer_; | 871 EmbedderHeapTracer* embedder_heap_tracer_; |
861 | 872 |
862 bool have_code_to_deoptimize_; | |
863 | |
864 List<Page*> evacuation_candidates_; | 873 List<Page*> evacuation_candidates_; |
865 List<Page*> newspace_evacuation_candidates_; | 874 List<Page*> newspace_evacuation_candidates_; |
866 | 875 |
867 // True if we are collecting slots to perform evacuation from evacuation | |
868 // candidates. | |
869 bool compacting_; | |
870 | |
871 bool black_allocation_; | |
872 | |
873 Sweeper sweeper_; | 876 Sweeper sweeper_; |
874 | 877 |
875 friend class Heap; | 878 friend class Heap; |
876 friend class StoreBuffer; | 879 friend class StoreBuffer; |
877 }; | 880 }; |
878 | 881 |
879 | 882 |
880 class EvacuationScope BASE_EMBEDDED { | 883 class EvacuationScope BASE_EMBEDDED { |
881 public: | 884 public: |
882 explicit EvacuationScope(MarkCompactCollector* collector) | 885 explicit EvacuationScope(MarkCompactCollector* collector) |
883 : collector_(collector) { | 886 : collector_(collector) { |
884 collector_->set_evacuation(true); | 887 collector_->set_evacuation(true); |
885 } | 888 } |
886 | 889 |
887 ~EvacuationScope() { collector_->set_evacuation(false); } | 890 ~EvacuationScope() { collector_->set_evacuation(false); } |
888 | 891 |
889 private: | 892 private: |
890 MarkCompactCollector* collector_; | 893 MarkCompactCollector* collector_; |
891 }; | 894 }; |
892 | 895 |
893 | 896 |
894 const char* AllocationSpaceName(AllocationSpace space); | 897 const char* AllocationSpaceName(AllocationSpace space); |
895 } // namespace internal | 898 } // namespace internal |
896 } // namespace v8 | 899 } // namespace v8 |
897 | 900 |
898 #endif // V8_HEAP_MARK_COMPACT_H_ | 901 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |