RFR: 8310675: Fix -Wconversion warnings in ZGC code

Stefan Karlsson stefank at openjdk.org
Tue Aug 6 14:24:32 UTC 2024


On Wed, 31 Jul 2024 13:01:50 GMT, Joel Sikström <duke at openjdk.org> wrote:

> Fixed `-Wconversion` warnings in ZGC code, either by adding an explicit type cast, changin the type of the variable or calling an equivalent method with other types. The largest change is the addition of `ZStatDurationSample`, which typecasts `Tickspan::value()` to a `uint64_t` and calls `ZStatSample` to make the code more readable.
> 
> I isolated the `-Wconversion` warnings for ZGC by adding the flag to clangd and displaying the errors in my IDE and going through each file directly associated with ZGC one by one.
> 
> Tested with tiers 1-3.

This change looks good to me.

I've looked through the code with Joel and I think that this is good set of changes to the ZGC code base. When fixing -Wconversion warnings there are always multiple ways to juggle around the types. Some of the added casts could probably be cleaned up by updating non-ZGC code instead (E.g. TimeHelper), but for Joel's first patch we wanted to limit the changes to the ZGC code base.

Note that we're intentionally only fixing the Generational ZGC code  and leaving the single-generation code left as is.

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

Marked as reviewed by stefank (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/20406#pullrequestreview-2221462496


More information about the hotspot-gc-dev mailing list