3183 klass_is_exact = ik->is_final(); 3184 if (!klass_is_exact && klass_change 3185 && deps != NULL && UseUniqueSubclasses) { 3186 ciInstanceKlass* sub = ik->unique_concrete_subklass(); 3187 if (sub != NULL) { 3188 deps->assert_abstract_with_unique_concrete_subtype(ik, sub); 3189 klass = ik = sub; 3190 klass_is_exact = sub->is_final(); 3191 } 3192 } 3193 if (!klass_is_exact && try_for_exact 3194 && deps != NULL && UseExactTypes) { 3195 if (!ik->is_interface() && !ik->has_subklass()) { 3196 // Add a dependence; if concrete subclass added we need to recompile 3197 deps->assert_leaf_type(ik); 3198 klass_is_exact = true; 3199 } 3200 } 3201 } 3202 return TypeInstPtr::make(TypePtr::BotPTR, klass, klass_is_exact, NULL, 0); 3203 } else if (klass->is_obj_array_klass()) { 3204 // Element is an object array. Recursively call ourself. 3205 const TypeOopPtr *etype = TypeOopPtr::make_from_klass_common(klass->as_obj_array_klass()->element_klass(), false, try_for_exact); 3206 bool xk = etype->klass_is_exact(); 3207 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS); 3208 // We used to pass NotNull in here, asserting that the sub-arrays 3209 // are all not-null. This is not true in generally, as code can 3210 // slam NULLs down in the subarrays. 3211 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, xk, 0); 3212 return arr; 3213 } else if (klass->is_type_array_klass()) { 3214 // Element is an typeArray 3215 const Type* etype = get_const_basic_type(klass->as_type_array_klass()->element_type()); 3216 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS); 3217 // We used to pass NotNull in here, asserting that the array pointer 3218 // is not-null. That was not true in general. 3219 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, true, 0); 3220 return arr; 3221 } else { 3222 ShouldNotReachHere(); 3223 return NULL; 3224 } 3225 } 3228 // Make a java pointer from an oop constant 3229 const TypeOopPtr* TypeOopPtr::make_from_constant(ciObject* o, bool require_constant) { 3230 assert(!o->is_null_object(), "null object not yet handled here."); 3231 ciKlass* klass = o->klass(); 3232 if (klass->is_valuetype()) { 3233 // Element is a value type 3234 if (require_constant) { 3235 if (!o->can_be_constant()) return NULL; 3236 } else if (!o->should_be_constant()) { 3237 return TypeValueTypePtr::make(TypePtr::NotNull, klass->as_value_klass()); 3238 } 3239 return TypeValueTypePtr::make(o); 3240 } else if (klass->is_instance_klass()) { 3241 // Element is an instance 3242 if (require_constant) { 3243 if (!o->can_be_constant()) return NULL; 3244 } else if (!o->should_be_constant()) { 3245 return TypeInstPtr::make(TypePtr::NotNull, klass, true, NULL, 0); 3246 } 3247 return TypeInstPtr::make(o); 3248 } else if (klass->is_obj_array_klass()) { 3249 // Element is an object array. Recursively call ourself. 3250 const TypeOopPtr *etype = 3251 TypeOopPtr::make_from_klass_raw(klass->as_obj_array_klass()->element_klass()); 3252 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length())); 3253 // We used to pass NotNull in here, asserting that the sub-arrays 3254 // are all not-null. This is not true in generally, as code can 3255 // slam NULLs down in the subarrays. 3256 if (require_constant) { 3257 if (!o->can_be_constant()) return NULL; 3258 } else if (!o->should_be_constant()) { 3259 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); 3260 } 3261 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); 3262 return arr; 3263 } else if (klass->is_type_array_klass()) { 3264 // Element is an typeArray 3265 const Type* etype = 3266 (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type()); 3267 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length())); 3268 // We used to pass NotNull in here, asserting that the array pointer 3269 // is not-null. That was not true in general. 3270 if (require_constant) { 3271 if (!o->can_be_constant()) return NULL; 5098 return Type::TOP; // Canonical empty value 5099 } 5100 5101 // Interface klass type could be exact in opposite to interface type, 5102 // return it here instead of incorrect Constant ptr J/L/Object (6894807). 5103 if (ftkp != NULL && ktkp != NULL && 5104 ftkp->is_loaded() && ftkp->klass()->is_interface() && 5105 !ftkp->klass_is_exact() && // Keep exact interface klass 5106 ktkp->is_loaded() && !ktkp->klass()->is_interface()) { 5107 return ktkp->cast_to_ptr_type(ftkp->ptr()); 5108 } 5109 5110 return ft; 5111 } 5112 5113 //----------------------compute_klass------------------------------------------ 5114 // Compute the defining klass for this class 5115 ciKlass* TypeAryPtr::compute_klass(DEBUG_ONLY(bool verify)) const { 5116 // Compute _klass based on element type. 5117 ciKlass* k_ary = NULL; 5118 const TypeInstPtr *tinst; 5119 const TypeAryPtr *tary; 5120 const Type* el = elem(); 5121 if (el->isa_narrowoop()) { 5122 el = el->make_ptr(); 5123 } 5124 5125 // Get element klass 5126 if ((tinst = el->isa_instptr()) != NULL) { 5127 // Compute array klass from element klass 5128 k_ary = ciObjArrayKlass::make(tinst->klass()); 5129 } else if ((tary = el->isa_aryptr()) != NULL) { 5130 // Compute array klass from element klass 5131 ciKlass* k_elem = tary->klass(); 5132 // If element type is something like bottom[], k_elem will be null. 5133 if (k_elem != NULL) 5134 k_ary = ciObjArrayKlass::make(k_elem); 5135 } else if ((el->base() == Type::Top) || 5136 (el->base() == Type::Bottom)) { 5137 // element type of Bottom occurs from meet of basic type 5138 // and object; Top occurs when doing join on Bottom. 5139 // Leave k_ary at NULL. 5140 } else { 5141 // Cannot compute array klass directly from basic type, 5142 // since subtypes of TypeInt all have basic type T_INT. 5143 #ifdef ASSERT 5144 if (verify && el->isa_int()) { 5145 // Check simple cases when verifying klass. 5146 BasicType bt = T_ILLEGAL; 5147 if (el == TypeInt::BYTE) { 5148 bt = T_BYTE; | 3183 klass_is_exact = ik->is_final(); 3184 if (!klass_is_exact && klass_change 3185 && deps != NULL && UseUniqueSubclasses) { 3186 ciInstanceKlass* sub = ik->unique_concrete_subklass(); 3187 if (sub != NULL) { 3188 deps->assert_abstract_with_unique_concrete_subtype(ik, sub); 3189 klass = ik = sub; 3190 klass_is_exact = sub->is_final(); 3191 } 3192 } 3193 if (!klass_is_exact && try_for_exact 3194 && deps != NULL && UseExactTypes) { 3195 if (!ik->is_interface() && !ik->has_subklass()) { 3196 // Add a dependence; if concrete subclass added we need to recompile 3197 deps->assert_leaf_type(ik); 3198 klass_is_exact = true; 3199 } 3200 } 3201 } 3202 return TypeInstPtr::make(TypePtr::BotPTR, klass, klass_is_exact, NULL, 0); 3203 } else if (klass->is_obj_array_klass() || klass->is_value_array_klass()) { 3204 // Element is an object or value array. Recursively call ourself. 3205 const TypeOopPtr* etype = TypeOopPtr::make_from_klass_common(klass->as_array_klass()->element_klass(), false, try_for_exact); 3206 bool xk = etype->klass_is_exact(); 3207 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS); 3208 // We used to pass NotNull in here, asserting that the sub-arrays 3209 // are all not-null. This is not true in generally, as code can 3210 // slam NULLs down in the subarrays. 3211 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, xk, 0); 3212 return arr; 3213 } else if (klass->is_type_array_klass()) { 3214 // Element is an typeArray 3215 const Type* etype = get_const_basic_type(klass->as_type_array_klass()->element_type()); 3216 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS); 3217 // We used to pass NotNull in here, asserting that the array pointer 3218 // is not-null. That was not true in general. 3219 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, true, 0); 3220 return arr; 3221 } else { 3222 ShouldNotReachHere(); 3223 return NULL; 3224 } 3225 } 3228 // Make a java pointer from an oop constant 3229 const TypeOopPtr* TypeOopPtr::make_from_constant(ciObject* o, bool require_constant) { 3230 assert(!o->is_null_object(), "null object not yet handled here."); 3231 ciKlass* klass = o->klass(); 3232 if (klass->is_valuetype()) { 3233 // Element is a value type 3234 if (require_constant) { 3235 if (!o->can_be_constant()) return NULL; 3236 } else if (!o->should_be_constant()) { 3237 return TypeValueTypePtr::make(TypePtr::NotNull, klass->as_value_klass()); 3238 } 3239 return TypeValueTypePtr::make(o); 3240 } else if (klass->is_instance_klass()) { 3241 // Element is an instance 3242 if (require_constant) { 3243 if (!o->can_be_constant()) return NULL; 3244 } else if (!o->should_be_constant()) { 3245 return TypeInstPtr::make(TypePtr::NotNull, klass, true, NULL, 0); 3246 } 3247 return TypeInstPtr::make(o); 3248 } else if (klass->is_obj_array_klass() || klass->is_value_array_klass()) { 3249 // Element is an object array. Recursively call ourself. 3250 const TypeOopPtr *etype = 3251 TypeOopPtr::make_from_klass_raw(klass->as_array_klass()->element_klass()); 3252 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length())); 3253 // We used to pass NotNull in here, asserting that the sub-arrays 3254 // are all not-null. This is not true in generally, as code can 3255 // slam NULLs down in the subarrays. 3256 if (require_constant) { 3257 if (!o->can_be_constant()) return NULL; 3258 } else if (!o->should_be_constant()) { 3259 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); 3260 } 3261 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); 3262 return arr; 3263 } else if (klass->is_type_array_klass()) { 3264 // Element is an typeArray 3265 const Type* etype = 3266 (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type()); 3267 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length())); 3268 // We used to pass NotNull in here, asserting that the array pointer 3269 // is not-null. That was not true in general. 3270 if (require_constant) { 3271 if (!o->can_be_constant()) return NULL; 5098 return Type::TOP; // Canonical empty value 5099 } 5100 5101 // Interface klass type could be exact in opposite to interface type, 5102 // return it here instead of incorrect Constant ptr J/L/Object (6894807). 5103 if (ftkp != NULL && ktkp != NULL && 5104 ftkp->is_loaded() && ftkp->klass()->is_interface() && 5105 !ftkp->klass_is_exact() && // Keep exact interface klass 5106 ktkp->is_loaded() && !ktkp->klass()->is_interface()) { 5107 return ktkp->cast_to_ptr_type(ftkp->ptr()); 5108 } 5109 5110 return ft; 5111 } 5112 5113 //----------------------compute_klass------------------------------------------ 5114 // Compute the defining klass for this class 5115 ciKlass* TypeAryPtr::compute_klass(DEBUG_ONLY(bool verify)) const { 5116 // Compute _klass based on element type. 5117 ciKlass* k_ary = NULL; 5118 const TypeAryPtr *tary; 5119 const Type* el = elem(); 5120 if (el->isa_narrowoop()) { 5121 el = el->make_ptr(); 5122 } 5123 5124 // Get element klass 5125 if (el->isa_instptr() || el->isa_valuetypeptr()) { 5126 // Compute object array klass from element klass 5127 k_ary = ciArrayKlass::make(el->is_oopptr()->klass()); 5128 } else if ((tary = el->isa_aryptr()) != NULL) { 5129 // Compute array klass from element klass 5130 ciKlass* k_elem = tary->klass(); 5131 // If element type is something like bottom[], k_elem will be null. 5132 if (k_elem != NULL) 5133 k_ary = ciObjArrayKlass::make(k_elem); 5134 } else if ((el->base() == Type::Top) || 5135 (el->base() == Type::Bottom)) { 5136 // element type of Bottom occurs from meet of basic type 5137 // and object; Top occurs when doing join on Bottom. 5138 // Leave k_ary at NULL. 5139 } else { 5140 // Cannot compute array klass directly from basic type, 5141 // since subtypes of TypeInt all have basic type T_INT. 5142 #ifdef ASSERT 5143 if (verify && el->isa_int()) { 5144 // Check simple cases when verifying klass. 5145 BasicType bt = T_ILLEGAL; 5146 if (el == TypeInt::BYTE) { 5147 bt = T_BYTE; |