< 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,353 **** // 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; 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 } --- 342,353 ---- // 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 = 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 }
*** 459,470 **** // 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; 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 } --- 459,470 ---- // 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 = 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 >