46 #include "utilities/stack.hpp"
47
48 // A "G1CollectedHeap" is an implementation of a java heap for HotSpot.
49 // It uses the "Garbage First" heap organization and algorithm, which
50 // may combine concurrent marking with parallel, incremental compaction of
51 // heap subsets that will yield large amounts of garbage.
52
53 // Forward declarations
54 class HeapRegion;
55 class HRRSCleanupTask;
56 class GenerationSpec;
57 class OopsInHeapRegionClosure;
58 class G1KlassScanClosure;
59 class ObjectClosure;
60 class SpaceClosure;
61 class CompactibleSpaceClosure;
62 class Space;
63 class G1CollectorPolicy;
64 class GenRemSet;
65 class G1RemSet;
66 class HeapRegionRemSetIterator;
67 class ConcurrentMark;
68 class ConcurrentMarkThread;
69 class ConcurrentG1Refine;
70 class ConcurrentGCTimer;
71 class GenerationCounters;
72 class STWGCTimer;
73 class G1NewTracer;
74 class G1OldTracer;
75 class EvacuationFailedInfo;
76 class nmethod;
77 class Ticks;
78
79 typedef OverflowTaskQueue<StarTask, mtGC> RefToScanQueue;
80 typedef GenericTaskQueueSet<RefToScanQueue, mtGC> RefToScanQueueSet;
81
82 typedef int RegionIdx_t; // needs to hold [ 0..max_regions() )
83 typedef int CardIdx_t; // needs to hold [ 0..CardsPerRegion )
84
85 class YoungList : public CHeapObj<mtGC> {
778 void free_collection_set(HeapRegion* cs_head, EvacuationInfo& evacuation_info);
779
780 // Abandon the current collection set without recording policy
781 // statistics or updating free lists.
782 void abandon_collection_set(HeapRegion* cs_head);
783
784 // Applies "scan_non_heap_roots" to roots outside the heap,
785 // "scan_rs" to roots inside the heap (having done "set_region" to
786 // indicate the region in which the root resides),
787 // and does "scan_metadata" If "scan_rs" is
788 // NULL, then this step is skipped. The "worker_i"
789 // param is for use with parallel roots processing, and should be
790 // the "i" of the calling parallel worker thread's work(i) function.
791 // In the sequential case this param will be ignored.
792 void g1_process_roots(OopClosure* scan_non_heap_roots,
793 OopClosure* scan_non_heap_weak_roots,
794 G1ParPushHeapRSClosure* scan_rs,
795 CLDClosure* scan_strong_clds,
796 CLDClosure* scan_weak_clds,
797 CodeBlobClosure* scan_strong_code,
798 uint worker_i);
799
800 // The concurrent marker (and the thread it runs in.)
801 ConcurrentMark* _cm;
802 ConcurrentMarkThread* _cmThread;
803 bool _mark_in_progress;
804
805 // The concurrent refiner.
806 ConcurrentG1Refine* _cg1r;
807
808 // The parallel task queues
809 RefToScanQueueSet *_task_queues;
810
811 // True iff a evacuation has failed in the current collection.
812 bool _evacuation_failed;
813
814 EvacuationFailedInfo* _evacuation_failed_info_array;
815
816 // Failed evacuations cause some logical from-space objects to have
817 // forwarding pointers to themselves. Reset them.
818 void remove_self_forwarding_pointers();
966 ReferenceProcessor* _ref_processor_cm;
967
968 // Instance of the concurrent mark is_alive closure for embedding
969 // into the Concurrent Marking reference processor as the
970 // _is_alive_non_header field. Supplying a value for the
971 // _is_alive_non_header field is optional but doing so prevents
972 // unnecessary additions to the discovered lists during reference
973 // discovery.
974 G1CMIsAliveClosure _is_alive_closure_cm;
975
976 // Cache used by G1CollectedHeap::start_cset_region_for_worker().
977 HeapRegion** _worker_cset_start_region;
978
979 // Time stamp to validate the regions recorded in the cache
980 // used by G1CollectedHeap::start_cset_region_for_worker().
981 // The heap region entry for a given worker is valid iff
982 // the associated time stamp value matches the current value
983 // of G1CollectedHeap::_gc_time_stamp.
984 uint* _worker_cset_start_region_time_stamp;
985
986 enum G1H_process_roots_tasks {
987 G1H_PS_filter_satb_buffers,
988 G1H_PS_refProcessor_oops_do,
989 // Leave this one last.
990 G1H_PS_NumElements
991 };
992
993 SubTasksDone* _process_strong_tasks;
994
995 volatile bool _free_regions_coming;
996
997 public:
998
999 SubTasksDone* process_strong_tasks() { return _process_strong_tasks; }
1000
1001 void set_refine_cte_cl_concurrency(bool concurrent);
1002
1003 RefToScanQueue *task_queue(int i) const;
1004
1005 // A set of cards where updates happened during the GC
1006 DirtyCardQueueSet& dirty_card_queue_set() { return _dirty_card_queue_set; }
1007
1008 // A DirtyCardQueueSet that is used to hold cards that contain
1009 // references into the current collection set. This is used to
1010 // update the remembered sets of the regions in the collection
1011 // set in the event of an evacuation failure.
1012 DirtyCardQueueSet& into_cset_dirty_card_queue_set()
1013 { return _into_cset_dirty_card_queue_set; }
1014
1015 // Create a G1CollectedHeap with the specified policy.
1016 // Must call the initialize method afterwards.
1017 // May not return if something goes wrong.
|
46 #include "utilities/stack.hpp"
47
48 // A "G1CollectedHeap" is an implementation of a java heap for HotSpot.
49 // It uses the "Garbage First" heap organization and algorithm, which
50 // may combine concurrent marking with parallel, incremental compaction of
51 // heap subsets that will yield large amounts of garbage.
52
53 // Forward declarations
54 class HeapRegion;
55 class HRRSCleanupTask;
56 class GenerationSpec;
57 class OopsInHeapRegionClosure;
58 class G1KlassScanClosure;
59 class ObjectClosure;
60 class SpaceClosure;
61 class CompactibleSpaceClosure;
62 class Space;
63 class G1CollectorPolicy;
64 class GenRemSet;
65 class G1RemSet;
66 class G1PhaseTimeTracker;
67 class HeapRegionRemSetIterator;
68 class ConcurrentMark;
69 class ConcurrentMarkThread;
70 class ConcurrentG1Refine;
71 class ConcurrentGCTimer;
72 class GenerationCounters;
73 class STWGCTimer;
74 class G1NewTracer;
75 class G1OldTracer;
76 class EvacuationFailedInfo;
77 class nmethod;
78 class Ticks;
79
80 typedef OverflowTaskQueue<StarTask, mtGC> RefToScanQueue;
81 typedef GenericTaskQueueSet<RefToScanQueue, mtGC> RefToScanQueueSet;
82
83 typedef int RegionIdx_t; // needs to hold [ 0..max_regions() )
84 typedef int CardIdx_t; // needs to hold [ 0..CardsPerRegion )
85
86 class YoungList : public CHeapObj<mtGC> {
779 void free_collection_set(HeapRegion* cs_head, EvacuationInfo& evacuation_info);
780
781 // Abandon the current collection set without recording policy
782 // statistics or updating free lists.
783 void abandon_collection_set(HeapRegion* cs_head);
784
785 // Applies "scan_non_heap_roots" to roots outside the heap,
786 // "scan_rs" to roots inside the heap (having done "set_region" to
787 // indicate the region in which the root resides),
788 // and does "scan_metadata" If "scan_rs" is
789 // NULL, then this step is skipped. The "worker_i"
790 // param is for use with parallel roots processing, and should be
791 // the "i" of the calling parallel worker thread's work(i) function.
792 // In the sequential case this param will be ignored.
793 void g1_process_roots(OopClosure* scan_non_heap_roots,
794 OopClosure* scan_non_heap_weak_roots,
795 G1ParPushHeapRSClosure* scan_rs,
796 CLDClosure* scan_strong_clds,
797 CLDClosure* scan_weak_clds,
798 CodeBlobClosure* scan_strong_code,
799 uint worker_i,
800 GCPhaseTimeTracker* phase_times);
801
802 // The concurrent marker (and the thread it runs in.)
803 ConcurrentMark* _cm;
804 ConcurrentMarkThread* _cmThread;
805 bool _mark_in_progress;
806
807 // The concurrent refiner.
808 ConcurrentG1Refine* _cg1r;
809
810 // The parallel task queues
811 RefToScanQueueSet *_task_queues;
812
813 // True iff a evacuation has failed in the current collection.
814 bool _evacuation_failed;
815
816 EvacuationFailedInfo* _evacuation_failed_info_array;
817
818 // Failed evacuations cause some logical from-space objects to have
819 // forwarding pointers to themselves. Reset them.
820 void remove_self_forwarding_pointers();
968 ReferenceProcessor* _ref_processor_cm;
969
970 // Instance of the concurrent mark is_alive closure for embedding
971 // into the Concurrent Marking reference processor as the
972 // _is_alive_non_header field. Supplying a value for the
973 // _is_alive_non_header field is optional but doing so prevents
974 // unnecessary additions to the discovered lists during reference
975 // discovery.
976 G1CMIsAliveClosure _is_alive_closure_cm;
977
978 // Cache used by G1CollectedHeap::start_cset_region_for_worker().
979 HeapRegion** _worker_cset_start_region;
980
981 // Time stamp to validate the regions recorded in the cache
982 // used by G1CollectedHeap::start_cset_region_for_worker().
983 // The heap region entry for a given worker is valid iff
984 // the associated time stamp value matches the current value
985 // of G1CollectedHeap::_gc_time_stamp.
986 uint* _worker_cset_start_region_time_stamp;
987
988 SubTasksDone* _process_strong_tasks;
989
990 volatile bool _free_regions_coming;
991
992
993 public:
994 enum G1H_process_roots_tasks {
995 G1H_PS_First,
996 G1H_PS_filter_satb_buffers = G1H_PS_First,
997 G1H_PS_refProcessor_oops_do,
998 G1H_PS_wait_strong_cld_nmethods,
999 G1H_PS_weak_clds_oops_do,
1000 // Leave this one last.
1001 G1H_PS_NumElements
1002 };
1003
1004 // Returns the number of external root tasks.
1005 static uint num_ext_root_tasks() { return G1H_PS_NumElements + SharedHeap::SH_PS_NumElements; }
1006 // Returns a human readable description of the given external root task.
1007 static const char* ext_roots_task_string(uint i);
1008
1009 SubTasksDone* process_strong_tasks() { return _process_strong_tasks; }
1010
1011 void set_refine_cte_cl_concurrency(bool concurrent);
1012
1013 RefToScanQueue *task_queue(int i) const;
1014
1015 // A set of cards where updates happened during the GC
1016 DirtyCardQueueSet& dirty_card_queue_set() { return _dirty_card_queue_set; }
1017
1018 // A DirtyCardQueueSet that is used to hold cards that contain
1019 // references into the current collection set. This is used to
1020 // update the remembered sets of the regions in the collection
1021 // set in the event of an evacuation failure.
1022 DirtyCardQueueSet& into_cset_dirty_card_queue_set()
1023 { return _into_cset_dirty_card_queue_set; }
1024
1025 // Create a G1CollectedHeap with the specified policy.
1026 // Must call the initialize method afterwards.
1027 // May not return if something goes wrong.
|