RFR: 8310537: Fix -Wconversion warnings in gcUtil.hpp

Axel Boldt-Christmas aboldtch at openjdk.org
Thu Jun 22 10:13:02 UTC 2023


On Wed, 21 Jun 2023 12:16:54 GMT, Coleen Phillimore <coleenp 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 89:

> 87:   // Now update the deviation and the padded average.
> 88:   float new_avg = average();
> 89:   float new_dev = compute_adaptive_average((float)fabsd(new_sample - new_avg),

Is JDK-6302670 still relevant, and/or are there other reasons we avoid `cmath`? This could just be `fabsf`

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)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14585#discussion_r1238307791
PR Review Comment: https://git.openjdk.org/jdk/pull/14585#discussion_r1238306747


More information about the hotspot-gc-dev mailing list