2355 #ifndef PRODUCT
2356 void TypeRawPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
2357 if( _ptr == Constant )
2358 st->print(INTPTR_FORMAT, _bits);
2359 else
2360 st->print("rawptr:%s", ptr_msg[_ptr]);
2361 }
2362 #endif
2363
2364 //=============================================================================
2365 // Convenience common pre-built type.
2366 const TypeOopPtr *TypeOopPtr::BOTTOM;
2367
2368 //------------------------------TypeOopPtr-------------------------------------
2369 TypeOopPtr::TypeOopPtr( TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id )
2370 : TypePtr(t, ptr, offset),
2371 _const_oop(o), _klass(k),
2372 _klass_is_exact(xk),
2373 _is_ptr_to_narrowoop(false),
2374 _is_ptr_to_narrowklass(false),
2375 _instance_id(instance_id) {
2376 #ifdef _LP64
2377 if (_offset != 0) {
2378 if (_offset == oopDesc::klass_offset_in_bytes()) {
2379 _is_ptr_to_narrowklass = UseCompressedKlassPointers;
2380 } else if (klass() == NULL) {
2381 // Array with unknown body type
2382 assert(this->isa_aryptr(), "only arrays without klass");
2383 _is_ptr_to_narrowoop = UseCompressedOops;
2384 } else if (this->isa_aryptr()) {
2385 _is_ptr_to_narrowoop = (UseCompressedOops && klass()->is_obj_array_klass() &&
2386 _offset != arrayOopDesc::length_offset_in_bytes());
2387 } else if (klass()->is_instance_klass()) {
2388 ciInstanceKlass* ik = klass()->as_instance_klass();
2389 ciField* field = NULL;
2390 if (this->isa_klassptr()) {
2391 // Perm objects don't use compressed references
2392 } else if (_offset == OffsetBot || _offset == OffsetTop) {
2393 // unsafe access
2394 _is_ptr_to_narrowoop = UseCompressedOops;
2395 } else { // exclude unsafe ops
2596 // are all not-null. This is not true in generally, as code can
2597 // slam NULLs down in the subarrays.
2598 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, xk, 0);
2599 return arr;
2600 } else if (klass->is_type_array_klass()) {
2601 // Element is an typeArray
2602 const Type* etype = get_const_basic_type(klass->as_type_array_klass()->element_type());
2603 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS);
2604 // We used to pass NotNull in here, asserting that the array pointer
2605 // is not-null. That was not true in general.
2606 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, true, 0);
2607 return arr;
2608 } else {
2609 ShouldNotReachHere();
2610 return NULL;
2611 }
2612 }
2613
2614 //------------------------------make_from_constant-----------------------------
2615 // Make a java pointer from an oop constant
2616 const TypeOopPtr* TypeOopPtr::make_from_constant(ciObject* o, bool require_constant) {
2617 assert(!o->is_null_object(), "null object not yet handled here.");
2618 ciKlass* klass = o->klass();
2619 if (klass->is_instance_klass()) {
2620 // Element is an instance
2621 if (require_constant) {
2622 if (!o->can_be_constant()) return NULL;
2623 } else if (!o->should_be_constant()) {
2624 return TypeInstPtr::make(TypePtr::NotNull, klass, true, NULL, 0);
2625 }
2626 return TypeInstPtr::make(o);
2627 } else if (klass->is_obj_array_klass()) {
2628 // Element is an object array. Recursively call ourself.
2629 const Type *etype =
2630 TypeOopPtr::make_from_klass_raw(klass->as_obj_array_klass()->element_klass());
2631 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()));
2632 // We used to pass NotNull in here, asserting that the sub-arrays
2633 // are all not-null. This is not true in generally, as code can
2634 // slam NULLs down in the subarrays.
2635 if (require_constant) {
2636 if (!o->can_be_constant()) return NULL;
2637 } else if (!o->should_be_constant()) {
2638 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
2639 }
2640 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0);
2641 return arr;
2642 } else if (klass->is_type_array_klass()) {
2643 // Element is an typeArray
2644 const Type* etype =
2645 (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type());
2646 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()));
2647 // We used to pass NotNull in here, asserting that the array pointer
2648 // is not-null. That was not true in general.
2649 if (require_constant) {
2650 if (!o->can_be_constant()) return NULL;
2651 } else if (!o->should_be_constant()) {
2652 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
2653 }
2654 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0);
2655 return arr;
2656 }
2657
2658 fatal("unhandled object type");
2659 return NULL;
2660 }
2839 assert( ptr != Null, "NULL pointers are not typed" );
2840
2841 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
2842 if (!UseExactTypes) xk = false;
2843 if (ptr == Constant) {
2844 // Note: This case includes meta-object constants, such as methods.
2845 xk = true;
2846 } else if (k->is_loaded()) {
2847 ciInstanceKlass* ik = k->as_instance_klass();
2848 if (!xk && ik->is_final()) xk = true; // no inexact final klass
2849 if (xk && ik->is_interface()) xk = false; // no exact interface
2850 }
2851
2852 // Now hash this baby
2853 TypeInstPtr *result =
2854 (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id))->hashcons();
2855
2856 return result;
2857 }
2858
2859
2860 //------------------------------cast_to_ptr_type-------------------------------
2861 const Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const {
2862 if( ptr == _ptr ) return this;
2863 // Reconstruct _sig info here since not a problem with later lazy
2864 // construction, _sig will show up on demand.
2865 return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id);
2866 }
2867
2868
2869 //-----------------------------cast_to_exactness-------------------------------
2870 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const {
2871 if( klass_is_exact == _klass_is_exact ) return this;
2872 if (!UseExactTypes) return this;
2873 if (!_klass->is_loaded()) return this;
2874 ciInstanceKlass* ik = _klass->as_instance_klass();
2875 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk
2876 if( ik->is_interface() ) return this; // cannot set xk
2877 return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id);
2878 }
3313 //=============================================================================
3314 // Convenience common pre-built types.
3315 const TypeAryPtr *TypeAryPtr::RANGE;
3316 const TypeAryPtr *TypeAryPtr::OOPS;
3317 const TypeAryPtr *TypeAryPtr::NARROWOOPS;
3318 const TypeAryPtr *TypeAryPtr::BYTES;
3319 const TypeAryPtr *TypeAryPtr::SHORTS;
3320 const TypeAryPtr *TypeAryPtr::CHARS;
3321 const TypeAryPtr *TypeAryPtr::INTS;
3322 const TypeAryPtr *TypeAryPtr::LONGS;
3323 const TypeAryPtr *TypeAryPtr::FLOATS;
3324 const TypeAryPtr *TypeAryPtr::DOUBLES;
3325
3326 //------------------------------make-------------------------------------------
3327 const TypeAryPtr *TypeAryPtr::make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id ) {
3328 assert(!(k == NULL && ary->_elem->isa_int()),
3329 "integral arrays must be pre-equipped with a class");
3330 if (!xk) xk = ary->ary_must_be_exact();
3331 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
3332 if (!UseExactTypes) xk = (ptr == Constant);
3333 return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id))->hashcons();
3334 }
3335
3336 //------------------------------make-------------------------------------------
3337 const TypeAryPtr *TypeAryPtr::make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id ) {
3338 assert(!(k == NULL && ary->_elem->isa_int()),
3339 "integral arrays must be pre-equipped with a class");
3340 assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" );
3341 if (!xk) xk = (o != NULL) || ary->ary_must_be_exact();
3342 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
3343 if (!UseExactTypes) xk = (ptr == Constant);
3344 return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id))->hashcons();
3345 }
3346
3347 //------------------------------cast_to_ptr_type-------------------------------
3348 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const {
3349 if( ptr == _ptr ) return this;
3350 return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id);
3351 }
3352
3353
3354 //-----------------------------cast_to_exactness-------------------------------
3355 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const {
3356 if( klass_is_exact == _klass_is_exact ) return this;
3357 if (!UseExactTypes) return this;
3358 if (_ary->ary_must_be_exact()) return this; // cannot clear xk
3359 return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id);
3360 }
3361
3362 //-----------------------------cast_to_instance_id----------------------------
3363 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const {
3364 if( instance_id == _instance_id ) return this;
3380 case T_NARROWKLASS:
3381 case T_CONFLICT:
3382 case T_ILLEGAL:
3383 case T_VOID:
3384 etype = T_BYTE; // will produce conservatively high value
3385 }
3386 cache = res = arrayOopDesc::max_array_length(etype);
3387 }
3388 return res;
3389 }
3390
3391 // Narrow the given size type to the index range for the given array base type.
3392 // Return NULL if the resulting int type becomes empty.
3393 const TypeInt* TypeAryPtr::narrow_size_type(const TypeInt* size) const {
3394 jint hi = size->_hi;
3395 jint lo = size->_lo;
3396 jint min_lo = 0;
3397 jint max_hi = max_array_length(elem()->basic_type());
3398 //if (index_not_size) --max_hi; // type of a valid array index, FTR
3399 bool chg = false;
3400 if (lo < min_lo) { lo = min_lo; chg = true; }
3401 if (hi > max_hi) { hi = max_hi; chg = true; }
3402 // Negative length arrays will produce weird intermediate dead fast-path code
3403 if (lo > hi)
3404 return TypeInt::ZERO;
3405 if (!chg)
3406 return size;
3407 return TypeInt::make(lo, hi, Type::WidenMin);
3408 }
3409
3410 //-------------------------------cast_to_size----------------------------------
3411 const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const {
3412 assert(new_size != NULL, "");
3413 new_size = narrow_size_type(new_size);
3414 if (new_size == size()) return this;
3415 const TypeAry* new_ary = TypeAry::make(elem(), new_size);
3416 return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id);
3417 }
3418
3419
3420 //------------------------------eq---------------------------------------------
3421 // Structural equality check for Type representations
3613 return make( ptr, (ptr == Constant ? const_oop() : NULL),
3614 _ary, _klass, _klass_is_exact, offset, instance_id );
3615 }
3616 }
3617 // The other case cannot happen, since t cannot be a subtype of an array.
3618 // The meet falls down to Object class below centerline.
3619 if( ptr == Constant )
3620 ptr = NotNull;
3621 instance_id = InstanceBot;
3622 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id);
3623 default: typerr(t);
3624 }
3625 }
3626 }
3627 return this; // Lint noise
3628 }
3629
3630 //------------------------------xdual------------------------------------------
3631 // Dual: compute field-by-field dual
3632 const Type *TypeAryPtr::xdual() const {
3633 return new TypeAryPtr( dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id() );
3634 }
3635
3636 //----------------------interface_vs_oop---------------------------------------
3637 #ifdef ASSERT
3638 bool TypeAryPtr::interface_vs_oop(const Type *t) const {
3639 const TypeAryPtr* t_aryptr = t->isa_aryptr();
3640 if (t_aryptr) {
3641 return _ary->interface_vs_oop(t_aryptr->_ary);
3642 }
3643 return false;
3644 }
3645 #endif
3646
3647 //------------------------------dump2------------------------------------------
3648 #ifndef PRODUCT
3649 void TypeAryPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
3650 _ary->dump2(d,depth,st);
3651 switch( _ptr ) {
3652 case Constant:
3653 const_oop()->print(st);
|
2355 #ifndef PRODUCT
2356 void TypeRawPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
2357 if( _ptr == Constant )
2358 st->print(INTPTR_FORMAT, _bits);
2359 else
2360 st->print("rawptr:%s", ptr_msg[_ptr]);
2361 }
2362 #endif
2363
2364 //=============================================================================
2365 // Convenience common pre-built type.
2366 const TypeOopPtr *TypeOopPtr::BOTTOM;
2367
2368 //------------------------------TypeOopPtr-------------------------------------
2369 TypeOopPtr::TypeOopPtr( TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id )
2370 : TypePtr(t, ptr, offset),
2371 _const_oop(o), _klass(k),
2372 _klass_is_exact(xk),
2373 _is_ptr_to_narrowoop(false),
2374 _is_ptr_to_narrowklass(false),
2375 _is_ptr_to_boxed_value(false),
2376 _instance_id(instance_id) {
2377 if (Compile::current()->eliminate_boxing() && (t == InstPtr) &&
2378 (offset > 0) && xk && (k != 0) && k->is_instance_klass()) {
2379 _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset);
2380 }
2381 #ifdef _LP64
2382 if (_offset != 0) {
2383 if (_offset == oopDesc::klass_offset_in_bytes()) {
2384 _is_ptr_to_narrowklass = UseCompressedKlassPointers;
2385 } else if (klass() == NULL) {
2386 // Array with unknown body type
2387 assert(this->isa_aryptr(), "only arrays without klass");
2388 _is_ptr_to_narrowoop = UseCompressedOops;
2389 } else if (this->isa_aryptr()) {
2390 _is_ptr_to_narrowoop = (UseCompressedOops && klass()->is_obj_array_klass() &&
2391 _offset != arrayOopDesc::length_offset_in_bytes());
2392 } else if (klass()->is_instance_klass()) {
2393 ciInstanceKlass* ik = klass()->as_instance_klass();
2394 ciField* field = NULL;
2395 if (this->isa_klassptr()) {
2396 // Perm objects don't use compressed references
2397 } else if (_offset == OffsetBot || _offset == OffsetTop) {
2398 // unsafe access
2399 _is_ptr_to_narrowoop = UseCompressedOops;
2400 } else { // exclude unsafe ops
2601 // are all not-null. This is not true in generally, as code can
2602 // slam NULLs down in the subarrays.
2603 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, xk, 0);
2604 return arr;
2605 } else if (klass->is_type_array_klass()) {
2606 // Element is an typeArray
2607 const Type* etype = get_const_basic_type(klass->as_type_array_klass()->element_type());
2608 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS);
2609 // We used to pass NotNull in here, asserting that the array pointer
2610 // is not-null. That was not true in general.
2611 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, true, 0);
2612 return arr;
2613 } else {
2614 ShouldNotReachHere();
2615 return NULL;
2616 }
2617 }
2618
2619 //------------------------------make_from_constant-----------------------------
2620 // Make a java pointer from an oop constant
2621 const TypeOopPtr* TypeOopPtr::make_from_constant(ciObject* o,
2622 bool require_constant,
2623 bool is_autobox_cache) {
2624 assert(!o->is_null_object(), "null object not yet handled here.");
2625 ciKlass* klass = o->klass();
2626 if (klass->is_instance_klass()) {
2627 // Element is an instance
2628 if (require_constant) {
2629 if (!o->can_be_constant()) return NULL;
2630 } else if (!o->should_be_constant()) {
2631 return TypeInstPtr::make(TypePtr::NotNull, klass, true, NULL, 0);
2632 }
2633 return TypeInstPtr::make(o);
2634 } else if (klass->is_obj_array_klass()) {
2635 // Element is an object array. Recursively call ourself.
2636 const TypeOopPtr *etype =
2637 TypeOopPtr::make_from_klass_raw(klass->as_obj_array_klass()->element_klass());
2638 if (is_autobox_cache) {
2639 // The pointers in the autobox arrays are always non-null.
2640 etype = etype->cast_to_ptr_type(TypePtr::NotNull)->is_oopptr();
2641 }
2642 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()));
2643 // We used to pass NotNull in here, asserting that the sub-arrays
2644 // are all not-null. This is not true in generally, as code can
2645 // slam NULLs down in the subarrays.
2646 if (require_constant) {
2647 if (!o->can_be_constant()) return NULL;
2648 } else if (!o->should_be_constant()) {
2649 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
2650 }
2651 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, is_autobox_cache);
2652 return arr;
2653 } else if (klass->is_type_array_klass()) {
2654 // Element is an typeArray
2655 const Type* etype =
2656 (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type());
2657 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length()));
2658 // We used to pass NotNull in here, asserting that the array pointer
2659 // is not-null. That was not true in general.
2660 if (require_constant) {
2661 if (!o->can_be_constant()) return NULL;
2662 } else if (!o->should_be_constant()) {
2663 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
2664 }
2665 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0);
2666 return arr;
2667 }
2668
2669 fatal("unhandled object type");
2670 return NULL;
2671 }
2850 assert( ptr != Null, "NULL pointers are not typed" );
2851
2852 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
2853 if (!UseExactTypes) xk = false;
2854 if (ptr == Constant) {
2855 // Note: This case includes meta-object constants, such as methods.
2856 xk = true;
2857 } else if (k->is_loaded()) {
2858 ciInstanceKlass* ik = k->as_instance_klass();
2859 if (!xk && ik->is_final()) xk = true; // no inexact final klass
2860 if (xk && ik->is_interface()) xk = false; // no exact interface
2861 }
2862
2863 // Now hash this baby
2864 TypeInstPtr *result =
2865 (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id))->hashcons();
2866
2867 return result;
2868 }
2869
2870 /**
2871 * Create constant type for a constant boxed value
2872 */
2873 const Type* TypeInstPtr::get_const_boxed_value() const {
2874 assert(is_ptr_to_boxed_value(), "should be called only for boxed value");
2875 assert((const_oop() != NULL), "should be called only for constant object");
2876 ciConstant constant = const_oop()->as_instance()->field_value_by_offset(offset());
2877 BasicType bt = constant.basic_type();
2878 switch (bt) {
2879 case T_BOOLEAN: return TypeInt::make(constant.as_boolean());
2880 case T_INT: return TypeInt::make(constant.as_int());
2881 case T_CHAR: return TypeInt::make(constant.as_char());
2882 case T_BYTE: return TypeInt::make(constant.as_byte());
2883 case T_SHORT: return TypeInt::make(constant.as_short());
2884 case T_FLOAT: return TypeF::make(constant.as_float());
2885 case T_DOUBLE: return TypeD::make(constant.as_double());
2886 case T_LONG: return TypeLong::make(constant.as_long());
2887 default: break;
2888 }
2889 fatal(err_msg_res("Invalid boxed value type '%s'", type2name(bt)));
2890 return NULL;
2891 }
2892
2893 //------------------------------cast_to_ptr_type-------------------------------
2894 const Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const {
2895 if( ptr == _ptr ) return this;
2896 // Reconstruct _sig info here since not a problem with later lazy
2897 // construction, _sig will show up on demand.
2898 return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id);
2899 }
2900
2901
2902 //-----------------------------cast_to_exactness-------------------------------
2903 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const {
2904 if( klass_is_exact == _klass_is_exact ) return this;
2905 if (!UseExactTypes) return this;
2906 if (!_klass->is_loaded()) return this;
2907 ciInstanceKlass* ik = _klass->as_instance_klass();
2908 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk
2909 if( ik->is_interface() ) return this; // cannot set xk
2910 return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id);
2911 }
3346 //=============================================================================
3347 // Convenience common pre-built types.
3348 const TypeAryPtr *TypeAryPtr::RANGE;
3349 const TypeAryPtr *TypeAryPtr::OOPS;
3350 const TypeAryPtr *TypeAryPtr::NARROWOOPS;
3351 const TypeAryPtr *TypeAryPtr::BYTES;
3352 const TypeAryPtr *TypeAryPtr::SHORTS;
3353 const TypeAryPtr *TypeAryPtr::CHARS;
3354 const TypeAryPtr *TypeAryPtr::INTS;
3355 const TypeAryPtr *TypeAryPtr::LONGS;
3356 const TypeAryPtr *TypeAryPtr::FLOATS;
3357 const TypeAryPtr *TypeAryPtr::DOUBLES;
3358
3359 //------------------------------make-------------------------------------------
3360 const TypeAryPtr *TypeAryPtr::make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id ) {
3361 assert(!(k == NULL && ary->_elem->isa_int()),
3362 "integral arrays must be pre-equipped with a class");
3363 if (!xk) xk = ary->ary_must_be_exact();
3364 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
3365 if (!UseExactTypes) xk = (ptr == Constant);
3366 return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false))->hashcons();
3367 }
3368
3369 //------------------------------make-------------------------------------------
3370 const TypeAryPtr *TypeAryPtr::make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, bool is_autobox_cache) {
3371 assert(!(k == NULL && ary->_elem->isa_int()),
3372 "integral arrays must be pre-equipped with a class");
3373 assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" );
3374 if (!xk) xk = (o != NULL) || ary->ary_must_be_exact();
3375 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
3376 if (!UseExactTypes) xk = (ptr == Constant);
3377 return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache))->hashcons();
3378 }
3379
3380 //------------------------------cast_to_ptr_type-------------------------------
3381 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const {
3382 if( ptr == _ptr ) return this;
3383 return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id);
3384 }
3385
3386
3387 //-----------------------------cast_to_exactness-------------------------------
3388 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const {
3389 if( klass_is_exact == _klass_is_exact ) return this;
3390 if (!UseExactTypes) return this;
3391 if (_ary->ary_must_be_exact()) return this; // cannot clear xk
3392 return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id);
3393 }
3394
3395 //-----------------------------cast_to_instance_id----------------------------
3396 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const {
3397 if( instance_id == _instance_id ) return this;
3413 case T_NARROWKLASS:
3414 case T_CONFLICT:
3415 case T_ILLEGAL:
3416 case T_VOID:
3417 etype = T_BYTE; // will produce conservatively high value
3418 }
3419 cache = res = arrayOopDesc::max_array_length(etype);
3420 }
3421 return res;
3422 }
3423
3424 // Narrow the given size type to the index range for the given array base type.
3425 // Return NULL if the resulting int type becomes empty.
3426 const TypeInt* TypeAryPtr::narrow_size_type(const TypeInt* size) const {
3427 jint hi = size->_hi;
3428 jint lo = size->_lo;
3429 jint min_lo = 0;
3430 jint max_hi = max_array_length(elem()->basic_type());
3431 //if (index_not_size) --max_hi; // type of a valid array index, FTR
3432 bool chg = false;
3433 if (lo < min_lo) {
3434 lo = min_lo;
3435 if (size->is_con()) {
3436 hi = lo;
3437 }
3438 chg = true;
3439 }
3440 if (hi > max_hi) {
3441 hi = max_hi;
3442 if (size->is_con()) {
3443 lo = hi;
3444 }
3445 chg = true;
3446 }
3447 // Negative length arrays will produce weird intermediate dead fast-path code
3448 if (lo > hi)
3449 return TypeInt::ZERO;
3450 if (!chg)
3451 return size;
3452 return TypeInt::make(lo, hi, Type::WidenMin);
3453 }
3454
3455 //-------------------------------cast_to_size----------------------------------
3456 const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const {
3457 assert(new_size != NULL, "");
3458 new_size = narrow_size_type(new_size);
3459 if (new_size == size()) return this;
3460 const TypeAry* new_ary = TypeAry::make(elem(), new_size);
3461 return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id);
3462 }
3463
3464
3465 //------------------------------eq---------------------------------------------
3466 // Structural equality check for Type representations
3658 return make( ptr, (ptr == Constant ? const_oop() : NULL),
3659 _ary, _klass, _klass_is_exact, offset, instance_id );
3660 }
3661 }
3662 // The other case cannot happen, since t cannot be a subtype of an array.
3663 // The meet falls down to Object class below centerline.
3664 if( ptr == Constant )
3665 ptr = NotNull;
3666 instance_id = InstanceBot;
3667 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id);
3668 default: typerr(t);
3669 }
3670 }
3671 }
3672 return this; // Lint noise
3673 }
3674
3675 //------------------------------xdual------------------------------------------
3676 // Dual: compute field-by-field dual
3677 const Type *TypeAryPtr::xdual() const {
3678 return new TypeAryPtr( dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id(), is_autobox_cache() );
3679 }
3680
3681 //----------------------interface_vs_oop---------------------------------------
3682 #ifdef ASSERT
3683 bool TypeAryPtr::interface_vs_oop(const Type *t) const {
3684 const TypeAryPtr* t_aryptr = t->isa_aryptr();
3685 if (t_aryptr) {
3686 return _ary->interface_vs_oop(t_aryptr->_ary);
3687 }
3688 return false;
3689 }
3690 #endif
3691
3692 //------------------------------dump2------------------------------------------
3693 #ifndef PRODUCT
3694 void TypeAryPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
3695 _ary->dump2(d,depth,st);
3696 switch( _ptr ) {
3697 case Constant:
3698 const_oop()->print(st);
|