3072 // Type-specific hashing function.
3073 int TypeRawPtr::hash(void) const {
3074 return (intptr_t)_bits + TypePtr::hash();
3075 }
3076
3077 //------------------------------dump2------------------------------------------
3078 #ifndef PRODUCT
3079 void TypeRawPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
3080 if( _ptr == Constant )
3081 st->print(INTPTR_FORMAT, p2i(_bits));
3082 else
3083 st->print("rawptr:%s", ptr_msg[_ptr]);
3084 }
3085 #endif
3086
3087 //=============================================================================
3088 // Convenience common pre-built type.
3089 const TypeOopPtr *TypeOopPtr::BOTTOM;
3090
3091 //------------------------------TypeOopPtr-------------------------------------
3092 TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset offset,
3093 int instance_id, const TypePtr* speculative, int inline_depth)
3094 : TypePtr(t, ptr, offset, speculative, inline_depth),
3095 _const_oop(o), _klass(k),
3096 _klass_is_exact(xk),
3097 _is_ptr_to_narrowoop(false),
3098 _is_ptr_to_narrowklass(false),
3099 _is_ptr_to_boxed_value(false),
3100 _instance_id(instance_id) {
3101 if (Compile::current()->eliminate_boxing() && (t == InstPtr) &&
3102 (offset.get() > 0) && xk && (k != 0) && k->is_instance_klass()) {
3103 _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset.get());
3104 }
3105 #ifdef _LP64
3106 if (this->offset() != 0) {
3107 if (this->offset() == oopDesc::klass_offset_in_bytes()) {
3108 _is_ptr_to_narrowklass = UseCompressedClassPointers;
3109 } else if (klass() == NULL) {
3110 // Array with unknown body type
3111 assert(this->isa_aryptr(), "only arrays without klass");
3112 _is_ptr_to_narrowoop = UseCompressedOops;
3113 } else if (this->isa_aryptr()) {
3114 _is_ptr_to_narrowoop = (UseCompressedOops && klass()->is_obj_array_klass() &&
3115 this->offset() != arrayOopDesc::length_offset_in_bytes());
3116 } else if (klass()->is_instance_klass()) {
3117 ciInstanceKlass* ik = klass()->as_instance_klass();
3118 ciField* field = NULL;
3119 if (this->isa_klassptr()) {
3120 // Perm objects don't use compressed references
3121 } else if (_offset == Offset::bottom || _offset == Offset::top) {
3122 // unsafe access
3123 _is_ptr_to_narrowoop = UseCompressedOops;
3124 } else { // exclude unsafe ops
3125 assert(this->isa_instptr() || this->isa_valuetypeptr(), "must be an instance ptr.");
3126
3127 if (klass() == ciEnv::current()->Class_klass() &&
3128 (this->offset() == java_lang_Class::klass_offset_in_bytes() ||
3129 this->offset() == java_lang_Class::array_klass_offset_in_bytes())) {
3130 // Special hidden fields from the Class.
3131 assert(this->isa_instptr(), "must be an instance ptr.");
3132 _is_ptr_to_narrowoop = false;
3133 } else if (klass() == ciEnv::current()->Class_klass() &&
3134 this->offset() >= InstanceMirrorKlass::offset_of_static_fields()) {
3135 // Static fields
3152 // that it does not affect alias type.
3153 _is_ptr_to_narrowoop = UseCompressedOops;
3154 } else {
3155 // Type for the copy start in LibraryCallKit::inline_native_clone().
3156 _is_ptr_to_narrowoop = UseCompressedOops;
3157 }
3158 }
3159 }
3160 }
3161 }
3162 #endif
3163 }
3164
3165 //------------------------------make-------------------------------------------
3166 const TypeOopPtr *TypeOopPtr::make(PTR ptr, Offset offset, int instance_id,
3167 const TypePtr* speculative, int inline_depth) {
3168 assert(ptr != Constant, "no constant generic pointers");
3169 ciKlass* k = Compile::current()->env()->Object_klass();
3170 bool xk = false;
3171 ciObject* o = NULL;
3172 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative, inline_depth))->hashcons();
3173 }
3174
3175
3176 //------------------------------cast_to_ptr_type-------------------------------
3177 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const {
3178 assert(_base == OopPtr, "subclass must override cast_to_ptr_type");
3179 if( ptr == _ptr ) return this;
3180 return make(ptr, _offset, _instance_id, _speculative, _inline_depth);
3181 }
3182
3183 //-----------------------------cast_to_instance_id----------------------------
3184 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const {
3185 // There are no instances of a general oop.
3186 // Return self unchanged.
3187 return this;
3188 }
3189
3190 //-----------------------------cast_to_exactness-------------------------------
3191 const Type *TypeOopPtr::cast_to_exactness(bool klass_is_exact) const {
3192 // There is no such thing as an exact general oop.
3268 const TypePtr* speculative = xmeet_speculative(tp);
3269 int depth = meet_inline_depth(tp->inline_depth());
3270 return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative, depth);
3271 }
3272
3273 case InstPtr: // For these, flip the call around to cut down
3274 case ValueTypePtr:
3275 case AryPtr:
3276 return t->xmeet(this); // Call in reverse direction
3277
3278 } // End of switch
3279 return this; // Return the double constant
3280 }
3281
3282
3283 //------------------------------xdual------------------------------------------
3284 // Dual of a pure heap pointer. No relevant klass or oop information.
3285 const Type *TypeOopPtr::xdual() const {
3286 assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here");
3287 assert(const_oop() == NULL, "no constants here");
3288 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth());
3289 }
3290
3291 //--------------------------make_from_klass_common-----------------------------
3292 // Computes the element-type given a klass.
3293 const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) {
3294 if (klass->is_valuetype()) {
3295 return TypeValueTypePtr::make(TypePtr::NotNull, klass->as_value_klass());
3296 } else if (klass->is_instance_klass()) {
3297 Compile* C = Compile::current();
3298 Dependencies* deps = C->dependencies();
3299 assert((deps != NULL) == (C->method() != NULL && C->method()->code_size() > 0), "sanity");
3300 // Element is an instance
3301 bool klass_is_exact = false;
3302 if (klass->is_loaded()) {
3303 // Try to set klass_is_exact.
3304 ciInstanceKlass* ik = klass->as_instance_klass();
3305 klass_is_exact = ik->is_final();
3306 if (!klass_is_exact && klass_change
3307 && deps != NULL && UseUniqueSubclasses) {
3308 ciInstanceKlass* sub = ik->unique_concrete_subklass();
3603 */
3604 bool TypeOopPtr::would_improve_type(ciKlass* exact_kls, int inline_depth) const {
3605 // no way to improve an already exact type
3606 if (klass_is_exact()) {
3607 return false;
3608 }
3609 return TypePtr::would_improve_type(exact_kls, inline_depth);
3610 }
3611
3612 //=============================================================================
3613 // Convenience common pre-built types.
3614 const TypeInstPtr *TypeInstPtr::NOTNULL;
3615 const TypeInstPtr *TypeInstPtr::BOTTOM;
3616 const TypeInstPtr *TypeInstPtr::MIRROR;
3617 const TypeInstPtr *TypeInstPtr::MARK;
3618 const TypeInstPtr *TypeInstPtr::KLASS;
3619
3620 //------------------------------TypeInstPtr-------------------------------------
3621 TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset off,
3622 int instance_id, const TypePtr* speculative, int inline_depth)
3623 : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id, speculative, inline_depth),
3624 _name(k->name()) {
3625 assert(k != NULL &&
3626 (k->is_loaded() || o == NULL),
3627 "cannot have constants with non-loaded klass");
3628 };
3629
3630 //------------------------------make-------------------------------------------
3631 const TypeInstPtr *TypeInstPtr::make(PTR ptr,
3632 ciKlass* k,
3633 bool xk,
3634 ciObject* o,
3635 Offset offset,
3636 int instance_id,
3637 const TypePtr* speculative,
3638 int inline_depth) {
3639 assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance");
3640 // Either const_oop() is NULL or else ptr is Constant
3641 assert( (!o && ptr != Constant) || (o && ptr == Constant),
3642 "constant pointers must have a value supplied" );
3643 // Ptr is never Null
3787 typerr(t);
3788
3789 case MetadataPtr:
3790 case KlassPtr:
3791 case RawPtr: return TypePtr::BOTTOM;
3792
3793 case AryPtr: { // All arrays inherit from Object class
3794 const TypeAryPtr *tp = t->is_aryptr();
3795 Offset offset = meet_offset(tp->offset());
3796 PTR ptr = meet_ptr(tp->ptr());
3797 int instance_id = meet_instance_id(tp->instance_id());
3798 const TypePtr* speculative = xmeet_speculative(tp);
3799 int depth = meet_inline_depth(tp->inline_depth());
3800 switch (ptr) {
3801 case TopPTR:
3802 case AnyNull: // Fall 'down' to dual of object klass
3803 // For instances when a subclass meets a superclass we fall
3804 // below the centerline when the superclass is exact. We need to
3805 // do the same here.
3806 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) {
3807 return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, tp->_field_offset, instance_id, speculative, depth);
3808 } else {
3809 // cannot subclass, so the meet has to fall badly below the centerline
3810 ptr = NotNull;
3811 instance_id = InstanceBot;
3812 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth);
3813 }
3814 case Constant:
3815 case NotNull:
3816 case BotPTR: // Fall down to object klass
3817 // LCA is object_klass, but if we subclass from the top we can do better
3818 if( above_centerline(_ptr) ) { // if( _ptr == TopPTR || _ptr == AnyNull )
3819 // If 'this' (InstPtr) is above the centerline and it is Object class
3820 // then we can subclass in the Java class hierarchy.
3821 // For instances when a subclass meets a superclass we fall
3822 // below the centerline when the superclass is exact. We need
3823 // to do the same here.
3824 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) {
3825 // that is, tp's array type is a subtype of my klass
3826 return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL),
3827 tp->ary(), tp->klass(), tp->klass_is_exact(), offset, tp->_field_offset, instance_id, speculative, depth);
3828 }
3829 }
3830 // The other case cannot happen, since I cannot be a subtype of an array.
3831 // The meet falls down to Object class below centerline.
3832 if( ptr == Constant )
3833 ptr = NotNull;
3834 instance_id = InstanceBot;
3835 return make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth);
3836 default: typerr(t);
3837 }
3838 }
3839
3840 case OopPtr: { // Meeting to OopPtrs
3841 // Found a OopPtr type vs self-InstPtr type
3842 const TypeOopPtr *tp = t->is_oopptr();
3843 Offset offset = meet_offset(tp->offset());
3844 PTR ptr = meet_ptr(tp->ptr());
3845 switch (tp->ptr()) {
3846 case TopPTR:
3847 case AnyNull: {
4330 // The pointers in the autobox arrays are always non-null.
4331 TypePtr::PTR ptr_type = cache ? TypePtr::NotNull : TypePtr::AnyNull;
4332 etype = etype->cast_to_ptr_type(TypePtr::NotNull)->is_oopptr();
4333 const TypeAry* new_ary = TypeAry::make(etype, size(), is_stable());
4334 return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _field_offset, _instance_id, _speculative, _inline_depth, cache);
4335 }
4336
4337 //------------------------------eq---------------------------------------------
4338 // Structural equality check for Type representations
4339 bool TypeAryPtr::eq( const Type *t ) const {
4340 const TypeAryPtr *p = t->is_aryptr();
4341 return
4342 _ary == p->_ary && // Check array
4343 TypeOopPtr::eq(p) &&// Check sub-parts
4344 _field_offset == p->_field_offset;
4345 }
4346
4347 //------------------------------hash-------------------------------------------
4348 // Type-specific hashing function.
4349 int TypeAryPtr::hash(void) const {
4350 return (intptr_t)_ary + TypeOopPtr::hash() + field_offset();
4351 }
4352
4353 //------------------------------meet-------------------------------------------
4354 // Compute the MEET of two types. It returns a new Type object.
4355 const Type *TypeAryPtr::xmeet_helper(const Type *t) const {
4356 // Perform a fast test for common case; meeting the same types together.
4357 if( this == t ) return this; // Meeting same type-rep?
4358 // Current "this->_base" is Pointer
4359 switch (t->base()) { // switch on original type
4360
4361 // Mixing ints & oops happens when javac reuses local variables
4362 case Int:
4363 case Long:
4364 case FloatTop:
4365 case FloatCon:
4366 case FloatBot:
4367 case DoubleTop:
4368 case DoubleCon:
4369 case DoubleBot:
4370 case NarrowOop:
4516 // All arrays inherit from Object class
4517 case InstPtr: {
4518 const TypeInstPtr *tp = t->is_instptr();
4519 Offset offset = meet_offset(tp->offset());
4520 PTR ptr = meet_ptr(tp->ptr());
4521 int instance_id = meet_instance_id(tp->instance_id());
4522 const TypePtr* speculative = xmeet_speculative(tp);
4523 int depth = meet_inline_depth(tp->inline_depth());
4524 switch (ptr) {
4525 case TopPTR:
4526 case AnyNull: // Fall 'down' to dual of object klass
4527 // For instances when a subclass meets a superclass we fall
4528 // below the centerline when the superclass is exact. We need to
4529 // do the same here.
4530 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
4531 return TypeAryPtr::make(ptr, _ary, _klass, _klass_is_exact, offset, _field_offset, instance_id, speculative, depth);
4532 } else {
4533 // cannot subclass, so the meet has to fall badly below the centerline
4534 ptr = NotNull;
4535 instance_id = InstanceBot;
4536 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth);
4537 }
4538 case Constant:
4539 case NotNull:
4540 case BotPTR: // Fall down to object klass
4541 // LCA is object_klass, but if we subclass from the top we can do better
4542 if (above_centerline(tp->ptr())) {
4543 // If 'tp' is above the centerline and it is Object class
4544 // then we can subclass in the Java class hierarchy.
4545 // For instances when a subclass meets a superclass we fall
4546 // below the centerline when the superclass is exact. We need
4547 // to do the same here.
4548 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
4549 // that is, my array type is a subtype of 'tp' klass
4550 return make(ptr, (ptr == Constant ? const_oop() : NULL),
4551 _ary, _klass, _klass_is_exact, offset, _field_offset, instance_id, speculative, depth);
4552 }
4553 }
4554 // The other case cannot happen, since t cannot be a subtype of an array.
4555 // The meet falls down to Object class below centerline.
4556 if( ptr == Constant )
4557 ptr = NotNull;
4558 instance_id = InstanceBot;
4559 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth);
4560 default: typerr(t);
4561 }
4562 }
4563 }
4564 return this; // Lint noise
4565 }
4566
4567 //------------------------------xdual------------------------------------------
4568 // Dual: compute field-by-field dual
4569 const Type *TypeAryPtr::xdual() const {
4570 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());
4571 }
4572
4573 Type::Offset TypeAryPtr::meet_field_offset(int field_offset) const {
4574 return _field_offset.meet(Offset(field_offset));
4575 }
4576
4577 //------------------------------dual_offset------------------------------------
4578 Type::Offset TypeAryPtr::dual_field_offset() const {
4579 return _field_offset.dual();
4580 }
4581
4582 //----------------------interface_vs_oop---------------------------------------
4583 #ifdef ASSERT
4584 bool TypeAryPtr::interface_vs_oop(const Type *t) const {
4585 const TypeAryPtr* t_aryptr = t->isa_aryptr();
4586 if (t_aryptr) {
4587 return _ary->interface_vs_oop(t_aryptr->_ary);
4588 }
4589 return false;
4590 }
4591 #endif
4592
4593 //------------------------------dump2------------------------------------------
4594 #ifndef PRODUCT
|
3072 // Type-specific hashing function.
3073 int TypeRawPtr::hash(void) const {
3074 return (intptr_t)_bits + TypePtr::hash();
3075 }
3076
3077 //------------------------------dump2------------------------------------------
3078 #ifndef PRODUCT
3079 void TypeRawPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
3080 if( _ptr == Constant )
3081 st->print(INTPTR_FORMAT, p2i(_bits));
3082 else
3083 st->print("rawptr:%s", ptr_msg[_ptr]);
3084 }
3085 #endif
3086
3087 //=============================================================================
3088 // Convenience common pre-built type.
3089 const TypeOopPtr *TypeOopPtr::BOTTOM;
3090
3091 //------------------------------TypeOopPtr-------------------------------------
3092 TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset offset, Offset field_offset,
3093 int instance_id, const TypePtr* speculative, int inline_depth)
3094 : TypePtr(t, ptr, offset, speculative, inline_depth),
3095 _const_oop(o), _klass(k),
3096 _klass_is_exact(xk),
3097 _is_ptr_to_narrowoop(false),
3098 _is_ptr_to_narrowklass(false),
3099 _is_ptr_to_boxed_value(false),
3100 _instance_id(instance_id) {
3101 if (Compile::current()->eliminate_boxing() && (t == InstPtr) &&
3102 (offset.get() > 0) && xk && (k != 0) && k->is_instance_klass()) {
3103 _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset.get());
3104 }
3105 #ifdef _LP64
3106 if (this->offset() != 0) {
3107 if (this->offset() == oopDesc::klass_offset_in_bytes()) {
3108 _is_ptr_to_narrowklass = UseCompressedClassPointers;
3109 } else if (klass() == NULL) {
3110 // Array with unknown body type
3111 assert(this->isa_aryptr(), "only arrays without klass");
3112 _is_ptr_to_narrowoop = UseCompressedOops;
3113 } else if (UseCompressedOops && this->isa_aryptr() && this->offset() != arrayOopDesc::length_offset_in_bytes()) {
3114 if (klass()->is_obj_array_klass()) {
3115 _is_ptr_to_narrowoop = true;
3116 } else if (klass()->is_value_array_klass() && field_offset != Offset::top && field_offset != Offset::bottom) {
3117 // Check if the field of the value type array element contains oops
3118 ciValueKlass* vk = klass()->as_value_array_klass()->element_klass()->as_value_klass();
3119 int foffset = field_offset.get() + vk->first_field_offset();
3120 ciField* field = vk->get_field_by_offset(foffset, false);
3121 assert(field != NULL, "missing field");
3122 BasicType bt = field->layout_type();
3123 assert(bt != T_VALUETYPE, "should be flattened");
3124 _is_ptr_to_narrowoop = (bt == T_OBJECT || bt == T_ARRAY);
3125 }
3126 } else if (klass()->is_instance_klass()) {
3127 ciInstanceKlass* ik = klass()->as_instance_klass();
3128 ciField* field = NULL;
3129 if (this->isa_klassptr()) {
3130 // Perm objects don't use compressed references
3131 } else if (_offset == Offset::bottom || _offset == Offset::top) {
3132 // unsafe access
3133 _is_ptr_to_narrowoop = UseCompressedOops;
3134 } else { // exclude unsafe ops
3135 assert(this->isa_instptr() || this->isa_valuetypeptr(), "must be an instance ptr.");
3136
3137 if (klass() == ciEnv::current()->Class_klass() &&
3138 (this->offset() == java_lang_Class::klass_offset_in_bytes() ||
3139 this->offset() == java_lang_Class::array_klass_offset_in_bytes())) {
3140 // Special hidden fields from the Class.
3141 assert(this->isa_instptr(), "must be an instance ptr.");
3142 _is_ptr_to_narrowoop = false;
3143 } else if (klass() == ciEnv::current()->Class_klass() &&
3144 this->offset() >= InstanceMirrorKlass::offset_of_static_fields()) {
3145 // Static fields
3162 // that it does not affect alias type.
3163 _is_ptr_to_narrowoop = UseCompressedOops;
3164 } else {
3165 // Type for the copy start in LibraryCallKit::inline_native_clone().
3166 _is_ptr_to_narrowoop = UseCompressedOops;
3167 }
3168 }
3169 }
3170 }
3171 }
3172 #endif
3173 }
3174
3175 //------------------------------make-------------------------------------------
3176 const TypeOopPtr *TypeOopPtr::make(PTR ptr, Offset offset, int instance_id,
3177 const TypePtr* speculative, int inline_depth) {
3178 assert(ptr != Constant, "no constant generic pointers");
3179 ciKlass* k = Compile::current()->env()->Object_klass();
3180 bool xk = false;
3181 ciObject* o = NULL;
3182 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, Offset::bottom, instance_id, speculative, inline_depth))->hashcons();
3183 }
3184
3185
3186 //------------------------------cast_to_ptr_type-------------------------------
3187 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const {
3188 assert(_base == OopPtr, "subclass must override cast_to_ptr_type");
3189 if( ptr == _ptr ) return this;
3190 return make(ptr, _offset, _instance_id, _speculative, _inline_depth);
3191 }
3192
3193 //-----------------------------cast_to_instance_id----------------------------
3194 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const {
3195 // There are no instances of a general oop.
3196 // Return self unchanged.
3197 return this;
3198 }
3199
3200 //-----------------------------cast_to_exactness-------------------------------
3201 const Type *TypeOopPtr::cast_to_exactness(bool klass_is_exact) const {
3202 // There is no such thing as an exact general oop.
3278 const TypePtr* speculative = xmeet_speculative(tp);
3279 int depth = meet_inline_depth(tp->inline_depth());
3280 return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative, depth);
3281 }
3282
3283 case InstPtr: // For these, flip the call around to cut down
3284 case ValueTypePtr:
3285 case AryPtr:
3286 return t->xmeet(this); // Call in reverse direction
3287
3288 } // End of switch
3289 return this; // Return the double constant
3290 }
3291
3292
3293 //------------------------------xdual------------------------------------------
3294 // Dual of a pure heap pointer. No relevant klass or oop information.
3295 const Type *TypeOopPtr::xdual() const {
3296 assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here");
3297 assert(const_oop() == NULL, "no constants here");
3298 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), Offset::bottom, dual_instance_id(), dual_speculative(), dual_inline_depth());
3299 }
3300
3301 //--------------------------make_from_klass_common-----------------------------
3302 // Computes the element-type given a klass.
3303 const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) {
3304 if (klass->is_valuetype()) {
3305 return TypeValueTypePtr::make(TypePtr::NotNull, klass->as_value_klass());
3306 } else if (klass->is_instance_klass()) {
3307 Compile* C = Compile::current();
3308 Dependencies* deps = C->dependencies();
3309 assert((deps != NULL) == (C->method() != NULL && C->method()->code_size() > 0), "sanity");
3310 // Element is an instance
3311 bool klass_is_exact = false;
3312 if (klass->is_loaded()) {
3313 // Try to set klass_is_exact.
3314 ciInstanceKlass* ik = klass->as_instance_klass();
3315 klass_is_exact = ik->is_final();
3316 if (!klass_is_exact && klass_change
3317 && deps != NULL && UseUniqueSubclasses) {
3318 ciInstanceKlass* sub = ik->unique_concrete_subklass();
3613 */
3614 bool TypeOopPtr::would_improve_type(ciKlass* exact_kls, int inline_depth) const {
3615 // no way to improve an already exact type
3616 if (klass_is_exact()) {
3617 return false;
3618 }
3619 return TypePtr::would_improve_type(exact_kls, inline_depth);
3620 }
3621
3622 //=============================================================================
3623 // Convenience common pre-built types.
3624 const TypeInstPtr *TypeInstPtr::NOTNULL;
3625 const TypeInstPtr *TypeInstPtr::BOTTOM;
3626 const TypeInstPtr *TypeInstPtr::MIRROR;
3627 const TypeInstPtr *TypeInstPtr::MARK;
3628 const TypeInstPtr *TypeInstPtr::KLASS;
3629
3630 //------------------------------TypeInstPtr-------------------------------------
3631 TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset off,
3632 int instance_id, const TypePtr* speculative, int inline_depth)
3633 : TypeOopPtr(InstPtr, ptr, k, xk, o, off, Offset::bottom, instance_id, speculative, inline_depth),
3634 _name(k->name()) {
3635 assert(k != NULL &&
3636 (k->is_loaded() || o == NULL),
3637 "cannot have constants with non-loaded klass");
3638 };
3639
3640 //------------------------------make-------------------------------------------
3641 const TypeInstPtr *TypeInstPtr::make(PTR ptr,
3642 ciKlass* k,
3643 bool xk,
3644 ciObject* o,
3645 Offset offset,
3646 int instance_id,
3647 const TypePtr* speculative,
3648 int inline_depth) {
3649 assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance");
3650 // Either const_oop() is NULL or else ptr is Constant
3651 assert( (!o && ptr != Constant) || (o && ptr == Constant),
3652 "constant pointers must have a value supplied" );
3653 // Ptr is never Null
3797 typerr(t);
3798
3799 case MetadataPtr:
3800 case KlassPtr:
3801 case RawPtr: return TypePtr::BOTTOM;
3802
3803 case AryPtr: { // All arrays inherit from Object class
3804 const TypeAryPtr *tp = t->is_aryptr();
3805 Offset offset = meet_offset(tp->offset());
3806 PTR ptr = meet_ptr(tp->ptr());
3807 int instance_id = meet_instance_id(tp->instance_id());
3808 const TypePtr* speculative = xmeet_speculative(tp);
3809 int depth = meet_inline_depth(tp->inline_depth());
3810 switch (ptr) {
3811 case TopPTR:
3812 case AnyNull: // Fall 'down' to dual of object klass
3813 // For instances when a subclass meets a superclass we fall
3814 // below the centerline when the superclass is exact. We need to
3815 // do the same here.
3816 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) {
3817 return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, tp->field_offset(), instance_id, speculative, depth);
3818 } else {
3819 // cannot subclass, so the meet has to fall badly below the centerline
3820 ptr = NotNull;
3821 instance_id = InstanceBot;
3822 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth);
3823 }
3824 case Constant:
3825 case NotNull:
3826 case BotPTR: // Fall down to object klass
3827 // LCA is object_klass, but if we subclass from the top we can do better
3828 if( above_centerline(_ptr) ) { // if( _ptr == TopPTR || _ptr == AnyNull )
3829 // If 'this' (InstPtr) is above the centerline and it is Object class
3830 // then we can subclass in the Java class hierarchy.
3831 // For instances when a subclass meets a superclass we fall
3832 // below the centerline when the superclass is exact. We need
3833 // to do the same here.
3834 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) {
3835 // that is, tp's array type is a subtype of my klass
3836 return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL),
3837 tp->ary(), tp->klass(), tp->klass_is_exact(), offset, tp->field_offset(), instance_id, speculative, depth);
3838 }
3839 }
3840 // The other case cannot happen, since I cannot be a subtype of an array.
3841 // The meet falls down to Object class below centerline.
3842 if( ptr == Constant )
3843 ptr = NotNull;
3844 instance_id = InstanceBot;
3845 return make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth);
3846 default: typerr(t);
3847 }
3848 }
3849
3850 case OopPtr: { // Meeting to OopPtrs
3851 // Found a OopPtr type vs self-InstPtr type
3852 const TypeOopPtr *tp = t->is_oopptr();
3853 Offset offset = meet_offset(tp->offset());
3854 PTR ptr = meet_ptr(tp->ptr());
3855 switch (tp->ptr()) {
3856 case TopPTR:
3857 case AnyNull: {
4340 // The pointers in the autobox arrays are always non-null.
4341 TypePtr::PTR ptr_type = cache ? TypePtr::NotNull : TypePtr::AnyNull;
4342 etype = etype->cast_to_ptr_type(TypePtr::NotNull)->is_oopptr();
4343 const TypeAry* new_ary = TypeAry::make(etype, size(), is_stable());
4344 return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _field_offset, _instance_id, _speculative, _inline_depth, cache);
4345 }
4346
4347 //------------------------------eq---------------------------------------------
4348 // Structural equality check for Type representations
4349 bool TypeAryPtr::eq( const Type *t ) const {
4350 const TypeAryPtr *p = t->is_aryptr();
4351 return
4352 _ary == p->_ary && // Check array
4353 TypeOopPtr::eq(p) &&// Check sub-parts
4354 _field_offset == p->_field_offset;
4355 }
4356
4357 //------------------------------hash-------------------------------------------
4358 // Type-specific hashing function.
4359 int TypeAryPtr::hash(void) const {
4360 return (intptr_t)_ary + TypeOopPtr::hash() + _field_offset.get();
4361 }
4362
4363 //------------------------------meet-------------------------------------------
4364 // Compute the MEET of two types. It returns a new Type object.
4365 const Type *TypeAryPtr::xmeet_helper(const Type *t) const {
4366 // Perform a fast test for common case; meeting the same types together.
4367 if( this == t ) return this; // Meeting same type-rep?
4368 // Current "this->_base" is Pointer
4369 switch (t->base()) { // switch on original type
4370
4371 // Mixing ints & oops happens when javac reuses local variables
4372 case Int:
4373 case Long:
4374 case FloatTop:
4375 case FloatCon:
4376 case FloatBot:
4377 case DoubleTop:
4378 case DoubleCon:
4379 case DoubleBot:
4380 case NarrowOop:
4526 // All arrays inherit from Object class
4527 case InstPtr: {
4528 const TypeInstPtr *tp = t->is_instptr();
4529 Offset offset = meet_offset(tp->offset());
4530 PTR ptr = meet_ptr(tp->ptr());
4531 int instance_id = meet_instance_id(tp->instance_id());
4532 const TypePtr* speculative = xmeet_speculative(tp);
4533 int depth = meet_inline_depth(tp->inline_depth());
4534 switch (ptr) {
4535 case TopPTR:
4536 case AnyNull: // Fall 'down' to dual of object klass
4537 // For instances when a subclass meets a superclass we fall
4538 // below the centerline when the superclass is exact. We need to
4539 // do the same here.
4540 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
4541 return TypeAryPtr::make(ptr, _ary, _klass, _klass_is_exact, offset, _field_offset, instance_id, speculative, depth);
4542 } else {
4543 // cannot subclass, so the meet has to fall badly below the centerline
4544 ptr = NotNull;
4545 instance_id = InstanceBot;
4546 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth);
4547 }
4548 case Constant:
4549 case NotNull:
4550 case BotPTR: // Fall down to object klass
4551 // LCA is object_klass, but if we subclass from the top we can do better
4552 if (above_centerline(tp->ptr())) {
4553 // If 'tp' is above the centerline and it is Object class
4554 // then we can subclass in the Java class hierarchy.
4555 // For instances when a subclass meets a superclass we fall
4556 // below the centerline when the superclass is exact. We need
4557 // to do the same here.
4558 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
4559 // that is, my array type is a subtype of 'tp' klass
4560 return make(ptr, (ptr == Constant ? const_oop() : NULL),
4561 _ary, _klass, _klass_is_exact, offset, _field_offset, instance_id, speculative, depth);
4562 }
4563 }
4564 // The other case cannot happen, since t cannot be a subtype of an array.
4565 // The meet falls down to Object class below centerline.
4566 if( ptr == Constant )
4567 ptr = NotNull;
4568 instance_id = InstanceBot;
4569 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth);
4570 default: typerr(t);
4571 }
4572 }
4573 }
4574 return this; // Lint noise
4575 }
4576
4577 //------------------------------xdual------------------------------------------
4578 // Dual: compute field-by-field dual
4579 const Type *TypeAryPtr::xdual() const {
4580 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());
4581 }
4582
4583 Type::Offset TypeAryPtr::meet_field_offset(const Type::Offset offset) const {
4584 return _field_offset.meet(offset);
4585 }
4586
4587 //------------------------------dual_offset------------------------------------
4588 Type::Offset TypeAryPtr::dual_field_offset() const {
4589 return _field_offset.dual();
4590 }
4591
4592 //----------------------interface_vs_oop---------------------------------------
4593 #ifdef ASSERT
4594 bool TypeAryPtr::interface_vs_oop(const Type *t) const {
4595 const TypeAryPtr* t_aryptr = t->isa_aryptr();
4596 if (t_aryptr) {
4597 return _ary->interface_vs_oop(t_aryptr->_ary);
4598 }
4599 return false;
4600 }
4601 #endif
4602
4603 //------------------------------dump2------------------------------------------
4604 #ifndef PRODUCT
|