2219 BasicType basic_elem_type = field->layout_type();
2220 _is_ptr_to_narrowoop = (basic_elem_type == T_OBJECT ||
2221 basic_elem_type == T_ARRAY);
2222 } else if (klass()->equals(ciEnv::current()->Object_klass())) {
2223 // Compile::find_alias_type() cast exactness on all types to verify
2224 // that it does not affect alias type.
2225 _is_ptr_to_narrowoop = true;
2226 } else {
2227 // Type for the copy start in LibraryCallKit::inline_native_clone().
2228 assert(!klass_is_exact(), "only non-exact klass");
2229 _is_ptr_to_narrowoop = true;
2230 }
2231 }
2232 }
2233 }
2234 #endif
2235 }
2236
2237 //------------------------------make-------------------------------------------
2238 const TypeOopPtr *TypeOopPtr::make(PTR ptr,
2239 int offset) {
2240 assert(ptr != Constant, "no constant generic pointers");
2241 ciKlass* k = ciKlassKlass::make();
2242 bool xk = false;
2243 ciObject* o = NULL;
2244 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, InstanceBot))->hashcons();
2245 }
2246
2247
2248 //------------------------------cast_to_ptr_type-------------------------------
2249 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const {
2250 assert(_base == OopPtr, "subclass must override cast_to_ptr_type");
2251 if( ptr == _ptr ) return this;
2252 return make(ptr, _offset);
2253 }
2254
2255 //-----------------------------cast_to_instance_id----------------------------
2256 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const {
2257 // There are no instances of a general oop.
2258 // Return self unchanged.
2259 return this;
2260 }
2261
2262 //-----------------------------cast_to_exactness-------------------------------
2263 const Type *TypeOopPtr::cast_to_exactness(bool klass_is_exact) const {
2264 // There is no such thing as an exact general oop.
2313 // Found an AnyPtr type vs self-OopPtr type
2314 const TypePtr *tp = t->is_ptr();
2315 int offset = meet_offset(tp->offset());
2316 PTR ptr = meet_ptr(tp->ptr());
2317 switch (tp->ptr()) {
2318 case Null:
2319 if (ptr == Null) return TypePtr::make(AnyPtr, ptr, offset);
2320 // else fall through:
2321 case TopPTR:
2322 case AnyNull:
2323 return make(ptr, offset);
2324 case BotPTR:
2325 case NotNull:
2326 return TypePtr::make(AnyPtr, ptr, offset);
2327 default: typerr(t);
2328 }
2329 }
2330
2331 case OopPtr: { // Meeting to other OopPtrs
2332 const TypeOopPtr *tp = t->is_oopptr();
2333 return make( meet_ptr(tp->ptr()), meet_offset(tp->offset()) );
2334 }
2335
2336 case InstPtr: // For these, flip the call around to cut down
2337 case KlassPtr: // on the cases I have to handle.
2338 case AryPtr:
2339 return t->xmeet(this); // Call in reverse direction
2340
2341 } // End of switch
2342 return this; // Return the double constant
2343 }
2344
2345
2346 //------------------------------xdual------------------------------------------
2347 // Dual of a pure heap pointer. No relevant klass or oop information.
2348 const Type *TypeOopPtr::xdual() const {
2349 assert(klass() == ciKlassKlass::make(), "no klasses here");
2350 assert(const_oop() == NULL, "no constants here");
2351 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id() );
2352 }
2353
2784 if( above_centerline(_ptr) ) { // if( _ptr == TopPTR || _ptr == AnyNull )
2785 // If 'this' (InstPtr) is above the centerline and it is Object class
2786 // then we can subclass in the Java class hierarchy.
2787 if (klass()->equals(ciEnv::current()->Object_klass())) {
2788 // that is, tp's array type is a subtype of my klass
2789 return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id);
2790 }
2791 }
2792 // The other case cannot happen, since I cannot be a subtype of an array.
2793 // The meet falls down to Object class below centerline.
2794 if( ptr == Constant )
2795 ptr = NotNull;
2796 instance_id = InstanceBot;
2797 return make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id );
2798 default: typerr(t);
2799 }
2800 }
2801
2802 case OopPtr: { // Meeting to OopPtrs
2803 // Found a OopPtr type vs self-InstPtr type
2804 const TypePtr *tp = t->is_oopptr();
2805 int offset = meet_offset(tp->offset());
2806 PTR ptr = meet_ptr(tp->ptr());
2807 switch (tp->ptr()) {
2808 case TopPTR:
2809 case AnyNull: {
2810 int instance_id = meet_instance_id(InstanceTop);
2811 return make(ptr, klass(), klass_is_exact(),
2812 (ptr == Constant ? const_oop() : NULL), offset, instance_id);
2813 }
2814 case NotNull:
2815 case BotPTR:
2816 return TypeOopPtr::make(ptr, offset);
2817 default: typerr(t);
2818 }
2819 }
2820
2821 case AnyPtr: { // Meeting to AnyPtrs
2822 // Found an AnyPtr type vs self-InstPtr type
2823 const TypePtr *tp = t->is_ptr();
2824 int offset = meet_offset(tp->offset());
2825 PTR ptr = meet_ptr(tp->ptr());
2826 switch (tp->ptr()) {
2827 case Null:
2828 if( ptr == Null ) return TypePtr::make( AnyPtr, ptr, offset );
2829 // else fall through to AnyNull
2830 case TopPTR:
2831 case AnyNull: {
2832 int instance_id = meet_instance_id(InstanceTop);
2833 return make( ptr, klass(), klass_is_exact(),
2834 (ptr == Constant ? const_oop() : NULL), offset, instance_id);
2835 }
2836 case NotNull:
3242 // Mixing ints & oops happens when javac reuses local variables
3243 case Int:
3244 case Long:
3245 case FloatTop:
3246 case FloatCon:
3247 case FloatBot:
3248 case DoubleTop:
3249 case DoubleCon:
3250 case DoubleBot:
3251 case NarrowOop:
3252 case Bottom: // Ye Olde Default
3253 return Type::BOTTOM;
3254 case Top:
3255 return this;
3256
3257 default: // All else is a mistake
3258 typerr(t);
3259
3260 case OopPtr: { // Meeting to OopPtrs
3261 // Found a OopPtr type vs self-AryPtr type
3262 const TypePtr *tp = t->is_oopptr();
3263 int offset = meet_offset(tp->offset());
3264 PTR ptr = meet_ptr(tp->ptr());
3265 switch (tp->ptr()) {
3266 case TopPTR:
3267 case AnyNull: {
3268 int instance_id = meet_instance_id(InstanceTop);
3269 return make(ptr, (ptr == Constant ? const_oop() : NULL),
3270 _ary, _klass, _klass_is_exact, offset, instance_id);
3271 }
3272 case BotPTR:
3273 case NotNull:
3274 return TypeOopPtr::make(ptr, offset);
3275 default: ShouldNotReachHere();
3276 }
3277 }
3278
3279 case AnyPtr: { // Meeting two AnyPtrs
3280 // Found an AnyPtr type vs self-AryPtr type
3281 const TypePtr *tp = t->is_ptr();
3282 int offset = meet_offset(tp->offset());
3283 PTR ptr = meet_ptr(tp->ptr());
3284 switch (tp->ptr()) {
3285 case TopPTR:
3286 return this;
3287 case BotPTR:
3288 case NotNull:
3289 return TypePtr::make(AnyPtr, ptr, offset);
3290 case Null:
3291 if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset);
3292 // else fall through to AnyNull
3293 case AnyNull: {
3294 int instance_id = meet_instance_id(InstanceTop);
|
2219 BasicType basic_elem_type = field->layout_type();
2220 _is_ptr_to_narrowoop = (basic_elem_type == T_OBJECT ||
2221 basic_elem_type == T_ARRAY);
2222 } else if (klass()->equals(ciEnv::current()->Object_klass())) {
2223 // Compile::find_alias_type() cast exactness on all types to verify
2224 // that it does not affect alias type.
2225 _is_ptr_to_narrowoop = true;
2226 } else {
2227 // Type for the copy start in LibraryCallKit::inline_native_clone().
2228 assert(!klass_is_exact(), "only non-exact klass");
2229 _is_ptr_to_narrowoop = true;
2230 }
2231 }
2232 }
2233 }
2234 #endif
2235 }
2236
2237 //------------------------------make-------------------------------------------
2238 const TypeOopPtr *TypeOopPtr::make(PTR ptr,
2239 int offset, int instance_id) {
2240 assert(ptr != Constant, "no constant generic pointers");
2241 ciKlass* k = ciKlassKlass::make();
2242 bool xk = false;
2243 ciObject* o = NULL;
2244 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id))->hashcons();
2245 }
2246
2247
2248 //------------------------------cast_to_ptr_type-------------------------------
2249 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const {
2250 assert(_base == OopPtr, "subclass must override cast_to_ptr_type");
2251 if( ptr == _ptr ) return this;
2252 return make(ptr, _offset);
2253 }
2254
2255 //-----------------------------cast_to_instance_id----------------------------
2256 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const {
2257 // There are no instances of a general oop.
2258 // Return self unchanged.
2259 return this;
2260 }
2261
2262 //-----------------------------cast_to_exactness-------------------------------
2263 const Type *TypeOopPtr::cast_to_exactness(bool klass_is_exact) const {
2264 // There is no such thing as an exact general oop.
2313 // Found an AnyPtr type vs self-OopPtr type
2314 const TypePtr *tp = t->is_ptr();
2315 int offset = meet_offset(tp->offset());
2316 PTR ptr = meet_ptr(tp->ptr());
2317 switch (tp->ptr()) {
2318 case Null:
2319 if (ptr == Null) return TypePtr::make(AnyPtr, ptr, offset);
2320 // else fall through:
2321 case TopPTR:
2322 case AnyNull:
2323 return make(ptr, offset);
2324 case BotPTR:
2325 case NotNull:
2326 return TypePtr::make(AnyPtr, ptr, offset);
2327 default: typerr(t);
2328 }
2329 }
2330
2331 case OopPtr: { // Meeting to other OopPtrs
2332 const TypeOopPtr *tp = t->is_oopptr();
2333 int instance_id = meet_instance_id(tp->instance_id());
2334 return make( meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id );
2335 }
2336
2337 case InstPtr: // For these, flip the call around to cut down
2338 case KlassPtr: // on the cases I have to handle.
2339 case AryPtr:
2340 return t->xmeet(this); // Call in reverse direction
2341
2342 } // End of switch
2343 return this; // Return the double constant
2344 }
2345
2346
2347 //------------------------------xdual------------------------------------------
2348 // Dual of a pure heap pointer. No relevant klass or oop information.
2349 const Type *TypeOopPtr::xdual() const {
2350 assert(klass() == ciKlassKlass::make(), "no klasses here");
2351 assert(const_oop() == NULL, "no constants here");
2352 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id() );
2353 }
2354
2785 if( above_centerline(_ptr) ) { // if( _ptr == TopPTR || _ptr == AnyNull )
2786 // If 'this' (InstPtr) is above the centerline and it is Object class
2787 // then we can subclass in the Java class hierarchy.
2788 if (klass()->equals(ciEnv::current()->Object_klass())) {
2789 // that is, tp's array type is a subtype of my klass
2790 return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id);
2791 }
2792 }
2793 // The other case cannot happen, since I cannot be a subtype of an array.
2794 // The meet falls down to Object class below centerline.
2795 if( ptr == Constant )
2796 ptr = NotNull;
2797 instance_id = InstanceBot;
2798 return make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id );
2799 default: typerr(t);
2800 }
2801 }
2802
2803 case OopPtr: { // Meeting to OopPtrs
2804 // Found a OopPtr type vs self-InstPtr type
2805 const TypeOopPtr *tp = t->is_oopptr();
2806 int offset = meet_offset(tp->offset());
2807 PTR ptr = meet_ptr(tp->ptr());
2808 switch (tp->ptr()) {
2809 case TopPTR:
2810 case AnyNull: {
2811 int instance_id = meet_instance_id(InstanceTop);
2812 return make(ptr, klass(), klass_is_exact(),
2813 (ptr == Constant ? const_oop() : NULL), offset, instance_id);
2814 }
2815 case NotNull:
2816 case BotPTR: {
2817 int instance_id = meet_instance_id(tp->instance_id());
2818 return TypeOopPtr::make(ptr, offset, instance_id);
2819 }
2820 default: typerr(t);
2821 }
2822 }
2823
2824 case AnyPtr: { // Meeting to AnyPtrs
2825 // Found an AnyPtr type vs self-InstPtr type
2826 const TypePtr *tp = t->is_ptr();
2827 int offset = meet_offset(tp->offset());
2828 PTR ptr = meet_ptr(tp->ptr());
2829 switch (tp->ptr()) {
2830 case Null:
2831 if( ptr == Null ) return TypePtr::make( AnyPtr, ptr, offset );
2832 // else fall through to AnyNull
2833 case TopPTR:
2834 case AnyNull: {
2835 int instance_id = meet_instance_id(InstanceTop);
2836 return make( ptr, klass(), klass_is_exact(),
2837 (ptr == Constant ? const_oop() : NULL), offset, instance_id);
2838 }
2839 case NotNull:
3245 // Mixing ints & oops happens when javac reuses local variables
3246 case Int:
3247 case Long:
3248 case FloatTop:
3249 case FloatCon:
3250 case FloatBot:
3251 case DoubleTop:
3252 case DoubleCon:
3253 case DoubleBot:
3254 case NarrowOop:
3255 case Bottom: // Ye Olde Default
3256 return Type::BOTTOM;
3257 case Top:
3258 return this;
3259
3260 default: // All else is a mistake
3261 typerr(t);
3262
3263 case OopPtr: { // Meeting to OopPtrs
3264 // Found a OopPtr type vs self-AryPtr type
3265 const TypeOopPtr *tp = t->is_oopptr();
3266 int offset = meet_offset(tp->offset());
3267 PTR ptr = meet_ptr(tp->ptr());
3268 switch (tp->ptr()) {
3269 case TopPTR:
3270 case AnyNull: {
3271 int instance_id = meet_instance_id(InstanceTop);
3272 return make(ptr, (ptr == Constant ? const_oop() : NULL),
3273 _ary, _klass, _klass_is_exact, offset, instance_id);
3274 }
3275 case BotPTR:
3276 case NotNull: {
3277 int instance_id = meet_instance_id(tp->instance_id());
3278 return TypeOopPtr::make(ptr, offset, instance_id);
3279 }
3280 default: ShouldNotReachHere();
3281 }
3282 }
3283
3284 case AnyPtr: { // Meeting two AnyPtrs
3285 // Found an AnyPtr type vs self-AryPtr type
3286 const TypePtr *tp = t->is_ptr();
3287 int offset = meet_offset(tp->offset());
3288 PTR ptr = meet_ptr(tp->ptr());
3289 switch (tp->ptr()) {
3290 case TopPTR:
3291 return this;
3292 case BotPTR:
3293 case NotNull:
3294 return TypePtr::make(AnyPtr, ptr, offset);
3295 case Null:
3296 if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset);
3297 // else fall through to AnyNull
3298 case AnyNull: {
3299 int instance_id = meet_instance_id(InstanceTop);
|