RFR: 8359678: C2: assert(static_cast<T1>(result) == thing) caused by ReverseBytesNode::Value() [v3]

Hannes Greule hgreule at openjdk.org
Sat Jul 12 08:16:25 UTC 2025


On Tue, 8 Jul 2025 07:40:02 GMT, Hannes Greule <hgreule at openjdk.org> wrote:

>> Fixes an assertion when passing an int larger than short/char to the corresponding reverseBytes method in a constant-folding scenario. By just using static_cast, we can ignore the upper bytes and just swap the lower bytes.
>> 
>> Using jasm, I added a test case that covers such inputs. It felt easier to test this way than the other scenarios mentioned in the bug report.
>> 
>> I also removed the redundant checked_cast calls from the int/long case; we already have the correct type there.
>> 
>> Please review. Thanks.
>
> Hannes Greule has updated the pull request incrementally with one additional commit since the last revision:
> 
>   re-add package, add methods to Run annotation

Oh I see, that explains why I didn't run into that problem testing on my x86 machine :) The `Short.valueOf(short)` case doesn't crash because the method checks the lower bound too, it's just that `Character.valueOf(char)` assumes that the given value is >= 0 and therefore accesses the array if the value actually is < 0.

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

PR Comment: https://git.openjdk.org/jdk/pull/25988#issuecomment-3064923635


More information about the hotspot-compiler-dev mailing list