RFR: 8310606: Fix signed integer overflow, part 3

Andrew Haley aph at openjdk.org
Fri Jun 23 17:49:05 UTC 2023


On Fri, 23 Jun 2023 17:43:00 GMT, Andrew Haley <aph at openjdk.org> wrote:

>> Most of these changes are straight-forward, but these could use some explaining:
>> 
>> AllocatePrefetchDistance was accessed before it's dynamic constraint function got run.  I changed it to use static constraints.
>> 
>> RangeCheckEliminator::update_bound(): for constant bounds with meaningless values, bail out.  For X + c bounds, use Java wrap-around semantics.
>
> src/hotspot/share/jfr/leakprofiler/utilities/granularTimer.cpp line 41:
> 
>> 39:   const julong end_time_ticks = (julong)_start_time_ticks.value() + (julong)duration_ticks;
>> 40:   _finish_time_ticks = end_time_ticks > (julong)max_jlong ? JfrTicks(max_jlong) : JfrTicks(end_time_ticks);
>> 41:   _finished = _finish_time_ticks == _start_time_ticks;
> 
> Isn't there a much better way to fix this?

If you change 

`if (JfrTicks::now() > _finish_time_ticks) {`

to

`if (JfrTicks::now() - _finish_time_ticks > 0) {`

you get natural wrap-around semantics. As long as the total interval is less than half the total julong range. And you don't need to worry about `max_jlong`, etc.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14619#discussion_r1240108771


More information about the hotspot-dev mailing list