< prev index next >

src/hotspot/share/opto/type.cpp

Print this page
rev 57329 : 8234974: Shenandoah: Do concurrent roots even when no evacuation is necessary


3034   bool      xk = false;
3035   ciObject* o = NULL;
3036   return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative, inline_depth))->hashcons();
3037 }
3038 
3039 
3040 //------------------------------cast_to_ptr_type-------------------------------
3041 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const {
3042   assert(_base == OopPtr, "subclass must override cast_to_ptr_type");
3043   if( ptr == _ptr ) return this;
3044   return make(ptr, _offset, _instance_id, _speculative, _inline_depth);
3045 }
3046 
3047 //-----------------------------cast_to_instance_id----------------------------
3048 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const {
3049   // There are no instances of a general oop.
3050   // Return self unchanged.
3051   return this;
3052 }
3053 
3054 const TypeOopPtr *TypeOopPtr::cast_to_nonconst() const {
3055   return this;
3056 }
3057 
3058 //-----------------------------cast_to_exactness-------------------------------
3059 const Type *TypeOopPtr::cast_to_exactness(bool klass_is_exact) const {
3060   // There is no such thing as an exact general oop.
3061   // Return self unchanged.
3062   return this;
3063 }
3064 
3065 
3066 //------------------------------as_klass_type----------------------------------
3067 // Return the klass type corresponding to this instance or array type.
3068 // It is the type that is loaded from an object of this type.
3069 const TypeKlassPtr* TypeOopPtr::as_klass_type() const {
3070   ciKlass* k = klass();
3071   bool    xk = klass_is_exact();
3072   if (k == NULL)
3073     return TypeKlassPtr::OBJECT;
3074   else
3075     return TypeKlassPtr::make(xk? Constant: NotNull, k, 0);
3076 }
3077 


3544 }
3545 
3546 
3547 //-----------------------------cast_to_exactness-------------------------------
3548 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const {
3549   if( klass_is_exact == _klass_is_exact ) return this;
3550   if (!UseExactTypes)  return this;
3551   if (!_klass->is_loaded())  return this;
3552   ciInstanceKlass* ik = _klass->as_instance_klass();
3553   if( (ik->is_final() || _const_oop) )  return this;  // cannot clear xk
3554   if( ik->is_interface() )              return this;  // cannot set xk
3555   return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative, _inline_depth);
3556 }
3557 
3558 //-----------------------------cast_to_instance_id----------------------------
3559 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const {
3560   if( instance_id == _instance_id ) return this;
3561   return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative, _inline_depth);
3562 }
3563 
3564 const TypeOopPtr *TypeInstPtr::cast_to_nonconst() const {
3565   if (const_oop() == NULL) return this;
3566   return make(NotNull, klass(), _klass_is_exact, NULL, _offset, _instance_id, _speculative, _inline_depth);
3567 }
3568 
3569 //------------------------------xmeet_unloaded---------------------------------
3570 // Compute the MEET of two InstPtrs when at least one is unloaded.
3571 // Assume classes are different since called after check for same name/class-loader
3572 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const {
3573     int off = meet_offset(tinst->offset());
3574     PTR ptr = meet_ptr(tinst->ptr());
3575     int instance_id = meet_instance_id(tinst->instance_id());
3576     const TypePtr* speculative = xmeet_speculative(tinst);
3577     int depth = meet_inline_depth(tinst->inline_depth());
3578 
3579     const TypeInstPtr *loaded    = is_loaded() ? this  : tinst;
3580     const TypeInstPtr *unloaded  = is_loaded() ? tinst : this;
3581     if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) {
3582       //
3583       // Meet unloaded class with java/lang/Object
3584       //
3585       // Meet
3586       //          |                     Unloaded Class
3587       //  Object  |   TOP    |   AnyNull | Constant |   NotNull |  BOTTOM   |
3588       //  ===================================================================


4079 
4080 //------------------------------cast_to_ptr_type-------------------------------
4081 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const {
4082   if( ptr == _ptr ) return this;
4083   return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth);
4084 }
4085 
4086 
4087 //-----------------------------cast_to_exactness-------------------------------
4088 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const {
4089   if( klass_is_exact == _klass_is_exact ) return this;
4090   if (!UseExactTypes)  return this;
4091   if (_ary->ary_must_be_exact())  return this;  // cannot clear xk
4092   return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative, _inline_depth);
4093 }
4094 
4095 //-----------------------------cast_to_instance_id----------------------------
4096 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const {
4097   if( instance_id == _instance_id ) return this;
4098   return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative, _inline_depth);
4099 }
4100 
4101 const TypeOopPtr *TypeAryPtr::cast_to_nonconst() const {
4102   if (const_oop() == NULL) return this;
4103   return make(NotNull, NULL, _ary, klass(), _klass_is_exact, _offset, _instance_id, _speculative, _inline_depth);
4104 }
4105 
4106 
4107 //-----------------------------max_array_length-------------------------------
4108 // A wrapper around arrayOopDesc::max_array_length(etype) with some input normalization.
4109 jint TypeAryPtr::max_array_length(BasicType etype) {
4110   if (!is_java_primitive(etype) && !is_reference_type(etype)) {
4111     if (etype == T_NARROWOOP) {
4112       etype = T_OBJECT;
4113     } else if (etype == T_ILLEGAL) { // bottom[]
4114       etype = T_BYTE; // will produce conservatively high value
4115     } else {
4116       fatal("not an element type: %s", type2name(etype));
4117     }
4118   }
4119   return arrayOopDesc::max_array_length(etype);
4120 }
4121 
4122 //-----------------------------narrow_size_type-------------------------------
4123 // Narrow the given size type to the index range for the given array base type.




