RFR: 8308975: Fix signed integer overflow in compiler code, part 2 [v2]

Dean Long dlong at openjdk.org
Tue May 30 23:57:59 UTC 2023


On Tue, 30 May 2023 20:58:00 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> Dean Long has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - use uint64_t for nanos
>>  - fix alignment
>
> 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.

I did it this way on purpose, because it makes more sense to me to do the `+` as `uint` rather than `uintptr_t`.  The `uintptr_t` is there only because the fields are pointers, but the hash function doesn't need to do 64-bit `+` on a 64-bit platform, though I guess it wouldn't hurt either.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14188#discussion_r1210946793


More information about the hotspot-dev mailing list