RFR: 8253420: Refactor HeapRegionManager::find_highest_free
Stefan Johansson
sjohanss at openjdk.java.net
Sat Jan 23 14:05:38 UTC 2021
On Fri, 22 Jan 2021 21:05:27 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:
>> src/hotspot/share/gc/g1/heapRegionManager.cpp line 541:
>>
>>> 539: // committed, expand at that index.
>>> 540: for (uint i = 0; i < reserved_length(); ++i) {
>>> 541: uint curr = reserved_length() - 1 - i;
>>
>> Maybe this instead?
>> for (uint curr = reserved_length(); curr-- > 0; ) {
>
> I would prefer not having side effect in the condition. At first glance, it's not obvious how many iteration the loop entails, `length` or `length - 1`?
Avoiding side effects is normally good, but in this case I think it actually make the whole intent of the code clearer. We could add to the comment that we loop backwards through all reserved regions to make it clear what the bound is.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2193
More information about the hotspot-gc-dev
mailing list