RFR: 8145096: Undefined behaviour in HotSpot

Kim Barrett kim.barrett at oracle.com
Thu Dec 17 18:58:19 UTC 2015


On Dec 17, 2015, at 12:56 PM, Andrew Haley <aph at redhat.com> wrote:
> 
> On 12/17/2015 05:13 PM, Kim Barrett wrote:
>> Nice.
>> 
>> There's another that looks like that here:
>> src/share/vm/opto/mulnode.cpp
>> 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.

You’re right, this one looks messy.

As far as I’m concerned, feel free to file an RFE for this one and call 8145096-3 done.




More information about the hotspot-dev mailing list