RFR: 8309685: Fix -Wconversion warnings in assembler and register code
Coleen Phillimore
coleenp at openjdk.org
Tue Jun 13 14:24:04 UTC 2023
On Tue, 13 Jun 2023 06:04:51 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
>> This change widens some int arguments, narrows some int returns and adds some casts and checked_casts where the compiler was doing the implicit conversion. I maintained existing types - ie if the parameter was short, I used a cast to short. Also int is used in places that might be better served as unsigned int but I didn't fix that because it would be too large and risky. The registers encode an offset in an array, so it's safe to checked_cast<> to get their encoding. This fix is limited so that the types changed and casts added are intentional.
>> See CR for counts of -Wconversion warnings this resolves.
>> Tested with tier1-7, also tested with tier1 on all Oracle supported platforms.
>
> src/hotspot/share/code/vmreg.cpp line 33:
>
>> 31: // "know" that stack0 is an integer masquerading as a pointer. For the
>> 32: // sake of those clients, we preserve this interface.
>> 33: VMReg VMRegImpl::stack0 = (VMReg)(intptr_t)VMRegImpl::stack_0()->value();
>
> So enlighten me - why the two-step cast?
I changed value() to return an int rather than intptr_t, so the compiler objects:
src/hotspot/share/code/vmreg.cpp:33:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
33 | VMReg VMRegImpl::stack0 = (VMReg)VMRegImpl::stack_0()->value();
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14396#discussion_r1228209685
More information about the hotspot-dev
mailing list