356 TypeInstPtr::MIRROR = TypeInstPtr::make(TypePtr::NotNull, current->env()->Class_klass()); |
356 TypeInstPtr::MIRROR = TypeInstPtr::make(TypePtr::NotNull, current->env()->Class_klass()); |
357 TypeInstPtr::MARK = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), |
357 TypeInstPtr::MARK = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), |
358 false, 0, oopDesc::mark_offset_in_bytes()); |
358 false, 0, oopDesc::mark_offset_in_bytes()); |
359 TypeInstPtr::KLASS = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), |
359 TypeInstPtr::KLASS = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), |
360 false, 0, oopDesc::klass_offset_in_bytes()); |
360 false, 0, oopDesc::klass_offset_in_bytes()); |
361 TypeOopPtr::BOTTOM = TypeOopPtr::make(TypePtr::BotPTR, OffsetBot, TypeOopPtr::InstanceBot); |
361 TypeOopPtr::BOTTOM = TypeOopPtr::make(TypePtr::BotPTR, OffsetBot, TypeOopPtr::InstanceBot, NULL); |
362 |
362 |
363 TypeMetadataPtr::BOTTOM = TypeMetadataPtr::make(TypePtr::BotPTR, NULL, OffsetBot); |
363 TypeMetadataPtr::BOTTOM = TypeMetadataPtr::make(TypePtr::BotPTR, NULL, OffsetBot); |
364 |
364 |
365 TypeNarrowOop::NULL_PTR = TypeNarrowOop::make( TypePtr::NULL_PTR ); |
365 TypeNarrowOop::NULL_PTR = TypeNarrowOop::make( TypePtr::NULL_PTR ); |
366 TypeNarrowOop::BOTTOM = TypeNarrowOop::make( TypeInstPtr::BOTTOM ); |
366 TypeNarrowOop::BOTTOM = TypeNarrowOop::make( TypeInstPtr::BOTTOM ); |
2405 //============================================================================= |
2428 //============================================================================= |
2406 // Convenience common pre-built type. |
2429 // Convenience common pre-built type. |
2407 const TypeOopPtr *TypeOopPtr::BOTTOM; |
2430 const TypeOopPtr *TypeOopPtr::BOTTOM; |
2408 |
2431 |
2409 //------------------------------TypeOopPtr------------------------------------- |
2432 //------------------------------TypeOopPtr------------------------------------- |
2410 TypeOopPtr::TypeOopPtr( TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id ) |
2433 TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative) |
2411 : TypePtr(t, ptr, offset), |
2434 : TypePtr(t, ptr, offset), |
2412 _const_oop(o), _klass(k), |
2435 _const_oop(o), _klass(k), |
2413 _klass_is_exact(xk), |
2436 _klass_is_exact(xk), |
2414 _is_ptr_to_narrowoop(false), |
2437 _is_ptr_to_narrowoop(false), |
2415 _is_ptr_to_narrowklass(false), |
2438 _is_ptr_to_narrowklass(false), |
2416 _is_ptr_to_boxed_value(false), |
2439 _is_ptr_to_boxed_value(false), |
2417 _instance_id(instance_id) { |
2440 _instance_id(instance_id), |
|
2441 _speculative(speculative) { |
2418 if (Compile::current()->eliminate_boxing() && (t == InstPtr) && |
2442 if (Compile::current()->eliminate_boxing() && (t == InstPtr) && |
2419 (offset > 0) && xk && (k != 0) && k->is_instance_klass()) { |
2443 (offset > 0) && xk && (k != 0) && k->is_instance_klass()) { |
2420 _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset); |
2444 _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset); |
2421 } |
2445 } |
2422 #ifdef _LP64 |
2446 #ifdef _LP64 |
2479 #endif |
2503 #endif |
2480 } |
2504 } |
2481 |
2505 |
2482 //------------------------------make------------------------------------------- |
2506 //------------------------------make------------------------------------------- |
2483 const TypeOopPtr *TypeOopPtr::make(PTR ptr, |
2507 const TypeOopPtr *TypeOopPtr::make(PTR ptr, |
2484 int offset, int instance_id) { |
2508 int offset, int instance_id, const TypeOopPtr* speculative) { |
2485 assert(ptr != Constant, "no constant generic pointers"); |
2509 assert(ptr != Constant, "no constant generic pointers"); |
2486 ciKlass* k = Compile::current()->env()->Object_klass(); |
2510 ciKlass* k = Compile::current()->env()->Object_klass(); |
2487 bool xk = false; |
2511 bool xk = false; |
2488 ciObject* o = NULL; |
2512 ciObject* o = NULL; |
2489 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id))->hashcons(); |
2513 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative))->hashcons(); |
2490 } |
2514 } |
2491 |
2515 |
2492 |
2516 |
2493 //------------------------------cast_to_ptr_type------------------------------- |
2517 //------------------------------cast_to_ptr_type------------------------------- |
2494 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const { |
2518 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const { |
2495 assert(_base == OopPtr, "subclass must override cast_to_ptr_type"); |
2519 assert(_base == OopPtr, "subclass must override cast_to_ptr_type"); |
2496 if( ptr == _ptr ) return this; |
2520 if( ptr == _ptr ) return this; |
2497 return make(ptr, _offset, _instance_id); |
2521 return make(ptr, _offset, _instance_id, _speculative); |
2498 } |
2522 } |
2499 |
2523 |
2500 //-----------------------------cast_to_instance_id---------------------------- |
2524 //-----------------------------cast_to_instance_id---------------------------- |
2501 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const { |
2525 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const { |
2502 // There are no instances of a general oop. |
2526 // There are no instances of a general oop. |
2522 return TypeKlassPtr::OBJECT; |
2546 return TypeKlassPtr::OBJECT; |
2523 else |
2547 else |
2524 return TypeKlassPtr::make(xk? Constant: NotNull, k, 0); |
2548 return TypeKlassPtr::make(xk? Constant: NotNull, k, 0); |
2525 } |
2549 } |
2526 |
2550 |
|
2551 const Type *TypeOopPtr::xmeet(const Type *t) const { |
|
2552 const Type* res = xmeet_helper(t); |
|
2553 if (res->isa_oopptr() == NULL) { |
|
2554 return res; |
|
2555 } |
|
2556 |
|
2557 if (res->isa_oopptr() != NULL) { |
|
2558 // type->speculative() == NULL means that speculation is no better |
|
2559 // than type, i.e. type->speculative() == type. So there are 2 |
|
2560 // ways to represent the fact that we have no useful speculative |
|
2561 // data and we should use a single one to be able to test for |
|
2562 // equality between types. Check whether type->speculative() == |
|
2563 // type and set speculative to NULL if it is the case. |
|
2564 const TypeOopPtr* res_oopptr = res->is_oopptr(); |
|
2565 if (res_oopptr->remove_speculative() == res_oopptr->speculative()) { |
|
2566 return res_oopptr->remove_speculative(); |
|
2567 } |
|
2568 } |
|
2569 |
|
2570 return res; |
|
2571 } |
2527 |
2572 |
2528 //------------------------------meet------------------------------------------- |
2573 //------------------------------meet------------------------------------------- |
2529 // Compute the MEET of two types. It returns a new Type object. |
2574 // Compute the MEET of two types. It returns a new Type object. |
2530 const Type *TypeOopPtr::xmeet( const Type *t ) const { |
2575 const Type *TypeOopPtr::xmeet_helper(const Type *t) const { |
2531 // Perform a fast test for common case; meeting the same types together. |
2576 // Perform a fast test for common case; meeting the same types together. |
2532 if( this == t ) return this; // Meeting same type-rep? |
2577 if( this == t ) return this; // Meeting same type-rep? |
2533 |
2578 |
2534 // Current "this->_base" is OopPtr |
2579 // Current "this->_base" is OopPtr |
2535 switch (t->base()) { // switch on original type |
2580 switch (t->base()) { // switch on original type |
2596 //------------------------------xdual------------------------------------------ |
2643 //------------------------------xdual------------------------------------------ |
2597 // Dual of a pure heap pointer. No relevant klass or oop information. |
2644 // Dual of a pure heap pointer. No relevant klass or oop information. |
2598 const Type *TypeOopPtr::xdual() const { |
2645 const Type *TypeOopPtr::xdual() const { |
2599 assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here"); |
2646 assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here"); |
2600 assert(const_oop() == NULL, "no constants here"); |
2647 assert(const_oop() == NULL, "no constants here"); |
2601 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id() ); |
2648 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative()); |
2602 } |
2649 } |
2603 |
2650 |
2604 //--------------------------make_from_klass_common----------------------------- |
2651 //--------------------------make_from_klass_common----------------------------- |
2605 // Computes the element-type given a klass. |
2652 // Computes the element-type given a klass. |
2606 const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) { |
2653 const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) { |
2857 if( _instance_id == InstanceTop ) return InstanceBot; // Map TOP into BOTTOM |
2926 if( _instance_id == InstanceTop ) return InstanceBot; // Map TOP into BOTTOM |
2858 if( _instance_id == InstanceBot ) return InstanceTop; // Map BOTTOM into TOP |
2927 if( _instance_id == InstanceBot ) return InstanceTop; // Map BOTTOM into TOP |
2859 return _instance_id; // Map everything else into self |
2928 return _instance_id; // Map everything else into self |
2860 } |
2929 } |
2861 |
2930 |
|
2931 /** |
|
2932 * meet of the speculative parts of 2 types |
|
2933 * |
|
2934 * @param other type to meet with |
|
2935 */ |
|
2936 const TypeOopPtr* TypeOopPtr::meet_speculative(const TypeOopPtr* other) const { |
|
2937 bool this_has_spec = (_speculative != NULL); |
|
2938 bool other_has_spec = (other->speculative() != NULL); |
|
2939 |
|
2940 if (!this_has_spec && !other_has_spec) { |
|
2941 return NULL; |
|
2942 } |
|
2943 |
|
2944 // If we are at a point where control flow meets and one branch has |
|
2945 // a speculative type and the other has not, we meet the speculative |
|
2946 // type of one branch with the actual type of the other. If the |
|
2947 // actual type is exact and the speculative is as well, then the |
|
2948 // result is a speculative type which is exact and we can continue |
|
2949 // speculation further. |
|
2950 const TypeOopPtr* this_spec = _speculative; |
|
2951 const TypeOopPtr* other_spec = other->speculative(); |
|
2952 |
|
2953 if (!this_has_spec) { |
|
2954 this_spec = this; |
|
2955 } |
|
2956 |
|
2957 if (!other_has_spec) { |
|
2958 other_spec = other; |
|
2959 } |
|
2960 |
|
2961 return this_spec->meet(other_spec)->is_oopptr(); |
|
2962 } |
|
2963 |
|
2964 /** |
|
2965 * dual of the speculative part of the type |
|
2966 */ |
|
2967 const TypeOopPtr* TypeOopPtr::dual_speculative() const { |
|
2968 if (_speculative == NULL) { |
|
2969 return NULL; |
|
2970 } |
|
2971 return _speculative->dual()->is_oopptr(); |
|
2972 } |
|
2973 |
|
2974 /** |
|
2975 * add offset to the speculative part of the type |
|
2976 * |
|
2977 * @param offset offset to add |
|
2978 */ |
|
2979 const TypeOopPtr* TypeOopPtr::add_offset_speculative(intptr_t offset) const { |
|
2980 if (_speculative == NULL) { |
|
2981 return NULL; |
|
2982 } |
|
2983 return _speculative->add_offset(offset)->is_oopptr(); |
|
2984 } |
|
2985 |
|
2986 /** |
|
2987 * Are the speculative parts of 2 types equal? |
|
2988 * |
|
2989 * @param other type to compare this one to |
|
2990 */ |
|
2991 bool TypeOopPtr::eq_speculative(const TypeOopPtr* other) const { |
|
2992 if (_speculative == NULL || other->speculative() == NULL) { |
|
2993 return _speculative == other->speculative(); |
|
2994 } |
|
2995 |
|
2996 if (_speculative->base() != other->speculative()->base()) { |
|
2997 return false; |
|
2998 } |
|
2999 |
|
3000 return _speculative->eq(other->speculative()); |
|
3001 } |
|
3002 |
|
3003 /** |
|
3004 * Hash of the speculative part of the type |
|
3005 */ |
|
3006 int TypeOopPtr::hash_speculative() const { |
|
3007 if (_speculative == NULL) { |
|
3008 return 0; |
|
3009 } |
|
3010 |
|
3011 return _speculative->hash(); |
|
3012 } |
|
3013 |
2862 |
3014 |
2863 //============================================================================= |
3015 //============================================================================= |
2864 // Convenience common pre-built types. |
3016 // Convenience common pre-built types. |
2865 const TypeInstPtr *TypeInstPtr::NOTNULL; |
3017 const TypeInstPtr *TypeInstPtr::NOTNULL; |
2866 const TypeInstPtr *TypeInstPtr::BOTTOM; |
3018 const TypeInstPtr *TypeInstPtr::BOTTOM; |
2867 const TypeInstPtr *TypeInstPtr::MIRROR; |
3019 const TypeInstPtr *TypeInstPtr::MIRROR; |
2868 const TypeInstPtr *TypeInstPtr::MARK; |
3020 const TypeInstPtr *TypeInstPtr::MARK; |
2869 const TypeInstPtr *TypeInstPtr::KLASS; |
3021 const TypeInstPtr *TypeInstPtr::KLASS; |
2870 |
3022 |
2871 //------------------------------TypeInstPtr------------------------------------- |
3023 //------------------------------TypeInstPtr------------------------------------- |
2872 TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id) |
3024 TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id, const TypeOopPtr* speculative) |
2873 : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id), _name(k->name()) { |
3025 : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id, speculative), _name(k->name()) { |
2874 assert(k != NULL && |
3026 assert(k != NULL && |
2875 (k->is_loaded() || o == NULL), |
3027 (k->is_loaded() || o == NULL), |
2876 "cannot have constants with non-loaded klass"); |
3028 "cannot have constants with non-loaded klass"); |
2877 }; |
3029 }; |
2878 |
3030 |
2946 if (!UseExactTypes) return this; |
3099 if (!UseExactTypes) return this; |
2947 if (!_klass->is_loaded()) return this; |
3100 if (!_klass->is_loaded()) return this; |
2948 ciInstanceKlass* ik = _klass->as_instance_klass(); |
3101 ciInstanceKlass* ik = _klass->as_instance_klass(); |
2949 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk |
3102 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk |
2950 if( ik->is_interface() ) return this; // cannot set xk |
3103 if( ik->is_interface() ) return this; // cannot set xk |
2951 return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id); |
3104 return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative); |
2952 } |
3105 } |
2953 |
3106 |
2954 //-----------------------------cast_to_instance_id---------------------------- |
3107 //-----------------------------cast_to_instance_id---------------------------- |
2955 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const { |
3108 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const { |
2956 if( instance_id == _instance_id ) return this; |
3109 if( instance_id == _instance_id ) return this; |
2957 return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id); |
3110 return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative); |
2958 } |
3111 } |
2959 |
3112 |
2960 //------------------------------xmeet_unloaded--------------------------------- |
3113 //------------------------------xmeet_unloaded--------------------------------- |
2961 // Compute the MEET of two InstPtrs when at least one is unloaded. |
3114 // Compute the MEET of two InstPtrs when at least one is unloaded. |
2962 // Assume classes are different since called after check for same name/class-loader |
3115 // Assume classes are different since called after check for same name/class-loader |
2963 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const { |
3116 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const { |
2964 int off = meet_offset(tinst->offset()); |
3117 int off = meet_offset(tinst->offset()); |
2965 PTR ptr = meet_ptr(tinst->ptr()); |
3118 PTR ptr = meet_ptr(tinst->ptr()); |
2966 int instance_id = meet_instance_id(tinst->instance_id()); |
3119 int instance_id = meet_instance_id(tinst->instance_id()); |
|
3120 const TypeOopPtr* speculative = meet_speculative(tinst); |
2967 |
3121 |
2968 const TypeInstPtr *loaded = is_loaded() ? this : tinst; |
3122 const TypeInstPtr *loaded = is_loaded() ? this : tinst; |
2969 const TypeInstPtr *unloaded = is_loaded() ? tinst : this; |
3123 const TypeInstPtr *unloaded = is_loaded() ? tinst : this; |
2970 if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) { |
3124 if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) { |
2971 // |
3125 // |
3038 case AryPtr: { // All arrays inherit from Object class |
3192 case AryPtr: { // All arrays inherit from Object class |
3039 const TypeAryPtr *tp = t->is_aryptr(); |
3193 const TypeAryPtr *tp = t->is_aryptr(); |
3040 int offset = meet_offset(tp->offset()); |
3194 int offset = meet_offset(tp->offset()); |
3041 PTR ptr = meet_ptr(tp->ptr()); |
3195 PTR ptr = meet_ptr(tp->ptr()); |
3042 int instance_id = meet_instance_id(tp->instance_id()); |
3196 int instance_id = meet_instance_id(tp->instance_id()); |
|
3197 const TypeOopPtr* speculative = meet_speculative(tp); |
3043 switch (ptr) { |
3198 switch (ptr) { |
3044 case TopPTR: |
3199 case TopPTR: |
3045 case AnyNull: // Fall 'down' to dual of object klass |
3200 case AnyNull: // Fall 'down' to dual of object klass |
3046 if (klass()->equals(ciEnv::current()->Object_klass())) { |
3201 // For instances when a subclass meets a superclass we fall |
3047 return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id); |
3202 // below the centerline when the superclass is exact. We need to |
|
3203 // do the same here. |
|
3204 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { |
|
3205 return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative); |
3048 } else { |
3206 } else { |
3049 // cannot subclass, so the meet has to fall badly below the centerline |
3207 // cannot subclass, so the meet has to fall badly below the centerline |
3050 ptr = NotNull; |
3208 ptr = NotNull; |
3051 instance_id = InstanceBot; |
3209 instance_id = InstanceBot; |
3052 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id); |
3210 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative); |
3053 } |
3211 } |
3054 case Constant: |
3212 case Constant: |
3055 case NotNull: |
3213 case NotNull: |
3056 case BotPTR: // Fall down to object klass |
3214 case BotPTR: // Fall down to object klass |
3057 // LCA is object_klass, but if we subclass from the top we can do better |
3215 // LCA is object_klass, but if we subclass from the top we can do better |
3058 if( above_centerline(_ptr) ) { // if( _ptr == TopPTR || _ptr == AnyNull ) |
3216 if( above_centerline(_ptr) ) { // if( _ptr == TopPTR || _ptr == AnyNull ) |
3059 // If 'this' (InstPtr) is above the centerline and it is Object class |
3217 // If 'this' (InstPtr) is above the centerline and it is Object class |
3060 // then we can subclass in the Java class hierarchy. |
3218 // then we can subclass in the Java class hierarchy. |
3061 if (klass()->equals(ciEnv::current()->Object_klass())) { |
3219 // For instances when a subclass meets a superclass we fall |
|
3220 // below the centerline when the superclass is exact. We need |
|
3221 // to do the same here. |
|
3222 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { |
3062 // that is, tp's array type is a subtype of my klass |
3223 // that is, tp's array type is a subtype of my klass |
3063 return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL), |
3224 return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL), |
3064 tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id); |
3225 tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative); |
3065 } |
3226 } |
3066 } |
3227 } |
3067 // The other case cannot happen, since I cannot be a subtype of an array. |
3228 // The other case cannot happen, since I cannot be a subtype of an array. |
3068 // The meet falls down to Object class below centerline. |
3229 // The meet falls down to Object class below centerline. |
3069 if( ptr == Constant ) |
3230 if( ptr == Constant ) |
3070 ptr = NotNull; |
3231 ptr = NotNull; |
3071 instance_id = InstanceBot; |
3232 instance_id = InstanceBot; |
3072 return make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id ); |
3233 return make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative); |
3073 default: typerr(t); |
3234 default: typerr(t); |
3074 } |
3235 } |
3075 } |
3236 } |
3076 |
3237 |
3077 case OopPtr: { // Meeting to OopPtrs |
3238 case OopPtr: { // Meeting to OopPtrs |
3137 // Found an InstPtr sub-type vs self-InstPtr type |
3301 // Found an InstPtr sub-type vs self-InstPtr type |
3138 const TypeInstPtr *tinst = t->is_instptr(); |
3302 const TypeInstPtr *tinst = t->is_instptr(); |
3139 int off = meet_offset( tinst->offset() ); |
3303 int off = meet_offset( tinst->offset() ); |
3140 PTR ptr = meet_ptr( tinst->ptr() ); |
3304 PTR ptr = meet_ptr( tinst->ptr() ); |
3141 int instance_id = meet_instance_id(tinst->instance_id()); |
3305 int instance_id = meet_instance_id(tinst->instance_id()); |
|
3306 const TypeOopPtr* speculative = meet_speculative(tinst); |
3142 |
3307 |
3143 // Check for easy case; klasses are equal (and perhaps not loaded!) |
3308 // Check for easy case; klasses are equal (and perhaps not loaded!) |
3144 // If we have constants, then we created oops so classes are loaded |
3309 // If we have constants, then we created oops so classes are loaded |
3145 // and we can handle the constants further down. This case handles |
3310 // and we can handle the constants further down. This case handles |
3146 // both-not-loaded or both-loaded classes |
3311 // both-not-loaded or both-loaded classes |
3147 if (ptr != Constant && klass()->equals(tinst->klass()) && klass_is_exact() == tinst->klass_is_exact()) { |
3312 if (ptr != Constant && klass()->equals(tinst->klass()) && klass_is_exact() == tinst->klass_is_exact()) { |
3148 return make( ptr, klass(), klass_is_exact(), NULL, off, instance_id ); |
3313 return make(ptr, klass(), klass_is_exact(), NULL, off, instance_id, speculative); |
3149 } |
3314 } |
3150 |
3315 |
3151 // Classes require inspection in the Java klass hierarchy. Must be loaded. |
3316 // Classes require inspection in the Java klass hierarchy. Must be loaded. |
3152 ciKlass* tinst_klass = tinst->klass(); |
3317 ciKlass* tinst_klass = tinst->klass(); |
3153 ciKlass* this_klass = this->klass(); |
3318 ciKlass* this_klass = this->klass(); |
3283 else if (above_centerline(tinst ->_ptr)) |
3449 else if (above_centerline(tinst ->_ptr)) |
3284 o = this_oop; |
3450 o = this_oop; |
3285 else |
3451 else |
3286 ptr = NotNull; |
3452 ptr = NotNull; |
3287 } |
3453 } |
3288 return make( ptr, this_klass, this_xk, o, off, instance_id ); |
3454 return make(ptr, this_klass, this_xk, o, off, instance_id, speculative); |
3289 } // Else classes are not equal |
3455 } // Else classes are not equal |
3290 |
3456 |
3291 // Since klasses are different, we require a LCA in the Java |
3457 // Since klasses are different, we require a LCA in the Java |
3292 // class hierarchy - which means we have to fall to at least NotNull. |
3458 // class hierarchy - which means we have to fall to at least NotNull. |
3293 if( ptr == TopPTR || ptr == AnyNull || ptr == Constant ) |
3459 if( ptr == TopPTR || ptr == AnyNull || ptr == Constant ) |
3294 ptr = NotNull; |
3460 ptr = NotNull; |
3295 instance_id = InstanceBot; |
3461 instance_id = InstanceBot; |
3296 |
3462 |
3297 // Now we find the LCA of Java classes |
3463 // Now we find the LCA of Java classes |
3298 ciKlass* k = this_klass->least_common_ancestor(tinst_klass); |
3464 ciKlass* k = this_klass->least_common_ancestor(tinst_klass); |
3299 return make( ptr, k, false, NULL, off, instance_id ); |
3465 return make(ptr, k, false, NULL, off, instance_id, speculative); |
3300 } // End of case InstPtr |
3466 } // End of case InstPtr |
3301 |
3467 |
3302 } // End of switch |
3468 } // End of switch |
3303 return this; // Return the double constant |
3469 return this; // Return the double constant |
3304 } |
3470 } |
3374 st->print(" *"); |
3540 st->print(" *"); |
3375 if (_instance_id == InstanceTop) |
3541 if (_instance_id == InstanceTop) |
3376 st->print(",iid=top"); |
3542 st->print(",iid=top"); |
3377 else if (_instance_id != InstanceBot) |
3543 else if (_instance_id != InstanceBot) |
3378 st->print(",iid=%d",_instance_id); |
3544 st->print(",iid=%d",_instance_id); |
|
3545 |
|
3546 dump_speculative(st); |
3379 } |
3547 } |
3380 #endif |
3548 #endif |
3381 |
3549 |
3382 //------------------------------add_offset------------------------------------- |
3550 //------------------------------add_offset------------------------------------- |
3383 const TypePtr *TypeInstPtr::add_offset( intptr_t offset ) const { |
3551 const TypePtr *TypeInstPtr::add_offset(intptr_t offset) const { |
3384 return make( _ptr, klass(), klass_is_exact(), const_oop(), xadd_offset(offset), _instance_id ); |
3552 return make(_ptr, klass(), klass_is_exact(), const_oop(), xadd_offset(offset), _instance_id, add_offset_speculative(offset)); |
|
3553 } |
|
3554 |
|
3555 const TypeOopPtr *TypeInstPtr::remove_speculative() const { |
|
3556 return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, NULL); |
3385 } |
3557 } |
3386 |
3558 |
3387 //============================================================================= |
3559 //============================================================================= |
3388 // Convenience common pre-built types. |
3560 // Convenience common pre-built types. |
3389 const TypeAryPtr *TypeAryPtr::RANGE; |
3561 const TypeAryPtr *TypeAryPtr::RANGE; |
3396 const TypeAryPtr *TypeAryPtr::LONGS; |
3568 const TypeAryPtr *TypeAryPtr::LONGS; |
3397 const TypeAryPtr *TypeAryPtr::FLOATS; |
3569 const TypeAryPtr *TypeAryPtr::FLOATS; |
3398 const TypeAryPtr *TypeAryPtr::DOUBLES; |
3570 const TypeAryPtr *TypeAryPtr::DOUBLES; |
3399 |
3571 |
3400 //------------------------------make------------------------------------------- |
3572 //------------------------------make------------------------------------------- |
3401 const TypeAryPtr *TypeAryPtr::make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id ) { |
3573 const TypeAryPtr *TypeAryPtr::make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative) { |
3402 assert(!(k == NULL && ary->_elem->isa_int()), |
3574 assert(!(k == NULL && ary->_elem->isa_int()), |
3403 "integral arrays must be pre-equipped with a class"); |
3575 "integral arrays must be pre-equipped with a class"); |
3404 if (!xk) xk = ary->ary_must_be_exact(); |
3576 if (!xk) xk = ary->ary_must_be_exact(); |
3405 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); |
3577 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); |
3406 if (!UseExactTypes) xk = (ptr == Constant); |
3578 if (!UseExactTypes) xk = (ptr == Constant); |
3407 return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false))->hashcons(); |
3579 return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false, speculative))->hashcons(); |
3408 } |
3580 } |
3409 |
3581 |
3410 //------------------------------make------------------------------------------- |
3582 //------------------------------make------------------------------------------- |
3411 const TypeAryPtr *TypeAryPtr::make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, bool is_autobox_cache) { |
3583 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) { |
3412 assert(!(k == NULL && ary->_elem->isa_int()), |
3584 assert(!(k == NULL && ary->_elem->isa_int()), |
3413 "integral arrays must be pre-equipped with a class"); |
3585 "integral arrays must be pre-equipped with a class"); |
3414 assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" ); |
3586 assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" ); |
3415 if (!xk) xk = (o != NULL) || ary->ary_must_be_exact(); |
3587 if (!xk) xk = (o != NULL) || ary->ary_must_be_exact(); |
3416 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); |
3588 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); |
3417 if (!UseExactTypes) xk = (ptr == Constant); |
3589 if (!UseExactTypes) xk = (ptr == Constant); |
3418 return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache))->hashcons(); |
3590 return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache, speculative))->hashcons(); |
3419 } |
3591 } |
3420 |
3592 |
3421 //------------------------------cast_to_ptr_type------------------------------- |
3593 //------------------------------cast_to_ptr_type------------------------------- |
3422 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const { |
3594 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const { |
3423 if( ptr == _ptr ) return this; |
3595 if( ptr == _ptr ) return this; |
3424 return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id); |
3596 return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative); |
3425 } |
3597 } |
3426 |
3598 |
3427 |
3599 |
3428 //-----------------------------cast_to_exactness------------------------------- |
3600 //-----------------------------cast_to_exactness------------------------------- |
3429 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const { |
3601 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const { |
3430 if( klass_is_exact == _klass_is_exact ) return this; |
3602 if( klass_is_exact == _klass_is_exact ) return this; |
3431 if (!UseExactTypes) return this; |
3603 if (!UseExactTypes) return this; |
3432 if (_ary->ary_must_be_exact()) return this; // cannot clear xk |
3604 if (_ary->ary_must_be_exact()) return this; // cannot clear xk |
3433 return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id); |
3605 return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative); |
3434 } |
3606 } |
3435 |
3607 |
3436 //-----------------------------cast_to_instance_id---------------------------- |
3608 //-----------------------------cast_to_instance_id---------------------------- |
3437 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const { |
3609 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const { |
3438 if( instance_id == _instance_id ) return this; |
3610 if( instance_id == _instance_id ) return this; |
3439 return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id); |
3611 return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative); |
3440 } |
3612 } |
3441 |
3613 |
3442 //-----------------------------narrow_size_type------------------------------- |
3614 //-----------------------------narrow_size_type------------------------------- |
3443 // Local cache for arrayOopDesc::max_array_length(etype), |
3615 // Local cache for arrayOopDesc::max_array_length(etype), |
3444 // which is kind of slow (and cached elsewhere by other users). |
3616 // which is kind of slow (and cached elsewhere by other users). |
3652 // 'tap' is exact and super or unrelated: |
3828 // 'tap' is exact and super or unrelated: |
3653 (tap ->_klass_is_exact && !tap->klass()->is_subtype_of(klass())) || |
3829 (tap ->_klass_is_exact && !tap->klass()->is_subtype_of(klass())) || |
3654 // 'this' is exact and super or unrelated: |
3830 // 'this' is exact and super or unrelated: |
3655 (this->_klass_is_exact && !klass()->is_subtype_of(tap->klass())))) { |
3831 (this->_klass_is_exact && !klass()->is_subtype_of(tap->klass())))) { |
3656 tary = TypeAry::make(Type::BOTTOM, tary->_size, tary->_stable); |
3832 tary = TypeAry::make(Type::BOTTOM, tary->_size, tary->_stable); |
3657 return make( NotNull, NULL, tary, lazy_klass, false, off, InstanceBot ); |
3833 return make(NotNull, NULL, tary, lazy_klass, false, off, InstanceBot); |
3658 } |
3834 } |
3659 |
3835 |
3660 bool xk = false; |
3836 bool xk = false; |
3661 switch (tap->ptr()) { |
3837 switch (tap->ptr()) { |
3662 case AnyNull: |
3838 case AnyNull: |
3663 case TopPTR: |
3839 case TopPTR: |
3664 // Compute new klass on demand, do not use tap->_klass |
3840 // Compute new klass on demand, do not use tap->_klass |
3665 xk = (tap->_klass_is_exact | this->_klass_is_exact); |
3841 if (below_centerline(this->_ptr)) { |
3666 return make( ptr, const_oop(), tary, lazy_klass, xk, off, instance_id ); |
3842 xk = this->_klass_is_exact; |
|
3843 } else { |
|
3844 xk = (tap->_klass_is_exact | this->_klass_is_exact); |
|
3845 } |
|
3846 return make(ptr, const_oop(), tary, lazy_klass, xk, off, instance_id, speculative); |
3667 case Constant: { |
3847 case Constant: { |
3668 ciObject* o = const_oop(); |
3848 ciObject* o = const_oop(); |
3669 if( _ptr == Constant ) { |
3849 if( _ptr == Constant ) { |
3670 if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) { |
3850 if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) { |
3671 xk = (klass() == tap->klass()); |
3851 xk = (klass() == tap->klass()); |
3673 o = NULL; |
3853 o = NULL; |
3674 instance_id = InstanceBot; |
3854 instance_id = InstanceBot; |
3675 } else { |
3855 } else { |
3676 xk = true; |
3856 xk = true; |
3677 } |
3857 } |
3678 } else if( above_centerline(_ptr) ) { |
3858 } else if(above_centerline(_ptr)) { |
3679 o = tap->const_oop(); |
3859 o = tap->const_oop(); |
3680 xk = true; |
3860 xk = true; |
3681 } else { |
3861 } else { |
3682 // Only precise for identical arrays |
3862 // Only precise for identical arrays |
3683 xk = this->_klass_is_exact && (klass() == tap->klass()); |
3863 xk = this->_klass_is_exact && (klass() == tap->klass()); |
3684 } |
3864 } |
3685 return TypeAryPtr::make( ptr, o, tary, lazy_klass, xk, off, instance_id ); |
3865 return TypeAryPtr::make(ptr, o, tary, lazy_klass, xk, off, instance_id, speculative); |
3686 } |
3866 } |
3687 case NotNull: |
3867 case NotNull: |
3688 case BotPTR: |
3868 case BotPTR: |
3689 // Compute new klass on demand, do not use tap->_klass |
3869 // Compute new klass on demand, do not use tap->_klass |
3690 if (above_centerline(this->_ptr)) |
3870 if (above_centerline(this->_ptr)) |
3691 xk = tap->_klass_is_exact; |
3871 xk = tap->_klass_is_exact; |
3692 else if (above_centerline(tap->_ptr)) |
|
3693 xk = this->_klass_is_exact; |
|
3694 else xk = (tap->_klass_is_exact & this->_klass_is_exact) && |
3872 else xk = (tap->_klass_is_exact & this->_klass_is_exact) && |
3695 (klass() == tap->klass()); // Only precise for identical arrays |
3873 (klass() == tap->klass()); // Only precise for identical arrays |
3696 return TypeAryPtr::make( ptr, NULL, tary, lazy_klass, xk, off, instance_id ); |
3874 return TypeAryPtr::make(ptr, NULL, tary, lazy_klass, xk, off, instance_id, speculative); |
3697 default: ShouldNotReachHere(); |
3875 default: ShouldNotReachHere(); |
3698 } |
3876 } |
3699 } |
3877 } |
3700 |
3878 |
3701 // All arrays inherit from Object class |
3879 // All arrays inherit from Object class |
3702 case InstPtr: { |
3880 case InstPtr: { |
3703 const TypeInstPtr *tp = t->is_instptr(); |
3881 const TypeInstPtr *tp = t->is_instptr(); |
3704 int offset = meet_offset(tp->offset()); |
3882 int offset = meet_offset(tp->offset()); |
3705 PTR ptr = meet_ptr(tp->ptr()); |
3883 PTR ptr = meet_ptr(tp->ptr()); |
3706 int instance_id = meet_instance_id(tp->instance_id()); |
3884 int instance_id = meet_instance_id(tp->instance_id()); |
|
3885 const TypeOopPtr* speculative = meet_speculative(tp); |
3707 switch (ptr) { |
3886 switch (ptr) { |
3708 case TopPTR: |
3887 case TopPTR: |
3709 case AnyNull: // Fall 'down' to dual of object klass |
3888 case AnyNull: // Fall 'down' to dual of object klass |
3710 if( tp->klass()->equals(ciEnv::current()->Object_klass()) ) { |
3889 // For instances when a subclass meets a superclass we fall |
3711 return TypeAryPtr::make( ptr, _ary, _klass, _klass_is_exact, offset, instance_id ); |
3890 // below the centerline when the superclass is exact. We need to |
|
3891 // do the same here. |
|
3892 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { |
|
3893 return TypeAryPtr::make(ptr, _ary, _klass, _klass_is_exact, offset, instance_id, speculative); |
3712 } else { |
3894 } else { |
3713 // cannot subclass, so the meet has to fall badly below the centerline |
3895 // cannot subclass, so the meet has to fall badly below the centerline |
3714 ptr = NotNull; |
3896 ptr = NotNull; |
3715 instance_id = InstanceBot; |
3897 instance_id = InstanceBot; |
3716 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id); |
3898 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative); |
3717 } |
3899 } |
3718 case Constant: |
3900 case Constant: |
3719 case NotNull: |
3901 case NotNull: |
3720 case BotPTR: // Fall down to object klass |
3902 case BotPTR: // Fall down to object klass |
3721 // LCA is object_klass, but if we subclass from the top we can do better |
3903 // LCA is object_klass, but if we subclass from the top we can do better |
3722 if (above_centerline(tp->ptr())) { |
3904 if (above_centerline(tp->ptr())) { |
3723 // If 'tp' is above the centerline and it is Object class |
3905 // If 'tp' is above the centerline and it is Object class |
3724 // then we can subclass in the Java class hierarchy. |
3906 // then we can subclass in the Java class hierarchy. |
3725 if( tp->klass()->equals(ciEnv::current()->Object_klass()) ) { |
3907 // For instances when a subclass meets a superclass we fall |
|
3908 // below the centerline when the superclass is exact. We need |
|
3909 // to do the same here. |
|
3910 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { |
3726 // that is, my array type is a subtype of 'tp' klass |
3911 // that is, my array type is a subtype of 'tp' klass |
3727 return make( ptr, (ptr == Constant ? const_oop() : NULL), |
3912 return make(ptr, (ptr == Constant ? const_oop() : NULL), |
3728 _ary, _klass, _klass_is_exact, offset, instance_id ); |
3913 _ary, _klass, _klass_is_exact, offset, instance_id, speculative); |
3729 } |
3914 } |
3730 } |
3915 } |
3731 // The other case cannot happen, since t cannot be a subtype of an array. |
3916 // The other case cannot happen, since t cannot be a subtype of an array. |
3732 // The meet falls down to Object class below centerline. |
3917 // The meet falls down to Object class below centerline. |
3733 if( ptr == Constant ) |
3918 if( ptr == Constant ) |
3734 ptr = NotNull; |
3919 ptr = NotNull; |
3735 instance_id = InstanceBot; |
3920 instance_id = InstanceBot; |
3736 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id); |
3921 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative); |
3737 default: typerr(t); |
3922 default: typerr(t); |
3738 } |
3923 } |
3739 } |
3924 } |
3740 } |
3925 } |
3741 return this; // Lint noise |
3926 return this; // Lint noise |
3742 } |
3927 } |
3743 |
3928 |
3744 //------------------------------xdual------------------------------------------ |
3929 //------------------------------xdual------------------------------------------ |
3745 // Dual: compute field-by-field dual |
3930 // Dual: compute field-by-field dual |
3746 const Type *TypeAryPtr::xdual() const { |
3931 const Type *TypeAryPtr::xdual() const { |
3747 return new TypeAryPtr( dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id(), is_autobox_cache() ); |
3932 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()); |
3748 } |
3933 } |
3749 |
3934 |
3750 //----------------------interface_vs_oop--------------------------------------- |
3935 //----------------------interface_vs_oop--------------------------------------- |
3751 #ifdef ASSERT |
3936 #ifdef ASSERT |
3752 bool TypeAryPtr::interface_vs_oop(const Type *t) const { |
3937 bool TypeAryPtr::interface_vs_oop(const Type *t) const { |
3794 st->print(" *"); |
3979 st->print(" *"); |
3795 if (_instance_id == InstanceTop) |
3980 if (_instance_id == InstanceTop) |
3796 st->print(",iid=top"); |
3981 st->print(",iid=top"); |
3797 else if (_instance_id != InstanceBot) |
3982 else if (_instance_id != InstanceBot) |
3798 st->print(",iid=%d",_instance_id); |
3983 st->print(",iid=%d",_instance_id); |
|
3984 |
|
3985 dump_speculative(st); |
3799 } |
3986 } |
3800 #endif |
3987 #endif |
3801 |
3988 |
3802 bool TypeAryPtr::empty(void) const { |
3989 bool TypeAryPtr::empty(void) const { |
3803 if (_ary->empty()) return true; |
3990 if (_ary->empty()) return true; |
3804 return TypeOopPtr::empty(); |
3991 return TypeOopPtr::empty(); |
3805 } |
3992 } |
3806 |
3993 |
3807 //------------------------------add_offset------------------------------------- |
3994 //------------------------------add_offset------------------------------------- |
3808 const TypePtr *TypeAryPtr::add_offset( intptr_t offset ) const { |
3995 const TypePtr *TypeAryPtr::add_offset(intptr_t offset) const { |
3809 return make( _ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id ); |
3996 return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id, add_offset_speculative(offset)); |
3810 } |
3997 } |
3811 |
3998 |
|
3999 const TypeOopPtr *TypeAryPtr::remove_speculative() const { |
|
4000 return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, _offset, _instance_id, NULL); |
|
4001 } |
3812 |
4002 |
3813 //============================================================================= |
4003 //============================================================================= |
3814 |
4004 |
3815 //------------------------------hash------------------------------------------- |
4005 //------------------------------hash------------------------------------------- |
3816 // Type-specific hashing function. |
4006 // Type-specific hashing function. |