3027 bool xk = false; 3028 ciObject* o = NULL; 3029 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative, inline_depth))->hashcons(); 3030 } 3031 3032 3033 //------------------------------cast_to_ptr_type------------------------------- 3034 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const { 3035 assert(_base == OopPtr, "subclass must override cast_to_ptr_type"); 3036 if( ptr == _ptr ) return this; 3037 return make(ptr, _offset, _instance_id, _speculative, _inline_depth); 3038 } 3039 3040 //-----------------------------cast_to_instance_id---------------------------- 3041 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const { 3042 // There are no instances of a general oop. 3043 // Return self unchanged. 3044 return this; 3045 } 3046 3047 //-----------------------------cast_to_exactness------------------------------- 3048 const Type *TypeOopPtr::cast_to_exactness(bool klass_is_exact) const { 3049 // There is no such thing as an exact general oop. 3050 // Return self unchanged. 3051 return this; 3052 } 3053 3054 3055 //------------------------------as_klass_type---------------------------------- 3056 // Return the klass type corresponding to this instance or array type. 3057 // It is the type that is loaded from an object of this type. 3058 const TypeKlassPtr* TypeOopPtr::as_klass_type() const { 3059 ciKlass* k = klass(); 3060 bool xk = klass_is_exact(); 3061 if (k == NULL) 3062 return TypeKlassPtr::OBJECT; 3063 else 3064 return TypeKlassPtr::make(xk? Constant: NotNull, k, 0); 3065 } 3066 3529 } 3530 3531 3532 //-----------------------------cast_to_exactness------------------------------- 3533 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const { 3534 if( klass_is_exact == _klass_is_exact ) return this; 3535 if (!UseExactTypes) return this; 3536 if (!_klass->is_loaded()) return this; 3537 ciInstanceKlass* ik = _klass->as_instance_klass(); 3538 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk 3539 if( ik->is_interface() ) return this; // cannot set xk 3540 return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative, _inline_depth); 3541 } 3542 3543 //-----------------------------cast_to_instance_id---------------------------- 3544 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const { 3545 if( instance_id == _instance_id ) return this; 3546 return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative, _inline_depth); 3547 } 3548 3549 //------------------------------xmeet_unloaded--------------------------------- 3550 // Compute the MEET of two InstPtrs when at least one is unloaded. 3551 // Assume classes are different since called after check for same name/class-loader 3552 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const { 3553 int off = meet_offset(tinst->offset()); 3554 PTR ptr = meet_ptr(tinst->ptr()); 3555 int instance_id = meet_instance_id(tinst->instance_id()); 3556 const TypePtr* speculative = xmeet_speculative(tinst); 3557 int depth = meet_inline_depth(tinst->inline_depth()); 3558 3559 const TypeInstPtr *loaded = is_loaded() ? this : tinst; 3560 const TypeInstPtr *unloaded = is_loaded() ? tinst : this; 3561 if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) { 3562 // 3563 // Meet unloaded class with java/lang/Object 3564 // 3565 // Meet 3566 // | Unloaded Class 3567 // Object | TOP | AnyNull | Constant | NotNull | BOTTOM | 3568 // =================================================================== 4055 //------------------------------cast_to_ptr_type------------------------------- 4056 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const { 4057 if( ptr == _ptr ) return this; 4058 return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth); 4059 } 4060 4061 4062 //-----------------------------cast_to_exactness------------------------------- 4063 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const { 4064 if( klass_is_exact == _klass_is_exact ) return this; 4065 if (!UseExactTypes) return this; 4066 if (_ary->ary_must_be_exact()) return this; // cannot clear xk 4067 return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative, _inline_depth); 4068 } 4069 4070 //-----------------------------cast_to_instance_id---------------------------- 4071 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const { 4072 if( instance_id == _instance_id ) return this; 4073 return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative, _inline_depth); 4074 } 4075 4076 //-----------------------------narrow_size_type------------------------------- 4077 // Local cache for arrayOopDesc::max_array_length(etype), 4078 // which is kind of slow (and cached elsewhere by other users). 4079 static jint max_array_length_cache[T_CONFLICT+1]; 4080 static jint max_array_length(BasicType etype) { 4081 jint& cache = max_array_length_cache[etype]; 4082 jint res = cache; 4083 if (res == 0) { 4084 switch (etype) { 4085 case T_NARROWOOP: 4086 etype = T_OBJECT; 4087 break; 4088 case T_NARROWKLASS: 4089 case T_CONFLICT: 4090 case T_ILLEGAL: 4091 case T_VOID: 4092 etype = T_BYTE; // will produce conservatively high value 4093 break; 4094 default: | 3027 bool xk = false; 3028 ciObject* o = NULL; 3029 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative, inline_depth))->hashcons(); 3030 } 3031 3032 3033 //------------------------------cast_to_ptr_type------------------------------- 3034 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const { 3035 assert(_base == OopPtr, "subclass must override cast_to_ptr_type"); 3036 if( ptr == _ptr ) return this; 3037 return make(ptr, _offset, _instance_id, _speculative, _inline_depth); 3038 } 3039 3040 //-----------------------------cast_to_instance_id---------------------------- 3041 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const { 3042 // There are no instances of a general oop. 3043 // Return self unchanged. 3044 return this; 3045 } 3046 3047 const TypeOopPtr *TypeOopPtr::cast_to_nonconst() const { 3048 return this; 3049 } 3050 3051 //-----------------------------cast_to_exactness------------------------------- 3052 const Type *TypeOopPtr::cast_to_exactness(bool klass_is_exact) const { 3053 // There is no such thing as an exact general oop. 3054 // Return self unchanged. 3055 return this; 3056 } 3057 3058 3059 //------------------------------as_klass_type---------------------------------- 3060 // Return the klass type corresponding to this instance or array type. 3061 // It is the type that is loaded from an object of this type. 3062 const TypeKlassPtr* TypeOopPtr::as_klass_type() const { 3063 ciKlass* k = klass(); 3064 bool xk = klass_is_exact(); 3065 if (k == NULL) 3066 return TypeKlassPtr::OBJECT; 3067 else 3068 return TypeKlassPtr::make(xk? Constant: NotNull, k, 0); 3069 } 3070 3533 } 3534 3535 3536 //-----------------------------cast_to_exactness------------------------------- 3537 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const { 3538 if( klass_is_exact == _klass_is_exact ) return this; 3539 if (!UseExactTypes) return this; 3540 if (!_klass->is_loaded()) return this; 3541 ciInstanceKlass* ik = _klass->as_instance_klass(); 3542 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk 3543 if( ik->is_interface() ) return this; // cannot set xk 3544 return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative, _inline_depth); 3545 } 3546 3547 //-----------------------------cast_to_instance_id---------------------------- 3548 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const { 3549 if( instance_id == _instance_id ) return this; 3550 return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative, _inline_depth); 3551 } 3552 3553 const TypeOopPtr *TypeInstPtr::cast_to_nonconst() const { 3554 if (const_oop() == NULL) return this; 3555 return make(NotNull, klass(), _klass_is_exact, NULL, _offset, _instance_id, _speculative, _inline_depth); 3556 } 3557 3558 //------------------------------xmeet_unloaded--------------------------------- 3559 // Compute the MEET of two InstPtrs when at least one is unloaded. 3560 // Assume classes are different since called after check for same name/class-loader 3561 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const { 3562 int off = meet_offset(tinst->offset()); 3563 PTR ptr = meet_ptr(tinst->ptr()); 3564 int instance_id = meet_instance_id(tinst->instance_id()); 3565 const TypePtr* speculative = xmeet_speculative(tinst); 3566 int depth = meet_inline_depth(tinst->inline_depth()); 3567 3568 const TypeInstPtr *loaded = is_loaded() ? this : tinst; 3569 const TypeInstPtr *unloaded = is_loaded() ? tinst : this; 3570 if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) { 3571 // 3572 // Meet unloaded class with java/lang/Object 3573 // 3574 // Meet 3575 // | Unloaded Class 3576 // Object | TOP | AnyNull | Constant | NotNull | BOTTOM | 3577 // =================================================================== 4064 //------------------------------cast_to_ptr_type------------------------------- 4065 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const { 4066 if( ptr == _ptr ) return this; 4067 return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth); 4068 } 4069 4070 4071 //-----------------------------cast_to_exactness------------------------------- 4072 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const { 4073 if( klass_is_exact == _klass_is_exact ) return this; 4074 if (!UseExactTypes) return this; 4075 if (_ary->ary_must_be_exact()) return this; // cannot clear xk 4076 return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative, _inline_depth); 4077 } 4078 4079 //-----------------------------cast_to_instance_id---------------------------- 4080 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const { 4081 if( instance_id == _instance_id ) return this; 4082 return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative, _inline_depth); 4083 } 4084 4085 const TypeOopPtr *TypeAryPtr::cast_to_nonconst() const { 4086 if (const_oop() == NULL) return this; 4087 return make(NotNull, NULL, _ary, klass(), _klass_is_exact, _offset, _instance_id, _speculative, _inline_depth); 4088 } 4089 4090 4091 //-----------------------------narrow_size_type------------------------------- 4092 // Local cache for arrayOopDesc::max_array_length(etype), 4093 // which is kind of slow (and cached elsewhere by other users). 4094 static jint max_array_length_cache[T_CONFLICT+1]; 4095 static jint max_array_length(BasicType etype) { 4096 jint& cache = max_array_length_cache[etype]; 4097 jint res = cache; 4098 if (res == 0) { 4099 switch (etype) { 4100 case T_NARROWOOP: 4101 etype = T_OBJECT; 4102 break; 4103 case T_NARROWKLASS: 4104 case T_CONFLICT: 4105 case T_ILLEGAL: 4106 case T_VOID: 4107 etype = T_BYTE; // will produce conservatively high value 4108 break; 4109 default: |