2979 // Type-specific hashing function.
2980 int TypeRawPtr::hash(void) const {
2981 return (intptr_t)_bits + TypePtr::hash();
2982 }
2983
2984 //------------------------------dump2------------------------------------------
2985 #ifndef PRODUCT
2986 void TypeRawPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
2987 if( _ptr == Constant )
2988 st->print(INTPTR_FORMAT, p2i(_bits));
2989 else
2990 st->print("rawptr:%s", ptr_msg[_ptr]);
2991 }
2992 #endif
2993
2994 //=============================================================================
2995 // Convenience common pre-built type.
2996 const TypeOopPtr *TypeOopPtr::BOTTOM;
2997
2998 //------------------------------TypeOopPtr-------------------------------------
2999 TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset offset,
3000 int instance_id, const TypePtr* speculative, int inline_depth)
3001 : TypePtr(t, ptr, offset, speculative, inline_depth),
3002 _const_oop(o), _klass(k),
3003 _klass_is_exact(xk),
3004 _is_ptr_to_narrowoop(false),
3005 _is_ptr_to_narrowklass(false),
3006 _is_ptr_to_boxed_value(false),
3007 _instance_id(instance_id) {
3008 if (Compile::current()->eliminate_boxing() && (t == InstPtr) &&
3009 (offset.get() > 0) && xk && (k != 0) && k->is_instance_klass()) {
3010 _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset.get());
3011 }
3012 #ifdef _LP64
3013 if (this->offset() != 0) {
3014 if (this->offset() == oopDesc::klass_offset_in_bytes()) {
3015 _is_ptr_to_narrowklass = UseCompressedClassPointers;
3016 } else if (klass() == NULL) {
3017 // Array with unknown body type
3018 assert(this->isa_aryptr(), "only arrays without klass");
3019 _is_ptr_to_narrowoop = UseCompressedOops;
3020 } else if (this->isa_aryptr()) {
3021 _is_ptr_to_narrowoop = (UseCompressedOops && klass()->is_obj_array_klass() &&
3022 this->offset() != arrayOopDesc::length_offset_in_bytes());
3023 } else if (klass()->is_instance_klass()) {
3024 ciInstanceKlass* ik = klass()->as_instance_klass();
3025 ciField* field = NULL;
3026 if (this->isa_klassptr()) {
3027 // Perm objects don't use compressed references
3028 } else if (_offset == Offset::bottom || _offset == Offset::top) {
3029 // unsafe access
3030 _is_ptr_to_narrowoop = UseCompressedOops;
3031 } else { // exclude unsafe ops
3032 assert(this->isa_instptr() || this->isa_valuetypeptr(), "must be an instance ptr.");
3033
3034 if (klass() == ciEnv::current()->Class_klass() &&
3035 (this->offset() == java_lang_Class::klass_offset_in_bytes() ||
3036 this->offset() == java_lang_Class::array_klass_offset_in_bytes())) {
3037 // Special hidden fields from the Class.
3038 assert(this->isa_instptr(), "must be an instance ptr.");
3039 _is_ptr_to_narrowoop = false;
3040 } else if (klass() == ciEnv::current()->Class_klass() &&
3041 this->offset() >= InstanceMirrorKlass::offset_of_static_fields()) {
3042 // Static fields
3059 // that it does not affect alias type.
3060 _is_ptr_to_narrowoop = UseCompressedOops;
3061 } else {
3062 // Type for the copy start in LibraryCallKit::inline_native_clone().
3063 _is_ptr_to_narrowoop = UseCompressedOops;
3064 }
3065 }
3066 }
3067 }
3068 }
3069 #endif
3070 }
3071
3072 //------------------------------make-------------------------------------------
3073 const TypeOopPtr *TypeOopPtr::make(PTR ptr, Offset offset, int instance_id,
3074 const TypePtr* speculative, int inline_depth) {
3075 assert(ptr != Constant, "no constant generic pointers");
3076 ciKlass* k = Compile::current()->env()->Object_klass();
3077 bool xk = false;
3078 ciObject* o = NULL;
3079 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative, inline_depth))->hashcons();
3080 }
3081
3082
3083 //------------------------------cast_to_ptr_type-------------------------------
3084 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const {
3085 assert(_base == OopPtr, "subclass must override cast_to_ptr_type");
3086 if( ptr == _ptr ) return this;
3087 return make(ptr, _offset, _instance_id, _speculative, _inline_depth);
3088 }
3089
3090 //-----------------------------cast_to_instance_id----------------------------
3091 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const {
3092 // There are no instances of a general oop.
3093 // Return self unchanged.
3094 return this;
3095 }
3096
3097 //-----------------------------cast_to_exactness-------------------------------
3098 const Type *TypeOopPtr::cast_to_exactness(bool klass_is_exact) const {
3099 // There is no such thing as an exact general oop.
3175 const TypePtr* speculative = xmeet_speculative(tp);
3176 int depth = meet_inline_depth(tp->inline_depth());
3177 return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative, depth);
3178 }
3179
3180 case InstPtr: // For these, flip the call around to cut down
3181 case ValueTypePtr:
3182 case AryPtr:
3183 return t->xmeet(this); // Call in reverse direction
3184
3185 } // End of switch
3186 return this; // Return the double constant
3187 }
3188
3189
3190 //------------------------------xdual------------------------------------------
3191 // Dual of a pure heap pointer. No relevant klass or oop information.
3192 const Type *TypeOopPtr::xdual() const {
3193 assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here");
3194 assert(const_oop() == NULL, "no constants here");
3195 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth());
3196 }
3197
3198 //--------------------------make_from_klass_common-----------------------------
3199 // Computes the element-type given a klass.
3200 const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) {
3201 if (klass->is_valuetype()) {
3202 return TypeValueTypePtr::make(TypePtr::NotNull, klass->as_value_klass());
3203 } else if (klass->is_instance_klass()) {
3204 Compile* C = Compile::current();
3205 Dependencies* deps = C->dependencies();
3206 assert((deps != NULL) == (C->method() != NULL && C->method()->code_size() > 0), "sanity");
3207 // Element is an instance
3208 bool klass_is_exact = false;
3209 if (klass->is_loaded()) {
3210 // Try to set klass_is_exact.
3211 ciInstanceKlass* ik = klass->as_instance_klass();
3212 klass_is_exact = ik->is_final();
3213 if (!klass_is_exact && klass_change
3214 && deps != NULL && UseUniqueSubclasses) {
3215 ciInstanceKlass* sub = ik->unique_concrete_subklass();
3510 */
3511 bool TypeOopPtr::would_improve_type(ciKlass* exact_kls, int inline_depth) const {
3512 // no way to improve an already exact type
3513 if (klass_is_exact()) {
3514 return false;
3515 }
3516 return TypePtr::would_improve_type(exact_kls, inline_depth);
3517 }
3518
3519 //=============================================================================
3520 // Convenience common pre-built types.
3521 const TypeInstPtr *TypeInstPtr::NOTNULL;
3522 const TypeInstPtr *TypeInstPtr::BOTTOM;
3523 const TypeInstPtr *TypeInstPtr::MIRROR;
3524 const TypeInstPtr *TypeInstPtr::MARK;
3525 const TypeInstPtr *TypeInstPtr::KLASS;
3526
3527 //------------------------------TypeInstPtr-------------------------------------
3528 TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset off,
3529 int instance_id, const TypePtr* speculative, int inline_depth)
3530 : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id, speculative, inline_depth),
3531 _name(k->name()) {
3532 assert(k != NULL &&
3533 (k->is_loaded() || o == NULL),
3534 "cannot have constants with non-loaded klass");
3535 };
3536
3537 //------------------------------make-------------------------------------------
3538 const TypeInstPtr *TypeInstPtr::make(PTR ptr,
3539 ciKlass* k,
3540 bool xk,
3541 ciObject* o,
3542 Offset offset,
3543 int instance_id,
3544 const TypePtr* speculative,
3545 int inline_depth) {
3546 assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance");
3547 // Either const_oop() is NULL or else ptr is Constant
3548 assert( (!o && ptr != Constant) || (o && ptr == Constant),
3549 "constant pointers must have a value supplied" );
3550 // Ptr is never Null
3694 typerr(t);
3695
3696 case MetadataPtr:
3697 case KlassPtr:
3698 case RawPtr: return TypePtr::BOTTOM;
3699
3700 case AryPtr: { // All arrays inherit from Object class
3701 const TypeAryPtr *tp = t->is_aryptr();
3702 Offset offset = meet_offset(tp->offset());
3703 PTR ptr = meet_ptr(tp->ptr());
3704 int instance_id = meet_instance_id(tp->instance_id());
3705 const TypePtr* speculative = xmeet_speculative(tp);
3706 int depth = meet_inline_depth(tp->inline_depth());
3707 switch (ptr) {
3708 case TopPTR:
3709 case AnyNull: // Fall 'down' to dual of object klass
3710 // For instances when a subclass meets a superclass we fall
3711 // below the centerline when the superclass is exact. We need to
3712 // do the same here.
3713 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) {
3714 return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, tp->_field_offset, instance_id, speculative, depth);
3715 } else {
3716 // cannot subclass, so the meet has to fall badly below the centerline
3717 ptr = NotNull;
3718 instance_id = InstanceBot;
3719 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth);
3720 }
3721 case Constant:
3722 case NotNull:
3723 case BotPTR: // Fall down to object klass
3724 // LCA is object_klass, but if we subclass from the top we can do better
3725 if( above_centerline(_ptr) ) { // if( _ptr == TopPTR || _ptr == AnyNull )
3726 // If 'this' (InstPtr) is above the centerline and it is Object class
3727 // then we can subclass in the Java class hierarchy.
3728 // For instances when a subclass meets a superclass we fall
3729 // below the centerline when the superclass is exact. We need
3730 // to do the same here.
3731 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) {
3732 // that is, tp's array type is a subtype of my klass
3733 return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL),
3734 tp->ary(), tp->klass(), tp->klass_is_exact(), offset, tp->_field_offset, instance_id, speculative, depth);
3735 }
3736 }
3737 // The other case cannot happen, since I cannot be a subtype of an array.
3738 // The meet falls down to Object class below centerline.
3739 if( ptr == Constant )
3740 ptr = NotNull;
3741 instance_id = InstanceBot;
3742 return make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth);
3743 default: typerr(t);
3744 }
3745 }
3746
3747 case OopPtr: { // Meeting to OopPtrs
3748 // Found a OopPtr type vs self-InstPtr type
3749 const TypeOopPtr *tp = t->is_oopptr();
3750 Offset offset = meet_offset(tp->offset());
3751 PTR ptr = meet_ptr(tp->ptr());
3752 switch (tp->ptr()) {
3753 case TopPTR:
3754 case AnyNull: {
4237 // The pointers in the autobox arrays are always non-null.
4238 TypePtr::PTR ptr_type = cache ? TypePtr::NotNull : TypePtr::AnyNull;
4239 etype = etype->cast_to_ptr_type(TypePtr::NotNull)->is_oopptr();
4240 const TypeAry* new_ary = TypeAry::make(etype, size(), is_stable());
4241 return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _field_offset, _instance_id, _speculative, _inline_depth, cache);
4242 }
4243
4244 //------------------------------eq---------------------------------------------
4245 // Structural equality check for Type representations
4246 bool TypeAryPtr::eq( const Type *t ) const {
4247 const TypeAryPtr *p = t->is_aryptr();
4248 return
4249 _ary == p->_ary && // Check array
4250 TypeOopPtr::eq(p) &&// Check sub-parts
4251 _field_offset == p->_field_offset;
4252 }
4253
4254 //------------------------------hash-------------------------------------------
4255 // Type-specific hashing function.
4256 int TypeAryPtr::hash(void) const {
4257 return (intptr_t)_ary + TypeOopPtr::hash() + field_offset();
4258 }
4259
4260 //------------------------------meet-------------------------------------------
4261 // Compute the MEET of two types. It returns a new Type object.
4262 const Type *TypeAryPtr::xmeet_helper(const Type *t) const {
4263 // Perform a fast test for common case; meeting the same types together.
4264 if( this == t ) return this; // Meeting same type-rep?
4265 // Current "this->_base" is Pointer
4266 switch (t->base()) { // switch on original type
4267
4268 // Mixing ints & oops happens when javac reuses local variables
4269 case Int:
4270 case Long:
4271 case FloatTop:
4272 case FloatCon:
4273 case FloatBot:
4274 case DoubleTop:
4275 case DoubleCon:
4276 case DoubleBot:
4277 case NarrowOop:
4423 // All arrays inherit from Object class
4424 case InstPtr: {
4425 const TypeInstPtr *tp = t->is_instptr();
4426 Offset offset = meet_offset(tp->offset());
4427 PTR ptr = meet_ptr(tp->ptr());
4428 int instance_id = meet_instance_id(tp->instance_id());
4429 const TypePtr* speculative = xmeet_speculative(tp);
4430 int depth = meet_inline_depth(tp->inline_depth());
4431 switch (ptr) {
4432 case TopPTR:
4433 case AnyNull: // Fall 'down' to dual of object klass
4434 // For instances when a subclass meets a superclass we fall
4435 // below the centerline when the superclass is exact. We need to
4436 // do the same here.
4437 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
4438 return TypeAryPtr::make(ptr, _ary, _klass, _klass_is_exact, offset, _field_offset, instance_id, speculative, depth);
4439 } else {
4440 // cannot subclass, so the meet has to fall badly below the centerline
4441 ptr = NotNull;
4442 instance_id = InstanceBot;
4443 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth);
4444 }
4445 case Constant:
4446 case NotNull:
4447 case BotPTR: // Fall down to object klass
4448 // LCA is object_klass, but if we subclass from the top we can do better
4449 if (above_centerline(tp->ptr())) {
4450 // If 'tp' is above the centerline and it is Object class
4451 // then we can subclass in the Java class hierarchy.
4452 // For instances when a subclass meets a superclass we fall
4453 // below the centerline when the superclass is exact. We need
4454 // to do the same here.
4455 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
4456 // that is, my array type is a subtype of 'tp' klass
4457 return make(ptr, (ptr == Constant ? const_oop() : NULL),
4458 _ary, _klass, _klass_is_exact, offset, _field_offset, instance_id, speculative, depth);
4459 }
4460 }
4461 // The other case cannot happen, since t cannot be a subtype of an array.
4462 // The meet falls down to Object class below centerline.
4463 if( ptr == Constant )
4464 ptr = NotNull;
4465 instance_id = InstanceBot;
4466 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth);
4467 default: typerr(t);
4468 }
4469 }
4470 }
4471 return this; // Lint noise
4472 }
4473
4474 //------------------------------xdual------------------------------------------
4475 // Dual: compute field-by-field dual
4476 const Type *TypeAryPtr::xdual() const {
4477 return new TypeAryPtr(dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_field_offset(), dual_instance_id(), is_autobox_cache(), dual_speculative(), dual_inline_depth());
4478 }
4479
4480 Type::Offset TypeAryPtr::meet_field_offset(int field_offset) const {
4481 return _field_offset.meet(Offset(field_offset));
4482 }
4483
4484 //------------------------------dual_offset------------------------------------
4485 Type::Offset TypeAryPtr::dual_field_offset() const {
4486 return _field_offset.dual();
4487 }
4488
4489 //----------------------interface_vs_oop---------------------------------------
4490 #ifdef ASSERT
4491 bool TypeAryPtr::interface_vs_oop(const Type *t) const {
4492 const TypeAryPtr* t_aryptr = t->isa_aryptr();
4493 if (t_aryptr) {
4494 return _ary->interface_vs_oop(t_aryptr->_ary);
4495 }
4496 return false;
4497 }
4498 #endif
4499
4500 //------------------------------dump2------------------------------------------
4501 #ifndef PRODUCT
|
2979 // Type-specific hashing function.
2980 int TypeRawPtr::hash(void) const {
2981 return (intptr_t)_bits + TypePtr::hash();
2982 }
2983
2984 //------------------------------dump2------------------------------------------
2985 #ifndef PRODUCT
2986 void TypeRawPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
2987 if( _ptr == Constant )
2988 st->print(INTPTR_FORMAT, p2i(_bits));
2989 else
2990 st->print("rawptr:%s", ptr_msg[_ptr]);
2991 }
2992 #endif
2993
2994 //=============================================================================
2995 // Convenience common pre-built type.
2996 const TypeOopPtr *TypeOopPtr::BOTTOM;
2997
2998 //------------------------------TypeOopPtr-------------------------------------
2999 TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset offset, Offset field_offset,
3000 int instance_id, const TypePtr* speculative, int inline_depth)
3001 : TypePtr(t, ptr, offset, speculative, inline_depth),
3002 _const_oop(o), _klass(k),
3003 _klass_is_exact(xk),
3004 _is_ptr_to_narrowoop(false),
3005 _is_ptr_to_narrowklass(false),
3006 _is_ptr_to_boxed_value(false),
3007 _instance_id(instance_id) {
3008 if (Compile::current()->eliminate_boxing() && (t == InstPtr) &&
3009 (offset.get() > 0) && xk && (k != 0) && k->is_instance_klass()) {
3010 _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset.get());
3011 }
3012 #ifdef _LP64
3013 if (this->offset() != 0) {
3014 if (this->offset() == oopDesc::klass_offset_in_bytes()) {
3015 _is_ptr_to_narrowklass = UseCompressedClassPointers;
3016 } else if (klass() == NULL) {
3017 // Array with unknown body type
3018 assert(this->isa_aryptr(), "only arrays without klass");
3019 _is_ptr_to_narrowoop = UseCompressedOops;
3020 } else if (UseCompressedOops && this->isa_aryptr() && this->offset() != arrayOopDesc::length_offset_in_bytes()) {
3021 if (klass()->is_obj_array_klass()) {
3022 _is_ptr_to_narrowoop = true;
3023 } else if (klass()->is_value_array_klass() && field_offset != Offset::top && field_offset != Offset::bottom) {
3024 // Check if the field of the value type array element contains oops
3025 ciValueKlass* vk = klass()->as_value_array_klass()->element_klass()->as_value_klass();
3026 int foffset = field_offset.get() + vk->first_field_offset();
3027 ciField* field = vk->get_field_by_offset(foffset, false);
3028 assert(field != NULL, "missing field");
3029 BasicType bt = field->layout_type();
3030 assert(bt != T_VALUETYPE, "should be flattened");
3031 _is_ptr_to_narrowoop = (bt == T_OBJECT || bt == T_ARRAY);
3032 }
3033 } else if (klass()->is_instance_klass()) {
3034 ciInstanceKlass* ik = klass()->as_instance_klass();
3035 ciField* field = NULL;
3036 if (this->isa_klassptr()) {
3037 // Perm objects don't use compressed references
3038 } else if (_offset == Offset::bottom || _offset == Offset::top) {
3039 // unsafe access
3040 _is_ptr_to_narrowoop = UseCompressedOops;
3041 } else { // exclude unsafe ops
3042 assert(this->isa_instptr() || this->isa_valuetypeptr(), "must be an instance ptr.");
3043
3044 if (klass() == ciEnv::current()->Class_klass() &&
3045 (this->offset() == java_lang_Class::klass_offset_in_bytes() ||
3046 this->offset() == java_lang_Class::array_klass_offset_in_bytes())) {
3047 // Special hidden fields from the Class.
3048 assert(this->isa_instptr(), "must be an instance ptr.");
3049 _is_ptr_to_narrowoop = false;
3050 } else if (klass() == ciEnv::current()->Class_klass() &&
3051 this->offset() >= InstanceMirrorKlass::offset_of_static_fields()) {
3052 // Static fields
3069 // that it does not affect alias type.
3070 _is_ptr_to_narrowoop = UseCompressedOops;
3071 } else {
3072 // Type for the copy start in LibraryCallKit::inline_native_clone().
3073 _is_ptr_to_narrowoop = UseCompressedOops;
3074 }
3075 }
3076 }
3077 }
3078 }
3079 #endif
3080 }
3081
3082 //------------------------------make-------------------------------------------
3083 const TypeOopPtr *TypeOopPtr::make(PTR ptr, Offset offset, int instance_id,
3084 const TypePtr* speculative, int inline_depth) {
3085 assert(ptr != Constant, "no constant generic pointers");
3086 ciKlass* k = Compile::current()->env()->Object_klass();
3087 bool xk = false;
3088 ciObject* o = NULL;
3089 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, Offset::bottom, instance_id, speculative, inline_depth))->hashcons();
3090 }
3091
3092
3093 //------------------------------cast_to_ptr_type-------------------------------
3094 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const {
3095 assert(_base == OopPtr, "subclass must override cast_to_ptr_type");
3096 if( ptr == _ptr ) return this;
3097 return make(ptr, _offset, _instance_id, _speculative, _inline_depth);
3098 }
3099
3100 //-----------------------------cast_to_instance_id----------------------------
3101 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const {
3102 // There are no instances of a general oop.
3103 // Return self unchanged.
3104 return this;
3105 }
3106
3107 //-----------------------------cast_to_exactness-------------------------------
3108 const Type *TypeOopPtr::cast_to_exactness(bool klass_is_exact) const {
3109 // There is no such thing as an exact general oop.
3185 const TypePtr* speculative = xmeet_speculative(tp);
3186 int depth = meet_inline_depth(tp->inline_depth());
3187 return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative, depth);
3188 }
3189
3190 case InstPtr: // For these, flip the call around to cut down
3191 case ValueTypePtr:
3192 case AryPtr:
3193 return t->xmeet(this); // Call in reverse direction
3194
3195 } // End of switch
3196 return this; // Return the double constant
3197 }
3198
3199
3200 //------------------------------xdual------------------------------------------
3201 // Dual of a pure heap pointer. No relevant klass or oop information.
3202 const Type *TypeOopPtr::xdual() const {
3203 assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here");
3204 assert(const_oop() == NULL, "no constants here");
3205 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), Offset::bottom, dual_instance_id(), dual_speculative(), dual_inline_depth());
3206 }
3207
3208 //--------------------------make_from_klass_common-----------------------------
3209 // Computes the element-type given a klass.
3210 const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) {
3211 if (klass->is_valuetype()) {
3212 return TypeValueTypePtr::make(TypePtr::NotNull, klass->as_value_klass());
3213 } else if (klass->is_instance_klass()) {
3214 Compile* C = Compile::current();
3215 Dependencies* deps = C->dependencies();
3216 assert((deps != NULL) == (C->method() != NULL && C->method()->code_size() > 0), "sanity");
3217 // Element is an instance
3218 bool klass_is_exact = false;
3219 if (klass->is_loaded()) {
3220 // Try to set klass_is_exact.
3221 ciInstanceKlass* ik = klass->as_instance_klass();
3222 klass_is_exact = ik->is_final();
3223 if (!klass_is_exact && klass_change
3224 && deps != NULL && UseUniqueSubclasses) {
3225 ciInstanceKlass* sub = ik->unique_concrete_subklass();
3520 */
3521 bool TypeOopPtr::would_improve_type(ciKlass* exact_kls, int inline_depth) const {
3522 // no way to improve an already exact type
3523 if (klass_is_exact()) {
3524 return false;
3525 }
3526 return TypePtr::would_improve_type(exact_kls, inline_depth);
3527 }
3528
3529 //=============================================================================
3530 // Convenience common pre-built types.
3531 const TypeInstPtr *TypeInstPtr::NOTNULL;
3532 const TypeInstPtr *TypeInstPtr::BOTTOM;
3533 const TypeInstPtr *TypeInstPtr::MIRROR;
3534 const TypeInstPtr *TypeInstPtr::MARK;
3535 const TypeInstPtr *TypeInstPtr::KLASS;
3536
3537 //------------------------------TypeInstPtr-------------------------------------
3538 TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset off,
3539 int instance_id, const TypePtr* speculative, int inline_depth)
3540 : TypeOopPtr(InstPtr, ptr, k, xk, o, off, Offset::bottom, instance_id, speculative, inline_depth),
3541 _name(k->name()) {
3542 assert(k != NULL &&
3543 (k->is_loaded() || o == NULL),
3544 "cannot have constants with non-loaded klass");
3545 };
3546
3547 //------------------------------make-------------------------------------------
3548 const TypeInstPtr *TypeInstPtr::make(PTR ptr,
3549 ciKlass* k,
3550 bool xk,
3551 ciObject* o,
3552 Offset offset,
3553 int instance_id,
3554 const TypePtr* speculative,
3555 int inline_depth) {
3556 assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance");
3557 // Either const_oop() is NULL or else ptr is Constant
3558 assert( (!o && ptr != Constant) || (o && ptr == Constant),
3559 "constant pointers must have a value supplied" );
3560 // Ptr is never Null
3704 typerr(t);
3705
3706 case MetadataPtr:
3707 case KlassPtr:
3708 case RawPtr: return TypePtr::BOTTOM;
3709
3710 case AryPtr: { // All arrays inherit from Object class
3711 const TypeAryPtr *tp = t->is_aryptr();
3712 Offset offset = meet_offset(tp->offset());
3713 PTR ptr = meet_ptr(tp->ptr());
3714 int instance_id = meet_instance_id(tp->instance_id());
3715 const TypePtr* speculative = xmeet_speculative(tp);
3716 int depth = meet_inline_depth(tp->inline_depth());
3717 switch (ptr) {
3718 case TopPTR:
3719 case AnyNull: // Fall 'down' to dual of object klass
3720 // For instances when a subclass meets a superclass we fall
3721 // below the centerline when the superclass is exact. We need to
3722 // do the same here.
3723 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) {
3724 return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, tp->field_offset(), instance_id, speculative, depth);
3725 } else {
3726 // cannot subclass, so the meet has to fall badly below the centerline
3727 ptr = NotNull;
3728 instance_id = InstanceBot;
3729 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth);
3730 }
3731 case Constant:
3732 case NotNull:
3733 case BotPTR: // Fall down to object klass
3734 // LCA is object_klass, but if we subclass from the top we can do better
3735 if( above_centerline(_ptr) ) { // if( _ptr == TopPTR || _ptr == AnyNull )
3736 // If 'this' (InstPtr) is above the centerline and it is Object class
3737 // then we can subclass in the Java class hierarchy.
3738 // For instances when a subclass meets a superclass we fall
3739 // below the centerline when the superclass is exact. We need
3740 // to do the same here.
3741 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) {
3742 // that is, tp's array type is a subtype of my klass
3743 return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL),
3744 tp->ary(), tp->klass(), tp->klass_is_exact(), offset, tp->field_offset(), instance_id, speculative, depth);
3745 }
3746 }
3747 // The other case cannot happen, since I cannot be a subtype of an array.
3748 // The meet falls down to Object class below centerline.
3749 if( ptr == Constant )
3750 ptr = NotNull;
3751 instance_id = InstanceBot;
3752 return make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth);
3753 default: typerr(t);
3754 }
3755 }
3756
3757 case OopPtr: { // Meeting to OopPtrs
3758 // Found a OopPtr type vs self-InstPtr type
3759 const TypeOopPtr *tp = t->is_oopptr();
3760 Offset offset = meet_offset(tp->offset());
3761 PTR ptr = meet_ptr(tp->ptr());
3762 switch (tp->ptr()) {
3763 case TopPTR:
3764 case AnyNull: {
4247 // The pointers in the autobox arrays are always non-null.
4248 TypePtr::PTR ptr_type = cache ? TypePtr::NotNull : TypePtr::AnyNull;
4249 etype = etype->cast_to_ptr_type(TypePtr::NotNull)->is_oopptr();
4250 const TypeAry* new_ary = TypeAry::make(etype, size(), is_stable());
4251 return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _field_offset, _instance_id, _speculative, _inline_depth, cache);
4252 }
4253
4254 //------------------------------eq---------------------------------------------
4255 // Structural equality check for Type representations
4256 bool TypeAryPtr::eq( const Type *t ) const {
4257 const TypeAryPtr *p = t->is_aryptr();
4258 return
4259 _ary == p->_ary && // Check array
4260 TypeOopPtr::eq(p) &&// Check sub-parts
4261 _field_offset == p->_field_offset;
4262 }
4263
4264 //------------------------------hash-------------------------------------------
4265 // Type-specific hashing function.
4266 int TypeAryPtr::hash(void) const {
4267 return (intptr_t)_ary + TypeOopPtr::hash() + _field_offset.get();
4268 }
4269
4270 //------------------------------meet-------------------------------------------
4271 // Compute the MEET of two types. It returns a new Type object.
4272 const Type *TypeAryPtr::xmeet_helper(const Type *t) const {
4273 // Perform a fast test for common case; meeting the same types together.
4274 if( this == t ) return this; // Meeting same type-rep?
4275 // Current "this->_base" is Pointer
4276 switch (t->base()) { // switch on original type
4277
4278 // Mixing ints & oops happens when javac reuses local variables
4279 case Int:
4280 case Long:
4281 case FloatTop:
4282 case FloatCon:
4283 case FloatBot:
4284 case DoubleTop:
4285 case DoubleCon:
4286 case DoubleBot:
4287 case NarrowOop:
4433 // All arrays inherit from Object class
4434 case InstPtr: {
4435 const TypeInstPtr *tp = t->is_instptr();
4436 Offset offset = meet_offset(tp->offset());
4437 PTR ptr = meet_ptr(tp->ptr());
4438 int instance_id = meet_instance_id(tp->instance_id());
4439 const TypePtr* speculative = xmeet_speculative(tp);
4440 int depth = meet_inline_depth(tp->inline_depth());
4441 switch (ptr) {
4442 case TopPTR:
4443 case AnyNull: // Fall 'down' to dual of object klass
4444 // For instances when a subclass meets a superclass we fall
4445 // below the centerline when the superclass is exact. We need to
4446 // do the same here.
4447 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
4448 return TypeAryPtr::make(ptr, _ary, _klass, _klass_is_exact, offset, _field_offset, instance_id, speculative, depth);
4449 } else {
4450 // cannot subclass, so the meet has to fall badly below the centerline
4451 ptr = NotNull;
4452 instance_id = InstanceBot;
4453 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth);
4454 }
4455 case Constant:
4456 case NotNull:
4457 case BotPTR: // Fall down to object klass
4458 // LCA is object_klass, but if we subclass from the top we can do better
4459 if (above_centerline(tp->ptr())) {
4460 // If 'tp' is above the centerline and it is Object class
4461 // then we can subclass in the Java class hierarchy.
4462 // For instances when a subclass meets a superclass we fall
4463 // below the centerline when the superclass is exact. We need
4464 // to do the same here.
4465 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
4466 // that is, my array type is a subtype of 'tp' klass
4467 return make(ptr, (ptr == Constant ? const_oop() : NULL),
4468 _ary, _klass, _klass_is_exact, offset, _field_offset, instance_id, speculative, depth);
4469 }
4470 }
4471 // The other case cannot happen, since t cannot be a subtype of an array.
4472 // The meet falls down to Object class below centerline.
4473 if( ptr == Constant )
4474 ptr = NotNull;
4475 instance_id = InstanceBot;
4476 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth);
4477 default: typerr(t);
4478 }
4479 }
4480 }
4481 return this; // Lint noise
4482 }
4483
4484 //------------------------------xdual------------------------------------------
4485 // Dual: compute field-by-field dual
4486 const Type *TypeAryPtr::xdual() const {
4487 return new TypeAryPtr(dual_ptr(), _const_oop, _ary->dual()->is_ary(), _klass, _klass_is_exact, dual_offset(), dual_field_offset(), dual_instance_id(), is_autobox_cache(), dual_speculative(), dual_inline_depth());
4488 }
4489
4490 Type::Offset TypeAryPtr::meet_field_offset(const Type::Offset offset) const {
4491 return _field_offset.meet(offset);
4492 }
4493
4494 //------------------------------dual_offset------------------------------------
4495 Type::Offset TypeAryPtr::dual_field_offset() const {
4496 return _field_offset.dual();
4497 }
4498
4499 //----------------------interface_vs_oop---------------------------------------
4500 #ifdef ASSERT
4501 bool TypeAryPtr::interface_vs_oop(const Type *t) const {
4502 const TypeAryPtr* t_aryptr = t->isa_aryptr();
4503 if (t_aryptr) {
4504 return _ary->interface_vs_oop(t_aryptr->_ary);
4505 }
4506 return false;
4507 }
4508 #endif
4509
4510 //------------------------------dump2------------------------------------------
4511 #ifndef PRODUCT
|