RFR: 8328626: GenShen: Combine old generation surplus/deficit fields into a single balance field [v2]

William Kemper wkemper at openjdk.org
Mon Mar 25 16:15:44 UTC 2024


On Fri, 22 Mar 2024 22:42:45 GMT, Kelvin Nilsen <kdnilsen at openjdk.org> wrote:

>> William Kemper has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - Fix zero build
>>  - Fix comments
>
> src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp line 128:
> 
>> 126: 
>> 127:   if (old_region_balance > 0) {
>> 128:     const auto old_region_surplus = checked_cast<size_t>(old_region_balance);
> 
> Just curious: what happens with a checked_cast<size_t> if old_region_balance < 0.  (I see that's impossible here, but what is the point of declaring checked_cast?)

`checked_cast` asserts that the cast did not change the value, defined here: https://github.com/openjdk/shenandoah/blob/master/src/hotspot/share/utilities/checkedCast.hpp#L39. If `old_region_balance` were less than zero, it would assert out. It will also assert out if `old_region_balance` were greater than `SSIZE_MAX`. Which is unlikely, but there is no harm in checking.

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

PR Review Comment: https://git.openjdk.org/shenandoah/pull/410#discussion_r1537855598


More information about the shenandoah-dev mailing list