< prev index next >

src/share/vm/opto/type.cpp

Print this page




 252           if (con_type != NULL) {
 253             if (Compile::current()->eliminate_boxing() && is_autobox_cache) {
 254               con_type = con_type->is_aryptr()->cast_to_autobox_cache(true);
 255             }
 256             if (stable_dimension > 0) {
 257               assert(FoldStableValues, "sanity");
 258               assert(!con_type->is_zero_type(), "default value for stable field");
 259               con_type = con_type->is_aryptr()->cast_to_stable(true, stable_dimension);
 260             }
 261           }
 262         }
 263         if (is_narrow_oop) {
 264           con_type = con_type->make_narrowoop();
 265         }
 266         return con_type;
 267       }
 268     case T_ILLEGAL:
 269       // Invalid ciConstant returned due to OutOfMemoryError in the CI
 270       assert(Compile::current()->env()->failing(), "otherwise should not see this");
 271       return NULL;
 272   }
 273   // Fall through to failure
 274   return NULL;

 275 }
 276 
 277 static ciConstant check_mismatched_access(ciConstant con, BasicType loadbt, bool is_unsigned) {
 278   BasicType conbt = con.basic_type();
 279   switch (conbt) {
 280     case T_BOOLEAN: conbt = T_BYTE;   break;
 281     case T_ARRAY:   conbt = T_OBJECT; break;

 282   }
 283   switch (loadbt) {
 284     case T_BOOLEAN:   loadbt = T_BYTE;   break;
 285     case T_NARROWOOP: loadbt = T_OBJECT; break;
 286     case T_ARRAY:     loadbt = T_OBJECT; break;
 287     case T_ADDRESS:   loadbt = T_OBJECT; break;

 288   }
 289   if (conbt == loadbt) {
 290     if (is_unsigned && conbt == T_BYTE) {
 291       // LoadB (T_BYTE) with a small mask (<=8-bit) is converted to LoadUB (T_BYTE).
 292       return ciConstant(T_INT, con.as_int() & 0xFF);
 293     } else {
 294       return con;
 295     }
 296   }
 297   if (conbt == T_SHORT && loadbt == T_CHAR) {
 298     // LoadS (T_SHORT) with a small mask (<=16-bit) is converted to LoadUS (T_CHAR).
 299     return ciConstant(T_INT, con.as_int() & 0xFFFF);
 300   }
 301   return ciConstant(); // T_ILLEGAL
 302 }
 303 
 304 // Try to constant-fold a stable array element.
 305 const Type* Type::make_constant_from_array_element(ciArray* array, int off, int stable_dimension,
 306                                                    BasicType loadbt, bool is_unsigned_load) {
 307   // Decode the results of GraphKit::array_element_address.


1031   return _base == Top || _base == Half;
1032 }
1033 
1034 //------------------------------empty------------------------------------------
1035 // TRUE if Type is a type with no values, FALSE otherwise.
1036 bool Type::empty(void) const {
1037   switch (_base) {
1038   case DoubleTop:
1039   case FloatTop:
1040   case Top:
1041     return true;
1042 
1043   case Half:
1044   case Abio:
1045   case Return_Address:
1046   case Memory:
1047   case Bottom:
1048   case FloatBot:
1049   case DoubleBot:
1050     return false;  // never a singleton, therefore never empty
1051   }
1052 

1053   ShouldNotReachHere();
1054   return false;

1055 }
1056 
1057 //------------------------------dump_stats-------------------------------------
1058 // Dump collected statistics to stderr
1059 #ifndef PRODUCT
1060 void Type::dump_stats() {
1061   tty->print("Types made: %d\n", type_dict()->Size());
1062 }
1063 #endif
1064 
1065 //------------------------------typerr-----------------------------------------
1066 void Type::typerr( const Type *t ) const {
1067 #ifndef PRODUCT
1068   tty->print("\nError mixing types: ");
1069   dump();
1070   tty->print(" and ");
1071   t->dump();
1072   tty->print("\n");
1073 #endif
1074   ShouldNotReachHere();


4063   return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative, _inline_depth);
4064 }
4065 
4066 //-----------------------------narrow_size_type-------------------------------
4067 // Local cache for arrayOopDesc::max_array_length(etype),
4068 // which is kind of slow (and cached elsewhere by other users).
4069 static jint max_array_length_cache[T_CONFLICT+1];
4070 static jint max_array_length(BasicType etype) {
4071   jint& cache = max_array_length_cache[etype];
4072   jint res = cache;
4073   if (res == 0) {
4074     switch (etype) {
4075     case T_NARROWOOP:
4076       etype = T_OBJECT;
4077       break;
4078     case T_NARROWKLASS:
4079     case T_CONFLICT:
4080     case T_ILLEGAL:
4081     case T_VOID:
4082       etype = T_BYTE;           // will produce conservatively high value



4083     }
4084     cache = res = arrayOopDesc::max_array_length(etype);
4085   }
4086   return res;
4087 }
4088 
4089 // Narrow the given size type to the index range for the given array base type.
4090 // Return NULL if the resulting int type becomes empty.
4091 const TypeInt* TypeAryPtr::narrow_size_type(const TypeInt* size) const {
4092   jint hi = size->_hi;
4093   jint lo = size->_lo;
4094   jint min_lo = 0;
4095   jint max_hi = max_array_length(elem()->basic_type());
4096   //if (index_not_size)  --max_hi;     // type of a valid array index, FTR
4097   bool chg = false;
4098   if (lo < min_lo) {
4099     lo = min_lo;
4100     if (size->is_con()) {
4101       hi = lo;
4102     }




 252           if (con_type != NULL) {
 253             if (Compile::current()->eliminate_boxing() && is_autobox_cache) {
 254               con_type = con_type->is_aryptr()->cast_to_autobox_cache(true);
 255             }
 256             if (stable_dimension > 0) {
 257               assert(FoldStableValues, "sanity");
 258               assert(!con_type->is_zero_type(), "default value for stable field");
 259               con_type = con_type->is_aryptr()->cast_to_stable(true, stable_dimension);
 260             }
 261           }
 262         }
 263         if (is_narrow_oop) {
 264           con_type = con_type->make_narrowoop();
 265         }
 266         return con_type;
 267       }
 268     case T_ILLEGAL:
 269       // Invalid ciConstant returned due to OutOfMemoryError in the CI
 270       assert(Compile::current()->env()->failing(), "otherwise should not see this");
 271       return NULL;
 272     default:
 273       // Fall through to failure
 274       return NULL;
 275   }
 276 }
 277 
 278 static ciConstant check_mismatched_access(ciConstant con, BasicType loadbt, bool is_unsigned) {
 279   BasicType conbt = con.basic_type();
 280   switch (conbt) {
 281     case T_BOOLEAN: conbt = T_BYTE;   break;
 282     case T_ARRAY:   conbt = T_OBJECT; break;
 283     default:                          break;
 284   }
 285   switch (loadbt) {
 286     case T_BOOLEAN:   loadbt = T_BYTE;   break;
 287     case T_NARROWOOP: loadbt = T_OBJECT; break;
 288     case T_ARRAY:     loadbt = T_OBJECT; break;
 289     case T_ADDRESS:   loadbt = T_OBJECT; break;
 290     default:                             break;
 291   }
 292   if (conbt == loadbt) {
 293     if (is_unsigned && conbt == T_BYTE) {
 294       // LoadB (T_BYTE) with a small mask (<=8-bit) is converted to LoadUB (T_BYTE).
 295       return ciConstant(T_INT, con.as_int() & 0xFF);
 296     } else {
 297       return con;
 298     }
 299   }
 300   if (conbt == T_SHORT && loadbt == T_CHAR) {
 301     // LoadS (T_SHORT) with a small mask (<=16-bit) is converted to LoadUS (T_CHAR).
 302     return ciConstant(T_INT, con.as_int() & 0xFFFF);
 303   }
 304   return ciConstant(); // T_ILLEGAL
 305 }
 306 
 307 // Try to constant-fold a stable array element.
 308 const Type* Type::make_constant_from_array_element(ciArray* array, int off, int stable_dimension,
 309                                                    BasicType loadbt, bool is_unsigned_load) {
 310   // Decode the results of GraphKit::array_element_address.


1034   return _base == Top || _base == Half;
1035 }
1036 
1037 //------------------------------empty------------------------------------------
1038 // TRUE if Type is a type with no values, FALSE otherwise.
1039 bool Type::empty(void) const {
1040   switch (_base) {
1041   case DoubleTop:
1042   case FloatTop:
1043   case Top:
1044     return true;
1045 
1046   case Half:
1047   case Abio:
1048   case Return_Address:
1049   case Memory:
1050   case Bottom:
1051   case FloatBot:
1052   case DoubleBot:
1053     return false;  // never a singleton, therefore never empty

1054 
1055   default:
1056     ShouldNotReachHere();
1057     return false;
1058   }
1059 }
1060 
1061 //------------------------------dump_stats-------------------------------------
1062 // Dump collected statistics to stderr
1063 #ifndef PRODUCT
1064 void Type::dump_stats() {
1065   tty->print("Types made: %d\n", type_dict()->Size());
1066 }
1067 #endif
1068 
1069 //------------------------------typerr-----------------------------------------
1070 void Type::typerr( const Type *t ) const {
1071 #ifndef PRODUCT
1072   tty->print("\nError mixing types: ");
1073   dump();
1074   tty->print(" and ");
1075   t->dump();
1076   tty->print("\n");
1077 #endif
1078   ShouldNotReachHere();


4067   return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative, _inline_depth);
4068 }
4069 
4070 //-----------------------------narrow_size_type-------------------------------
4071 // Local cache for arrayOopDesc::max_array_length(etype),
4072 // which is kind of slow (and cached elsewhere by other users).
4073 static jint max_array_length_cache[T_CONFLICT+1];
4074 static jint max_array_length(BasicType etype) {
4075   jint& cache = max_array_length_cache[etype];
4076   jint res = cache;
4077   if (res == 0) {
4078     switch (etype) {
4079     case T_NARROWOOP:
4080       etype = T_OBJECT;
4081       break;
4082     case T_NARROWKLASS:
4083     case T_CONFLICT:
4084     case T_ILLEGAL:
4085     case T_VOID:
4086       etype = T_BYTE;           // will produce conservatively high value
4087       break;
4088     default:
4089       break;
4090     }
4091     cache = res = arrayOopDesc::max_array_length(etype);
4092   }
4093   return res;
4094 }
4095 
4096 // Narrow the given size type to the index range for the given array base type.
4097 // Return NULL if the resulting int type becomes empty.
4098 const TypeInt* TypeAryPtr::narrow_size_type(const TypeInt* size) const {
4099   jint hi = size->_hi;
4100   jint lo = size->_lo;
4101   jint min_lo = 0;
4102   jint max_hi = max_array_length(elem()->basic_type());
4103   //if (index_not_size)  --max_hi;     // type of a valid array index, FTR
4104   bool chg = false;
4105   if (lo < min_lo) {
4106     lo = min_lo;
4107     if (size->is_con()) {
4108       hi = lo;
4109     }


< prev index next >