2979 _is_ptr_to_narrowoop = (UseCompressedOops && klass()->is_obj_array_klass() &&
2980 _offset != arrayOopDesc::length_offset_in_bytes());
2981 } else if (klass()->is_instance_klass()) {
2982 ciInstanceKlass* ik = klass()->as_instance_klass();
2983 ciField* field = NULL;
2984 if (this->isa_klassptr()) {
2985 // Perm objects don't use compressed references
2986 } else if (_offset == OffsetBot || _offset == OffsetTop) {
2987 // unsafe access
2988 _is_ptr_to_narrowoop = UseCompressedOops;
2989 } else { // exclude unsafe ops
2990 assert(this->isa_instptr(), "must be an instance ptr.");
2991
2992 if (klass() == ciEnv::current()->Class_klass() &&
2993 (_offset == java_lang_Class::klass_offset_in_bytes() ||
2994 _offset == java_lang_Class::array_klass_offset_in_bytes())) {
2995 // Special hidden fields from the Class.
2996 assert(this->isa_instptr(), "must be an instance ptr.");
2997 _is_ptr_to_narrowoop = false;
2998 } else if (klass() == ciEnv::current()->Class_klass() &&
2999 _offset >= InstanceMirrorKlass::offset_of_static_fields() &&
3000 !UseShenandoahGC) {
3001 // Static fields
3002 assert(o != NULL, "must be constant");
3003 ciInstanceKlass* k = o->as_instance()->java_lang_Class_klass()->as_instance_klass();
3004 ciField* field = k->get_field_by_offset(_offset, true);
3005 assert(field != NULL, "missing field");
3006 BasicType basic_elem_type = field->layout_type();
3007 _is_ptr_to_narrowoop = UseCompressedOops && (basic_elem_type == T_OBJECT ||
3008 basic_elem_type == T_ARRAY);
3009 } else {
3010 // Instance fields which contains a compressed oop references.
3011 field = ik->get_field_by_offset(_offset, false);
3012 if (field != NULL) {
3013 BasicType basic_elem_type = field->layout_type();
3014 _is_ptr_to_narrowoop = UseCompressedOops && (basic_elem_type == T_OBJECT ||
3015 basic_elem_type == T_ARRAY);
3016 } else if (klass()->equals(ciEnv::current()->Object_klass())) {
3017 // Compile::find_alias_type() cast exactness on all types to verify
3018 // that it does not affect alias type.
3019 _is_ptr_to_narrowoop = UseCompressedOops;
3020 } else {
3036 bool xk = false;
3037 ciObject* o = NULL;
3038 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative, inline_depth))->hashcons();
3039 }
3040
3041
3042 //------------------------------cast_to_ptr_type-------------------------------
3043 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const {
3044 assert(_base == OopPtr, "subclass must override cast_to_ptr_type");
3045 if( ptr == _ptr ) return this;
3046 return make(ptr, _offset, _instance_id, _speculative, _inline_depth);
3047 }
3048
3049 //-----------------------------cast_to_instance_id----------------------------
3050 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const {
3051 // There are no instances of a general oop.
3052 // Return self unchanged.
3053 return this;
3054 }
3055
3056 const TypeOopPtr *TypeOopPtr::cast_to_nonconst() const {
3057 return this;
3058 }
3059
3060 //-----------------------------cast_to_exactness-------------------------------
3061 const Type *TypeOopPtr::cast_to_exactness(bool klass_is_exact) const {
3062 // There is no such thing as an exact general oop.
3063 // Return self unchanged.
3064 return this;
3065 }
3066
3067
3068 //------------------------------as_klass_type----------------------------------
3069 // Return the klass type corresponding to this instance or array type.
3070 // It is the type that is loaded from an object of this type.
3071 const TypeKlassPtr* TypeOopPtr::as_klass_type() const {
3072 ciKlass* k = klass();
3073 bool xk = klass_is_exact();
3074 if (k == NULL)
3075 return TypeKlassPtr::OBJECT;
3076 else
3077 return TypeKlassPtr::make(xk? Constant: NotNull, k, 0);
3078 }
3079
3542 }
3543
3544
3545 //-----------------------------cast_to_exactness-------------------------------
3546 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const {
3547 if( klass_is_exact == _klass_is_exact ) return this;
3548 if (!UseExactTypes) return this;
3549 if (!_klass->is_loaded()) return this;
3550 ciInstanceKlass* ik = _klass->as_instance_klass();
3551 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk
3552 if( ik->is_interface() ) return this; // cannot set xk
3553 return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative, _inline_depth);
3554 }
3555
3556 //-----------------------------cast_to_instance_id----------------------------
3557 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const {
3558 if( instance_id == _instance_id ) return this;
3559 return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative, _inline_depth);
3560 }
3561
3562 const TypeOopPtr *TypeInstPtr::cast_to_nonconst() const {
3563 if (const_oop() == NULL) return this;
3564 return make(NotNull, klass(), _klass_is_exact, NULL, _offset, _instance_id, _speculative, _inline_depth);
3565 }
3566
3567 //------------------------------xmeet_unloaded---------------------------------
3568 // Compute the MEET of two InstPtrs when at least one is unloaded.
3569 // Assume classes are different since called after check for same name/class-loader
3570 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const {
3571 int off = meet_offset(tinst->offset());
3572 PTR ptr = meet_ptr(tinst->ptr());
3573 int instance_id = meet_instance_id(tinst->instance_id());
3574 const TypePtr* speculative = xmeet_speculative(tinst);
3575 int depth = meet_inline_depth(tinst->inline_depth());
3576
3577 const TypeInstPtr *loaded = is_loaded() ? this : tinst;
3578 const TypeInstPtr *unloaded = is_loaded() ? tinst : this;
3579 if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) {
3580 //
3581 // Meet unloaded class with java/lang/Object
3582 //
3583 // Meet
3584 // | Unloaded Class
3585 // Object | TOP | AnyNull | Constant | NotNull | BOTTOM |
3586 // ===================================================================
4073 //------------------------------cast_to_ptr_type-------------------------------
4074 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const {
4075 if( ptr == _ptr ) return this;
4076 return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth);
4077 }
4078
4079
4080 //-----------------------------cast_to_exactness-------------------------------
4081 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const {
4082 if( klass_is_exact == _klass_is_exact ) return this;
4083 if (!UseExactTypes) return this;
4084 if (_ary->ary_must_be_exact()) return this; // cannot clear xk
4085 return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative, _inline_depth);
4086 }
4087
4088 //-----------------------------cast_to_instance_id----------------------------
4089 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const {
4090 if( instance_id == _instance_id ) return this;
4091 return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative, _inline_depth);
4092 }
4093
4094 const TypeOopPtr *TypeAryPtr::cast_to_nonconst() const {
4095 if (const_oop() == NULL) return this;
4096 return make(NotNull, NULL, _ary, klass(), _klass_is_exact, _offset, _instance_id, _speculative, _inline_depth);
4097 }
4098
4099
4100 //-----------------------------narrow_size_type-------------------------------
4101 // Local cache for arrayOopDesc::max_array_length(etype),
4102 // which is kind of slow (and cached elsewhere by other users).
4103 static jint max_array_length_cache[T_CONFLICT+1];
4104 static jint max_array_length(BasicType etype) {
4105 jint& cache = max_array_length_cache[etype];
4106 jint res = cache;
4107 if (res == 0) {
4108 switch (etype) {
4109 case T_NARROWOOP:
4110 etype = T_OBJECT;
4111 break;
4112 case T_NARROWKLASS:
4113 case T_CONFLICT:
4114 case T_ILLEGAL:
4115 case T_VOID:
4116 etype = T_BYTE; // will produce conservatively high value
4117 break;
4118 default:
|
2979 _is_ptr_to_narrowoop = (UseCompressedOops && klass()->is_obj_array_klass() &&
2980 _offset != arrayOopDesc::length_offset_in_bytes());
2981 } else if (klass()->is_instance_klass()) {
2982 ciInstanceKlass* ik = klass()->as_instance_klass();
2983 ciField* field = NULL;
2984 if (this->isa_klassptr()) {
2985 // Perm objects don't use compressed references
2986 } else if (_offset == OffsetBot || _offset == OffsetTop) {
2987 // unsafe access
2988 _is_ptr_to_narrowoop = UseCompressedOops;
2989 } else { // exclude unsafe ops
2990 assert(this->isa_instptr(), "must be an instance ptr.");
2991
2992 if (klass() == ciEnv::current()->Class_klass() &&
2993 (_offset == java_lang_Class::klass_offset_in_bytes() ||
2994 _offset == java_lang_Class::array_klass_offset_in_bytes())) {
2995 // Special hidden fields from the Class.
2996 assert(this->isa_instptr(), "must be an instance ptr.");
2997 _is_ptr_to_narrowoop = false;
2998 } else if (klass() == ciEnv::current()->Class_klass() &&
2999 _offset >= InstanceMirrorKlass::offset_of_static_fields()) {
3000 // Static fields
3001 assert(o != NULL, "must be constant");
3002 ciInstanceKlass* k = o->as_instance()->java_lang_Class_klass()->as_instance_klass();
3003 ciField* field = k->get_field_by_offset(_offset, true);
3004 assert(field != NULL, "missing field");
3005 BasicType basic_elem_type = field->layout_type();
3006 _is_ptr_to_narrowoop = UseCompressedOops && (basic_elem_type == T_OBJECT ||
3007 basic_elem_type == T_ARRAY);
3008 } else {
3009 // Instance fields which contains a compressed oop references.
3010 field = ik->get_field_by_offset(_offset, false);
3011 if (field != NULL) {
3012 BasicType basic_elem_type = field->layout_type();
3013 _is_ptr_to_narrowoop = UseCompressedOops && (basic_elem_type == T_OBJECT ||
3014 basic_elem_type == T_ARRAY);
3015 } else if (klass()->equals(ciEnv::current()->Object_klass())) {
3016 // Compile::find_alias_type() cast exactness on all types to verify
3017 // that it does not affect alias type.
3018 _is_ptr_to_narrowoop = UseCompressedOops;
3019 } else {
3035 bool xk = false;
3036 ciObject* o = NULL;
3037 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative, inline_depth))->hashcons();
3038 }
3039
3040
3041 //------------------------------cast_to_ptr_type-------------------------------
3042 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const {
3043 assert(_base == OopPtr, "subclass must override cast_to_ptr_type");
3044 if( ptr == _ptr ) return this;
3045 return make(ptr, _offset, _instance_id, _speculative, _inline_depth);
3046 }
3047
3048 //-----------------------------cast_to_instance_id----------------------------
3049 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const {
3050 // There are no instances of a general oop.
3051 // Return self unchanged.
3052 return this;
3053 }
3054
3055 //-----------------------------cast_to_exactness-------------------------------
3056 const Type *TypeOopPtr::cast_to_exactness(bool klass_is_exact) const {
3057 // There is no such thing as an exact general oop.
3058 // Return self unchanged.
3059 return this;
3060 }
3061
3062
3063 //------------------------------as_klass_type----------------------------------
3064 // Return the klass type corresponding to this instance or array type.
3065 // It is the type that is loaded from an object of this type.
3066 const TypeKlassPtr* TypeOopPtr::as_klass_type() const {
3067 ciKlass* k = klass();
3068 bool xk = klass_is_exact();
3069 if (k == NULL)
3070 return TypeKlassPtr::OBJECT;
3071 else
3072 return TypeKlassPtr::make(xk? Constant: NotNull, k, 0);
3073 }
3074
3537 }
3538
3539
3540 //-----------------------------cast_to_exactness-------------------------------
3541 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const {
3542 if( klass_is_exact == _klass_is_exact ) return this;
3543 if (!UseExactTypes) return this;
3544 if (!_klass->is_loaded()) return this;
3545 ciInstanceKlass* ik = _klass->as_instance_klass();
3546 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk
3547 if( ik->is_interface() ) return this; // cannot set xk
3548 return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative, _inline_depth);
3549 }
3550
3551 //-----------------------------cast_to_instance_id----------------------------
3552 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const {
3553 if( instance_id == _instance_id ) return this;
3554 return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative, _inline_depth);
3555 }
3556
3557 //------------------------------xmeet_unloaded---------------------------------
3558 // Compute the MEET of two InstPtrs when at least one is unloaded.
3559 // Assume classes are different since called after check for same name/class-loader
3560 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const {
3561 int off = meet_offset(tinst->offset());
3562 PTR ptr = meet_ptr(tinst->ptr());
3563 int instance_id = meet_instance_id(tinst->instance_id());
3564 const TypePtr* speculative = xmeet_speculative(tinst);
3565 int depth = meet_inline_depth(tinst->inline_depth());
3566
3567 const TypeInstPtr *loaded = is_loaded() ? this : tinst;
3568 const TypeInstPtr *unloaded = is_loaded() ? tinst : this;
3569 if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) {
3570 //
3571 // Meet unloaded class with java/lang/Object
3572 //
3573 // Meet
3574 // | Unloaded Class
3575 // Object | TOP | AnyNull | Constant | NotNull | BOTTOM |
3576 // ===================================================================
4063 //------------------------------cast_to_ptr_type-------------------------------
4064 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const {
4065 if( ptr == _ptr ) return this;
4066 return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth);
4067 }
4068
4069
4070 //-----------------------------cast_to_exactness-------------------------------
4071 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const {
4072 if( klass_is_exact == _klass_is_exact ) return this;
4073 if (!UseExactTypes) return this;
4074 if (_ary->ary_must_be_exact()) return this; // cannot clear xk
4075 return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative, _inline_depth);
4076 }
4077
4078 //-----------------------------cast_to_instance_id----------------------------
4079 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const {
4080 if( instance_id == _instance_id ) return this;
4081 return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative, _inline_depth);
4082 }
4083
4084 //-----------------------------narrow_size_type-------------------------------
4085 // Local cache for arrayOopDesc::max_array_length(etype),
4086 // which is kind of slow (and cached elsewhere by other users).
4087 static jint max_array_length_cache[T_CONFLICT+1];
4088 static jint max_array_length(BasicType etype) {
4089 jint& cache = max_array_length_cache[etype];
4090 jint res = cache;
4091 if (res == 0) {
4092 switch (etype) {
4093 case T_NARROWOOP:
4094 etype = T_OBJECT;
4095 break;
4096 case T_NARROWKLASS:
4097 case T_CONFLICT:
4098 case T_ILLEGAL:
4099 case T_VOID:
4100 etype = T_BYTE; // will produce conservatively high value
4101 break;
4102 default:
|