hotspot/src/share/vm/c1/c1_Instruction.cpp
changeset 20702 bbe0fcde6e13
parent 16611 6807a703dd6b
child 22234 da823d78ad65
equal deleted inserted replaced
20701:ef9996662fd5 20702:bbe0fcde6e13
   102   if (exception_state() != NULL){
   102   if (exception_state() != NULL){
   103     exception_state()->values_do(f);
   103     exception_state()->values_do(f);
   104   }
   104   }
   105 }
   105 }
   106 
   106 
       
   107 ciType* Instruction::exact_type() const {
       
   108   ciType* t =  declared_type();
       
   109   if (t != NULL && t->is_klass()) {
       
   110     return t->as_klass()->exact_klass();
       
   111   }
       
   112   return NULL;
       
   113 }
       
   114 
   107 
   115 
   108 #ifndef PRODUCT
   116 #ifndef PRODUCT
   109 void Instruction::check_state(ValueStack* state) {
   117 void Instruction::check_state(ValueStack* state) {
   110   if (state != NULL) {
   118   if (state != NULL) {
   111     state->verify();
   119     state->verify();
   133 #endif // PRODUCT
   141 #endif // PRODUCT
   134 
   142 
   135 
   143 
   136 // perform constant and interval tests on index value
   144 // perform constant and interval tests on index value
   137 bool AccessIndexed::compute_needs_range_check() {
   145 bool AccessIndexed::compute_needs_range_check() {
   138 
       
   139   if (length()) {
   146   if (length()) {
   140 
       
   141     Constant* clength = length()->as_Constant();
   147     Constant* clength = length()->as_Constant();
   142     Constant* cindex = index()->as_Constant();
   148     Constant* cindex = index()->as_Constant();
   143     if (clength && cindex) {
   149     if (clength && cindex) {
   144       IntConstant* l = clength->type()->as_IntConstant();
   150       IntConstant* l = clength->type()->as_IntConstant();
   145       IntConstant* i = cindex->type()->as_IntConstant();
   151       IntConstant* i = cindex->type()->as_IntConstant();
   155 
   161 
   156   return true;
   162   return true;
   157 }
   163 }
   158 
   164 
   159 
   165 
   160 ciType* Local::exact_type() const {
       
   161   ciType* type = declared_type();
       
   162 
       
   163   // for primitive arrays, the declared type is the exact type
       
   164   if (type->is_type_array_klass()) {
       
   165     return type;
       
   166   } else if (type->is_instance_klass()) {
       
   167     ciInstanceKlass* ik = (ciInstanceKlass*)type;
       
   168     if (ik->is_loaded() && ik->is_final() && !ik->is_interface()) {
       
   169       return type;
       
   170     }
       
   171   } else if (type->is_obj_array_klass()) {
       
   172     ciObjArrayKlass* oak = (ciObjArrayKlass*)type;
       
   173     ciType* base = oak->base_element_type();
       
   174     if (base->is_instance_klass()) {
       
   175       ciInstanceKlass* ik = base->as_instance_klass();
       
   176       if (ik->is_loaded() && ik->is_final()) {
       
   177         return type;
       
   178       }
       
   179     } else if (base->is_primitive_type()) {
       
   180       return type;
       
   181     }
       
   182   }
       
   183   return NULL;
       
   184 }
       
   185 
       
   186 ciType* Constant::exact_type() const {
   166 ciType* Constant::exact_type() const {
   187   if (type()->is_object()) {
   167   if (type()->is_object() && type()->as_ObjectType()->is_loaded()) {
   188     return type()->as_ObjectType()->exact_type();
   168     return type()->as_ObjectType()->exact_type();
   189   }
   169   }
   190   return NULL;
   170   return NULL;
   191 }
   171 }
   192 
   172 
   193 ciType* LoadIndexed::exact_type() const {
   173 ciType* LoadIndexed::exact_type() const {
   194   ciType* array_type = array()->exact_type();
   174   ciType* array_type = array()->exact_type();
   195   if (array_type == NULL) {
   175   if (array_type != NULL) {
   196     return NULL;
   176     assert(array_type->is_array_klass(), "what else?");
   197   }
   177     ciArrayKlass* ak = (ciArrayKlass*)array_type;
   198   assert(array_type->is_array_klass(), "what else?");
   178 
   199   ciArrayKlass* ak = (ciArrayKlass*)array_type;
   179     if (ak->element_type()->is_instance_klass()) {
   200 
   180       ciInstanceKlass* ik = (ciInstanceKlass*)ak->element_type();
   201   if (ak->element_type()->is_instance_klass()) {
   181       if (ik->is_loaded() && ik->is_final()) {
   202     ciInstanceKlass* ik = (ciInstanceKlass*)ak->element_type();
   182         return ik;
   203     if (ik->is_loaded() && ik->is_final()) {
   183       }
   204       return ik;
   184     }
   205     }
   185   }
   206   }
   186   return Instruction::exact_type();
   207   return NULL;
       
   208 }
   187 }
   209 
   188 
   210 
   189 
   211 ciType* LoadIndexed::declared_type() const {
   190 ciType* LoadIndexed::declared_type() const {
   212   ciType* array_type = array()->declared_type();
   191   ciType* array_type = array()->declared_type();
   222 ciType* LoadField::declared_type() const {
   201 ciType* LoadField::declared_type() const {
   223   return field()->type();
   202   return field()->type();
   224 }
   203 }
   225 
   204 
   226 
   205 
   227 ciType* LoadField::exact_type() const {
       
   228   ciType* type = declared_type();
       
   229   // for primitive arrays, the declared type is the exact type
       
   230   if (type->is_type_array_klass()) {
       
   231     return type;
       
   232   }
       
   233   if (type->is_instance_klass()) {
       
   234     ciInstanceKlass* ik = (ciInstanceKlass*)type;
       
   235     if (ik->is_loaded() && ik->is_final()) {
       
   236       return type;
       
   237     }
       
   238   }
       
   239   return NULL;
       
   240 }
       
   241 
       
   242 
       
   243 ciType* NewTypeArray::exact_type() const {
   206 ciType* NewTypeArray::exact_type() const {
   244   return ciTypeArrayKlass::make(elt_type());
   207   return ciTypeArrayKlass::make(elt_type());
   245 }
   208 }
   246 
   209 
   247 ciType* NewObjectArray::exact_type() const {
   210 ciType* NewObjectArray::exact_type() const {
   260   return exact_type();
   223   return exact_type();
   261 }
   224 }
   262 
   225 
   263 ciType* CheckCast::declared_type() const {
   226 ciType* CheckCast::declared_type() const {
   264   return klass();
   227   return klass();
   265 }
       
   266 
       
   267 ciType* CheckCast::exact_type() const {
       
   268   if (klass()->is_instance_klass()) {
       
   269     ciInstanceKlass* ik = (ciInstanceKlass*)klass();
       
   270     if (ik->is_loaded() && ik->is_final()) {
       
   271       return ik;
       
   272     }
       
   273   }
       
   274   return NULL;
       
   275 }
   228 }
   276 
   229 
   277 // Implementation of ArithmeticOp
   230 // Implementation of ArithmeticOp
   278 
   231 
   279 bool ArithmeticOp::is_commutative() const {
   232 bool ArithmeticOp::is_commutative() const {