RFR: 8309685: Fix -Wconversion warnings in assembler and register code [v3]
Dean Long
dlong at openjdk.org
Thu Jun 15 02:09:59 UTC 2023
On Wed, 14 Jun 2023 21:25:37 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:
>> The conversion from an unsigned type to a smaller unsigned type should have just worked if you convert back, like the old checked_cast code did, but callers of emit_intxxx were sign extending so the conversion back didn't work.
>>
>> Calls like emit_int8() are passed arguments like 0xf0, but there were multiple (~940) that are passed with something that did some bitwise calculation that was promoted up to int.
>>
>> Maybe the emit_intxx functions should take signed int, and then I could just check range in the checked_cast() without converting the argument to signed. That might work and still provide the range checking that we want.
>>
>> Yes, it should be max-1. Thank you for looking at this.
>
> Changing checked_cast<> to not convert to a signed type for T1 leads to very puzzling compiler errors. For these emit_int8 etc functions, maybe a straight cast is the best thing, and leaving the definition checked_cast<> alone. I'd be happy to do that as I had in my first patch.
I don't know what checked_cast<> should do for negative values when going between signed --> unsigned and for values greater than signed max for unsigned --> signed. It seems like both should fail because the sign changes.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14396#discussion_r1230338467
More information about the hotspot-dev
mailing list