RFR: 8145096: Undefined behaviour in HotSpot
aph at redhat.com
Thu Dec 17 17:56:43 UTC 2015
On 12/17/2015 05:13 PM, Kim Barrett wrote:
> There's another that looks like that here:
> 577 jlong t1_support = java_subtract(((jlong)1 << (1 + log2_long(t1->_hi))), (jlong)1);
> Everything else looks good.
Ah, I didn't want to touch that one. :-)
Here's the original:
jlong t1_support = ((jlong)1 << (1 + log2_long(t1->_hi))) - 1;
I think that the equivalent is
int type_bit_count = log2_long(t1->_hi) + 1;
jlong t1_support = jlong((~ UCONST64(0)) >> (BitsPerJavaLong - type_bit_count));
I've broken it apart for clarity.
However, I'm having trouble analysing this to prove that all the
corner cases are correct.
More information about the hotspot-dev