3034   bool      xk = false;
3035   ciObject* o = NULL;
3036   return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative, inline_depth))->hashcons();
3037 }
3038 
3039 
3040 //------------------------------cast_to_ptr_type-------------------------------
3041 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const {
3042   assert(_base == OopPtr, "subclass must override cast_to_ptr_type");
3043   if( ptr == _ptr ) return this;
3044   return make(ptr, _offset, _instance_id, _speculative, _inline_depth);
3045 }
3046 
3047 //-----------------------------cast_to_instance_id----------------------------
3048 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const {
3049   // There are no instances of a general oop.
3050   // Return self unchanged.
3051   return this;
3052 }
3053 




3054 //-----------------------------cast_to_exactness-------------------------------
3055 const Type *TypeOopPtr::cast_to_exactness(bool klass_is_exact) const {
3056   // There is no such thing as an exact general oop.
3057   // Return self unchanged.
3058   return this;
3059 }
3060 
3061 
3062 //------------------------------as_klass_type----------------------------------
3063 // Return the klass type corresponding to this instance or array type.
3064 // It is the type that is loaded from an object of this type.
3065 const TypeKlassPtr* TypeOopPtr::as_klass_type() const {
3066   ciKlass* k = klass();
3067   bool    xk = klass_is_exact();
3068   if (k == NULL)
3069     return TypeKlassPtr::OBJECT;
3070   else
3071     return TypeKlassPtr::make(xk? Constant: NotNull, k, 0);
3072 }
3073 


3540 }
3541 
3542 
3543 //-----------------------------cast_to_exactness-------------------------------
3544 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const {
3545   if( klass_is_exact == _klass_is_exact ) return this;
3546   if (!UseExactTypes)  return this;
3547   if (!_klass->is_loaded())  return this;
3548   ciInstanceKlass* ik = _klass->as_instance_klass();
3549   if( (ik->is_final() || _const_oop) )  return this;  // cannot clear xk
3550   if( ik->is_interface() )              return this;  // cannot set xk
3551   return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative, _inline_depth);
3552 }
3553 
3554 //-----------------------------cast_to_instance_id----------------------------
3555 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const {
3556   if( instance_id == _instance_id ) return this;
3557   return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative, _inline_depth);
3558 }
3559 





3560 //------------------------------xmeet_unloaded---------------------------------
3561 // Compute the MEET of two InstPtrs when at least one is unloaded.
3562 // Assume classes are different since called after check for same name/class-loader
3563 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const {
3564     int off = meet_offset(tinst->offset());
3565     PTR ptr = meet_ptr(tinst->ptr());
3566     int instance_id = meet_instance_id(tinst->instance_id());
3567     const TypePtr* speculative = xmeet_speculative(tinst);
3568     int depth = meet_inline_depth(tinst->inline_depth());
3569 
3570     const TypeInstPtr *loaded    = is_loaded() ? this  : tinst;
3571     const TypeInstPtr *unloaded  = is_loaded() ? tinst : this;
3572     if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) {
3573       //
3574       // Meet unloaded class with java/lang/Object
3575       //
3576       // Meet
3577       //          |                     Unloaded Class
3578       //  Object  |   TOP    |   AnyNull | Constant |   NotNull |  BOTTOM   |
3579       //  ===================================================================


4070 
4071 //------------------------------cast_to_ptr_type-------------------------------
4072 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const {
4073   if( ptr == _ptr ) return this;
4074   return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth);
4075 }
4076 
4077 
4078 //-----------------------------cast_to_exactness-------------------------------
4079 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const {
4080   if( klass_is_exact == _klass_is_exact ) return this;
4081   if (!UseExactTypes)  return this;
4082   if (_ary->ary_must_be_exact())  return this;  // cannot clear xk
4083   return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative, _inline_depth);
4084 }
4085 
4086 //-----------------------------cast_to_instance_id----------------------------
4087 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const {
4088   if( instance_id == _instance_id ) return this;
4089   return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative, _inline_depth);





4090 }
4091 
4092 
4093 //-----------------------------max_array_length-------------------------------
4094 // A wrapper around arrayOopDesc::max_array_length(etype) with some input normalization.
4095 jint TypeAryPtr::max_array_length(BasicType etype) {
4096   if (!is_java_primitive(etype) && !is_reference_type(etype)) {
4097     if (etype == T_NARROWOOP) {
4098       etype = T_OBJECT;
4099     } else if (etype == T_ILLEGAL) { // bottom[]
4100       etype = T_BYTE; // will produce conservatively high value
4101     } else {
4102       fatal("not an element type: %s", type2name(etype));
4103     }
4104   }
4105   return arrayOopDesc::max_array_length(etype);
4106 }
4107 
4108 //-----------------------------narrow_size_type-------------------------------
4109 // Narrow the given size type to the index range for the given array base type.


< prev index next >