< prev index next >

src/share/vm/opto/type.cpp

Print this page
@  rev 8243 : 8078666: JVM fastdebug build compiled with GCC 5 asserts with "widen increases"
|  Summary: Fix signed integer overflow in normalize_{int,long}_widen()


1141 const TypeInt *TypeInt::SHORT;  // Java shorts, -32768-32767
1142 const TypeInt *TypeInt::POS;    // Positive 32-bit integers or zero
1143 const TypeInt *TypeInt::POS1;   // Positive 32-bit integers
1144 const TypeInt *TypeInt::INT;    // 32-bit integers
1145 const TypeInt *TypeInt::SYMINT; // symmetric range [-max_jint..max_jint]
1146 const TypeInt *TypeInt::TYPE_DOMAIN; // alias for TypeInt::INT
1147 
1148 //------------------------------TypeInt----------------------------------------
1149 TypeInt::TypeInt( jint lo, jint hi, int w ) : Type(Int), _lo(lo), _hi(hi), _widen(w) {
1150 }
1151 
1152 //------------------------------make-------------------------------------------
1153 const TypeInt *TypeInt::make( jint lo ) {
1154   return (TypeInt*)(new TypeInt(lo,lo,WidenMin))->hashcons();
1155 }
1156 
1157 static int normalize_int_widen( jint lo, jint hi, int w ) {
1158   // Certain normalizations keep us sane when comparing types.
1159   // The 'SMALLINT' covers constants and also CC and its relatives.
1160   if (lo <= hi) {
1161     if ((juint)(hi - lo) <= SMALLINT)  w = Type::WidenMin;
1162     if ((juint)(hi - lo) >= max_juint) w = Type::WidenMax; // TypeInt::INT
1163   } else {
1164     if ((juint)(lo - hi) <= SMALLINT)  w = Type::WidenMin;
1165     if ((juint)(lo - hi) >= max_juint) w = Type::WidenMin; // dual TypeInt::INT
1166   }
1167   return w;
1168 }
1169 
1170 const TypeInt *TypeInt::make( jint lo, jint hi, int w ) {
1171   w = normalize_int_widen(lo, hi, w);
1172   return (TypeInt*)(new TypeInt(lo,hi,w))->hashcons();
1173 }
1174 
1175 //------------------------------meet-------------------------------------------
1176 // Compute the MEET of two types.  It returns a new Type representation object
1177 // with reference count equal to the number of Types pointing at it.
1178 // Caller should wrap a Types around it.
1179 const Type *TypeInt::xmeet( const Type *t ) const {
1180   // Perform a fast test for common case; meeting the same types together.
1181   if( this == t ) return this;  // Meeting same type?
1182 
1183   // Currently "this->_base" is a TypeInt
1184   switch (t->base()) {          // Switch on original type
1185   case AnyPtr:                  // Mixing with oops happens when javac


1399 const TypeLong *TypeLong::ONE;  // 1
1400 const TypeLong *TypeLong::POS;  // >=0
1401 const TypeLong *TypeLong::LONG; // 64-bit integers
1402 const TypeLong *TypeLong::INT;  // 32-bit subrange
1403 const TypeLong *TypeLong::UINT; // 32-bit unsigned subrange
1404 const TypeLong *TypeLong::TYPE_DOMAIN; // alias for TypeLong::LONG
1405 
1406 //------------------------------TypeLong---------------------------------------
1407 TypeLong::TypeLong( jlong lo, jlong hi, int w ) : Type(Long), _lo(lo), _hi(hi), _widen(w) {
1408 }
1409 
1410 //------------------------------make-------------------------------------------
1411 const TypeLong *TypeLong::make( jlong lo ) {
1412   return (TypeLong*)(new TypeLong(lo,lo,WidenMin))->hashcons();
1413 }
1414 
1415 static int normalize_long_widen( jlong lo, jlong hi, int w ) {
1416   // Certain normalizations keep us sane when comparing types.
1417   // The 'SMALLINT' covers constants.
1418   if (lo <= hi) {
1419     if ((julong)(hi - lo) <= SMALLINT)   w = Type::WidenMin;
1420     if ((julong)(hi - lo) >= max_julong) w = Type::WidenMax; // TypeLong::LONG
1421   } else {
1422     if ((julong)(lo - hi) <= SMALLINT)   w = Type::WidenMin;
1423     if ((julong)(lo - hi) >= max_julong) w = Type::WidenMin; // dual TypeLong::LONG
1424   }
1425   return w;
1426 }
1427 
1428 const TypeLong *TypeLong::make( jlong lo, jlong hi, int w ) {
1429   w = normalize_long_widen(lo, hi, w);
1430   return (TypeLong*)(new TypeLong(lo,hi,w))->hashcons();
1431 }
1432 
1433 
1434 //------------------------------meet-------------------------------------------
1435 // Compute the MEET of two types.  It returns a new Type representation object
1436 // with reference count equal to the number of Types pointing at it.
1437 // Caller should wrap a Types around it.
1438 const Type *TypeLong::xmeet( const Type *t ) const {
1439   // Perform a fast test for common case; meeting the same types together.
1440   if( this == t ) return this;  // Meeting same type?
1441 
1442   // Currently "this->_base" is a TypeLong
1443   switch (t->base()) {          // Switch on original type




1141 const TypeInt *TypeInt::SHORT;  // Java shorts, -32768-32767
1142 const TypeInt *TypeInt::POS;    // Positive 32-bit integers or zero
1143 const TypeInt *TypeInt::POS1;   // Positive 32-bit integers
1144 const TypeInt *TypeInt::INT;    // 32-bit integers
1145 const TypeInt *TypeInt::SYMINT; // symmetric range [-max_jint..max_jint]
1146 const TypeInt *TypeInt::TYPE_DOMAIN; // alias for TypeInt::INT
1147 
1148 //------------------------------TypeInt----------------------------------------
1149 TypeInt::TypeInt( jint lo, jint hi, int w ) : Type(Int), _lo(lo), _hi(hi), _widen(w) {
1150 }
1151 
1152 //------------------------------make-------------------------------------------
1153 const TypeInt *TypeInt::make( jint lo ) {
1154   return (TypeInt*)(new TypeInt(lo,lo,WidenMin))->hashcons();
1155 }
1156 
1157 static int normalize_int_widen( jint lo, jint hi, int w ) {
1158   // Certain normalizations keep us sane when comparing types.
1159   // The 'SMALLINT' covers constants and also CC and its relatives.
1160   if (lo <= hi) {
1161     if ((juint)hi - lo <= SMALLINT)  w = Type::WidenMin;
1162     if ((juint)hi - lo >= max_juint) w = Type::WidenMax; // TypeInt::INT
1163   } else {
1164     if ((juint)lo - hi <= SMALLINT)  w = Type::WidenMin;
1165     if ((juint)lo - hi >= max_juint) w = Type::WidenMin; // dual TypeInt::INT
1166   }
1167   return w;
1168 }
1169 
1170 const TypeInt *TypeInt::make( jint lo, jint hi, int w ) {
1171   w = normalize_int_widen(lo, hi, w);
1172   return (TypeInt*)(new TypeInt(lo,hi,w))->hashcons();
1173 }
1174 
1175 //------------------------------meet-------------------------------------------
1176 // Compute the MEET of two types.  It returns a new Type representation object
1177 // with reference count equal to the number of Types pointing at it.
1178 // Caller should wrap a Types around it.
1179 const Type *TypeInt::xmeet( const Type *t ) const {
1180   // Perform a fast test for common case; meeting the same types together.
1181   if( this == t ) return this;  // Meeting same type?
1182 
1183   // Currently "this->_base" is a TypeInt
1184   switch (t->base()) {          // Switch on original type
1185   case AnyPtr:                  // Mixing with oops happens when javac


1399 const TypeLong *TypeLong::ONE;  // 1
1400 const TypeLong *TypeLong::POS;  // >=0
1401 const TypeLong *TypeLong::LONG; // 64-bit integers
1402 const TypeLong *TypeLong::INT;  // 32-bit subrange
1403 const TypeLong *TypeLong::UINT; // 32-bit unsigned subrange
1404 const TypeLong *TypeLong::TYPE_DOMAIN; // alias for TypeLong::LONG
1405 
1406 //------------------------------TypeLong---------------------------------------
1407 TypeLong::TypeLong( jlong lo, jlong hi, int w ) : Type(Long), _lo(lo), _hi(hi), _widen(w) {
1408 }
1409 
1410 //------------------------------make-------------------------------------------
1411 const TypeLong *TypeLong::make( jlong lo ) {
1412   return (TypeLong*)(new TypeLong(lo,lo,WidenMin))->hashcons();
1413 }
1414 
1415 static int normalize_long_widen( jlong lo, jlong hi, int w ) {
1416   // Certain normalizations keep us sane when comparing types.
1417   // The 'SMALLINT' covers constants.
1418   if (lo <= hi) {
1419     if ((julong)hi - lo <= SMALLINT)   w = Type::WidenMin;
1420     if ((julong)hi - lo >= max_julong) w = Type::WidenMax; // TypeLong::LONG
1421   } else {
1422     if ((julong)lo - hi <= SMALLINT)   w = Type::WidenMin;
1423     if ((julong)lo - hi >= max_julong) w = Type::WidenMin; // dual TypeLong::LONG
1424   }
1425   return w;
1426 }
1427 
1428 const TypeLong *TypeLong::make( jlong lo, jlong hi, int w ) {
1429   w = normalize_long_widen(lo, hi, w);
1430   return (TypeLong*)(new TypeLong(lo,hi,w))->hashcons();
1431 }
1432 
1433 
1434 //------------------------------meet-------------------------------------------
1435 // Compute the MEET of two types.  It returns a new Type representation object
1436 // with reference count equal to the number of Types pointing at it.
1437 // Caller should wrap a Types around it.
1438 const Type *TypeLong::xmeet( const Type *t ) const {
1439   // Perform a fast test for common case; meeting the same types together.
1440   if( this == t ) return this;  // Meeting same type?
1441 
1442   // Currently "this->_base" is a TypeLong
1443   switch (t->base()) {          // Switch on original type


< prev index next >