RFR: 8310537: Fix -Wconversion warnings in gcUtil.hpp
Coleen Phillimore
coleenp at openjdk.org
Thu Jun 22 12:11:14 UTC 2023
On Thu, 22 Jun 2023 10:06:22 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:
>> Please review small changes to fix -Wconversion warnings in gc code. See CR for details.
>> Tested with tier1 on Oracle platforms.
>
> src/hotspot/share/gc/shared/gcUtil.cpp line 122:
>
>> 120: _sum_xy = _sum_xy + x * y;
>> 121: _mean_x.sample((float)x);
>> 122: _mean_y.sample((float)y);
>
> If this narrowed more than some small epsilon the behaviour would be strange. Seems like the actual interface here should be to sample float precision `x` and `y`. (`void LinearLeastSquareFit::update(float x, float y)`)
>
> I have no objection for doing it this way, just an observation of `LinearLeastSquareFit`
>
> I know from my own experiments with `-Wconversions` that we have many areas where it is the interface that seems wrong. (Sometimes moving from int -> long -> int -> long, just to fit different subcomponent interfaces)
Oh you've had experiences with -Wconversions? Thank you, I can ask you questions. I've tried to fix the interface when possible to be more precise with int types. In this case, it was float so not as sure if this is the right thing to do. I'm not sure I understand your comment. LinearLeastSquare fit seems determined to take double, and AdaptiveWeightedAverage uses float. I'm not sure how to change this to make it safer. My usual strategy would be to make the AdaptiveWeightedAverage take double but then the fall out from that would be more than I can deal with. What do you think?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14585#discussion_r1238435189
More information about the hotspot-gc-dev
mailing list