Skip to content

Commit fa40a96

Browse files
albertnetymkkstefanj
authored andcommitted
8253420: Refactor HeapRegionManager::find_highest_free
Reviewed-by: sjohanss, kbarrett
1 parent 4d004c9 commit fa40a96

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/hotspot/share/gc/g1/heapRegionManager.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,7 @@ uint HeapRegionManager::find_highest_free(bool* expanded) {
537537
// Loop downwards from the highest region index, looking for an
538538
// entry which is either free or not yet committed. If not yet
539539
// committed, expand at that index.
540-
uint curr = reserved_length() - 1;
541-
while (true) {
540+
for (uint curr = reserved_length(); curr-- > 0;) {
542541
HeapRegion *hr = _regions.get_by_index(curr);
543542
if (hr == NULL || !is_available(curr)) {
544543
// Found uncommitted and free region, expand to make it available for use.
@@ -547,17 +546,13 @@ uint HeapRegionManager::find_highest_free(bool* expanded) {
547546

548547
*expanded = true;
549548
return curr;
550-
} else {
551-
if (hr->is_free()) {
552-
*expanded = false;
553-
return curr;
554-
}
555549
}
556-
if (curr == 0) {
557-
return G1_NO_HRM_INDEX;
550+
if (hr->is_free()) {
551+
*expanded = false;
552+
return curr;
558553
}
559-
curr--;
560554
}
555+
return G1_NO_HRM_INDEX;
561556
}
562557

563558
bool HeapRegionManager::allocate_containing_regions(MemRegion range, size_t* commit_count, WorkGang* pretouch_workers) {

0 commit comments

Comments
 (0)