RFR: 8311583: tableswitch broken by JDK-8310577 [v2]

Dean Long dlong at openjdk.org
Tue Jul 11 01:12:08 UTC 2023


On Fri, 7 Jul 2023 16:59:12 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> src/hotspot/share/interpreter/bytecodes.cpp line 390:
>> 
>>> 388:       // Promote calculation to 64 bits to do range checks, used by the verifier.
>>> 389:       int64_t lo = (int)Bytes::get_Java_u4(aligned_bcp + 1*jintSize);
>>> 390:       int64_t hi = (int)Bytes::get_Java_u4(aligned_bcp + 2*jintSize);
>> 
>> Are the int casts needed?
>
> Yes they are.    get_Java_u4 returns u4 (unsigned) and the 'int' cast sign extends it to int, then further sign extended to int64_t for the length calculation.  The tableswitch bytecode operands are signed int.
> 
> 
> static inline u4   get_Java_u4(address p)           { return get_Java<u4>(p); }

I think this should really be a new API with a name like get_Java_s4(), but that can be a separate RFE.  There are other functions in globalDefinitions.hpp where we try really hard not to use undefined or implemention-defined behavior, and casting from unsigned to signed seems to be one of those, at least until c++20 fixes it.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14788#discussion_r1259059785


More information about the hotspot-runtime-dev mailing list