RFR: 8145096: Undefined behaviour in HotSpot

Andrew Haley aph at redhat.com
Mon Dec 21 17:07:40 UTC 2015


I've analysed the last remaining changes and I'm now convinced that
it's safe to make this change:

--- a/src/share/vm/opto/mulnode.cpp
+++ b/src/share/vm/opto/mulnode.cpp
@@ -574,7 +574,8 @@
     // Masking off high bits which are always zero is useless.
     const TypeLong* t1 = phase->type( in(1) )->isa_long();
     if (t1 != NULL && t1->_lo >= 0) {
-      jlong t1_support = ((jlong)1 << (1 + log2_long(t1->_hi))) - 1;
+      int bit_count = log2_long(t1->_hi) + 1;
+      jlong t1_support = jlong(max_julong >> (BitsPerJavaLong - bit_count));
       if ((t1_support & con) == t1_support)
         return usr;
     }

Webrev at http://cr.openjdk.java.net/~aph/8145096-4/

Andrew.


More information about the hotspot-dev mailing list