diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp index 8aaab14ad75..705dcd7895b 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp @@ -1004,7 +1004,7 @@ bool G1CollectedHeap::expand(size_t expand_bytes, WorkerThreads* pretouch_worker log_debug(gc, ergo, heap)("Expand the heap. requested expansion amount: %zuB expansion amount: %zuB", expand_bytes, aligned_expand_bytes); - if (is_maximal_no_gc()) { + if (num_inactive_regions() == 0) { log_debug(gc, ergo, heap)("Did not expand the heap (heap already fully expanded)"); return false; } @@ -1031,7 +1031,7 @@ bool G1CollectedHeap::expand_single_region(uint node_index) { uint expanded_by = _hrm.expand_on_preferred_node(node_index); if (expanded_by == 0) { - assert(is_maximal_no_gc(), "Should be no regions left, available: %u", _hrm.num_inactive_regions()); + assert(num_inactive_regions() == 0, "Should be no regions left, available: %u", num_inactive_regions()); log_debug(gc, ergo, heap)("Did not expand the heap (heap already fully expanded)"); return false; } diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp index 965d01c7089..fbd1fe6165f 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.hpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.hpp @@ -966,16 +966,15 @@ public: // end fields defining the extent of the contiguous allocation region.) // But G1CollectedHeap doesn't yet support this. - bool is_maximal_no_gc() const { - return _hrm.num_inactive_regions() == 0; - } - // Returns true if an incremental GC should be upgrade to a full gc. This // is done when there are no free regions and the heap can't be expanded. bool should_upgrade_to_full_gc() const { - return is_maximal_no_gc() && num_free_regions() == 0; + return num_inactive_regions() == 0 && num_free_regions() == 0; } + // The number of inactive regions. + uint num_inactive_regions() const { return _hrm.num_inactive_regions(); } + // The current number of regions in the heap. uint num_committed_regions() const { return _hrm.num_committed_regions(); }