< prev index next >
src/share/vm/opto/addnode.cpp
Print this page
rev 9644 : 8145096: Undefined behaviour in HotSpot
Summary: Fix some integer overflows
Reviewed-by: duke
@@ -342,12 +342,12 @@
// to be passed a TOP or BOTTOM type, these are filtered out by
// pre-check.
const Type *AddINode::add_ring( const Type *t0, const Type *t1 ) const {
const TypeInt *r0 = t0->is_int(); // Handy access
const TypeInt *r1 = t1->is_int();
- int lo = r0->_lo + r1->_lo;
- int hi = r0->_hi + r1->_hi;
+ int lo = java_add(r0->_lo, r1->_lo);
+ int hi = java_add(r0->_hi, r1->_hi);
if( !(r0->is_con() && r1->is_con()) ) {
// Not both constants, compute approximate result
if( (r0->_lo & r1->_lo) < 0 && lo >= 0 ) {
lo = min_jint; hi = max_jint; // Underflow on the low side
}
@@ -451,20 +451,19 @@
return in(2)->in(1);
}
return AddNode::Identity(phase);
}
-
//------------------------------add_ring---------------------------------------
// Supplied function returns the sum of the inputs. Guaranteed never
// to be passed a TOP or BOTTOM type, these are filtered out by
// pre-check.
const Type *AddLNode::add_ring( const Type *t0, const Type *t1 ) const {
const TypeLong *r0 = t0->is_long(); // Handy access
const TypeLong *r1 = t1->is_long();
- jlong lo = r0->_lo + r1->_lo;
- jlong hi = r0->_hi + r1->_hi;
+ jlong lo = java_add(r0->_lo, r1->_lo);
+ jlong hi = java_add(r0->_hi, r1->_hi);
if( !(r0->is_con() && r1->is_con()) ) {
// Not both constants, compute approximate result
if( (r0->_lo & r1->_lo) < 0 && lo >= 0 ) {
lo =min_jlong; hi = max_jlong; // Underflow on the low side
}
< prev index next >