RFR: 8253420: Refactor HeapRegionManager::find_highest_free

Albert Mingkun Yang ayang at openjdk.java.net
Fri Jan 22 21:08:41 UTC 2021


On Fri, 22 Jan 2021 20:46:46 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> Using for-loop to make the number of iterations more explicit. Direct backward iteration, `for (uint curr = reserved_length() - 1; curr >= 0; curr--)` doesn't work due to underflow of `uint` type. Therefore, I went for current approach.
>> 
>> Test: hotspot_gc
>
> 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`?

-------------

PR: https://git.openjdk.java.net/jdk/pull/2193



More information about the hotspot-gc-dev mailing list