RFR: 8324649: Shenandoah: refactor implementation of free set [v4]

Y. Srinivas Ramakrishna ysr at openjdk.org
Wed Jan 31 17:36:06 UTC 2024


On Wed, 31 Jan 2024 00:56:41 GMT, Kelvin Nilsen <kdnilsen at openjdk.org> wrote:

>> src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp line 423:
>> 
>>> 421:       // Allocate within mutator free from high memory to low so as to preserve low memory for humongous allocations
>>> 422:       if (!_free_sets.is_empty(Mutator)) {
>>> 423:         // Use signed idx.  Otherwise, loop will never terminate.
>> 
>> Can you use `ssize_t` for the index and the return values from the methods? (I assume the problem you have in mind arises when `leftmost` below is 0?
>
> The problem happens when leftmost is zero.  If we decrement idx beyond zero, we would get MAXINT rather than -1, so the test that idx >= leftmost is always true and loop never terminates...  I think I discovered this the hard way... :(

`ssize_t` is signed, unlike `size_t` which is unsigned.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17561#discussion_r1473201175


More information about the hotspot-gc-dev mailing list