comparison src/share/vm/opto/type.cpp @ 14513:16c705d792be

Merge
author morris
date Fri, 28 Feb 2014 08:02:20 -0800
parents 484a359ff649
children 4ca6dc0799b6
comparison
equal deleted inserted replaced
14493:7d30d4f37d31 14513:16c705d792be
304 TypeInt::SHORT = TypeInt::make(-32768,32767, WidenMin); // Java shorts 304 TypeInt::SHORT = TypeInt::make(-32768,32767, WidenMin); // Java shorts
305 TypeInt::POS = TypeInt::make(0,max_jint, WidenMin); // Non-neg values 305 TypeInt::POS = TypeInt::make(0,max_jint, WidenMin); // Non-neg values
306 TypeInt::POS1 = TypeInt::make(1,max_jint, WidenMin); // Positive values 306 TypeInt::POS1 = TypeInt::make(1,max_jint, WidenMin); // Positive values
307 TypeInt::INT = TypeInt::make(min_jint,max_jint, WidenMax); // 32-bit integers 307 TypeInt::INT = TypeInt::make(min_jint,max_jint, WidenMax); // 32-bit integers
308 TypeInt::SYMINT = TypeInt::make(-max_jint,max_jint,WidenMin); // symmetric range 308 TypeInt::SYMINT = TypeInt::make(-max_jint,max_jint,WidenMin); // symmetric range
309 TypeInt::TYPE_DOMAIN = TypeInt::INT;
309 // CmpL is overloaded both as the bytecode computation returning 310 // CmpL is overloaded both as the bytecode computation returning
310 // a trinary (-1,0,+1) integer result AND as an efficient long 311 // a trinary (-1,0,+1) integer result AND as an efficient long
311 // compare returning optimizer ideal-type flags. 312 // compare returning optimizer ideal-type flags.
312 assert( TypeInt::CC_LT == TypeInt::MINUS_1, "types must match for CmpL to work" ); 313 assert( TypeInt::CC_LT == TypeInt::MINUS_1, "types must match for CmpL to work" );
313 assert( TypeInt::CC_GT == TypeInt::ONE, "types must match for CmpL to work" ); 314 assert( TypeInt::CC_GT == TypeInt::ONE, "types must match for CmpL to work" );
320 TypeLong::ONE = TypeLong::make( 1); // 1 321 TypeLong::ONE = TypeLong::make( 1); // 1
321 TypeLong::POS = TypeLong::make(0,max_jlong, WidenMin); // Non-neg values 322 TypeLong::POS = TypeLong::make(0,max_jlong, WidenMin); // Non-neg values
322 TypeLong::LONG = TypeLong::make(min_jlong,max_jlong,WidenMax); // 64-bit integers 323 TypeLong::LONG = TypeLong::make(min_jlong,max_jlong,WidenMax); // 64-bit integers
323 TypeLong::INT = TypeLong::make((jlong)min_jint,(jlong)max_jint,WidenMin); 324 TypeLong::INT = TypeLong::make((jlong)min_jint,(jlong)max_jint,WidenMin);
324 TypeLong::UINT = TypeLong::make(0,(jlong)max_juint,WidenMin); 325 TypeLong::UINT = TypeLong::make(0,(jlong)max_juint,WidenMin);
326 TypeLong::TYPE_DOMAIN = TypeLong::LONG;
325 327
326 const Type **fboth =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); 328 const Type **fboth =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
327 fboth[0] = Type::CONTROL; 329 fboth[0] = Type::CONTROL;
328 fboth[1] = Type::CONTROL; 330 fboth[1] = Type::CONTROL;
329 TypeTuple::IFBOTH = TypeTuple::make( 2, fboth ); 331 TypeTuple::IFBOTH = TypeTuple::make( 2, fboth );
1159 const TypeInt *TypeInt::SHORT; // Java shorts, -32768-32767 1161 const TypeInt *TypeInt::SHORT; // Java shorts, -32768-32767
1160 const TypeInt *TypeInt::POS; // Positive 32-bit integers or zero 1162 const TypeInt *TypeInt::POS; // Positive 32-bit integers or zero
1161 const TypeInt *TypeInt::POS1; // Positive 32-bit integers 1163 const TypeInt *TypeInt::POS1; // Positive 32-bit integers
1162 const TypeInt *TypeInt::INT; // 32-bit integers 1164 const TypeInt *TypeInt::INT; // 32-bit integers
1163 const TypeInt *TypeInt::SYMINT; // symmetric range [-max_jint..max_jint] 1165 const TypeInt *TypeInt::SYMINT; // symmetric range [-max_jint..max_jint]
1166 const TypeInt *TypeInt::TYPE_DOMAIN; // alias for TypeInt::INT
1164 1167
1165 //------------------------------TypeInt---------------------------------------- 1168 //------------------------------TypeInt----------------------------------------
1166 TypeInt::TypeInt( jint lo, jint hi, int w ) : Type(Int), _lo(lo), _hi(hi), _widen(w) { 1169 TypeInt::TypeInt( jint lo, jint hi, int w ) : Type(Int), _lo(lo), _hi(hi), _widen(w) {
1167 } 1170 }
1168 1171
1416 const TypeLong *TypeLong::ONE; // 1 1419 const TypeLong *TypeLong::ONE; // 1
1417 const TypeLong *TypeLong::POS; // >=0 1420 const TypeLong *TypeLong::POS; // >=0
1418 const TypeLong *TypeLong::LONG; // 64-bit integers 1421 const TypeLong *TypeLong::LONG; // 64-bit integers
1419 const TypeLong *TypeLong::INT; // 32-bit subrange 1422 const TypeLong *TypeLong::INT; // 32-bit subrange
1420 const TypeLong *TypeLong::UINT; // 32-bit unsigned subrange 1423 const TypeLong *TypeLong::UINT; // 32-bit unsigned subrange
1424 const TypeLong *TypeLong::TYPE_DOMAIN; // alias for TypeLong::LONG
1421 1425
1422 //------------------------------TypeLong--------------------------------------- 1426 //------------------------------TypeLong---------------------------------------
1423 TypeLong::TypeLong( jlong lo, jlong hi, int w ) : Type(Long), _lo(lo), _hi(hi), _widen(w) { 1427 TypeLong::TypeLong( jlong lo, jlong hi, int w ) : Type(Long), _lo(lo), _hi(hi), _widen(w) {
1424 } 1428 }
1425 1429
2457 //============================================================================= 2461 //=============================================================================
2458 // Convenience common pre-built type. 2462 // Convenience common pre-built type.
2459 const TypeOopPtr *TypeOopPtr::BOTTOM; 2463 const TypeOopPtr *TypeOopPtr::BOTTOM;
2460 2464
2461 //------------------------------TypeOopPtr------------------------------------- 2465 //------------------------------TypeOopPtr-------------------------------------
2462 TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative) 2466 TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth)
2463 : TypePtr(t, ptr, offset), 2467 : TypePtr(t, ptr, offset),
2464 _const_oop(o), _klass(k), 2468 _const_oop(o), _klass(k),
2465 _klass_is_exact(xk), 2469 _klass_is_exact(xk),
2466 _is_ptr_to_narrowoop(false), 2470 _is_ptr_to_narrowoop(false),
2467 _is_ptr_to_narrowklass(false), 2471 _is_ptr_to_narrowklass(false),
2468 _is_ptr_to_boxed_value(false), 2472 _is_ptr_to_boxed_value(false),
2469 _instance_id(instance_id), 2473 _instance_id(instance_id),
2470 _speculative(speculative) { 2474 _speculative(speculative),
2475 _inline_depth(inline_depth){
2471 if (Compile::current()->eliminate_boxing() && (t == InstPtr) && 2476 if (Compile::current()->eliminate_boxing() && (t == InstPtr) &&
2472 (offset > 0) && xk && (k != 0) && k->is_instance_klass()) { 2477 (offset > 0) && xk && (k != 0) && k->is_instance_klass()) {
2473 _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset); 2478 _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset);
2474 } 2479 }
2475 #ifdef _LP64 2480 #ifdef _LP64
2532 #endif 2537 #endif
2533 } 2538 }
2534 2539
2535 //------------------------------make------------------------------------------- 2540 //------------------------------make-------------------------------------------
2536 const TypeOopPtr *TypeOopPtr::make(PTR ptr, 2541 const TypeOopPtr *TypeOopPtr::make(PTR ptr,
2537 int offset, int instance_id, const TypeOopPtr* speculative) { 2542 int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth) {
2538 assert(ptr != Constant, "no constant generic pointers"); 2543 assert(ptr != Constant, "no constant generic pointers");
2539 ciKlass* k = Compile::current()->env()->Object_klass(); 2544 ciKlass* k = Compile::current()->env()->Object_klass();
2540 bool xk = false; 2545 bool xk = false;
2541 ciObject* o = NULL; 2546 ciObject* o = NULL;
2542 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative))->hashcons(); 2547 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative, inline_depth))->hashcons();
2543 } 2548 }
2544 2549
2545 2550
2546 //------------------------------cast_to_ptr_type------------------------------- 2551 //------------------------------cast_to_ptr_type-------------------------------
2547 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const { 2552 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const {
2548 assert(_base == OopPtr, "subclass must override cast_to_ptr_type"); 2553 assert(_base == OopPtr, "subclass must override cast_to_ptr_type");
2549 if( ptr == _ptr ) return this; 2554 if( ptr == _ptr ) return this;
2550 return make(ptr, _offset, _instance_id, _speculative); 2555 return make(ptr, _offset, _instance_id, _speculative, _inline_depth);
2551 } 2556 }
2552 2557
2553 //-----------------------------cast_to_instance_id---------------------------- 2558 //-----------------------------cast_to_instance_id----------------------------
2554 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const { 2559 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const {
2555 // There are no instances of a general oop. 2560 // There are no instances of a general oop.
2642 // else fall through: 2647 // else fall through:
2643 case TopPTR: 2648 case TopPTR:
2644 case AnyNull: { 2649 case AnyNull: {
2645 int instance_id = meet_instance_id(InstanceTop); 2650 int instance_id = meet_instance_id(InstanceTop);
2646 const TypeOopPtr* speculative = _speculative; 2651 const TypeOopPtr* speculative = _speculative;
2647 return make(ptr, offset, instance_id, speculative); 2652 return make(ptr, offset, instance_id, speculative, _inline_depth);
2648 } 2653 }
2649 case BotPTR: 2654 case BotPTR:
2650 case NotNull: 2655 case NotNull:
2651 return TypePtr::make(AnyPtr, ptr, offset); 2656 return TypePtr::make(AnyPtr, ptr, offset);
2652 default: typerr(t); 2657 default: typerr(t);
2655 2660
2656 case OopPtr: { // Meeting to other OopPtrs 2661 case OopPtr: { // Meeting to other OopPtrs
2657 const TypeOopPtr *tp = t->is_oopptr(); 2662 const TypeOopPtr *tp = t->is_oopptr();
2658 int instance_id = meet_instance_id(tp->instance_id()); 2663 int instance_id = meet_instance_id(tp->instance_id());
2659 const TypeOopPtr* speculative = xmeet_speculative(tp); 2664 const TypeOopPtr* speculative = xmeet_speculative(tp);
2660 return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative); 2665 int depth = meet_inline_depth(tp->inline_depth());
2666 return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative, depth);
2661 } 2667 }
2662 2668
2663 case InstPtr: // For these, flip the call around to cut down 2669 case InstPtr: // For these, flip the call around to cut down
2664 case AryPtr: 2670 case AryPtr:
2665 return t->xmeet(this); // Call in reverse direction 2671 return t->xmeet(this); // Call in reverse direction
2672 //------------------------------xdual------------------------------------------ 2678 //------------------------------xdual------------------------------------------
2673 // Dual of a pure heap pointer. No relevant klass or oop information. 2679 // Dual of a pure heap pointer. No relevant klass or oop information.
2674 const Type *TypeOopPtr::xdual() const { 2680 const Type *TypeOopPtr::xdual() const {
2675 assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here"); 2681 assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here");
2676 assert(const_oop() == NULL, "no constants here"); 2682 assert(const_oop() == NULL, "no constants here");
2677 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative()); 2683 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth());
2678 } 2684 }
2679 2685
2680 //--------------------------make_from_klass_common----------------------------- 2686 //--------------------------make_from_klass_common-----------------------------
2681 // Computes the element-type given a klass. 2687 // Computes the element-type given a klass.
2682 const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) { 2688 const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) {
2763 if (require_constant) { 2769 if (require_constant) {
2764 if (!o->can_be_constant()) return NULL; 2770 if (!o->can_be_constant()) return NULL;
2765 } else if (!o->should_be_constant()) { 2771 } else if (!o->should_be_constant()) {
2766 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); 2772 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
2767 } 2773 }
2768 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, NULL, is_autobox_cache); 2774 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, NULL, InlineDepthBottom, is_autobox_cache);
2769 return arr; 2775 return arr;
2770 } else if (klass->is_type_array_klass()) { 2776 } else if (klass->is_type_array_klass()) {
2771 // Element is an typeArray 2777 // Element is an typeArray
2772 const Type* etype = 2778 const Type* etype =
2773 (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type()); 2779 (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type());
2852 // Structural equality check for Type representations 2858 // Structural equality check for Type representations
2853 bool TypeOopPtr::eq( const Type *t ) const { 2859 bool TypeOopPtr::eq( const Type *t ) const {
2854 const TypeOopPtr *a = (const TypeOopPtr*)t; 2860 const TypeOopPtr *a = (const TypeOopPtr*)t;
2855 if (_klass_is_exact != a->_klass_is_exact || 2861 if (_klass_is_exact != a->_klass_is_exact ||
2856 _instance_id != a->_instance_id || 2862 _instance_id != a->_instance_id ||
2857 !eq_speculative(a)) return false; 2863 !eq_speculative(a) ||
2864 _inline_depth != a->_inline_depth) return false;
2858 ciObject* one = const_oop(); 2865 ciObject* one = const_oop();
2859 ciObject* two = a->const_oop(); 2866 ciObject* two = a->const_oop();
2860 if (one == NULL || two == NULL) { 2867 if (one == NULL || two == NULL) {
2861 return (one == two) && TypePtr::eq(t); 2868 return (one == two) && TypePtr::eq(t);
2862 } else { 2869 } else {
2870 return 2877 return
2871 (const_oop() ? const_oop()->hash() : 0) + 2878 (const_oop() ? const_oop()->hash() : 0) +
2872 _klass_is_exact + 2879 _klass_is_exact +
2873 _instance_id + 2880 _instance_id +
2874 hash_speculative() + 2881 hash_speculative() +
2882 _inline_depth +
2875 TypePtr::hash(); 2883 TypePtr::hash();
2876 } 2884 }
2877 2885
2878 //------------------------------dump2------------------------------------------ 2886 //------------------------------dump2------------------------------------------
2879 #ifndef PRODUCT 2887 #ifndef PRODUCT
2890 if (_instance_id == InstanceTop) 2898 if (_instance_id == InstanceTop)
2891 st->print(",iid=top"); 2899 st->print(",iid=top");
2892 else if (_instance_id != InstanceBot) 2900 else if (_instance_id != InstanceBot)
2893 st->print(",iid=%d",_instance_id); 2901 st->print(",iid=%d",_instance_id);
2894 2902
2903 dump_inline_depth(st);
2895 dump_speculative(st); 2904 dump_speculative(st);
2896 } 2905 }
2897 2906
2898 /** 2907 /**
2899 *dump the speculative part of the type 2908 *dump the speculative part of the type
2903 st->print(" (speculative="); 2912 st->print(" (speculative=");
2904 _speculative->dump_on(st); 2913 _speculative->dump_on(st);
2905 st->print(")"); 2914 st->print(")");
2906 } 2915 }
2907 } 2916 }
2917
2918 void TypeOopPtr::dump_inline_depth(outputStream *st) const {
2919 if (_inline_depth != InlineDepthBottom) {
2920 if (_inline_depth == InlineDepthTop) {
2921 st->print(" (inline_depth=InlineDepthTop)");
2922 } else {
2923 st->print(" (inline_depth=%d)", _inline_depth);
2924 }
2925 }
2926 }
2908 #endif 2927 #endif
2909 2928
2910 //------------------------------singleton-------------------------------------- 2929 //------------------------------singleton--------------------------------------
2911 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple 2930 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple
2912 // constants 2931 // constants
2916 return (_offset == 0) && !below_centerline(_ptr); 2935 return (_offset == 0) && !below_centerline(_ptr);
2917 } 2936 }
2918 2937
2919 //------------------------------add_offset------------------------------------- 2938 //------------------------------add_offset-------------------------------------
2920 const TypePtr *TypeOopPtr::add_offset(intptr_t offset) const { 2939 const TypePtr *TypeOopPtr::add_offset(intptr_t offset) const {
2921 return make(_ptr, xadd_offset(offset), _instance_id, add_offset_speculative(offset)); 2940 return make(_ptr, xadd_offset(offset), _instance_id, add_offset_speculative(offset), _inline_depth);
2922 } 2941 }
2923 2942
2924 /** 2943 /**
2925 * Return same type without a speculative part 2944 * Return same type without a speculative part
2926 */ 2945 */
2927 const Type* TypeOopPtr::remove_speculative() const { 2946 const Type* TypeOopPtr::remove_speculative() const {
2928 if (_speculative == NULL) { 2947 if (_speculative == NULL) {
2929 return this; 2948 return this;
2930 } 2949 }
2931 return make(_ptr, _offset, _instance_id, NULL); 2950 assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth");
2951 return make(_ptr, _offset, _instance_id, NULL, _inline_depth);
2952 }
2953
2954 /**
2955 * Return same type but with a different inline depth (used for speculation)
2956 *
2957 * @param depth depth to meet with
2958 */
2959 const TypeOopPtr* TypeOopPtr::with_inline_depth(int depth) const {
2960 if (!UseInlineDepthForSpeculativeTypes) {
2961 return this;
2962 }
2963 return make(_ptr, _offset, _instance_id, _speculative, depth);
2964 }
2965
2966 /**
2967 * Check whether new profiling would improve speculative type
2968 *
2969 * @param exact_kls class from profiling
2970 * @param inline_depth inlining depth of profile point
2971 *
2972 * @return true if type profile is valuable
2973 */
2974 bool TypeOopPtr::would_improve_type(ciKlass* exact_kls, int inline_depth) const {
2975 // no way to improve an already exact type
2976 if (klass_is_exact()) {
2977 return false;
2978 }
2979 // no profiling?
2980 if (exact_kls == NULL) {
2981 return false;
2982 }
2983 // no speculative type or non exact speculative type?
2984 if (speculative_type() == NULL) {
2985 return true;
2986 }
2987 // If the node already has an exact speculative type keep it,
2988 // unless it was provided by profiling that is at a deeper
2989 // inlining level. Profiling at a higher inlining depth is
2990 // expected to be less accurate.
2991 if (_speculative->inline_depth() == InlineDepthBottom) {
2992 return false;
2993 }
2994 assert(_speculative->inline_depth() != InlineDepthTop, "can't do the comparison");
2995 return inline_depth < _speculative->inline_depth();
2932 } 2996 }
2933 2997
2934 //------------------------------meet_instance_id-------------------------------- 2998 //------------------------------meet_instance_id--------------------------------
2935 int TypeOopPtr::meet_instance_id( int instance_id ) const { 2999 int TypeOopPtr::meet_instance_id( int instance_id ) const {
2936 // Either is 'TOP' instance? Return the other instance! 3000 // Either is 'TOP' instance? Return the other instance!
3029 } 3093 }
3030 3094
3031 return _speculative->hash(); 3095 return _speculative->hash();
3032 } 3096 }
3033 3097
3098 /**
3099 * dual of the inline depth for this type (used for speculation)
3100 */
3101 int TypeOopPtr::dual_inline_depth() const {
3102 return -inline_depth();
3103 }
3104
3105 /**
3106 * meet of 2 inline depth (used for speculation)
3107 *
3108 * @param depth depth to meet with
3109 */
3110 int TypeOopPtr::meet_inline_depth(int depth) const {
3111 return MAX2(inline_depth(), depth);
3112 }
3034 3113
3035 //============================================================================= 3114 //=============================================================================
3036 // Convenience common pre-built types. 3115 // Convenience common pre-built types.
3037 const TypeInstPtr *TypeInstPtr::NOTNULL; 3116 const TypeInstPtr *TypeInstPtr::NOTNULL;
3038 const TypeInstPtr *TypeInstPtr::BOTTOM; 3117 const TypeInstPtr *TypeInstPtr::BOTTOM;
3039 const TypeInstPtr *TypeInstPtr::MIRROR; 3118 const TypeInstPtr *TypeInstPtr::MIRROR;
3040 const TypeInstPtr *TypeInstPtr::MARK; 3119 const TypeInstPtr *TypeInstPtr::MARK;
3041 const TypeInstPtr *TypeInstPtr::KLASS; 3120 const TypeInstPtr *TypeInstPtr::KLASS;
3042 3121
3043 //------------------------------TypeInstPtr------------------------------------- 3122 //------------------------------TypeInstPtr-------------------------------------
3044 TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id, const TypeOopPtr* speculative) 3123 TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id, const TypeOopPtr* speculative, int inline_depth)
3045 : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id, speculative), _name(k->name()) { 3124 : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id, speculative, inline_depth), _name(k->name()) {
3046 assert(k != NULL && 3125 assert(k != NULL &&
3047 (k->is_loaded() || o == NULL), 3126 (k->is_loaded() || o == NULL),
3048 "cannot have constants with non-loaded klass"); 3127 "cannot have constants with non-loaded klass");
3049 }; 3128 };
3050 3129
3053 ciKlass* k, 3132 ciKlass* k,
3054 bool xk, 3133 bool xk,
3055 ciObject* o, 3134 ciObject* o,
3056 int offset, 3135 int offset,
3057 int instance_id, 3136 int instance_id,
3058 const TypeOopPtr* speculative) { 3137 const TypeOopPtr* speculative,
3138 int inline_depth) {
3059 assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance"); 3139 assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance");
3060 // Either const_oop() is NULL or else ptr is Constant 3140 // Either const_oop() is NULL or else ptr is Constant
3061 assert( (!o && ptr != Constant) || (o && ptr == Constant), 3141 assert( (!o && ptr != Constant) || (o && ptr == Constant),
3062 "constant pointers must have a value supplied" ); 3142 "constant pointers must have a value supplied" );
3063 // Ptr is never Null 3143 // Ptr is never Null
3074 if (xk && ik->is_interface()) xk = false; // no exact interface 3154 if (xk && ik->is_interface()) xk = false; // no exact interface
3075 } 3155 }
3076 3156
3077 // Now hash this baby 3157 // Now hash this baby
3078 TypeInstPtr *result = 3158 TypeInstPtr *result =
3079 (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id, speculative))->hashcons(); 3159 (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id, speculative, inline_depth))->hashcons();
3080 3160
3081 return result; 3161 return result;
3082 } 3162 }
3083 3163
3084 /** 3164 /**
3107 //------------------------------cast_to_ptr_type------------------------------- 3187 //------------------------------cast_to_ptr_type-------------------------------
3108 const Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const { 3188 const Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const {
3109 if( ptr == _ptr ) return this; 3189 if( ptr == _ptr ) return this;
3110 // Reconstruct _sig info here since not a problem with later lazy 3190 // Reconstruct _sig info here since not a problem with later lazy
3111 // construction, _sig will show up on demand. 3191 // construction, _sig will show up on demand.
3112 return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative); 3192 return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, _inline_depth);
3113 } 3193 }
3114 3194
3115 3195
3116 //-----------------------------cast_to_exactness------------------------------- 3196 //-----------------------------cast_to_exactness-------------------------------
3117 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const { 3197 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const {
3119 if (!UseExactTypes) return this; 3199 if (!UseExactTypes) return this;
3120 if (!_klass->is_loaded()) return this; 3200 if (!_klass->is_loaded()) return this;
3121 ciInstanceKlass* ik = _klass->as_instance_klass(); 3201 ciInstanceKlass* ik = _klass->as_instance_klass();
3122 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk 3202 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk
3123 if( ik->is_interface() ) return this; // cannot set xk 3203 if( ik->is_interface() ) return this; // cannot set xk
3124 return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative); 3204 return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative, _inline_depth);
3125 } 3205 }
3126 3206
3127 //-----------------------------cast_to_instance_id---------------------------- 3207 //-----------------------------cast_to_instance_id----------------------------
3128 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const { 3208 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const {
3129 if( instance_id == _instance_id ) return this; 3209 if( instance_id == _instance_id ) return this;
3130 return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative); 3210 return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative, _inline_depth);
3131 } 3211 }
3132 3212
3133 //------------------------------xmeet_unloaded--------------------------------- 3213 //------------------------------xmeet_unloaded---------------------------------
3134 // Compute the MEET of two InstPtrs when at least one is unloaded. 3214 // Compute the MEET of two InstPtrs when at least one is unloaded.
3135 // Assume classes are different since called after check for same name/class-loader 3215 // Assume classes are different since called after check for same name/class-loader
3136 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const { 3216 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const {
3137 int off = meet_offset(tinst->offset()); 3217 int off = meet_offset(tinst->offset());
3138 PTR ptr = meet_ptr(tinst->ptr()); 3218 PTR ptr = meet_ptr(tinst->ptr());
3139 int instance_id = meet_instance_id(tinst->instance_id()); 3219 int instance_id = meet_instance_id(tinst->instance_id());
3140 const TypeOopPtr* speculative = xmeet_speculative(tinst); 3220 const TypeOopPtr* speculative = xmeet_speculative(tinst);
3221 int depth = meet_inline_depth(tinst->inline_depth());
3141 3222
3142 const TypeInstPtr *loaded = is_loaded() ? this : tinst; 3223 const TypeInstPtr *loaded = is_loaded() ? this : tinst;
3143 const TypeInstPtr *unloaded = is_loaded() ? tinst : this; 3224 const TypeInstPtr *unloaded = is_loaded() ? tinst : this;
3144 if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) { 3225 if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) {
3145 // 3226 //
3156 // BOTTOM | ........................Object-BOTTOM ..................| 3237 // BOTTOM | ........................Object-BOTTOM ..................|
3157 // 3238 //
3158 assert(loaded->ptr() != TypePtr::Null, "insanity check"); 3239 assert(loaded->ptr() != TypePtr::Null, "insanity check");
3159 // 3240 //
3160 if( loaded->ptr() == TypePtr::TopPTR ) { return unloaded; } 3241 if( loaded->ptr() == TypePtr::TopPTR ) { return unloaded; }
3161 else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make(ptr, unloaded->klass(), false, NULL, off, instance_id, speculative); } 3242 else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make(ptr, unloaded->klass(), false, NULL, off, instance_id, speculative, depth); }
3162 else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } 3243 else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; }
3163 else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) { 3244 else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) {
3164 if (unloaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } 3245 if (unloaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; }
3165 else { return TypeInstPtr::NOTNULL; } 3246 else { return TypeInstPtr::NOTNULL; }
3166 } 3247 }
3213 const TypeAryPtr *tp = t->is_aryptr(); 3294 const TypeAryPtr *tp = t->is_aryptr();
3214 int offset = meet_offset(tp->offset()); 3295 int offset = meet_offset(tp->offset());
3215 PTR ptr = meet_ptr(tp->ptr()); 3296 PTR ptr = meet_ptr(tp->ptr());
3216 int instance_id = meet_instance_id(tp->instance_id()); 3297 int instance_id = meet_instance_id(tp->instance_id());
3217 const TypeOopPtr* speculative = xmeet_speculative(tp); 3298 const TypeOopPtr* speculative = xmeet_speculative(tp);
3299 int depth = meet_inline_depth(tp->inline_depth());
3218 switch (ptr) { 3300 switch (ptr) {
3219 case TopPTR: 3301 case TopPTR:
3220 case AnyNull: // Fall 'down' to dual of object klass 3302 case AnyNull: // Fall 'down' to dual of object klass
3221 // For instances when a subclass meets a superclass we fall 3303 // For instances when a subclass meets a superclass we fall
3222 // below the centerline when the superclass is exact. We need to 3304 // below the centerline when the superclass is exact. We need to
3223 // do the same here. 3305 // do the same here.
3224 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { 3306 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) {
3225 return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative); 3307 return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative, depth);
3226 } else { 3308 } else {
3227 // cannot subclass, so the meet has to fall badly below the centerline 3309 // cannot subclass, so the meet has to fall badly below the centerline
3228 ptr = NotNull; 3310 ptr = NotNull;
3229 instance_id = InstanceBot; 3311 instance_id = InstanceBot;
3230 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative); 3312 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth);
3231 } 3313 }
3232 case Constant: 3314 case Constant:
3233 case NotNull: 3315 case NotNull:
3234 case BotPTR: // Fall down to object klass 3316 case BotPTR: // Fall down to object klass
3235 // LCA is object_klass, but if we subclass from the top we can do better 3317 // LCA is object_klass, but if we subclass from the top we can do better
3240 // below the centerline when the superclass is exact. We need 3322 // below the centerline when the superclass is exact. We need
3241 // to do the same here. 3323 // to do the same here.
3242 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { 3324 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) {
3243 // that is, tp's array type is a subtype of my klass 3325 // that is, tp's array type is a subtype of my klass
3244 return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL), 3326 return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL),
3245 tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative); 3327 tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative, depth);
3246 } 3328 }
3247 } 3329 }
3248 // The other case cannot happen, since I cannot be a subtype of an array. 3330 // The other case cannot happen, since I cannot be a subtype of an array.
3249 // The meet falls down to Object class below centerline. 3331 // The meet falls down to Object class below centerline.
3250 if( ptr == Constant ) 3332 if( ptr == Constant )
3251 ptr = NotNull; 3333 ptr = NotNull;
3252 instance_id = InstanceBot; 3334 instance_id = InstanceBot;
3253 return make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative); 3335 return make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth);
3254 default: typerr(t); 3336 default: typerr(t);
3255 } 3337 }
3256 } 3338 }
3257 3339
3258 case OopPtr: { // Meeting to OopPtrs 3340 case OopPtr: { // Meeting to OopPtrs
3263 switch (tp->ptr()) { 3345 switch (tp->ptr()) {
3264 case TopPTR: 3346 case TopPTR:
3265 case AnyNull: { 3347 case AnyNull: {
3266 int instance_id = meet_instance_id(InstanceTop); 3348 int instance_id = meet_instance_id(InstanceTop);
3267 const TypeOopPtr* speculative = xmeet_speculative(tp); 3349 const TypeOopPtr* speculative = xmeet_speculative(tp);
3350 int depth = meet_inline_depth(tp->inline_depth());
3268 return make(ptr, klass(), klass_is_exact(), 3351 return make(ptr, klass(), klass_is_exact(),
3269 (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative); 3352 (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative, depth);
3270 } 3353 }
3271 case NotNull: 3354 case NotNull:
3272 case BotPTR: { 3355 case BotPTR: {
3273 int instance_id = meet_instance_id(tp->instance_id()); 3356 int instance_id = meet_instance_id(tp->instance_id());
3274 const TypeOopPtr* speculative = xmeet_speculative(tp); 3357 const TypeOopPtr* speculative = xmeet_speculative(tp);
3275 return TypeOopPtr::make(ptr, offset, instance_id, speculative); 3358 int depth = meet_inline_depth(tp->inline_depth());
3359 return TypeOopPtr::make(ptr, offset, instance_id, speculative, depth);
3276 } 3360 }
3277 default: typerr(t); 3361 default: typerr(t);
3278 } 3362 }
3279 } 3363 }
3280 3364
3290 case TopPTR: 3374 case TopPTR:
3291 case AnyNull: { 3375 case AnyNull: {
3292 int instance_id = meet_instance_id(InstanceTop); 3376 int instance_id = meet_instance_id(InstanceTop);
3293 const TypeOopPtr* speculative = _speculative; 3377 const TypeOopPtr* speculative = _speculative;
3294 return make(ptr, klass(), klass_is_exact(), 3378 return make(ptr, klass(), klass_is_exact(),
3295 (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative); 3379 (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative, _inline_depth);
3296 } 3380 }
3297 case NotNull: 3381 case NotNull:
3298 case BotPTR: 3382 case BotPTR:
3299 return TypePtr::make(AnyPtr, ptr, offset); 3383 return TypePtr::make(AnyPtr, ptr, offset);
3300 default: typerr(t); 3384 default: typerr(t);
3322 const TypeInstPtr *tinst = t->is_instptr(); 3406 const TypeInstPtr *tinst = t->is_instptr();
3323 int off = meet_offset( tinst->offset() ); 3407 int off = meet_offset( tinst->offset() );
3324 PTR ptr = meet_ptr( tinst->ptr() ); 3408 PTR ptr = meet_ptr( tinst->ptr() );
3325 int instance_id = meet_instance_id(tinst->instance_id()); 3409 int instance_id = meet_instance_id(tinst->instance_id());
3326 const TypeOopPtr* speculative = xmeet_speculative(tinst); 3410 const TypeOopPtr* speculative = xmeet_speculative(tinst);
3411 int depth = meet_inline_depth(tinst->inline_depth());
3327 3412
3328 // Check for easy case; klasses are equal (and perhaps not loaded!) 3413 // Check for easy case; klasses are equal (and perhaps not loaded!)
3329 // If we have constants, then we created oops so classes are loaded 3414 // If we have constants, then we created oops so classes are loaded
3330 // and we can handle the constants further down. This case handles 3415 // and we can handle the constants further down. This case handles
3331 // both-not-loaded or both-loaded classes 3416 // both-not-loaded or both-loaded classes
3332 if (ptr != Constant && klass()->equals(tinst->klass()) && klass_is_exact() == tinst->klass_is_exact()) { 3417 if (ptr != Constant && klass()->equals(tinst->klass()) && klass_is_exact() == tinst->klass_is_exact()) {
3333 return make(ptr, klass(), klass_is_exact(), NULL, off, instance_id, speculative); 3418 return make(ptr, klass(), klass_is_exact(), NULL, off, instance_id, speculative, depth);
3334 } 3419 }
3335 3420
3336 // Classes require inspection in the Java klass hierarchy. Must be loaded. 3421 // Classes require inspection in the Java klass hierarchy. Must be loaded.
3337 ciKlass* tinst_klass = tinst->klass(); 3422 ciKlass* tinst_klass = tinst->klass();
3338 ciKlass* this_klass = this->klass(); 3423 ciKlass* this_klass = this->klass();
3392 ciObject* o = NULL; // the Constant value, if any 3477 ciObject* o = NULL; // the Constant value, if any
3393 if (ptr == Constant) { 3478 if (ptr == Constant) {
3394 // Find out which constant. 3479 // Find out which constant.
3395 o = (this_klass == klass()) ? const_oop() : tinst->const_oop(); 3480 o = (this_klass == klass()) ? const_oop() : tinst->const_oop();
3396 } 3481 }
3397 return make(ptr, k, xk, o, off, instance_id, speculative); 3482 return make(ptr, k, xk, o, off, instance_id, speculative, depth);
3398 } 3483 }
3399 3484
3400 // Either oop vs oop or interface vs interface or interface vs Object 3485 // Either oop vs oop or interface vs interface or interface vs Object
3401 3486
3402 // !!! Here's how the symmetry requirement breaks down into invariants: 3487 // !!! Here's how the symmetry requirement breaks down into invariants:
3469 else if (above_centerline(tinst ->_ptr)) 3554 else if (above_centerline(tinst ->_ptr))
3470 o = this_oop; 3555 o = this_oop;
3471 else 3556 else
3472 ptr = NotNull; 3557 ptr = NotNull;
3473 } 3558 }
3474 return make(ptr, this_klass, this_xk, o, off, instance_id, speculative); 3559 return make(ptr, this_klass, this_xk, o, off, instance_id, speculative, depth);
3475 } // Else classes are not equal 3560 } // Else classes are not equal
3476 3561
3477 // Since klasses are different, we require a LCA in the Java 3562 // Since klasses are different, we require a LCA in the Java
3478 // class hierarchy - which means we have to fall to at least NotNull. 3563 // class hierarchy - which means we have to fall to at least NotNull.
3479 if( ptr == TopPTR || ptr == AnyNull || ptr == Constant ) 3564 if( ptr == TopPTR || ptr == AnyNull || ptr == Constant )
3480 ptr = NotNull; 3565 ptr = NotNull;
3481 instance_id = InstanceBot; 3566 instance_id = InstanceBot;
3482 3567
3483 // Now we find the LCA of Java classes 3568 // Now we find the LCA of Java classes
3484 ciKlass* k = this_klass->least_common_ancestor(tinst_klass); 3569 ciKlass* k = this_klass->least_common_ancestor(tinst_klass);
3485 return make(ptr, k, false, NULL, off, instance_id, speculative); 3570 return make(ptr, k, false, NULL, off, instance_id, speculative, depth);
3486 } // End of case InstPtr 3571 } // End of case InstPtr
3487 3572
3488 } // End of switch 3573 } // End of switch
3489 return this; // Return the double constant 3574 return this; // Return the double constant
3490 } 3575 }
3504 3589
3505 //------------------------------xdual------------------------------------------ 3590 //------------------------------xdual------------------------------------------
3506 // Dual: do NOT dual on klasses. This means I do NOT understand the Java 3591 // Dual: do NOT dual on klasses. This means I do NOT understand the Java
3507 // inheritance mechanism. 3592 // inheritance mechanism.
3508 const Type *TypeInstPtr::xdual() const { 3593 const Type *TypeInstPtr::xdual() const {
3509 return new TypeInstPtr(dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative()); 3594 return new TypeInstPtr(dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth());
3510 } 3595 }
3511 3596
3512 //------------------------------eq--------------------------------------------- 3597 //------------------------------eq---------------------------------------------
3513 // Structural equality check for Type representations 3598 // Structural equality check for Type representations
3514 bool TypeInstPtr::eq( const Type *t ) const { 3599 bool TypeInstPtr::eq( const Type *t ) const {
3561 if (_instance_id == InstanceTop) 3646 if (_instance_id == InstanceTop)
3562 st->print(",iid=top"); 3647 st->print(",iid=top");
3563 else if (_instance_id != InstanceBot) 3648 else if (_instance_id != InstanceBot)
3564 st->print(",iid=%d",_instance_id); 3649 st->print(",iid=%d",_instance_id);
3565 3650
3651 dump_inline_depth(st);
3566 dump_speculative(st); 3652 dump_speculative(st);
3567 } 3653 }
3568 #endif 3654 #endif
3569 3655
3570 //------------------------------add_offset------------------------------------- 3656 //------------------------------add_offset-------------------------------------
3574 3660
3575 const Type *TypeInstPtr::remove_speculative() const { 3661 const Type *TypeInstPtr::remove_speculative() const {
3576 if (_speculative == NULL) { 3662 if (_speculative == NULL) {
3577 return this; 3663 return this;
3578 } 3664 }
3579 return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, NULL); 3665 assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth");
3666 return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, NULL, _inline_depth);
3667 }
3668
3669 const TypeOopPtr *TypeInstPtr::with_inline_depth(int depth) const {
3670 if (!UseInlineDepthForSpeculativeTypes) {
3671 return this;
3672 }
3673 return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, depth);
3580 } 3674 }
3581 3675
3582 //============================================================================= 3676 //=============================================================================
3583 // Convenience common pre-built types. 3677 // Convenience common pre-built types.
3584 const TypeAryPtr *TypeAryPtr::RANGE; 3678 const TypeAryPtr *TypeAryPtr::RANGE;
3591 const TypeAryPtr *TypeAryPtr::LONGS; 3685 const TypeAryPtr *TypeAryPtr::LONGS;
3592 const TypeAryPtr *TypeAryPtr::FLOATS; 3686 const TypeAryPtr *TypeAryPtr::FLOATS;
3593 const TypeAryPtr *TypeAryPtr::DOUBLES; 3687 const TypeAryPtr *TypeAryPtr::DOUBLES;
3594 3688
3595 //------------------------------make------------------------------------------- 3689 //------------------------------make-------------------------------------------
3596 const TypeAryPtr *TypeAryPtr::make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative) { 3690 const TypeAryPtr *TypeAryPtr::make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth) {
3597 assert(!(k == NULL && ary->_elem->isa_int()), 3691 assert(!(k == NULL && ary->_elem->isa_int()),
3598 "integral arrays must be pre-equipped with a class"); 3692 "integral arrays must be pre-equipped with a class");
3599 if (!xk) xk = ary->ary_must_be_exact(); 3693 if (!xk) xk = ary->ary_must_be_exact();
3600 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); 3694 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
3601 if (!UseExactTypes) xk = (ptr == Constant); 3695 if (!UseExactTypes) xk = (ptr == Constant);
3602 return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false, speculative))->hashcons(); 3696 return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false, speculative, inline_depth))->hashcons();
3603 } 3697 }
3604 3698
3605 //------------------------------make------------------------------------------- 3699 //------------------------------make-------------------------------------------
3606 const TypeAryPtr *TypeAryPtr::make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative, bool is_autobox_cache) { 3700 const TypeAryPtr *TypeAryPtr::make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth, bool is_autobox_cache) {
3607 assert(!(k == NULL && ary->_elem->isa_int()), 3701 assert(!(k == NULL && ary->_elem->isa_int()),
3608 "integral arrays must be pre-equipped with a class"); 3702 "integral arrays must be pre-equipped with a class");
3609 assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" ); 3703 assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" );
3610 if (!xk) xk = (o != NULL) || ary->ary_must_be_exact(); 3704 if (!xk) xk = (o != NULL) || ary->ary_must_be_exact();
3611 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); 3705 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
3612 if (!UseExactTypes) xk = (ptr == Constant); 3706 if (!UseExactTypes) xk = (ptr == Constant);
3613 return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache, speculative))->hashcons(); 3707 return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache, speculative, inline_depth))->hashcons();
3614 } 3708 }
3615 3709
3616 //------------------------------cast_to_ptr_type------------------------------- 3710 //------------------------------cast_to_ptr_type-------------------------------
3617 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const { 3711 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const {
3618 if( ptr == _ptr ) return this; 3712 if( ptr == _ptr ) return this;
3619 return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative); 3713 return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth);
3620 } 3714 }
3621 3715
3622 3716
3623 //-----------------------------cast_to_exactness------------------------------- 3717 //-----------------------------cast_to_exactness-------------------------------
3624 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const { 3718 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const {
3625 if( klass_is_exact == _klass_is_exact ) return this; 3719 if( klass_is_exact == _klass_is_exact ) return this;
3626 if (!UseExactTypes) return this; 3720 if (!UseExactTypes) return this;
3627 if (_ary->ary_must_be_exact()) return this; // cannot clear xk 3721 if (_ary->ary_must_be_exact()) return this; // cannot clear xk
3628 return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative); 3722 return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative, _inline_depth);
3629 } 3723 }
3630 3724
3631 //-----------------------------cast_to_instance_id---------------------------- 3725 //-----------------------------cast_to_instance_id----------------------------
3632 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const { 3726 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const {
3633 if( instance_id == _instance_id ) return this; 3727 if( instance_id == _instance_id ) return this;
3634 return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative); 3728 return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative, _inline_depth);
3635 } 3729 }
3636 3730
3637 //-----------------------------narrow_size_type------------------------------- 3731 //-----------------------------narrow_size_type-------------------------------
3638 // Local cache for arrayOopDesc::max_array_length(etype), 3732 // Local cache for arrayOopDesc::max_array_length(etype),
3639 // which is kind of slow (and cached elsewhere by other users). 3733 // which is kind of slow (and cached elsewhere by other users).
3692 const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const { 3786 const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const {
3693 assert(new_size != NULL, ""); 3787 assert(new_size != NULL, "");
3694 new_size = narrow_size_type(new_size); 3788 new_size = narrow_size_type(new_size);
3695 if (new_size == size()) return this; 3789 if (new_size == size()) return this;
3696 const TypeAry* new_ary = TypeAry::make(elem(), new_size, is_stable()); 3790 const TypeAry* new_ary = TypeAry::make(elem(), new_size, is_stable());
3697 return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative); 3791 return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth);
3698 } 3792 }
3699 3793
3700 3794
3701 //------------------------------cast_to_stable--------------------------------- 3795 //------------------------------cast_to_stable---------------------------------
3702 const TypeAryPtr* TypeAryPtr::cast_to_stable(bool stable, int stable_dimension) const { 3796 const TypeAryPtr* TypeAryPtr::cast_to_stable(bool stable, int stable_dimension) const {
3771 case OopPtr: { // Meeting to OopPtrs 3865 case OopPtr: { // Meeting to OopPtrs
3772 // Found a OopPtr type vs self-AryPtr type 3866 // Found a OopPtr type vs self-AryPtr type
3773 const TypeOopPtr *tp = t->is_oopptr(); 3867 const TypeOopPtr *tp = t->is_oopptr();
3774 int offset = meet_offset(tp->offset()); 3868 int offset = meet_offset(tp->offset());
3775 PTR ptr = meet_ptr(tp->ptr()); 3869 PTR ptr = meet_ptr(tp->ptr());
3870 int depth = meet_inline_depth(tp->inline_depth());
3776 switch (tp->ptr()) { 3871 switch (tp->ptr()) {
3777 case TopPTR: 3872 case TopPTR:
3778 case AnyNull: { 3873 case AnyNull: {
3779 int instance_id = meet_instance_id(InstanceTop); 3874 int instance_id = meet_instance_id(InstanceTop);
3780 const TypeOopPtr* speculative = xmeet_speculative(tp); 3875 const TypeOopPtr* speculative = xmeet_speculative(tp);
3781 return make(ptr, (ptr == Constant ? const_oop() : NULL), 3876 return make(ptr, (ptr == Constant ? const_oop() : NULL),
3782 _ary, _klass, _klass_is_exact, offset, instance_id, speculative); 3877 _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth);
3783 } 3878 }
3784 case BotPTR: 3879 case BotPTR:
3785 case NotNull: { 3880 case NotNull: {
3786 int instance_id = meet_instance_id(tp->instance_id()); 3881 int instance_id = meet_instance_id(tp->instance_id());
3787 const TypeOopPtr* speculative = xmeet_speculative(tp); 3882 const TypeOopPtr* speculative = xmeet_speculative(tp);
3788 return TypeOopPtr::make(ptr, offset, instance_id, speculative); 3883 return TypeOopPtr::make(ptr, offset, instance_id, speculative, depth);
3789 } 3884 }
3790 default: ShouldNotReachHere(); 3885 default: ShouldNotReachHere();
3791 } 3886 }
3792 } 3887 }
3793 3888
3807 // else fall through to AnyNull 3902 // else fall through to AnyNull
3808 case AnyNull: { 3903 case AnyNull: {
3809 int instance_id = meet_instance_id(InstanceTop); 3904 int instance_id = meet_instance_id(InstanceTop);
3810 const TypeOopPtr* speculative = _speculative; 3905 const TypeOopPtr* speculative = _speculative;
3811 return make(ptr, (ptr == Constant ? const_oop() : NULL), 3906 return make(ptr, (ptr == Constant ? const_oop() : NULL),
3812 _ary, _klass, _klass_is_exact, offset, instance_id, speculative); 3907 _ary, _klass, _klass_is_exact, offset, instance_id, speculative, _inline_depth);
3813 } 3908 }
3814 default: ShouldNotReachHere(); 3909 default: ShouldNotReachHere();
3815 } 3910 }
3816 } 3911 }
3817 3912
3824 int off = meet_offset(tap->offset()); 3919 int off = meet_offset(tap->offset());
3825 const TypeAry *tary = _ary->meet_speculative(tap->_ary)->is_ary(); 3920 const TypeAry *tary = _ary->meet_speculative(tap->_ary)->is_ary();
3826 PTR ptr = meet_ptr(tap->ptr()); 3921 PTR ptr = meet_ptr(tap->ptr());
3827 int instance_id = meet_instance_id(tap->instance_id()); 3922 int instance_id = meet_instance_id(tap->instance_id());
3828 const TypeOopPtr* speculative = xmeet_speculative(tap); 3923 const TypeOopPtr* speculative = xmeet_speculative(tap);
3924 int depth = meet_inline_depth(tap->inline_depth());
3829 ciKlass* lazy_klass = NULL; 3925 ciKlass* lazy_klass = NULL;
3830 if (tary->_elem->isa_int()) { 3926 if (tary->_elem->isa_int()) {
3831 // Integral array element types have irrelevant lattice relations. 3927 // Integral array element types have irrelevant lattice relations.
3832 // It is the klass that determines array layout, not the element type. 3928 // It is the klass that determines array layout, not the element type.
3833 if (_klass == NULL) 3929 if (_klass == NULL)
3864 if (below_centerline(this->_ptr)) { 3960 if (below_centerline(this->_ptr)) {
3865 xk = this->_klass_is_exact; 3961 xk = this->_klass_is_exact;
3866 } else { 3962 } else {
3867 xk = (tap->_klass_is_exact | this->_klass_is_exact); 3963 xk = (tap->_klass_is_exact | this->_klass_is_exact);
3868 } 3964 }
3869 return make(ptr, const_oop(), tary, lazy_klass, xk, off, instance_id, speculative); 3965 return make(ptr, const_oop(), tary, lazy_klass, xk, off, instance_id, speculative, depth);
3870 case Constant: { 3966 case Constant: {
3871 ciObject* o = const_oop(); 3967 ciObject* o = const_oop();
3872 if( _ptr == Constant ) { 3968 if( _ptr == Constant ) {
3873 if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) { 3969 if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) {
3874 xk = (klass() == tap->klass()); 3970 xk = (klass() == tap->klass());
3883 xk = true; 3979 xk = true;
3884 } else { 3980 } else {
3885 // Only precise for identical arrays 3981 // Only precise for identical arrays
3886 xk = this->_klass_is_exact && (klass() == tap->klass()); 3982 xk = this->_klass_is_exact && (klass() == tap->klass());
3887 } 3983 }
3888 return TypeAryPtr::make(ptr, o, tary, lazy_klass, xk, off, instance_id, speculative); 3984 return TypeAryPtr::make(ptr, o, tary, lazy_klass, xk, off, instance_id, speculative, depth);
3889 } 3985 }
3890 case NotNull: 3986 case NotNull:
3891 case BotPTR: 3987 case BotPTR:
3892 // Compute new klass on demand, do not use tap->_klass 3988 // Compute new klass on demand, do not use tap->_klass
3893 if (above_centerline(this->_ptr)) 3989 if (above_centerline(this->_ptr))
3894 xk = tap->_klass_is_exact; 3990 xk = tap->_klass_is_exact;
3895 else xk = (tap->_klass_is_exact & this->_klass_is_exact) && 3991 else xk = (tap->_klass_is_exact & this->_klass_is_exact) &&
3896 (klass() == tap->klass()); // Only precise for identical arrays 3992 (klass() == tap->klass()); // Only precise for identical arrays
3897 return TypeAryPtr::make(ptr, NULL, tary, lazy_klass, xk, off, instance_id, speculative); 3993 return TypeAryPtr::make(ptr, NULL, tary, lazy_klass, xk, off, instance_id, speculative, depth);
3898 default: ShouldNotReachHere(); 3994 default: ShouldNotReachHere();
3899 } 3995 }
3900 } 3996 }
3901 3997
3902 // All arrays inherit from Object class 3998 // All arrays inherit from Object class
3904 const TypeInstPtr *tp = t->is_instptr(); 4000 const TypeInstPtr *tp = t->is_instptr();
3905 int offset = meet_offset(tp->offset()); 4001 int offset = meet_offset(tp->offset());
3906 PTR ptr = meet_ptr(tp->ptr()); 4002 PTR ptr = meet_ptr(tp->ptr());
3907 int instance_id = meet_instance_id(tp->instance_id()); 4003 int instance_id = meet_instance_id(tp->instance_id());
3908 const TypeOopPtr* speculative = xmeet_speculative(tp); 4004 const TypeOopPtr* speculative = xmeet_speculative(tp);
4005 int depth = meet_inline_depth(tp->inline_depth());
3909 switch (ptr) { 4006 switch (ptr) {
3910 case TopPTR: 4007 case TopPTR:
3911 case AnyNull: // Fall 'down' to dual of object klass 4008 case AnyNull: // Fall 'down' to dual of object klass
3912 // For instances when a subclass meets a superclass we fall 4009 // For instances when a subclass meets a superclass we fall
3913 // below the centerline when the superclass is exact. We need to 4010 // below the centerline when the superclass is exact. We need to
3914 // do the same here. 4011 // do the same here.
3915 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { 4012 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
3916 return TypeAryPtr::make(ptr, _ary, _klass, _klass_is_exact, offset, instance_id, speculative); 4013 return TypeAryPtr::make(ptr, _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth);
3917 } else { 4014 } else {
3918 // cannot subclass, so the meet has to fall badly below the centerline 4015 // cannot subclass, so the meet has to fall badly below the centerline
3919 ptr = NotNull; 4016 ptr = NotNull;
3920 instance_id = InstanceBot; 4017 instance_id = InstanceBot;
3921 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative); 4018 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth);
3922 } 4019 }
3923 case Constant: 4020 case Constant:
3924 case NotNull: 4021 case NotNull:
3925 case BotPTR: // Fall down to object klass 4022 case BotPTR: // Fall down to object klass
3926 // LCA is object_klass, but if we subclass from the top we can do better 4023 // LCA is object_klass, but if we subclass from the top we can do better
3931 // below the centerline when the superclass is exact. We need 4028 // below the centerline when the superclass is exact. We need
3932 // to do the same here. 4029 // to do the same here.
3933 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { 4030 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
3934 // that is, my array type is a subtype of 'tp' klass 4031 // that is, my array type is a subtype of 'tp' klass
3935 return make(ptr, (ptr == Constant ? const_oop() : NULL), 4032 return make(ptr, (ptr == Constant ? const_oop() : NULL),
3936 _ary, _klass, _klass_is_exact, offset, instance_id, speculative); 4033 _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth);
3937 } 4034 }
3938 } 4035 }
3939 // The other case cannot happen, since t cannot be a subtype of an array. 4036 // The other case cannot happen, since t cannot be a subtype of an array.
3940 // The meet falls down to Object class below centerline. 4037 // The meet falls down to Object class below centerline.
3941 if( ptr == Constant ) 4038 if( ptr == Constant )
3942 ptr = NotNull; 4039 ptr = NotNull;
3943 instance_id = InstanceBot; 4040 instance_id = InstanceBot;
3944 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative); 4041 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth);
3945 default: typerr(t); 4042 default: typerr(t);
3946 } 4043 }
3947 } 4044 }
3948 } 4045 }
3949 return this; // Lint noise 4046 return this; // Lint noise
3950 } 4047 }
3951 4048
3952 //------------------------------xdual------------------------------------------ 4049 //------------------------------xdual------------------------------------------
3953 // Dual: compute field-by-field dual 4050 // Dual: compute field-by-field dual
3954 const Type *TypeAryPtr::xdual() const { 4051 const Type *TypeAryPtr::xdual() const {
3955 return new TypeAryPtr(dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id(), is_autobox_cache(), dual_speculative()); 4052 return new TypeAryPtr(dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id(), is_autobox_cache(), dual_speculative(), dual_inline_depth());
3956 } 4053 }
3957 4054
3958 //----------------------interface_vs_oop--------------------------------------- 4055 //----------------------interface_vs_oop---------------------------------------
3959 #ifdef ASSERT 4056 #ifdef ASSERT
3960 bool TypeAryPtr::interface_vs_oop(const Type *t) const { 4057 bool TypeAryPtr::interface_vs_oop(const Type *t) const {
4003 if (_instance_id == InstanceTop) 4100 if (_instance_id == InstanceTop)
4004 st->print(",iid=top"); 4101 st->print(",iid=top");
4005 else if (_instance_id != InstanceBot) 4102 else if (_instance_id != InstanceBot)
4006 st->print(",iid=%d",_instance_id); 4103 st->print(",iid=%d",_instance_id);
4007 4104
4105 dump_inline_depth(st);
4008 dump_speculative(st); 4106 dump_speculative(st);
4009 } 4107 }
4010 #endif 4108 #endif
4011 4109
4012 bool TypeAryPtr::empty(void) const { 4110 bool TypeAryPtr::empty(void) const {
4014 return TypeOopPtr::empty(); 4112 return TypeOopPtr::empty();
4015 } 4113 }
4016 4114
4017 //------------------------------add_offset------------------------------------- 4115 //------------------------------add_offset-------------------------------------
4018 const TypePtr *TypeAryPtr::add_offset(intptr_t offset) const { 4116 const TypePtr *TypeAryPtr::add_offset(intptr_t offset) const {
4019 return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id, add_offset_speculative(offset)); 4117 return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id, add_offset_speculative(offset), _inline_depth);
4020 } 4118 }
4021 4119
4022 const Type *TypeAryPtr::remove_speculative() const { 4120 const Type *TypeAryPtr::remove_speculative() const {
4023 return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, NULL); 4121 if (_speculative == NULL) {
4122 return this;
4123 }
4124 assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth");
4125 return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, NULL, _inline_depth);
4126 }
4127
4128 const TypeOopPtr *TypeAryPtr::with_inline_depth(int depth) const {
4129 if (!UseInlineDepthForSpeculativeTypes) {
4130 return this;
4131 }
4132 return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, _speculative, depth);
4024 } 4133 }
4025 4134
4026 //============================================================================= 4135 //=============================================================================
4027 4136
4028 //------------------------------hash------------------------------------------- 4137 //------------------------------hash-------------------------------------------