--- old/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp 2019-06-04 13:17:00.188651314 -0700 +++ new/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp 2019-06-04 13:16:59.940651323 -0700 @@ -222,7 +222,7 @@ template void iterate(Fn fn) const PRODUCT_RETURN; }; -// Root Regions are regions that contain objects from nTAMS to top. These are roots +// Root MemRegions are memory regions that contain objects from nTAMS to top. These are roots // for marking, i.e. their referenced objects must be kept alive to maintain the // SATB invariant. // We could scan and mark them through during the initial-mark pause, but for @@ -230,10 +230,13 @@ // We need to complete this procedure before the next GC because it might determine // that some of these "root objects" are dead, potentially dropping some required // references. -// Root regions comprise of the complete contents of survivor regions, and any +// Root MemRegions comprise of the complete contents of survivor regions, and any // objects copied into old gen during GC. -class G1CMRootRegions { - HeapRegion** _root_regions; +class G1CMRootMemRegions { + // The set of root MemRegions. We store the corresponding nTAMS and top() pointer + // for a given heap region into MemRegion to know the exact area to scan because + // the top of a reused survivor region changes over time. + MemRegion* _root_regions; size_t const _max_regions; volatile size_t _num_root_regions; // Actual number of root regions. @@ -246,13 +249,13 @@ void notify_scan_done(); public: - G1CMRootRegions(uint const max_regions); - ~G1CMRootRegions(); + G1CMRootMemRegions(uint const max_regions); + ~G1CMRootMemRegions(); // Reset the data structure to allow addition of new root regions. void reset(); - void add(HeapRegion* hr); + void add(HeapWord* start, HeapWord* end); // Reset the claiming / scanning of the root regions. void prepare_for_scan(); @@ -264,9 +267,9 @@ // false otherwise. bool scan_in_progress() { return _scan_in_progress; } - // Claim the next root region to scan atomically, or return NULL if + // Claim the next root MemRegion to scan atomically, or return NULL if // all have been claimed. - HeapRegion* claim_next(); + MemRegion* claim_next(); // The number of root regions to scan. uint num_root_regions() const; @@ -310,7 +313,7 @@ MemRegion const _heap; // Root region tracking and claiming - G1CMRootRegions _root_regions; + G1CMRootMemRegions _root_regions; // For grey objects G1CMMarkStack _global_mark_stack; // Grey objects behind global finger @@ -501,7 +504,7 @@ size_t partial_mark_stack_size_target() const { return _global_mark_stack.capacity() / 3; } bool mark_stack_empty() const { return _global_mark_stack.is_empty(); } - G1CMRootRegions* root_regions() { return &_root_regions; } + G1CMRootMemRegions* root_regions() { return &_root_regions; } void concurrent_cycle_start(); // Abandon current marking iteration due to a Full GC. @@ -554,8 +557,8 @@ // them. void scan_root_regions(); - // Scan a single root region from nTAMS to top and mark everything reachable from it. - void scan_root_region(HeapRegion* hr, uint worker_id); + // Scan a single root MemRegion which holds from nTAMS to top and mark everything reachable from it. + void scan_root_region(MemRegion* region, uint worker_id); // Do concurrent phase of marking, to a tentative transitive closure. void mark_from_roots();