< prev index next >

src/hotspot/share/opto/type.cpp

Print this page




3463       if (!klass_is_exact && try_for_exact
3464           && deps != NULL && UseExactTypes) {
3465         if (!ik->is_interface() && !ik->has_subklass()) {
3466           // Add a dependence; if concrete subclass added we need to recompile
3467           deps->assert_leaf_type(ik);
3468           klass_is_exact = true;
3469         }
3470       }
3471     }
3472     return TypeInstPtr::make(TypePtr::BotPTR, klass, klass_is_exact, NULL, Offset(0));
3473   } else if (klass->is_obj_array_klass()) {
3474     // Element is an object or value array. Recursively call ourself.
3475     const TypeOopPtr* etype = TypeOopPtr::make_from_klass_common(klass->as_array_klass()->element_klass(), false, try_for_exact);
3476     bool null_free = klass->is_loaded() && klass->as_array_klass()->storage_properties().is_null_free();
3477     if (null_free) {
3478       assert(etype->is_valuetypeptr(), "must be a valuetypeptr");
3479       etype = etype->join_speculative(TypePtr::NOTNULL)->is_oopptr();
3480     }
3481     // [V? has a subtype: [V. So even though V is final, [V? is not exact.
3482     bool xk = etype->klass_is_exact() && (!etype->is_valuetypeptr() || null_free);
3483     bool not_flat = !ValueArrayFlatten || xk || !etype->can_be_value_type() || (etype->is_valuetypeptr() && !etype->value_klass()->flatten_array());
3484     bool not_null_free = !etype->can_be_value_type();
3485     const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS, false, not_flat, not_null_free);
3486     // We used to pass NotNull in here, asserting that the sub-arrays
3487     // are all not-null.  This is not true in generally, as code can
3488     // slam NULLs down in the subarrays.
3489     const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, xk, Offset(0));
3490     return arr;
3491   } else if (klass->is_type_array_klass()) {
3492     // Element is an typeArray
3493     const Type* etype = get_const_basic_type(klass->as_type_array_klass()->element_type());
3494     const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS,
3495                                         /* stable= */ false, /* not_flat= */ true, /* not_null_free= */ true);
3496     // We used to pass NotNull in here, asserting that the array pointer
3497     // is not-null. That was not true in general.
3498     const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, true, Offset(0));
3499     return arr;
3500   } else if (klass->is_value_array_klass()) {
3501     ciValueKlass* vk = klass->as_array_klass()->element_klass()->as_value_klass();
3502     const TypeAry* arr0 = TypeAry::make(TypeValueType::make(vk), TypeInt::POS);
3503     const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, true, Offset(0));
3504     return arr;


4398          "integral arrays must be pre-equipped with a class");
4399   assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" );
4400   if (!xk)  xk = (o != NULL) || ary->ary_must_be_exact();
4401   assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
4402   if (!UseExactTypes)  xk = (ptr == Constant);
4403   return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, field_offset, instance_id, is_autobox_cache, speculative, inline_depth))->hashcons();
4404 }
4405 
4406 //------------------------------cast_to_ptr_type-------------------------------
4407 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const {
4408   if( ptr == _ptr ) return this;
4409   return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _field_offset, _instance_id, _speculative, _inline_depth, _is_autobox_cache);
4410 }
4411 
4412 
4413 //-----------------------------cast_to_exactness-------------------------------
4414 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const {
4415   if( klass_is_exact == _klass_is_exact ) return this;
4416   if (!UseExactTypes)  return this;
4417   if (_ary->ary_must_be_exact())  return this;  // cannot clear xk
4418   return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _field_offset, _instance_id, _speculative, _inline_depth, _is_autobox_cache);






