RFR: 8308975: Fix signed integer overflow in compiler code, part 2 [v2]
Coleen Phillimore
coleenp at openjdk.org
Tue May 30 21:12:56 UTC 2023
On Tue, 30 May 2023 17:38:41 GMT, Dean Long <dlong at openjdk.org> wrote:
>> This is a followup from part 1. I had to use java_add/subtract/multiply/negate in a few more places.
>> cpu_loads_process had an overflow on BSD when the first snapshot is relative to the epoch in 1970.
>> Use unsigned for C2 Type hash functions.
>
> Dean Long has updated the pull request incrementally with two additional commits since the last revision:
>
> - use uint64_t for nanos
> - fix alignment
There's one cast that I think you should fix.
src/hotspot/share/opto/type.cpp line 2279:
> 2277: for( uint i=0; i<_cnt; i++ )
> 2278: sum += (uintptr_t)_fields[i]; // Hash on pointers directly
> 2279: return sum;
This looks like it's going to get a -Wconversion warning if we had them on - I think "sum" needs to be cast to uint.
src/hotspot/share/opto/type.cpp line 2579:
> 2577: // Type-specific hashing function.
> 2578: uint TypeVect::hash(void) const {
> 2579: return (uint)(uintptr_t)_elem + (uint)(uintptr_t)_length;
I think you might want (uint)((uintptr_t)_elem + _length); I think _length will promote to the uintptr_t from its declared type uint without warning.
-------------
PR Review: https://git.openjdk.org/jdk/pull/14188#pullrequestreview-1451804079
PR Review Comment: https://git.openjdk.org/jdk/pull/14188#discussion_r1210814371
PR Review Comment: https://git.openjdk.org/jdk/pull/14188#discussion_r1210817567
More information about the hotspot-dev
mailing list