Mercurial > hg > graal-jvmci-8
comparison src/share/vm/opto/type.cpp @ 17731:62825ea7e51f
8031754: Type speculation should favor profile data from outermost inlined method
Summary: favor profile data coming from outer most method
Reviewed-by: kvn, twisti
author | roland |
---|---|
date | Fri, 14 Mar 2014 17:15:32 +0100 |
parents | 085b304a1cc5 |
children | 606acabe7b5c |
comparison
equal
deleted
inserted
replaced
17728:b8413a9cbb84 | 17731:62825ea7e51f |
---|---|
2455 //============================================================================= | 2455 //============================================================================= |
2456 // Convenience common pre-built type. | 2456 // Convenience common pre-built type. |
2457 const TypeOopPtr *TypeOopPtr::BOTTOM; | 2457 const TypeOopPtr *TypeOopPtr::BOTTOM; |
2458 | 2458 |
2459 //------------------------------TypeOopPtr------------------------------------- | 2459 //------------------------------TypeOopPtr------------------------------------- |
2460 TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative) | 2460 TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth) |
2461 : TypePtr(t, ptr, offset), | 2461 : TypePtr(t, ptr, offset), |
2462 _const_oop(o), _klass(k), | 2462 _const_oop(o), _klass(k), |
2463 _klass_is_exact(xk), | 2463 _klass_is_exact(xk), |
2464 _is_ptr_to_narrowoop(false), | 2464 _is_ptr_to_narrowoop(false), |
2465 _is_ptr_to_narrowklass(false), | 2465 _is_ptr_to_narrowklass(false), |
2466 _is_ptr_to_boxed_value(false), | 2466 _is_ptr_to_boxed_value(false), |
2467 _instance_id(instance_id), | 2467 _instance_id(instance_id), |
2468 _speculative(speculative) { | 2468 _speculative(speculative), |
2469 _inline_depth(inline_depth){ | |
2469 if (Compile::current()->eliminate_boxing() && (t == InstPtr) && | 2470 if (Compile::current()->eliminate_boxing() && (t == InstPtr) && |
2470 (offset > 0) && xk && (k != 0) && k->is_instance_klass()) { | 2471 (offset > 0) && xk && (k != 0) && k->is_instance_klass()) { |
2471 _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset); | 2472 _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset); |
2472 } | 2473 } |
2473 #ifdef _LP64 | 2474 #ifdef _LP64 |
2530 #endif | 2531 #endif |
2531 } | 2532 } |
2532 | 2533 |
2533 //------------------------------make------------------------------------------- | 2534 //------------------------------make------------------------------------------- |
2534 const TypeOopPtr *TypeOopPtr::make(PTR ptr, | 2535 const TypeOopPtr *TypeOopPtr::make(PTR ptr, |
2535 int offset, int instance_id, const TypeOopPtr* speculative) { | 2536 int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth) { |
2536 assert(ptr != Constant, "no constant generic pointers"); | 2537 assert(ptr != Constant, "no constant generic pointers"); |
2537 ciKlass* k = Compile::current()->env()->Object_klass(); | 2538 ciKlass* k = Compile::current()->env()->Object_klass(); |
2538 bool xk = false; | 2539 bool xk = false; |
2539 ciObject* o = NULL; | 2540 ciObject* o = NULL; |
2540 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative))->hashcons(); | 2541 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative, inline_depth))->hashcons(); |
2541 } | 2542 } |
2542 | 2543 |
2543 | 2544 |
2544 //------------------------------cast_to_ptr_type------------------------------- | 2545 //------------------------------cast_to_ptr_type------------------------------- |
2545 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const { | 2546 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const { |
2546 assert(_base == OopPtr, "subclass must override cast_to_ptr_type"); | 2547 assert(_base == OopPtr, "subclass must override cast_to_ptr_type"); |
2547 if( ptr == _ptr ) return this; | 2548 if( ptr == _ptr ) return this; |
2548 return make(ptr, _offset, _instance_id, _speculative); | 2549 return make(ptr, _offset, _instance_id, _speculative, _inline_depth); |
2549 } | 2550 } |
2550 | 2551 |
2551 //-----------------------------cast_to_instance_id---------------------------- | 2552 //-----------------------------cast_to_instance_id---------------------------- |
2552 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const { | 2553 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const { |
2553 // There are no instances of a general oop. | 2554 // There are no instances of a general oop. |
2640 // else fall through: | 2641 // else fall through: |
2641 case TopPTR: | 2642 case TopPTR: |
2642 case AnyNull: { | 2643 case AnyNull: { |
2643 int instance_id = meet_instance_id(InstanceTop); | 2644 int instance_id = meet_instance_id(InstanceTop); |
2644 const TypeOopPtr* speculative = _speculative; | 2645 const TypeOopPtr* speculative = _speculative; |
2645 return make(ptr, offset, instance_id, speculative); | 2646 return make(ptr, offset, instance_id, speculative, _inline_depth); |
2646 } | 2647 } |
2647 case BotPTR: | 2648 case BotPTR: |
2648 case NotNull: | 2649 case NotNull: |
2649 return TypePtr::make(AnyPtr, ptr, offset); | 2650 return TypePtr::make(AnyPtr, ptr, offset); |
2650 default: typerr(t); | 2651 default: typerr(t); |
2653 | 2654 |
2654 case OopPtr: { // Meeting to other OopPtrs | 2655 case OopPtr: { // Meeting to other OopPtrs |
2655 const TypeOopPtr *tp = t->is_oopptr(); | 2656 const TypeOopPtr *tp = t->is_oopptr(); |
2656 int instance_id = meet_instance_id(tp->instance_id()); | 2657 int instance_id = meet_instance_id(tp->instance_id()); |
2657 const TypeOopPtr* speculative = xmeet_speculative(tp); | 2658 const TypeOopPtr* speculative = xmeet_speculative(tp); |
2658 return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative); | 2659 int depth = meet_inline_depth(tp->inline_depth()); |
2660 return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative, depth); | |
2659 } | 2661 } |
2660 | 2662 |
2661 case InstPtr: // For these, flip the call around to cut down | 2663 case InstPtr: // For these, flip the call around to cut down |
2662 case AryPtr: | 2664 case AryPtr: |
2663 return t->xmeet(this); // Call in reverse direction | 2665 return t->xmeet(this); // Call in reverse direction |
2670 //------------------------------xdual------------------------------------------ | 2672 //------------------------------xdual------------------------------------------ |
2671 // Dual of a pure heap pointer. No relevant klass or oop information. | 2673 // Dual of a pure heap pointer. No relevant klass or oop information. |
2672 const Type *TypeOopPtr::xdual() const { | 2674 const Type *TypeOopPtr::xdual() const { |
2673 assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here"); | 2675 assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here"); |
2674 assert(const_oop() == NULL, "no constants here"); | 2676 assert(const_oop() == NULL, "no constants here"); |
2675 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative()); | 2677 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth()); |
2676 } | 2678 } |
2677 | 2679 |
2678 //--------------------------make_from_klass_common----------------------------- | 2680 //--------------------------make_from_klass_common----------------------------- |
2679 // Computes the element-type given a klass. | 2681 // Computes the element-type given a klass. |
2680 const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) { | 2682 const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) { |
2761 if (require_constant) { | 2763 if (require_constant) { |
2762 if (!o->can_be_constant()) return NULL; | 2764 if (!o->can_be_constant()) return NULL; |
2763 } else if (!o->should_be_constant()) { | 2765 } else if (!o->should_be_constant()) { |
2764 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); | 2766 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); |
2765 } | 2767 } |
2766 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, NULL, is_autobox_cache); | 2768 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, NULL, InlineDepthBottom, is_autobox_cache); |
2767 return arr; | 2769 return arr; |
2768 } else if (klass->is_type_array_klass()) { | 2770 } else if (klass->is_type_array_klass()) { |
2769 // Element is an typeArray | 2771 // Element is an typeArray |
2770 const Type* etype = | 2772 const Type* etype = |
2771 (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type()); | 2773 (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type()); |
2850 // Structural equality check for Type representations | 2852 // Structural equality check for Type representations |
2851 bool TypeOopPtr::eq( const Type *t ) const { | 2853 bool TypeOopPtr::eq( const Type *t ) const { |
2852 const TypeOopPtr *a = (const TypeOopPtr*)t; | 2854 const TypeOopPtr *a = (const TypeOopPtr*)t; |
2853 if (_klass_is_exact != a->_klass_is_exact || | 2855 if (_klass_is_exact != a->_klass_is_exact || |
2854 _instance_id != a->_instance_id || | 2856 _instance_id != a->_instance_id || |
2855 !eq_speculative(a)) return false; | 2857 !eq_speculative(a) || |
2858 _inline_depth != a->_inline_depth) return false; | |
2856 ciObject* one = const_oop(); | 2859 ciObject* one = const_oop(); |
2857 ciObject* two = a->const_oop(); | 2860 ciObject* two = a->const_oop(); |
2858 if (one == NULL || two == NULL) { | 2861 if (one == NULL || two == NULL) { |
2859 return (one == two) && TypePtr::eq(t); | 2862 return (one == two) && TypePtr::eq(t); |
2860 } else { | 2863 } else { |
2868 return | 2871 return |
2869 (const_oop() ? const_oop()->hash() : 0) + | 2872 (const_oop() ? const_oop()->hash() : 0) + |
2870 _klass_is_exact + | 2873 _klass_is_exact + |
2871 _instance_id + | 2874 _instance_id + |
2872 hash_speculative() + | 2875 hash_speculative() + |
2876 _inline_depth + | |
2873 TypePtr::hash(); | 2877 TypePtr::hash(); |
2874 } | 2878 } |
2875 | 2879 |
2876 //------------------------------dump2------------------------------------------ | 2880 //------------------------------dump2------------------------------------------ |
2877 #ifndef PRODUCT | 2881 #ifndef PRODUCT |
2888 if (_instance_id == InstanceTop) | 2892 if (_instance_id == InstanceTop) |
2889 st->print(",iid=top"); | 2893 st->print(",iid=top"); |
2890 else if (_instance_id != InstanceBot) | 2894 else if (_instance_id != InstanceBot) |
2891 st->print(",iid=%d",_instance_id); | 2895 st->print(",iid=%d",_instance_id); |
2892 | 2896 |
2897 dump_inline_depth(st); | |
2893 dump_speculative(st); | 2898 dump_speculative(st); |
2894 } | 2899 } |
2895 | 2900 |
2896 /** | 2901 /** |
2897 *dump the speculative part of the type | 2902 *dump the speculative part of the type |
2901 st->print(" (speculative="); | 2906 st->print(" (speculative="); |
2902 _speculative->dump_on(st); | 2907 _speculative->dump_on(st); |
2903 st->print(")"); | 2908 st->print(")"); |
2904 } | 2909 } |
2905 } | 2910 } |
2911 | |
2912 void TypeOopPtr::dump_inline_depth(outputStream *st) const { | |
2913 if (_inline_depth != InlineDepthBottom) { | |
2914 if (_inline_depth == InlineDepthTop) { | |
2915 st->print(" (inline_depth=InlineDepthTop)"); | |
2916 } else { | |
2917 st->print(" (inline_depth=%d)", _inline_depth); | |
2918 } | |
2919 } | |
2920 } | |
2906 #endif | 2921 #endif |
2907 | 2922 |
2908 //------------------------------singleton-------------------------------------- | 2923 //------------------------------singleton-------------------------------------- |
2909 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | 2924 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple |
2910 // constants | 2925 // constants |
2914 return (_offset == 0) && !below_centerline(_ptr); | 2929 return (_offset == 0) && !below_centerline(_ptr); |
2915 } | 2930 } |
2916 | 2931 |
2917 //------------------------------add_offset------------------------------------- | 2932 //------------------------------add_offset------------------------------------- |
2918 const TypePtr *TypeOopPtr::add_offset(intptr_t offset) const { | 2933 const TypePtr *TypeOopPtr::add_offset(intptr_t offset) const { |
2919 return make(_ptr, xadd_offset(offset), _instance_id, add_offset_speculative(offset)); | 2934 return make(_ptr, xadd_offset(offset), _instance_id, add_offset_speculative(offset), _inline_depth); |
2920 } | 2935 } |
2921 | 2936 |
2922 /** | 2937 /** |
2923 * Return same type without a speculative part | 2938 * Return same type without a speculative part |
2924 */ | 2939 */ |
2925 const Type* TypeOopPtr::remove_speculative() const { | 2940 const Type* TypeOopPtr::remove_speculative() const { |
2926 if (_speculative == NULL) { | 2941 if (_speculative == NULL) { |
2927 return this; | 2942 return this; |
2928 } | 2943 } |
2929 return make(_ptr, _offset, _instance_id, NULL); | 2944 assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth"); |
2945 return make(_ptr, _offset, _instance_id, NULL, _inline_depth); | |
2946 } | |
2947 | |
2948 /** | |
2949 * Return same type but with a different inline depth (used for speculation) | |
2950 * | |
2951 * @param depth depth to meet with | |
2952 */ | |
2953 const TypeOopPtr* TypeOopPtr::with_inline_depth(int depth) const { | |
2954 if (!UseInlineDepthForSpeculativeTypes) { | |
2955 return this; | |
2956 } | |
2957 return make(_ptr, _offset, _instance_id, _speculative, depth); | |
2958 } | |
2959 | |
2960 /** | |
2961 * Check whether new profiling would improve speculative type | |
2962 * | |
2963 * @param exact_kls class from profiling | |
2964 * @param inline_depth inlining depth of profile point | |
2965 * | |
2966 * @return true if type profile is valuable | |
2967 */ | |
2968 bool TypeOopPtr::would_improve_type(ciKlass* exact_kls, int inline_depth) const { | |
2969 // no way to improve an already exact type | |
2970 if (klass_is_exact()) { | |
2971 return false; | |
2972 } | |
2973 // no profiling? | |
2974 if (exact_kls == NULL) { | |
2975 return false; | |
2976 } | |
2977 // no speculative type or non exact speculative type? | |
2978 if (speculative_type() == NULL) { | |
2979 return true; | |
2980 } | |
2981 // If the node already has an exact speculative type keep it, | |
2982 // unless it was provided by profiling that is at a deeper | |
2983 // inlining level. Profiling at a higher inlining depth is | |
2984 // expected to be less accurate. | |
2985 if (_speculative->inline_depth() == InlineDepthBottom) { | |
2986 return false; | |
2987 } | |
2988 assert(_speculative->inline_depth() != InlineDepthTop, "can't do the comparison"); | |
2989 return inline_depth < _speculative->inline_depth(); | |
2930 } | 2990 } |
2931 | 2991 |
2932 //------------------------------meet_instance_id-------------------------------- | 2992 //------------------------------meet_instance_id-------------------------------- |
2933 int TypeOopPtr::meet_instance_id( int instance_id ) const { | 2993 int TypeOopPtr::meet_instance_id( int instance_id ) const { |
2934 // Either is 'TOP' instance? Return the other instance! | 2994 // Either is 'TOP' instance? Return the other instance! |
3027 } | 3087 } |
3028 | 3088 |
3029 return _speculative->hash(); | 3089 return _speculative->hash(); |
3030 } | 3090 } |
3031 | 3091 |
3092 /** | |
3093 * dual of the inline depth for this type (used for speculation) | |
3094 */ | |
3095 int TypeOopPtr::dual_inline_depth() const { | |
3096 return -inline_depth(); | |
3097 } | |
3098 | |
3099 /** | |
3100 * meet of 2 inline depth (used for speculation) | |
3101 * | |
3102 * @param depth depth to meet with | |
3103 */ | |
3104 int TypeOopPtr::meet_inline_depth(int depth) const { | |
3105 return MAX2(inline_depth(), depth); | |
3106 } | |
3032 | 3107 |
3033 //============================================================================= | 3108 //============================================================================= |
3034 // Convenience common pre-built types. | 3109 // Convenience common pre-built types. |
3035 const TypeInstPtr *TypeInstPtr::NOTNULL; | 3110 const TypeInstPtr *TypeInstPtr::NOTNULL; |
3036 const TypeInstPtr *TypeInstPtr::BOTTOM; | 3111 const TypeInstPtr *TypeInstPtr::BOTTOM; |
3037 const TypeInstPtr *TypeInstPtr::MIRROR; | 3112 const TypeInstPtr *TypeInstPtr::MIRROR; |
3038 const TypeInstPtr *TypeInstPtr::MARK; | 3113 const TypeInstPtr *TypeInstPtr::MARK; |
3039 const TypeInstPtr *TypeInstPtr::KLASS; | 3114 const TypeInstPtr *TypeInstPtr::KLASS; |
3040 | 3115 |
3041 //------------------------------TypeInstPtr------------------------------------- | 3116 //------------------------------TypeInstPtr------------------------------------- |
3042 TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id, const TypeOopPtr* speculative) | 3117 TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id, const TypeOopPtr* speculative, int inline_depth) |
3043 : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id, speculative), _name(k->name()) { | 3118 : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id, speculative, inline_depth), _name(k->name()) { |
3044 assert(k != NULL && | 3119 assert(k != NULL && |
3045 (k->is_loaded() || o == NULL), | 3120 (k->is_loaded() || o == NULL), |
3046 "cannot have constants with non-loaded klass"); | 3121 "cannot have constants with non-loaded klass"); |
3047 }; | 3122 }; |
3048 | 3123 |
3051 ciKlass* k, | 3126 ciKlass* k, |
3052 bool xk, | 3127 bool xk, |
3053 ciObject* o, | 3128 ciObject* o, |
3054 int offset, | 3129 int offset, |
3055 int instance_id, | 3130 int instance_id, |
3056 const TypeOopPtr* speculative) { | 3131 const TypeOopPtr* speculative, |
3132 int inline_depth) { | |
3057 assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance"); | 3133 assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance"); |
3058 // Either const_oop() is NULL or else ptr is Constant | 3134 // Either const_oop() is NULL or else ptr is Constant |
3059 assert( (!o && ptr != Constant) || (o && ptr == Constant), | 3135 assert( (!o && ptr != Constant) || (o && ptr == Constant), |
3060 "constant pointers must have a value supplied" ); | 3136 "constant pointers must have a value supplied" ); |
3061 // Ptr is never Null | 3137 // Ptr is never Null |
3072 if (xk && ik->is_interface()) xk = false; // no exact interface | 3148 if (xk && ik->is_interface()) xk = false; // no exact interface |
3073 } | 3149 } |
3074 | 3150 |
3075 // Now hash this baby | 3151 // Now hash this baby |
3076 TypeInstPtr *result = | 3152 TypeInstPtr *result = |
3077 (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id, speculative))->hashcons(); | 3153 (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id, speculative, inline_depth))->hashcons(); |
3078 | 3154 |
3079 return result; | 3155 return result; |
3080 } | 3156 } |
3081 | 3157 |
3082 /** | 3158 /** |
3105 //------------------------------cast_to_ptr_type------------------------------- | 3181 //------------------------------cast_to_ptr_type------------------------------- |
3106 const Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const { | 3182 const Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const { |
3107 if( ptr == _ptr ) return this; | 3183 if( ptr == _ptr ) return this; |
3108 // Reconstruct _sig info here since not a problem with later lazy | 3184 // Reconstruct _sig info here since not a problem with later lazy |
3109 // construction, _sig will show up on demand. | 3185 // construction, _sig will show up on demand. |
3110 return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative); | 3186 return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, _inline_depth); |
3111 } | 3187 } |
3112 | 3188 |
3113 | 3189 |
3114 //-----------------------------cast_to_exactness------------------------------- | 3190 //-----------------------------cast_to_exactness------------------------------- |
3115 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const { | 3191 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const { |
3117 if (!UseExactTypes) return this; | 3193 if (!UseExactTypes) return this; |
3118 if (!_klass->is_loaded()) return this; | 3194 if (!_klass->is_loaded()) return this; |
3119 ciInstanceKlass* ik = _klass->as_instance_klass(); | 3195 ciInstanceKlass* ik = _klass->as_instance_klass(); |
3120 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk | 3196 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk |
3121 if( ik->is_interface() ) return this; // cannot set xk | 3197 if( ik->is_interface() ) return this; // cannot set xk |
3122 return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative); | 3198 return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative, _inline_depth); |
3123 } | 3199 } |
3124 | 3200 |
3125 //-----------------------------cast_to_instance_id---------------------------- | 3201 //-----------------------------cast_to_instance_id---------------------------- |
3126 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const { | 3202 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const { |
3127 if( instance_id == _instance_id ) return this; | 3203 if( instance_id == _instance_id ) return this; |
3128 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); |
3129 } | 3205 } |
3130 | 3206 |
3131 //------------------------------xmeet_unloaded--------------------------------- | 3207 //------------------------------xmeet_unloaded--------------------------------- |
3132 // Compute the MEET of two InstPtrs when at least one is unloaded. | 3208 // Compute the MEET of two InstPtrs when at least one is unloaded. |
3133 // Assume classes are different since called after check for same name/class-loader | 3209 // Assume classes are different since called after check for same name/class-loader |
3134 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const { | 3210 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const { |
3135 int off = meet_offset(tinst->offset()); | 3211 int off = meet_offset(tinst->offset()); |
3136 PTR ptr = meet_ptr(tinst->ptr()); | 3212 PTR ptr = meet_ptr(tinst->ptr()); |
3137 int instance_id = meet_instance_id(tinst->instance_id()); | 3213 int instance_id = meet_instance_id(tinst->instance_id()); |
3138 const TypeOopPtr* speculative = xmeet_speculative(tinst); | 3214 const TypeOopPtr* speculative = xmeet_speculative(tinst); |
3215 int depth = meet_inline_depth(tinst->inline_depth()); | |
3139 | 3216 |
3140 const TypeInstPtr *loaded = is_loaded() ? this : tinst; | 3217 const TypeInstPtr *loaded = is_loaded() ? this : tinst; |
3141 const TypeInstPtr *unloaded = is_loaded() ? tinst : this; | 3218 const TypeInstPtr *unloaded = is_loaded() ? tinst : this; |
3142 if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) { | 3219 if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) { |
3143 // | 3220 // |
3154 // BOTTOM | ........................Object-BOTTOM ..................| | 3231 // BOTTOM | ........................Object-BOTTOM ..................| |
3155 // | 3232 // |
3156 assert(loaded->ptr() != TypePtr::Null, "insanity check"); | 3233 assert(loaded->ptr() != TypePtr::Null, "insanity check"); |
3157 // | 3234 // |
3158 if( loaded->ptr() == TypePtr::TopPTR ) { return unloaded; } | 3235 if( loaded->ptr() == TypePtr::TopPTR ) { return unloaded; } |
3159 else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make(ptr, unloaded->klass(), false, NULL, off, instance_id, speculative); } | 3236 else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make(ptr, unloaded->klass(), false, NULL, off, instance_id, speculative, depth); } |
3160 else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } | 3237 else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } |
3161 else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) { | 3238 else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) { |
3162 if (unloaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } | 3239 if (unloaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } |
3163 else { return TypeInstPtr::NOTNULL; } | 3240 else { return TypeInstPtr::NOTNULL; } |
3164 } | 3241 } |
3211 const TypeAryPtr *tp = t->is_aryptr(); | 3288 const TypeAryPtr *tp = t->is_aryptr(); |
3212 int offset = meet_offset(tp->offset()); | 3289 int offset = meet_offset(tp->offset()); |
3213 PTR ptr = meet_ptr(tp->ptr()); | 3290 PTR ptr = meet_ptr(tp->ptr()); |
3214 int instance_id = meet_instance_id(tp->instance_id()); | 3291 int instance_id = meet_instance_id(tp->instance_id()); |
3215 const TypeOopPtr* speculative = xmeet_speculative(tp); | 3292 const TypeOopPtr* speculative = xmeet_speculative(tp); |
3293 int depth = meet_inline_depth(tp->inline_depth()); | |
3216 switch (ptr) { | 3294 switch (ptr) { |
3217 case TopPTR: | 3295 case TopPTR: |
3218 case AnyNull: // Fall 'down' to dual of object klass | 3296 case AnyNull: // Fall 'down' to dual of object klass |
3219 // For instances when a subclass meets a superclass we fall | 3297 // For instances when a subclass meets a superclass we fall |
3220 // below the centerline when the superclass is exact. We need to | 3298 // below the centerline when the superclass is exact. We need to |
3221 // do the same here. | 3299 // do the same here. |
3222 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { | 3300 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { |
3223 return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative); | 3301 return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative, depth); |
3224 } else { | 3302 } else { |
3225 // cannot subclass, so the meet has to fall badly below the centerline | 3303 // cannot subclass, so the meet has to fall badly below the centerline |
3226 ptr = NotNull; | 3304 ptr = NotNull; |
3227 instance_id = InstanceBot; | 3305 instance_id = InstanceBot; |
3228 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative); | 3306 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth); |
3229 } | 3307 } |
3230 case Constant: | 3308 case Constant: |
3231 case NotNull: | 3309 case NotNull: |
3232 case BotPTR: // Fall down to object klass | 3310 case BotPTR: // Fall down to object klass |
3233 // LCA is object_klass, but if we subclass from the top we can do better | 3311 // LCA is object_klass, but if we subclass from the top we can do better |
3238 // below the centerline when the superclass is exact. We need | 3316 // below the centerline when the superclass is exact. We need |
3239 // to do the same here. | 3317 // to do the same here. |
3240 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { | 3318 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { |
3241 // that is, tp's array type is a subtype of my klass | 3319 // that is, tp's array type is a subtype of my klass |
3242 return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL), | 3320 return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL), |
3243 tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative); | 3321 tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative, depth); |
3244 } | 3322 } |
3245 } | 3323 } |
3246 // The other case cannot happen, since I cannot be a subtype of an array. | 3324 // The other case cannot happen, since I cannot be a subtype of an array. |
3247 // The meet falls down to Object class below centerline. | 3325 // The meet falls down to Object class below centerline. |
3248 if( ptr == Constant ) | 3326 if( ptr == Constant ) |
3249 ptr = NotNull; | 3327 ptr = NotNull; |
3250 instance_id = InstanceBot; | 3328 instance_id = InstanceBot; |
3251 return make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative); | 3329 return make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth); |
3252 default: typerr(t); | 3330 default: typerr(t); |
3253 } | 3331 } |
3254 } | 3332 } |
3255 | 3333 |
3256 case OopPtr: { // Meeting to OopPtrs | 3334 case OopPtr: { // Meeting to OopPtrs |
3261 switch (tp->ptr()) { | 3339 switch (tp->ptr()) { |
3262 case TopPTR: | 3340 case TopPTR: |
3263 case AnyNull: { | 3341 case AnyNull: { |
3264 int instance_id = meet_instance_id(InstanceTop); | 3342 int instance_id = meet_instance_id(InstanceTop); |
3265 const TypeOopPtr* speculative = xmeet_speculative(tp); | 3343 const TypeOopPtr* speculative = xmeet_speculative(tp); |
3344 int depth = meet_inline_depth(tp->inline_depth()); | |
3266 return make(ptr, klass(), klass_is_exact(), | 3345 return make(ptr, klass(), klass_is_exact(), |
3267 (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative); | 3346 (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative, depth); |
3268 } | 3347 } |
3269 case NotNull: | 3348 case NotNull: |
3270 case BotPTR: { | 3349 case BotPTR: { |
3271 int instance_id = meet_instance_id(tp->instance_id()); | 3350 int instance_id = meet_instance_id(tp->instance_id()); |
3272 const TypeOopPtr* speculative = xmeet_speculative(tp); | 3351 const TypeOopPtr* speculative = xmeet_speculative(tp); |
3273 return TypeOopPtr::make(ptr, offset, instance_id, speculative); | 3352 int depth = meet_inline_depth(tp->inline_depth()); |
3353 return TypeOopPtr::make(ptr, offset, instance_id, speculative, depth); | |
3274 } | 3354 } |
3275 default: typerr(t); | 3355 default: typerr(t); |
3276 } | 3356 } |
3277 } | 3357 } |
3278 | 3358 |
3288 case TopPTR: | 3368 case TopPTR: |
3289 case AnyNull: { | 3369 case AnyNull: { |
3290 int instance_id = meet_instance_id(InstanceTop); | 3370 int instance_id = meet_instance_id(InstanceTop); |
3291 const TypeOopPtr* speculative = _speculative; | 3371 const TypeOopPtr* speculative = _speculative; |
3292 return make(ptr, klass(), klass_is_exact(), | 3372 return make(ptr, klass(), klass_is_exact(), |
3293 (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative); | 3373 (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative, _inline_depth); |
3294 } | 3374 } |
3295 case NotNull: | 3375 case NotNull: |
3296 case BotPTR: | 3376 case BotPTR: |
3297 return TypePtr::make(AnyPtr, ptr, offset); | 3377 return TypePtr::make(AnyPtr, ptr, offset); |
3298 default: typerr(t); | 3378 default: typerr(t); |
3320 const TypeInstPtr *tinst = t->is_instptr(); | 3400 const TypeInstPtr *tinst = t->is_instptr(); |
3321 int off = meet_offset( tinst->offset() ); | 3401 int off = meet_offset( tinst->offset() ); |
3322 PTR ptr = meet_ptr( tinst->ptr() ); | 3402 PTR ptr = meet_ptr( tinst->ptr() ); |
3323 int instance_id = meet_instance_id(tinst->instance_id()); | 3403 int instance_id = meet_instance_id(tinst->instance_id()); |
3324 const TypeOopPtr* speculative = xmeet_speculative(tinst); | 3404 const TypeOopPtr* speculative = xmeet_speculative(tinst); |
3405 int depth = meet_inline_depth(tinst->inline_depth()); | |
3325 | 3406 |
3326 // Check for easy case; klasses are equal (and perhaps not loaded!) | 3407 // Check for easy case; klasses are equal (and perhaps not loaded!) |
3327 // If we have constants, then we created oops so classes are loaded | 3408 // If we have constants, then we created oops so classes are loaded |
3328 // and we can handle the constants further down. This case handles | 3409 // and we can handle the constants further down. This case handles |
3329 // both-not-loaded or both-loaded classes | 3410 // both-not-loaded or both-loaded classes |
3330 if (ptr != Constant && klass()->equals(tinst->klass()) && klass_is_exact() == tinst->klass_is_exact()) { | 3411 if (ptr != Constant && klass()->equals(tinst->klass()) && klass_is_exact() == tinst->klass_is_exact()) { |
3331 return make(ptr, klass(), klass_is_exact(), NULL, off, instance_id, speculative); | 3412 return make(ptr, klass(), klass_is_exact(), NULL, off, instance_id, speculative, depth); |
3332 } | 3413 } |
3333 | 3414 |
3334 // Classes require inspection in the Java klass hierarchy. Must be loaded. | 3415 // Classes require inspection in the Java klass hierarchy. Must be loaded. |
3335 ciKlass* tinst_klass = tinst->klass(); | 3416 ciKlass* tinst_klass = tinst->klass(); |
3336 ciKlass* this_klass = this->klass(); | 3417 ciKlass* this_klass = this->klass(); |
3390 ciObject* o = NULL; // the Constant value, if any | 3471 ciObject* o = NULL; // the Constant value, if any |
3391 if (ptr == Constant) { | 3472 if (ptr == Constant) { |
3392 // Find out which constant. | 3473 // Find out which constant. |
3393 o = (this_klass == klass()) ? const_oop() : tinst->const_oop(); | 3474 o = (this_klass == klass()) ? const_oop() : tinst->const_oop(); |
3394 } | 3475 } |
3395 return make(ptr, k, xk, o, off, instance_id, speculative); | 3476 return make(ptr, k, xk, o, off, instance_id, speculative, depth); |
3396 } | 3477 } |
3397 | 3478 |
3398 // Either oop vs oop or interface vs interface or interface vs Object | 3479 // Either oop vs oop or interface vs interface or interface vs Object |
3399 | 3480 |
3400 // !!! Here's how the symmetry requirement breaks down into invariants: | 3481 // !!! Here's how the symmetry requirement breaks down into invariants: |
3467 else if (above_centerline(tinst ->_ptr)) | 3548 else if (above_centerline(tinst ->_ptr)) |
3468 o = this_oop; | 3549 o = this_oop; |
3469 else | 3550 else |
3470 ptr = NotNull; | 3551 ptr = NotNull; |
3471 } | 3552 } |
3472 return make(ptr, this_klass, this_xk, o, off, instance_id, speculative); | 3553 return make(ptr, this_klass, this_xk, o, off, instance_id, speculative, depth); |
3473 } // Else classes are not equal | 3554 } // Else classes are not equal |
3474 | 3555 |
3475 // Since klasses are different, we require a LCA in the Java | 3556 // Since klasses are different, we require a LCA in the Java |
3476 // class hierarchy - which means we have to fall to at least NotNull. | 3557 // class hierarchy - which means we have to fall to at least NotNull. |
3477 if( ptr == TopPTR || ptr == AnyNull || ptr == Constant ) | 3558 if( ptr == TopPTR || ptr == AnyNull || ptr == Constant ) |
3478 ptr = NotNull; | 3559 ptr = NotNull; |
3479 instance_id = InstanceBot; | 3560 instance_id = InstanceBot; |
3480 | 3561 |
3481 // Now we find the LCA of Java classes | 3562 // Now we find the LCA of Java classes |
3482 ciKlass* k = this_klass->least_common_ancestor(tinst_klass); | 3563 ciKlass* k = this_klass->least_common_ancestor(tinst_klass); |
3483 return make(ptr, k, false, NULL, off, instance_id, speculative); | 3564 return make(ptr, k, false, NULL, off, instance_id, speculative, depth); |
3484 } // End of case InstPtr | 3565 } // End of case InstPtr |
3485 | 3566 |
3486 } // End of switch | 3567 } // End of switch |
3487 return this; // Return the double constant | 3568 return this; // Return the double constant |
3488 } | 3569 } |
3502 | 3583 |
3503 //------------------------------xdual------------------------------------------ | 3584 //------------------------------xdual------------------------------------------ |
3504 // Dual: do NOT dual on klasses. This means I do NOT understand the Java | 3585 // Dual: do NOT dual on klasses. This means I do NOT understand the Java |
3505 // inheritance mechanism. | 3586 // inheritance mechanism. |
3506 const Type *TypeInstPtr::xdual() const { | 3587 const Type *TypeInstPtr::xdual() const { |
3507 return new TypeInstPtr(dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative()); | 3588 return new TypeInstPtr(dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth()); |
3508 } | 3589 } |
3509 | 3590 |
3510 //------------------------------eq--------------------------------------------- | 3591 //------------------------------eq--------------------------------------------- |
3511 // Structural equality check for Type representations | 3592 // Structural equality check for Type representations |
3512 bool TypeInstPtr::eq( const Type *t ) const { | 3593 bool TypeInstPtr::eq( const Type *t ) const { |
3559 if (_instance_id == InstanceTop) | 3640 if (_instance_id == InstanceTop) |
3560 st->print(",iid=top"); | 3641 st->print(",iid=top"); |
3561 else if (_instance_id != InstanceBot) | 3642 else if (_instance_id != InstanceBot) |
3562 st->print(",iid=%d",_instance_id); | 3643 st->print(",iid=%d",_instance_id); |
3563 | 3644 |
3645 dump_inline_depth(st); | |
3564 dump_speculative(st); | 3646 dump_speculative(st); |
3565 } | 3647 } |
3566 #endif | 3648 #endif |
3567 | 3649 |
3568 //------------------------------add_offset------------------------------------- | 3650 //------------------------------add_offset------------------------------------- |
3572 | 3654 |
3573 const Type *TypeInstPtr::remove_speculative() const { | 3655 const Type *TypeInstPtr::remove_speculative() const { |
3574 if (_speculative == NULL) { | 3656 if (_speculative == NULL) { |
3575 return this; | 3657 return this; |
3576 } | 3658 } |
3577 return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, NULL); | 3659 assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth"); |
3660 return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, NULL, _inline_depth); | |
3661 } | |
3662 | |
3663 const TypeOopPtr *TypeInstPtr::with_inline_depth(int depth) const { | |
3664 if (!UseInlineDepthForSpeculativeTypes) { | |
3665 return this; | |
3666 } | |
3667 return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, depth); | |
3578 } | 3668 } |
3579 | 3669 |
3580 //============================================================================= | 3670 //============================================================================= |
3581 // Convenience common pre-built types. | 3671 // Convenience common pre-built types. |
3582 const TypeAryPtr *TypeAryPtr::RANGE; | 3672 const TypeAryPtr *TypeAryPtr::RANGE; |
3589 const TypeAryPtr *TypeAryPtr::LONGS; | 3679 const TypeAryPtr *TypeAryPtr::LONGS; |
3590 const TypeAryPtr *TypeAryPtr::FLOATS; | 3680 const TypeAryPtr *TypeAryPtr::FLOATS; |
3591 const TypeAryPtr *TypeAryPtr::DOUBLES; | 3681 const TypeAryPtr *TypeAryPtr::DOUBLES; |
3592 | 3682 |
3593 //------------------------------make------------------------------------------- | 3683 //------------------------------make------------------------------------------- |
3594 const TypeAryPtr *TypeAryPtr::make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative) { | 3684 const TypeAryPtr *TypeAryPtr::make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth) { |
3595 assert(!(k == NULL && ary->_elem->isa_int()), | 3685 assert(!(k == NULL && ary->_elem->isa_int()), |
3596 "integral arrays must be pre-equipped with a class"); | 3686 "integral arrays must be pre-equipped with a class"); |
3597 if (!xk) xk = ary->ary_must_be_exact(); | 3687 if (!xk) xk = ary->ary_must_be_exact(); |
3598 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); | 3688 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); |
3599 if (!UseExactTypes) xk = (ptr == Constant); | 3689 if (!UseExactTypes) xk = (ptr == Constant); |
3600 return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false, speculative))->hashcons(); | 3690 return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false, speculative, inline_depth))->hashcons(); |
3601 } | 3691 } |
3602 | 3692 |
3603 //------------------------------make------------------------------------------- | 3693 //------------------------------make------------------------------------------- |
3604 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) { | 3694 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) { |
3605 assert(!(k == NULL && ary->_elem->isa_int()), | 3695 assert(!(k == NULL && ary->_elem->isa_int()), |
3606 "integral arrays must be pre-equipped with a class"); | 3696 "integral arrays must be pre-equipped with a class"); |
3607 assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" ); | 3697 assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" ); |
3608 if (!xk) xk = (o != NULL) || ary->ary_must_be_exact(); | 3698 if (!xk) xk = (o != NULL) || ary->ary_must_be_exact(); |
3609 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); | 3699 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); |
3610 if (!UseExactTypes) xk = (ptr == Constant); | 3700 if (!UseExactTypes) xk = (ptr == Constant); |
3611 return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache, speculative))->hashcons(); | 3701 return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache, speculative, inline_depth))->hashcons(); |
3612 } | 3702 } |
3613 | 3703 |
3614 //------------------------------cast_to_ptr_type------------------------------- | 3704 //------------------------------cast_to_ptr_type------------------------------- |
3615 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const { | 3705 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const { |
3616 if( ptr == _ptr ) return this; | 3706 if( ptr == _ptr ) return this; |
3617 return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative); | 3707 return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth); |
3618 } | 3708 } |
3619 | 3709 |
3620 | 3710 |
3621 //-----------------------------cast_to_exactness------------------------------- | 3711 //-----------------------------cast_to_exactness------------------------------- |
3622 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const { | 3712 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const { |
3623 if( klass_is_exact == _klass_is_exact ) return this; | 3713 if( klass_is_exact == _klass_is_exact ) return this; |
3624 if (!UseExactTypes) return this; | 3714 if (!UseExactTypes) return this; |
3625 if (_ary->ary_must_be_exact()) return this; // cannot clear xk | 3715 if (_ary->ary_must_be_exact()) return this; // cannot clear xk |
3626 return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative); | 3716 return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative, _inline_depth); |
3627 } | 3717 } |
3628 | 3718 |
3629 //-----------------------------cast_to_instance_id---------------------------- | 3719 //-----------------------------cast_to_instance_id---------------------------- |
3630 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const { | 3720 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const { |
3631 if( instance_id == _instance_id ) return this; | 3721 if( instance_id == _instance_id ) return this; |
3632 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); |
3633 } | 3723 } |
3634 | 3724 |
3635 //-----------------------------narrow_size_type------------------------------- | 3725 //-----------------------------narrow_size_type------------------------------- |
3636 // Local cache for arrayOopDesc::max_array_length(etype), | 3726 // Local cache for arrayOopDesc::max_array_length(etype), |
3637 // which is kind of slow (and cached elsewhere by other users). | 3727 // which is kind of slow (and cached elsewhere by other users). |
3690 const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const { | 3780 const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const { |
3691 assert(new_size != NULL, ""); | 3781 assert(new_size != NULL, ""); |
3692 new_size = narrow_size_type(new_size); | 3782 new_size = narrow_size_type(new_size); |
3693 if (new_size == size()) return this; | 3783 if (new_size == size()) return this; |
3694 const TypeAry* new_ary = TypeAry::make(elem(), new_size, is_stable()); | 3784 const TypeAry* new_ary = TypeAry::make(elem(), new_size, is_stable()); |
3695 return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative); | 3785 return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth); |
3696 } | 3786 } |
3697 | 3787 |
3698 | 3788 |
3699 //------------------------------cast_to_stable--------------------------------- | 3789 //------------------------------cast_to_stable--------------------------------- |
3700 const TypeAryPtr* TypeAryPtr::cast_to_stable(bool stable, int stable_dimension) const { | 3790 const TypeAryPtr* TypeAryPtr::cast_to_stable(bool stable, int stable_dimension) const { |
3769 case OopPtr: { // Meeting to OopPtrs | 3859 case OopPtr: { // Meeting to OopPtrs |
3770 // Found a OopPtr type vs self-AryPtr type | 3860 // Found a OopPtr type vs self-AryPtr type |
3771 const TypeOopPtr *tp = t->is_oopptr(); | 3861 const TypeOopPtr *tp = t->is_oopptr(); |
3772 int offset = meet_offset(tp->offset()); | 3862 int offset = meet_offset(tp->offset()); |
3773 PTR ptr = meet_ptr(tp->ptr()); | 3863 PTR ptr = meet_ptr(tp->ptr()); |
3864 int depth = meet_inline_depth(tp->inline_depth()); | |
3774 switch (tp->ptr()) { | 3865 switch (tp->ptr()) { |
3775 case TopPTR: | 3866 case TopPTR: |
3776 case AnyNull: { | 3867 case AnyNull: { |
3777 int instance_id = meet_instance_id(InstanceTop); | 3868 int instance_id = meet_instance_id(InstanceTop); |
3778 const TypeOopPtr* speculative = xmeet_speculative(tp); | 3869 const TypeOopPtr* speculative = xmeet_speculative(tp); |
3779 return make(ptr, (ptr == Constant ? const_oop() : NULL), | 3870 return make(ptr, (ptr == Constant ? const_oop() : NULL), |
3780 _ary, _klass, _klass_is_exact, offset, instance_id, speculative); | 3871 _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth); |
3781 } | 3872 } |
3782 case BotPTR: | 3873 case BotPTR: |
3783 case NotNull: { | 3874 case NotNull: { |
3784 int instance_id = meet_instance_id(tp->instance_id()); | 3875 int instance_id = meet_instance_id(tp->instance_id()); |
3785 const TypeOopPtr* speculative = xmeet_speculative(tp); | 3876 const TypeOopPtr* speculative = xmeet_speculative(tp); |
3786 return TypeOopPtr::make(ptr, offset, instance_id, speculative); | 3877 return TypeOopPtr::make(ptr, offset, instance_id, speculative, depth); |
3787 } | 3878 } |
3788 default: ShouldNotReachHere(); | 3879 default: ShouldNotReachHere(); |
3789 } | 3880 } |
3790 } | 3881 } |
3791 | 3882 |
3805 // else fall through to AnyNull | 3896 // else fall through to AnyNull |
3806 case AnyNull: { | 3897 case AnyNull: { |
3807 int instance_id = meet_instance_id(InstanceTop); | 3898 int instance_id = meet_instance_id(InstanceTop); |
3808 const TypeOopPtr* speculative = _speculative; | 3899 const TypeOopPtr* speculative = _speculative; |
3809 return make(ptr, (ptr == Constant ? const_oop() : NULL), | 3900 return make(ptr, (ptr == Constant ? const_oop() : NULL), |
3810 _ary, _klass, _klass_is_exact, offset, instance_id, speculative); | 3901 _ary, _klass, _klass_is_exact, offset, instance_id, speculative, _inline_depth); |
3811 } | 3902 } |
3812 default: ShouldNotReachHere(); | 3903 default: ShouldNotReachHere(); |
3813 } | 3904 } |
3814 } | 3905 } |
3815 | 3906 |
3822 int off = meet_offset(tap->offset()); | 3913 int off = meet_offset(tap->offset()); |
3823 const TypeAry *tary = _ary->meet_speculative(tap->_ary)->is_ary(); | 3914 const TypeAry *tary = _ary->meet_speculative(tap->_ary)->is_ary(); |
3824 PTR ptr = meet_ptr(tap->ptr()); | 3915 PTR ptr = meet_ptr(tap->ptr()); |
3825 int instance_id = meet_instance_id(tap->instance_id()); | 3916 int instance_id = meet_instance_id(tap->instance_id()); |
3826 const TypeOopPtr* speculative = xmeet_speculative(tap); | 3917 const TypeOopPtr* speculative = xmeet_speculative(tap); |
3918 int depth = meet_inline_depth(tap->inline_depth()); | |
3827 ciKlass* lazy_klass = NULL; | 3919 ciKlass* lazy_klass = NULL; |
3828 if (tary->_elem->isa_int()) { | 3920 if (tary->_elem->isa_int()) { |
3829 // Integral array element types have irrelevant lattice relations. | 3921 // Integral array element types have irrelevant lattice relations. |
3830 // It is the klass that determines array layout, not the element type. | 3922 // It is the klass that determines array layout, not the element type. |
3831 if (_klass == NULL) | 3923 if (_klass == NULL) |
3862 if (below_centerline(this->_ptr)) { | 3954 if (below_centerline(this->_ptr)) { |
3863 xk = this->_klass_is_exact; | 3955 xk = this->_klass_is_exact; |
3864 } else { | 3956 } else { |
3865 xk = (tap->_klass_is_exact | this->_klass_is_exact); | 3957 xk = (tap->_klass_is_exact | this->_klass_is_exact); |
3866 } | 3958 } |
3867 return make(ptr, const_oop(), tary, lazy_klass, xk, off, instance_id, speculative); | 3959 return make(ptr, const_oop(), tary, lazy_klass, xk, off, instance_id, speculative, depth); |
3868 case Constant: { | 3960 case Constant: { |
3869 ciObject* o = const_oop(); | 3961 ciObject* o = const_oop(); |
3870 if( _ptr == Constant ) { | 3962 if( _ptr == Constant ) { |
3871 if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) { | 3963 if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) { |
3872 xk = (klass() == tap->klass()); | 3964 xk = (klass() == tap->klass()); |
3881 xk = true; | 3973 xk = true; |
3882 } else { | 3974 } else { |
3883 // Only precise for identical arrays | 3975 // Only precise for identical arrays |
3884 xk = this->_klass_is_exact && (klass() == tap->klass()); | 3976 xk = this->_klass_is_exact && (klass() == tap->klass()); |
3885 } | 3977 } |
3886 return TypeAryPtr::make(ptr, o, tary, lazy_klass, xk, off, instance_id, speculative); | 3978 return TypeAryPtr::make(ptr, o, tary, lazy_klass, xk, off, instance_id, speculative, depth); |
3887 } | 3979 } |
3888 case NotNull: | 3980 case NotNull: |
3889 case BotPTR: | 3981 case BotPTR: |
3890 // Compute new klass on demand, do not use tap->_klass | 3982 // Compute new klass on demand, do not use tap->_klass |
3891 if (above_centerline(this->_ptr)) | 3983 if (above_centerline(this->_ptr)) |
3892 xk = tap->_klass_is_exact; | 3984 xk = tap->_klass_is_exact; |
3893 else xk = (tap->_klass_is_exact & this->_klass_is_exact) && | 3985 else xk = (tap->_klass_is_exact & this->_klass_is_exact) && |
3894 (klass() == tap->klass()); // Only precise for identical arrays | 3986 (klass() == tap->klass()); // Only precise for identical arrays |
3895 return TypeAryPtr::make(ptr, NULL, tary, lazy_klass, xk, off, instance_id, speculative); | 3987 return TypeAryPtr::make(ptr, NULL, tary, lazy_klass, xk, off, instance_id, speculative, depth); |
3896 default: ShouldNotReachHere(); | 3988 default: ShouldNotReachHere(); |
3897 } | 3989 } |
3898 } | 3990 } |
3899 | 3991 |
3900 // All arrays inherit from Object class | 3992 // All arrays inherit from Object class |
3902 const TypeInstPtr *tp = t->is_instptr(); | 3994 const TypeInstPtr *tp = t->is_instptr(); |
3903 int offset = meet_offset(tp->offset()); | 3995 int offset = meet_offset(tp->offset()); |
3904 PTR ptr = meet_ptr(tp->ptr()); | 3996 PTR ptr = meet_ptr(tp->ptr()); |
3905 int instance_id = meet_instance_id(tp->instance_id()); | 3997 int instance_id = meet_instance_id(tp->instance_id()); |
3906 const TypeOopPtr* speculative = xmeet_speculative(tp); | 3998 const TypeOopPtr* speculative = xmeet_speculative(tp); |
3999 int depth = meet_inline_depth(tp->inline_depth()); | |
3907 switch (ptr) { | 4000 switch (ptr) { |
3908 case TopPTR: | 4001 case TopPTR: |
3909 case AnyNull: // Fall 'down' to dual of object klass | 4002 case AnyNull: // Fall 'down' to dual of object klass |
3910 // For instances when a subclass meets a superclass we fall | 4003 // For instances when a subclass meets a superclass we fall |
3911 // below the centerline when the superclass is exact. We need to | 4004 // below the centerline when the superclass is exact. We need to |
3912 // do the same here. | 4005 // do the same here. |
3913 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { | 4006 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { |
3914 return TypeAryPtr::make(ptr, _ary, _klass, _klass_is_exact, offset, instance_id, speculative); | 4007 return TypeAryPtr::make(ptr, _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth); |
3915 } else { | 4008 } else { |
3916 // cannot subclass, so the meet has to fall badly below the centerline | 4009 // cannot subclass, so the meet has to fall badly below the centerline |
3917 ptr = NotNull; | 4010 ptr = NotNull; |
3918 instance_id = InstanceBot; | 4011 instance_id = InstanceBot; |
3919 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative); | 4012 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth); |
3920 } | 4013 } |
3921 case Constant: | 4014 case Constant: |
3922 case NotNull: | 4015 case NotNull: |
3923 case BotPTR: // Fall down to object klass | 4016 case BotPTR: // Fall down to object klass |
3924 // LCA is object_klass, but if we subclass from the top we can do better | 4017 // LCA is object_klass, but if we subclass from the top we can do better |
3929 // below the centerline when the superclass is exact. We need | 4022 // below the centerline when the superclass is exact. We need |
3930 // to do the same here. | 4023 // to do the same here. |
3931 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { | 4024 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { |
3932 // that is, my array type is a subtype of 'tp' klass | 4025 // that is, my array type is a subtype of 'tp' klass |
3933 return make(ptr, (ptr == Constant ? const_oop() : NULL), | 4026 return make(ptr, (ptr == Constant ? const_oop() : NULL), |
3934 _ary, _klass, _klass_is_exact, offset, instance_id, speculative); | 4027 _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth); |
3935 } | 4028 } |
3936 } | 4029 } |
3937 // The other case cannot happen, since t cannot be a subtype of an array. | 4030 // The other case cannot happen, since t cannot be a subtype of an array. |
3938 // The meet falls down to Object class below centerline. | 4031 // The meet falls down to Object class below centerline. |
3939 if( ptr == Constant ) | 4032 if( ptr == Constant ) |
3940 ptr = NotNull; | 4033 ptr = NotNull; |
3941 instance_id = InstanceBot; | 4034 instance_id = InstanceBot; |
3942 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative); | 4035 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth); |
3943 default: typerr(t); | 4036 default: typerr(t); |
3944 } | 4037 } |
3945 } | 4038 } |
3946 } | 4039 } |
3947 return this; // Lint noise | 4040 return this; // Lint noise |
3948 } | 4041 } |
3949 | 4042 |
3950 //------------------------------xdual------------------------------------------ | 4043 //------------------------------xdual------------------------------------------ |
3951 // Dual: compute field-by-field dual | 4044 // Dual: compute field-by-field dual |
3952 const Type *TypeAryPtr::xdual() const { | 4045 const Type *TypeAryPtr::xdual() const { |
3953 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()); | 4046 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()); |
3954 } | 4047 } |
3955 | 4048 |
3956 //----------------------interface_vs_oop--------------------------------------- | 4049 //----------------------interface_vs_oop--------------------------------------- |
3957 #ifdef ASSERT | 4050 #ifdef ASSERT |
3958 bool TypeAryPtr::interface_vs_oop(const Type *t) const { | 4051 bool TypeAryPtr::interface_vs_oop(const Type *t) const { |
4001 if (_instance_id == InstanceTop) | 4094 if (_instance_id == InstanceTop) |
4002 st->print(",iid=top"); | 4095 st->print(",iid=top"); |
4003 else if (_instance_id != InstanceBot) | 4096 else if (_instance_id != InstanceBot) |
4004 st->print(",iid=%d",_instance_id); | 4097 st->print(",iid=%d",_instance_id); |
4005 | 4098 |
4099 dump_inline_depth(st); | |
4006 dump_speculative(st); | 4100 dump_speculative(st); |
4007 } | 4101 } |
4008 #endif | 4102 #endif |
4009 | 4103 |
4010 bool TypeAryPtr::empty(void) const { | 4104 bool TypeAryPtr::empty(void) const { |
4012 return TypeOopPtr::empty(); | 4106 return TypeOopPtr::empty(); |
4013 } | 4107 } |
4014 | 4108 |
4015 //------------------------------add_offset------------------------------------- | 4109 //------------------------------add_offset------------------------------------- |
4016 const TypePtr *TypeAryPtr::add_offset(intptr_t offset) const { | 4110 const TypePtr *TypeAryPtr::add_offset(intptr_t offset) const { |
4017 return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id, add_offset_speculative(offset)); | 4111 return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id, add_offset_speculative(offset), _inline_depth); |
4018 } | 4112 } |
4019 | 4113 |
4020 const Type *TypeAryPtr::remove_speculative() const { | 4114 const Type *TypeAryPtr::remove_speculative() const { |
4021 return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, NULL); | 4115 if (_speculative == NULL) { |
4116 return this; | |
4117 } | |
4118 assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth"); | |
4119 return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, NULL, _inline_depth); | |
4120 } | |
4121 | |
4122 const TypeOopPtr *TypeAryPtr::with_inline_depth(int depth) const { | |
4123 if (!UseInlineDepthForSpeculativeTypes) { | |
4124 return this; | |
4125 } | |
4126 return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, _speculative, depth); | |
4022 } | 4127 } |
4023 | 4128 |
4024 //============================================================================= | 4129 //============================================================================= |
4025 | 4130 |
4026 //------------------------------hash------------------------------------------- | 4131 //------------------------------hash------------------------------------------- |