4419 }
4420 
4421 //-----------------------------cast_to_instance_id----------------------------
4422 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const {
4423   if( instance_id == _instance_id ) return this;
4424   return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, _field_offset, instance_id, _speculative, _inline_depth, _is_autobox_cache);
4425 }
4426 
4427 const TypeOopPtr *TypeAryPtr::cast_to_nonconst() const {
4428   if (const_oop() == NULL) return this;
4429   return make(NotNull, NULL, _ary, klass(), _klass_is_exact, _offset, _field_offset, _instance_id, _speculative, _inline_depth);
4430 }
4431 
4432 
4433 //-----------------------------narrow_size_type-------------------------------
4434 // Local cache for arrayOopDesc::max_array_length(etype),
4435 // which is kind of slow (and cached elsewhere by other users).
4436 static jint max_array_length_cache[T_CONFLICT+1];
4437 static jint max_array_length(BasicType etype) {
4438   jint& cache = max_array_length_cache[etype];




3463       if (!klass_is_exact && try_for_exact
3464           && deps != NULL && UseExactTypes) {
3465         if (!ik->is_interface() && !ik->has_subklass()) {
3466           // Add a dependence; if concrete subclass added we need to recompile
3467           deps->assert_leaf_type(ik);
3468           klass_is_exact = true;
3469         }
3470       }
3471     }
3472     return TypeInstPtr::make(TypePtr::BotPTR, klass, klass_is_exact, NULL, Offset(0));
3473   } else if (klass->is_obj_array_klass()) {
3474     // Element is an object or value array. Recursively call ourself.
3475     const TypeOopPtr* etype = TypeOopPtr::make_from_klass_common(klass->as_array_klass()->element_klass(), false, try_for_exact);
3476     bool null_free = klass->is_loaded() && klass->as_array_klass()->storage_properties().is_null_free();
3477     if (null_free) {
3478       assert(etype->is_valuetypeptr(), "must be a valuetypeptr");
3479       etype = etype->join_speculative(TypePtr::NOTNULL)->is_oopptr();
3480     }
3481     // [V? has a subtype: [V. So even though V is final, [V? is not exact.
3482     bool xk = etype->klass_is_exact() && (!etype->is_valuetypeptr() || null_free);
3483     bool not_null_free = !etype->can_be_value_type() || xk;
3484     bool not_flat = !ValueArrayFlatten || not_null_free || (etype->is_valuetypeptr() && !etype->value_klass()->flatten_array());
3485     const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS, false, not_flat, not_null_free);
3486     // We used to pass NotNull in here, asserting that the sub-arrays
3487     // are all not-null.  This is not true in generally, as code can
3488     // slam NULLs down in the subarrays.
3489     const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, xk, Offset(0));
3490     return arr;
3491   } else if (klass->is_type_array_klass()) {
3492     // Element is an typeArray
3493     const Type* etype = get_const_basic_type(klass->as_type_array_klass()->element_type());
3494     const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS,
3495                                         /* stable= */ false, /* not_flat= */ true, /* not_null_free= */ true);
3496     // We used to pass NotNull in here, asserting that the array pointer
3497     // is not-null. That was not true in general.
3498     const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, true, Offset(0));
3499     return arr;
3500   } else if (klass->is_value_array_klass()) {
3501     ciValueKlass* vk = klass->as_array_klass()->element_klass()->as_value_klass();
3502     const TypeAry* arr0 = TypeAry::make(TypeValueType::make(vk), TypeInt::POS);
3503     const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, true, Offset(0));
3504     return arr;


4398          "integral arrays must be pre-equipped with a class");
4399   assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" );
4400   if (!xk)  xk = (o != NULL) || ary->ary_must_be_exact();
4401   assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
4402   if (!UseExactTypes)  xk = (ptr == Constant);
4403   return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, field_offset, instance_id, is_autobox_cache, speculative, inline_depth))->hashcons();
4404 }
4405 
4406 //------------------------------cast_to_ptr_type-------------------------------
4407 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const {
4408   if( ptr == _ptr ) return this;
4409   return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _field_offset, _instance_id, _speculative, _inline_depth, _is_autobox_cache);
4410 }
4411 
4412 
4413 //-----------------------------cast_to_exactness-------------------------------
4414 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const {
4415   if( klass_is_exact == _klass_is_exact ) return this;
4416   if (!UseExactTypes)  return this;
4417   if (_ary->ary_must_be_exact())  return this;  // cannot clear xk
4418 
4419   const TypeAry* new_ary = _ary;
4420   if (klass() != NULL && klass()->is_obj_array_klass() && klass_is_exact) {
4421     // An object array can't be flat or null-free if the klass is exact
4422     new_ary = TypeAry::make(elem(), size(), is_stable(), /* not_flat= */ true, /* not_null_free= */ true);
4423   }
4424   return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact, _offset, _field_offset, _instance_id, _speculative, _inline_depth, _is_autobox_cache);
4425 }
4426 
4427 //-----------------------------cast_to_instance_id----------------------------
4428 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const {
4429   if( instance_id == _instance_id ) return this;
4430   return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, _field_offset, instance_id, _speculative, _inline_depth, _is_autobox_cache);
4431 }
4432 
4433 const TypeOopPtr *TypeAryPtr::cast_to_nonconst() const {
4434   if (const_oop() == NULL) return this;
4435   return make(NotNull, NULL, _ary, klass(), _klass_is_exact, _offset, _field_offset, _instance_id, _speculative, _inline_depth);
4436 }
4437 
4438 
4439 //-----------------------------narrow_size_type-------------------------------
4440 // Local cache for arrayOopDesc::max_array_length(etype),
4441 // which is kind of slow (and cached elsewhere by other users).
4442 static jint max_array_length_cache[T_CONFLICT+1];
4443 static jint max_array_length(BasicType etype) {
4444   jint& cache = max_array_length_cache[etype];


< prev index next >