8358483: G1: Remove G1HeapRegionManager::num_available_regions

Reviewed-by: tschatzl, sangheki
This commit is contained in:
Albert Mingkun Yang 2025-06-13 08:03:33 +00:00
parent a8b4284848
commit 032ead1d90
4 changed files with 6 additions and 9 deletions

View File

@ -347,6 +347,10 @@ HeapWord* G1CollectedHeap::humongous_obj_allocate(size_t word_size) {
_verifier->verify_region_sets_optional();
uint obj_regions = (uint) humongous_obj_size_in_regions(word_size);
if (obj_regions > num_available_regions()) {
// Can't satisfy this allocation; early-return.
return nullptr;
}
// Policy: First try to allocate a humongous object in the free list.
G1HeapRegion* humongous_start = _hrm.allocate_humongous(obj_regions);

View File

@ -969,7 +969,7 @@ public:
// 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 num_inactive_regions() == 0 && num_free_regions() == 0;
return num_available_regions() == 0;
}
// The number of inactive regions.
@ -988,13 +988,12 @@ public:
uint num_used_regions() const { return _hrm.num_used_regions(); }
// The number of regions that can be allocated into.
uint num_available_regions() const { return _hrm.num_available_regions(); }
uint num_available_regions() const { return num_free_regions() + num_inactive_regions(); }
MemoryUsage get_auxiliary_data_memory_usage() const {
return _hrm.get_auxiliary_data_memory_usage();
}
#ifdef ASSERT
bool is_on_master_free_list(G1HeapRegion* hr) {
return _hrm.is_free(hr);

View File

@ -477,10 +477,6 @@ uint G1HeapRegionManager::find_contiguous_in_free_list(uint num_regions) {
}
uint G1HeapRegionManager::find_contiguous_allow_expand(uint num_regions) {
// Check if we can actually satisfy the allocation.
if (num_regions > num_available_regions()) {
return G1_NO_HRM_INDEX;
}
// Find any candidate.
return find_contiguous_in_range(0, max_num_regions(), num_regions);
}

View File

@ -239,8 +239,6 @@ public:
// The number of regions reserved for the heap.
uint max_num_regions() const { return (uint)_regions.length(); }
uint num_available_regions() const { return num_free_regions() + num_inactive_regions(); }
MemoryUsage get_auxiliary_data_memory_usage() const;
MemRegion reserved() const { return MemRegion(heap_bottom(), heap_end()); }