Skip to content

Commit 8e16e67

Browse files
author
Ivan Walulya
committedOct 17, 2024
8342329: G1: Rename G1HeapRegionManager::_allocated_heapregions_length
Reviewed-by: tschatzl, shade
1 parent 3ebfc6c commit 8e16e67

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed
 

‎src/hotspot/share/gc/g1/g1HeapRegionManager.cpp

+17-17
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ G1HeapRegionManager::G1HeapRegionManager() :
6666
_bot_mapper(nullptr),
6767
_cardtable_mapper(nullptr),
6868
_committed_map(),
69-
_allocated_heapregions_length(0),
69+
_next_highest_used_hrm_index(0),
7070
_regions(), _heap_mapper(nullptr),
7171
_bitmap_mapper(nullptr),
7272
_free_list("Free list", new G1MasterFreeRegionListChecker())
@@ -76,7 +76,7 @@ void G1HeapRegionManager::initialize(G1RegionToSpaceMapper* heap_storage,
7676
G1RegionToSpaceMapper* bitmap,
7777
G1RegionToSpaceMapper* bot,
7878
G1RegionToSpaceMapper* cardtable) {
79-
_allocated_heapregions_length = 0;
79+
_next_highest_used_hrm_index = 0;
8080

8181
_heap_mapper = heap_storage;
8282

@@ -169,7 +169,7 @@ void G1HeapRegionManager::expand(uint start, uint num_regions, WorkerThreads* pr
169169
hr = new_heap_region(i);
170170
OrderAccess::storestore();
171171
_regions.set_by_index(i, hr);
172-
_allocated_heapregions_length = MAX2(_allocated_heapregions_length, i + 1);
172+
_next_highest_used_hrm_index = MAX2(_next_highest_used_hrm_index, i + 1);
173173
}
174174
G1HeapRegionPrinter::commit(hr);
175175
}
@@ -489,7 +489,7 @@ uint G1HeapRegionManager::find_contiguous_allow_expand(uint num_regions) {
489489
G1HeapRegion* G1HeapRegionManager::next_region_in_heap(const G1HeapRegion* r) const {
490490
guarantee(r != nullptr, "Start region must be a valid region");
491491
guarantee(is_available(r->hrm_index()), "Trying to iterate starting from region %u which is not in the heap", r->hrm_index());
492-
for (uint i = r->hrm_index() + 1; i < _allocated_heapregions_length; i++) {
492+
for (uint i = r->hrm_index() + 1; i < _next_highest_used_hrm_index; i++) {
493493
G1HeapRegion* hr = _regions.get_by_index(i);
494494
if (is_available(i)) {
495495
return hr;
@@ -583,16 +583,16 @@ void G1HeapRegionManager::par_iterate(G1HeapRegionClosure* blk, G1HeapRegionClai
583583

584584
uint G1HeapRegionManager::shrink_by(uint num_regions_to_remove) {
585585
assert(length() > 0, "the region sequence should not be empty");
586-
assert(length() <= _allocated_heapregions_length, "invariant");
587-
assert(_allocated_heapregions_length > 0, "we should have at least one region committed");
586+
assert(length() <= _next_highest_used_hrm_index, "invariant");
587+
assert(_next_highest_used_hrm_index > 0, "we should have at least one region committed");
588588
assert(num_regions_to_remove < length(), "We should never remove all regions");
589589

590590
if (num_regions_to_remove == 0) {
591591
return 0;
592592
}
593593

594594
uint removed = 0;
595-
uint cur = _allocated_heapregions_length;
595+
uint cur = _next_highest_used_hrm_index;
596596
uint idx_last_found = 0;
597597
uint num_last_found = 0;
598598

@@ -624,7 +624,7 @@ void G1HeapRegionManager::shrink_at(uint index, size_t num_regions) {
624624
}
625625

626626
uint G1HeapRegionManager::find_empty_from_idx_reverse(uint start_idx, uint* res_idx) const {
627-
guarantee(start_idx <= _allocated_heapregions_length, "checking");
627+
guarantee(start_idx <= _next_highest_used_hrm_index, "checking");
628628
guarantee(res_idx != nullptr, "checking");
629629

630630
auto is_available_and_empty = [&] (uint index) {
@@ -658,20 +658,20 @@ uint G1HeapRegionManager::find_empty_from_idx_reverse(uint start_idx, uint* res_
658658
}
659659

660660
void G1HeapRegionManager::verify() {
661-
guarantee(length() <= _allocated_heapregions_length,
662-
"invariant: _length: %u _allocated_length: %u",
663-
length(), _allocated_heapregions_length);
664-
guarantee(_allocated_heapregions_length <= reserved_length(),
665-
"invariant: _allocated_length: %u _max_length: %u",
666-
_allocated_heapregions_length, reserved_length());
661+
guarantee(length() <= _next_highest_used_hrm_index,
662+
"invariant: _length: %u _next_highest_used_hrm_index: %u",
663+
length(), _next_highest_used_hrm_index);
664+
guarantee(_next_highest_used_hrm_index <= reserved_length(),
665+
"invariant: _next_highest_used_hrm_index: %u _max_length: %u",
666+
_next_highest_used_hrm_index, reserved_length());
667667
guarantee(length() <= max_length(),
668668
"invariant: committed regions: %u max_regions: %u",
669669
length(), max_length());
670670

671671
bool prev_committed = true;
672672
uint num_committed = 0;
673673
HeapWord* prev_end = heap_bottom();
674-
for (uint i = 0; i < _allocated_heapregions_length; i++) {
674+
for (uint i = 0; i < _next_highest_used_hrm_index; i++) {
675675
if (!is_available(i)) {
676676
prev_committed = false;
677677
continue;
@@ -693,7 +693,7 @@ void G1HeapRegionManager::verify() {
693693
prev_committed = true;
694694
prev_end = hr->end();
695695
}
696-
for (uint i = _allocated_heapregions_length; i < reserved_length(); i++) {
696+
for (uint i = _next_highest_used_hrm_index; i < reserved_length(); i++) {
697697
guarantee(_regions.get_by_index(i) == nullptr, "invariant i: %u", i);
698698
}
699699

@@ -708,7 +708,7 @@ void G1HeapRegionManager::verify_optional() {
708708
#endif // PRODUCT
709709

710710
G1HeapRegionClaimer::G1HeapRegionClaimer(uint n_workers) :
711-
_n_workers(n_workers), _n_regions(G1CollectedHeap::heap()->_hrm._allocated_heapregions_length), _claims(nullptr) {
711+
_n_workers(n_workers), _n_regions(G1CollectedHeap::heap()->_hrm._next_highest_used_hrm_index), _claims(nullptr) {
712712
uint* new_claims = NEW_C_HEAP_ARRAY(uint, _n_regions, mtGC);
713713
memset(new_claims, Unclaimed, sizeof(*_claims) * _n_regions);
714714
_claims = new_claims;

‎src/hotspot/share/gc/g1/g1HeapRegionManager.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ class G1HeapRegionTable : public G1BiasedMappedArray<G1HeapRegion*> {
6464
//
6565
// * _num_committed (returned by length()) is the number of currently
6666
// committed regions. These may not be contiguous.
67-
// * _allocated_heapregions_length (not exposed outside this class) is the
68-
// number of regions+1 for which we have G1HeapRegions.
67+
// * _next_highest_used_hrm_index (not exposed outside this class) is the
68+
// highest heap region index +1 for which we have G1HeapRegions.
6969
// * max_length() returns the maximum number of regions the heap may commit.
7070
// * reserved_length() returns the maximum number of regions the heap has reserved.
7171
//
@@ -81,8 +81,8 @@ class G1HeapRegionManager: public CHeapObj<mtGC> {
8181
// can either be active (ready for use) or inactive (ready for uncommit).
8282
G1CommittedRegionMap _committed_map;
8383

84-
// Internal only. The highest heap region +1 we allocated a G1HeapRegion instance for.
85-
uint _allocated_heapregions_length;
84+
// Internal only. The highest heap region index +1 we allocated a G1HeapRegion instance for.
85+
uint _next_highest_used_hrm_index;
8686

8787
HeapWord* heap_bottom() const { return _regions.bottom_address_mapped(); }
8888
HeapWord* heap_end() const {return _regions.end_address_mapped(); }

0 commit comments

Comments
 (0)
Please sign in to comment.