RFR: 8324833: Signed integer overflows in ABS [v2]
Dean Long
dlong at openjdk.org
Thu Feb 1 20:28:03 UTC 2024
On Wed, 31 Jan 2024 15:55:25 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
>> See the details in the bug. I think current `ABS` implementation is beyond repair, and we should just switch to `uabs`.
>>
>> Additional testing:
>> - [x] Linux x86_64 fastdebug, `all` with `-ftrapv` (now fully passes!)
>> - [x] Linux x86_64 fastdebug, `all`
>
> Aleksey Shipilev has updated the pull request incrementally with one additional commit since the last revision:
>
> Unnecessary comment
src/hotspot/share/jvmci/jvmciCompilerToVM.cpp line 1063:
> 1061: int64_t off_low = (int64_t)target_addr - ((int64_t)CodeCache::low_bound() + sizeof(int));
> 1062: int64_t off_high = (int64_t)target_addr - ((int64_t)CodeCache::high_bound() + sizeof(int));
> 1063: return MAX2(ABS(off_low), ABS(off_high));
Wouldn't this trigger a warning with -Wsign-conversion enabled?
src/hotspot/share/opto/ifnode.cpp line 1978:
> 1976: // "x - y" -> must add one to the difference for number of elements in [x,y]
> 1977: const jlong diff = (jlong)MIN2(offset2, off_lo) - (jlong)MAX2(offset2, off_hi);
> 1978: if (uabs(diff) < maximum_number_of_min_max_interval_indices) {
unsigned vs signed comparison. Maybe the rhs should be unsigned as well?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17617#discussion_r1475100564
PR Review Comment: https://git.openjdk.org/jdk/pull/17617#discussion_r1475102253
More information about the graal-dev
mailing list