From f37674a8f7efb4304683dacc855f940be2768a09 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Thu, 23 Mar 2023 19:14:24 +0000 Subject: [PATCH] 8304711: Combine G1 root region abort and wait into a single method Reviewed-by: ayang, iwalulya --- src/hotspot/share/gc/g1/g1ConcurrentMark.cpp | 8 ++++++-- src/hotspot/share/gc/g1/g1ConcurrentMark.hpp | 9 +++++---- src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp | 3 +-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp index 7f2cbcd475e..a62bfd88819 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp @@ -994,6 +994,11 @@ void G1ConcurrentMark::add_root_region(HeapRegion* r) { root_regions()->add(r->top_at_mark_start(), r->top()); } +void G1ConcurrentMark::root_region_scan_abort_and_wait() { + root_regions()->abort(); + root_regions()->wait_until_scan_finished(); +} + void G1ConcurrentMark::concurrent_cycle_start() { _gc_timer_cm->register_gc_start(); @@ -2000,8 +2005,7 @@ bool G1ConcurrentMark::concurrent_cycle_abort() { // be moving objects / updating references. So let's wait until // they are done. By telling them to abort, they should complete // early. - root_regions()->abort(); - root_regions()->wait_until_scan_finished(); + root_region_scan_abort_and_wait(); // We haven't started a concurrent cycle no need to do anything; we might have // aborted the marking because of shutting down though. In this case the marking diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp index 0afa6bd3e75..187eaf1c2ca 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.hpp @@ -219,14 +219,14 @@ private: // Typically they contain the areas from TAMS to top of the regions. // We could scan and mark through these objects during the concurrent start pause, // but for pause time reasons we move this work to the concurrent phase. -// 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. +// We need to complete this procedure before we can evacuate a particular region +// because evacuation might determine that some of these "root objects" are dead, +// potentially dropping some required references. // Root MemRegions comprise of the contents of survivor regions at the end // of the GC, and any objects copied into the old gen during GC. class G1CMRootMemRegions { // The set of root MemRegions. - MemRegion* _root_regions; + MemRegion* _root_regions; size_t const _max_regions; volatile size_t _num_root_regions; // Actual number of root regions. @@ -557,6 +557,7 @@ public: void scan_root_regions(); bool wait_until_root_region_scan_finished(); void add_root_region(HeapRegion* r); + void root_region_scan_abort_and_wait(); private: G1CMRootMemRegions* root_regions() { return &_root_regions; } diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp index 996fe345f85..a04cea5e87b 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp @@ -142,8 +142,7 @@ void G1ConcurrentMarkThread::stop_service() { if (in_progress()) { // We are not allowed to abort the marking threads during root region scan. // Needs to be done separately. - _cm->root_regions()->abort(); - _cm->root_regions()->wait_until_scan_finished(); + _cm->root_region_scan_abort_and_wait(); _cm->abort_marking_threads(); }