RFR: 8313882: Fix -Wconversion warnings in runtime code [v2]
Dean Long
dlong at openjdk.org
Tue Aug 8 22:03:33 UTC 2023
On Tue, 8 Aug 2023 20:09:56 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:
>> Here are fixes to silence -Wconversion warnings in runtime code. Use direct cast for 64 bit int to double, otherwise default to checked_cast<>. I changed the declaration of _held_monitor_count and _jni_monitor count to intx to fix cascade of warnings coming from this.
>>
>> src/hotspot/share/runtime/synchronizer.cpp:1802:41: warning: conversion from 'intx' {aka 'long int'} to 'int' may change value [-Wconversion]
>> 1802 | _thread->dec_held_monitor_count(rec + 1);
>> | ~~~~^~~
>>
>> Tested with tier1-4 on linux-x64-debug and windows-x64-debug and tier1 on Oracle supported platforms.
>
> Coleen Phillimore has updated the pull request incrementally with one additional commit since the last revision:
>
> Make bytecode.hpp index() functions return u2 not long.
src/hotspot/share/runtime/objectMonitor.hpp line 238:
> 236: //
> 237: #define OM_OFFSET_NO_MONITOR_VALUE_TAG(f) \
> 238: ((in_bytes(ObjectMonitor::f ## _offset())) - (unsigned)markWord::monitor_value)
This makes it int vs uint (-Wsign-conversion warning), and assumes the range of monitor_value.
One option is to narrow the type of monitor_value. Option 2, cast the lhs to uintptr_t. Option 3, use offset_of instead of signed ByteSize.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15177#discussion_r1287727808
More information about the hotspot-dev
mailing list