1.1 --- a/src/share/vm/opto/type.cpp Wed Oct 07 12:43:50 2009 -0700 1.2 +++ b/src/share/vm/opto/type.cpp Wed Oct 07 15:38:37 2009 -0700 1.3 @@ -1115,7 +1115,7 @@ 1.4 1.5 //------------------------------widen------------------------------------------ 1.6 // Only happens for optimistic top-down optimizations. 1.7 -const Type *TypeInt::widen( const Type *old ) const { 1.8 +const Type *TypeInt::widen( const Type *old, const Type* limit ) const { 1.9 // Coming from TOP or such; no widening 1.10 if( old->base() != Int ) return this; 1.11 const TypeInt *ot = old->is_int(); 1.12 @@ -1134,15 +1134,21 @@ 1.13 // Now widen new guy. 1.14 // Check for widening too far 1.15 if (_widen == WidenMax) { 1.16 - if (min_jint < _lo && _hi < max_jint) { 1.17 + int max = max_jint; 1.18 + int min = min_jint; 1.19 + if (limit->isa_int()) { 1.20 + max = limit->is_int()->_hi; 1.21 + min = limit->is_int()->_lo; 1.22 + } 1.23 + if (min < _lo && _hi < max) { 1.24 // If neither endpoint is extremal yet, push out the endpoint 1.25 // which is closer to its respective limit. 1.26 if (_lo >= 0 || // easy common case 1.27 - (juint)(_lo - min_jint) >= (juint)(max_jint - _hi)) { 1.28 + (juint)(_lo - min) >= (juint)(max - _hi)) { 1.29 // Try to widen to an unsigned range type of 31 bits: 1.30 - return make(_lo, max_jint, WidenMax); 1.31 + return make(_lo, max, WidenMax); 1.32 } else { 1.33 - return make(min_jint, _hi, WidenMax); 1.34 + return make(min, _hi, WidenMax); 1.35 } 1.36 } 1.37 return TypeInt::INT; 1.38 @@ -1357,7 +1363,7 @@ 1.39 1.40 //------------------------------widen------------------------------------------ 1.41 // Only happens for optimistic top-down optimizations. 1.42 -const Type *TypeLong::widen( const Type *old ) const { 1.43 +const Type *TypeLong::widen( const Type *old, const Type* limit ) const { 1.44 // Coming from TOP or such; no widening 1.45 if( old->base() != Long ) return this; 1.46 const TypeLong *ot = old->is_long(); 1.47 @@ -1376,18 +1382,24 @@ 1.48 // Now widen new guy. 1.49 // Check for widening too far 1.50 if (_widen == WidenMax) { 1.51 - if (min_jlong < _lo && _hi < max_jlong) { 1.52 + jlong max = max_jlong; 1.53 + jlong min = min_jlong; 1.54 + if (limit->isa_long()) { 1.55 + max = limit->is_long()->_hi; 1.56 + min = limit->is_long()->_lo; 1.57 + } 1.58 + if (min < _lo && _hi < max) { 1.59 // If neither endpoint is extremal yet, push out the endpoint 1.60 // which is closer to its respective limit. 1.61 if (_lo >= 0 || // easy common case 1.62 - (julong)(_lo - min_jlong) >= (julong)(max_jlong - _hi)) { 1.63 + (julong)(_lo - min) >= (julong)(max - _hi)) { 1.64 // Try to widen to an unsigned range type of 32/63 bits: 1.65 - if (_hi < max_juint) 1.66 + if (max >= max_juint && _hi < max_juint) 1.67 return make(_lo, max_juint, WidenMax); 1.68 else 1.69 - return make(_lo, max_jlong, WidenMax); 1.70 + return make(_lo, max, WidenMax); 1.71 } else { 1.72 - return make(min_jlong, _hi, WidenMax); 1.73 + return make(min, _hi, WidenMax); 1.74 } 1.75 } 1.76 return TypeLong::LONG;