RFR: 8308975: Fix signed integer overflow in compiler code, part 2
Coleen Phillimore
coleenp at openjdk.org
Tue May 30 12:07:55 UTC 2023
On Fri, 26 May 2023 22:20:17 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.
I wandered into this wondering if -Wconversion would have found these signed integer overflow but it looks like maybe -Wsign-conversion might have found this? We've been enabling these flags and disabling -Werror and searching the result of the build.
src/hotspot/os/bsd/os_perf_bsd.cpp line 173:
> 171: result = OS_ERR;
> 172: } else {
> 173: long delta_nanos = active_processor_count * (total_cpu_nanos - _total_cpu_nanos);
We shouldn't use 'long' in the source code even though long is always 64 bits on bsd and this is specific to that, we often scan for this as a potential error since it's 32 bits on Windows. int64_t is preferable. Can you use that?
src/hotspot/share/opto/type.hpp line 525:
> 523: public:
> 524: virtual bool eq( const Type *t ) const;
> 525: virtual uint hash() const; // Type specific hashing
nit: align hash to singleton (a few places)
-------------
PR Review: https://git.openjdk.org/jdk/pull/14188#pullrequestreview-1450763238
PR Review Comment: https://git.openjdk.org/jdk/pull/14188#discussion_r1210162360
PR Review Comment: https://git.openjdk.org/jdk/pull/14188#discussion_r1210164058
More information about the hotspot-dev
mailing list