hotspot/src/share/vm/opto/type.cpp
changeset 21099 46e6bbecd9e5
parent 20289 35d78de0c547
child 21105 47618ee96ed5
equal deleted inserted replaced
21098:1820670a3362 21099:46e6bbecd9e5
   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 );
   575   return false;
   575   return false;
   576 }
   576 }
   577 
   577 
   578 //----------------------interface_vs_oop---------------------------------------
   578 //----------------------interface_vs_oop---------------------------------------
   579 #ifdef ASSERT
   579 #ifdef ASSERT
   580 bool Type::interface_vs_oop(const Type *t) const {
   580 bool Type::interface_vs_oop_helper(const Type *t) const {
   581   bool result = false;
   581   bool result = false;
   582 
   582 
   583   const TypePtr* this_ptr = this->make_ptr(); // In case it is narrow_oop
   583   const TypePtr* this_ptr = this->make_ptr(); // In case it is narrow_oop
   584   const TypePtr*    t_ptr =    t->make_ptr();
   584   const TypePtr*    t_ptr =    t->make_ptr();
   585   if( this_ptr == NULL || t_ptr == NULL )
   585   if( this_ptr == NULL || t_ptr == NULL )
   593     result = this_interface ^ t_interface;
   593     result = this_interface ^ t_interface;
   594   }
   594   }
   595 
   595 
   596   return result;
   596   return result;
   597 }
   597 }
       
   598 
       
   599 bool Type::interface_vs_oop(const Type *t) const {
       
   600   if (interface_vs_oop_helper(t)) {
       
   601     return true;
       
   602   }
       
   603   // Now check the speculative parts as well
       
   604   const TypeOopPtr* this_spec = isa_oopptr() != NULL ? isa_oopptr()->speculative() : NULL;
       
   605   const TypeOopPtr* t_spec = t->isa_oopptr() != NULL ? t->isa_oopptr()->speculative() : NULL;
       
   606   if (this_spec != NULL && t_spec != NULL) {
       
   607     if (this_spec->interface_vs_oop_helper(t_spec)) {
       
   608       return true;
       
   609     }
       
   610     return false;
       
   611   }
       
   612   if (this_spec != NULL && this_spec->interface_vs_oop_helper(t)) {
       
   613     return true;
       
   614   }
       
   615   if (t_spec != NULL && interface_vs_oop_helper(t_spec)) {
       
   616     return true;
       
   617   }
       
   618   return false;
       
   619 }
       
   620 
   598 #endif
   621 #endif
   599 
   622 
   600 //------------------------------meet-------------------------------------------
   623 //------------------------------meet-------------------------------------------
   601 // Compute the MEET of two types.  NOT virtual.  It enforces that meet is
   624 // Compute the MEET of two types.  NOT virtual.  It enforces that meet is
   602 // commutative and the lattice is symmetric.
   625 // commutative and the lattice is symmetric.
  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
  2567       if (ptr == Null)  return TypePtr::make(AnyPtr, ptr, offset);
  2612       if (ptr == Null)  return TypePtr::make(AnyPtr, ptr, offset);
  2568       // else fall through:
  2613       // else fall through:
  2569     case TopPTR:
  2614     case TopPTR:
  2570     case AnyNull: {
  2615     case AnyNull: {
  2571       int instance_id = meet_instance_id(InstanceTop);
  2616       int instance_id = meet_instance_id(InstanceTop);
  2572       return make(ptr, offset, instance_id);
  2617       const TypeOopPtr* speculative = _speculative;
       
  2618       return make(ptr, offset, instance_id, speculative);
  2573     }
  2619     }
  2574     case BotPTR:
  2620     case BotPTR:
  2575     case NotNull:
  2621     case NotNull:
  2576       return TypePtr::make(AnyPtr, ptr, offset);
  2622       return TypePtr::make(AnyPtr, ptr, offset);
  2577     default: typerr(t);
  2623     default: typerr(t);
  2579   }
  2625   }
  2580 
  2626 
  2581   case OopPtr: {                 // Meeting to other OopPtrs
  2627   case OopPtr: {                 // Meeting to other OopPtrs
  2582     const TypeOopPtr *tp = t->is_oopptr();
  2628     const TypeOopPtr *tp = t->is_oopptr();
  2583     int instance_id = meet_instance_id(tp->instance_id());
  2629     int instance_id = meet_instance_id(tp->instance_id());
  2584     return make( meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id );
  2630     const TypeOopPtr* speculative = meet_speculative(tp);
       
  2631     return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative);
  2585   }
  2632   }
  2586 
  2633 
  2587   case InstPtr:                  // For these, flip the call around to cut down
  2634   case InstPtr:                  // For these, flip the call around to cut down
  2588   case AryPtr:
  2635   case AryPtr:
  2589     return t->xmeet(this);      // Call in reverse direction
  2636     return t->xmeet(this);      // Call in reverse direction
  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) {
  2687     if (require_constant) {
  2734     if (require_constant) {
  2688       if (!o->can_be_constant())  return NULL;
  2735       if (!o->can_be_constant())  return NULL;
  2689     } else if (!o->should_be_constant()) {
  2736     } else if (!o->should_be_constant()) {
  2690       return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
  2737       return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
  2691     }
  2738     }
  2692     const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, is_autobox_cache);
  2739     const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, NULL, is_autobox_cache);
  2693     return arr;
  2740     return arr;
  2694   } else if (klass->is_type_array_klass()) {
  2741   } else if (klass->is_type_array_klass()) {
  2695     // Element is an typeArray
  2742     // Element is an typeArray
  2696     const Type* etype =
  2743     const Type* etype =
  2697       (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type());
  2744       (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type());
  2787 //------------------------------eq---------------------------------------------
  2834 //------------------------------eq---------------------------------------------
  2788 // Structural equality check for Type representations
  2835 // Structural equality check for Type representations
  2789 bool TypeOopPtr::eq( const Type *t ) const {
  2836 bool TypeOopPtr::eq( const Type *t ) const {
  2790   const TypeOopPtr *a = (const TypeOopPtr*)t;
  2837   const TypeOopPtr *a = (const TypeOopPtr*)t;
  2791   if (_klass_is_exact != a->_klass_is_exact ||
  2838   if (_klass_is_exact != a->_klass_is_exact ||
  2792       _instance_id != a->_instance_id)  return false;
  2839       _instance_id != a->_instance_id ||
       
  2840       !eq_speculative(a))  return false;
  2793   ciObject* one = const_oop();
  2841   ciObject* one = const_oop();
  2794   ciObject* two = a->const_oop();
  2842   ciObject* two = a->const_oop();
  2795   if (one == NULL || two == NULL) {
  2843   if (one == NULL || two == NULL) {
  2796     return (one == two) && TypePtr::eq(t);
  2844     return (one == two) && TypePtr::eq(t);
  2797   } else {
  2845   } else {
  2804 int TypeOopPtr::hash(void) const {
  2852 int TypeOopPtr::hash(void) const {
  2805   return
  2853   return
  2806     (const_oop() ? const_oop()->hash() : 0) +
  2854     (const_oop() ? const_oop()->hash() : 0) +
  2807     _klass_is_exact +
  2855     _klass_is_exact +
  2808     _instance_id +
  2856     _instance_id +
       
  2857     hash_speculative() +
  2809     TypePtr::hash();
  2858     TypePtr::hash();
  2810 }
  2859 }
  2811 
  2860 
  2812 //------------------------------dump2------------------------------------------
  2861 //------------------------------dump2------------------------------------------
  2813 #ifndef PRODUCT
  2862 #ifndef PRODUCT
  2823   }
  2872   }
  2824   if (_instance_id == InstanceTop)
  2873   if (_instance_id == InstanceTop)
  2825     st->print(",iid=top");
  2874     st->print(",iid=top");
  2826   else if (_instance_id != InstanceBot)
  2875   else if (_instance_id != InstanceBot)
  2827     st->print(",iid=%d",_instance_id);
  2876     st->print(",iid=%d",_instance_id);
       
  2877 
       
  2878   dump_speculative(st);
       
  2879 }
       
  2880 
       
  2881 /**
       
  2882  *dump the speculative part of the type
       
  2883  */
       
  2884 void TypeOopPtr::dump_speculative(outputStream *st) const {
       
  2885   if (_speculative != NULL) {
       
  2886     st->print(" (speculative=");
       
  2887     _speculative->dump_on(st);
       
  2888     st->print(")");
       
  2889   }
  2828 }
  2890 }
  2829 #endif
  2891 #endif
  2830 
  2892 
  2831 //------------------------------singleton--------------------------------------
  2893 //------------------------------singleton--------------------------------------
  2832 // TRUE if Type is a singleton type, FALSE otherwise.   Singletons are simple
  2894 // TRUE if Type is a singleton type, FALSE otherwise.   Singletons are simple
  2836   // TopPTR, Null, AnyNull, Constant are all singletons
  2898   // TopPTR, Null, AnyNull, Constant are all singletons
  2837   return (_offset == 0) && !below_centerline(_ptr);
  2899   return (_offset == 0) && !below_centerline(_ptr);
  2838 }
  2900 }
  2839 
  2901 
  2840 //------------------------------add_offset-------------------------------------
  2902 //------------------------------add_offset-------------------------------------
  2841 const TypePtr *TypeOopPtr::add_offset( intptr_t offset ) const {
  2903 const TypePtr *TypeOopPtr::add_offset(intptr_t offset) const {
  2842   return make( _ptr, xadd_offset(offset), _instance_id);
  2904   return make(_ptr, xadd_offset(offset), _instance_id, add_offset_speculative(offset));
       
  2905 }
       
  2906 
       
  2907 /**
       
  2908  * Return same type without a speculative part
       
  2909  */
       
  2910 const TypeOopPtr* TypeOopPtr::remove_speculative() const {
       
  2911   return make(_ptr, _offset, _instance_id, NULL);
  2843 }
  2912 }
  2844 
  2913 
  2845 //------------------------------meet_instance_id--------------------------------
  2914 //------------------------------meet_instance_id--------------------------------
  2846 int TypeOopPtr::meet_instance_id( int instance_id ) const {
  2915 int TypeOopPtr::meet_instance_id( int instance_id ) const {
  2847   // Either is 'TOP' instance?  Return the other instance!
  2916   // Either is 'TOP' instance?  Return the other instance!
  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 
  2880 const TypeInstPtr *TypeInstPtr::make(PTR ptr,
  3032 const TypeInstPtr *TypeInstPtr::make(PTR ptr,
  2881                                      ciKlass* k,
  3033                                      ciKlass* k,
  2882                                      bool xk,
  3034                                      bool xk,
  2883                                      ciObject* o,
  3035                                      ciObject* o,
  2884                                      int offset,
  3036                                      int offset,
  2885                                      int instance_id) {
  3037                                      int instance_id,
       
  3038                                      const TypeOopPtr* speculative) {
  2886   assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance");
  3039   assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance");
  2887   // Either const_oop() is NULL or else ptr is Constant
  3040   // Either const_oop() is NULL or else ptr is Constant
  2888   assert( (!o && ptr != Constant) || (o && ptr == Constant),
  3041   assert( (!o && ptr != Constant) || (o && ptr == Constant),
  2889           "constant pointers must have a value supplied" );
  3042           "constant pointers must have a value supplied" );
  2890   // Ptr is never Null
  3043   // Ptr is never Null
  2901     if (xk && ik->is_interface())  xk = false;  // no exact interface
  3054     if (xk && ik->is_interface())  xk = false;  // no exact interface
  2902   }
  3055   }
  2903 
  3056 
  2904   // Now hash this baby
  3057   // Now hash this baby
  2905   TypeInstPtr *result =
  3058   TypeInstPtr *result =
  2906     (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id))->hashcons();
  3059     (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id, speculative))->hashcons();
  2907 
  3060 
  2908   return result;
  3061   return result;
  2909 }
  3062 }
  2910 
  3063 
  2911 /**
  3064 /**
  2934 //------------------------------cast_to_ptr_type-------------------------------
  3087 //------------------------------cast_to_ptr_type-------------------------------
  2935 const Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const {
  3088 const Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const {
  2936   if( ptr == _ptr ) return this;
  3089   if( ptr == _ptr ) return this;
  2937   // Reconstruct _sig info here since not a problem with later lazy
  3090   // Reconstruct _sig info here since not a problem with later lazy
  2938   // construction, _sig will show up on demand.
  3091   // construction, _sig will show up on demand.
  2939   return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id);
  3092   return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative);
  2940 }
  3093 }
  2941 
  3094 
  2942 
  3095 
  2943 //-----------------------------cast_to_exactness-------------------------------
  3096 //-----------------------------cast_to_exactness-------------------------------
  2944 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const {
  3097 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const {
  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       //
  2982       //  BOTTOM  | ........................Object-BOTTOM ..................|
  3136       //  BOTTOM  | ........................Object-BOTTOM ..................|
  2983       //
  3137       //
  2984       assert(loaded->ptr() != TypePtr::Null, "insanity check");
  3138       assert(loaded->ptr() != TypePtr::Null, "insanity check");
  2985       //
  3139       //
  2986       if(      loaded->ptr() == TypePtr::TopPTR ) { return unloaded; }
  3140       if(      loaded->ptr() == TypePtr::TopPTR ) { return unloaded; }
  2987       else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make( ptr, unloaded->klass(), false, NULL, off, instance_id ); }
  3141       else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make(ptr, unloaded->klass(), false, NULL, off, instance_id, speculative); }
  2988       else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; }
  3142       else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; }
  2989       else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) {
  3143       else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) {
  2990         if (unloaded->ptr() == TypePtr::BotPTR  ) { return TypeInstPtr::BOTTOM;  }
  3144         if (unloaded->ptr() == TypePtr::BotPTR  ) { return TypeInstPtr::BOTTOM;  }
  2991         else                                      { return TypeInstPtr::NOTNULL; }
  3145         else                                      { return TypeInstPtr::NOTNULL; }
  2992       }
  3146       }
  3004 }
  3158 }
  3005 
  3159 
  3006 
  3160 
  3007 //------------------------------meet-------------------------------------------
  3161 //------------------------------meet-------------------------------------------
  3008 // Compute the MEET of two types.  It returns a new Type object.
  3162 // Compute the MEET of two types.  It returns a new Type object.
  3009 const Type *TypeInstPtr::xmeet( const Type *t ) const {
  3163 const Type *TypeInstPtr::xmeet_helper(const Type *t) const {
  3010   // Perform a fast test for common case; meeting the same types together.
  3164   // Perform a fast test for common case; meeting the same types together.
  3011   if( this == t ) return this;  // Meeting same type-rep?
  3165   if( this == t ) return this;  // Meeting same type-rep?
  3012 
  3166 
  3013   // Current "this->_base" is Pointer
  3167   // Current "this->_base" is Pointer
  3014   switch (t->base()) {          // switch on original type
  3168   switch (t->base()) {          // switch on original type
  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
  3081     PTR ptr = meet_ptr(tp->ptr());
  3242     PTR ptr = meet_ptr(tp->ptr());
  3082     switch (tp->ptr()) {
  3243     switch (tp->ptr()) {
  3083     case TopPTR:
  3244     case TopPTR:
  3084     case AnyNull: {
  3245     case AnyNull: {
  3085       int instance_id = meet_instance_id(InstanceTop);
  3246       int instance_id = meet_instance_id(InstanceTop);
       
  3247       const TypeOopPtr* speculative = meet_speculative(tp);
  3086       return make(ptr, klass(), klass_is_exact(),
  3248       return make(ptr, klass(), klass_is_exact(),
  3087                   (ptr == Constant ? const_oop() : NULL), offset, instance_id);
  3249                   (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative);
  3088     }
  3250     }
  3089     case NotNull:
  3251     case NotNull:
  3090     case BotPTR: {
  3252     case BotPTR: {
  3091       int instance_id = meet_instance_id(tp->instance_id());
  3253       int instance_id = meet_instance_id(tp->instance_id());
  3092       return TypeOopPtr::make(ptr, offset, instance_id);
  3254       const TypeOopPtr* speculative = meet_speculative(tp);
       
  3255       return TypeOopPtr::make(ptr, offset, instance_id, speculative);
  3093     }
  3256     }
  3094     default: typerr(t);
  3257     default: typerr(t);
  3095     }
  3258     }
  3096   }
  3259   }
  3097 
  3260 
  3100     const TypePtr *tp = t->is_ptr();
  3263     const TypePtr *tp = t->is_ptr();
  3101     int offset = meet_offset(tp->offset());
  3264     int offset = meet_offset(tp->offset());
  3102     PTR ptr = meet_ptr(tp->ptr());
  3265     PTR ptr = meet_ptr(tp->ptr());
  3103     switch (tp->ptr()) {
  3266     switch (tp->ptr()) {
  3104     case Null:
  3267     case Null:
  3105       if( ptr == Null ) return TypePtr::make( AnyPtr, ptr, offset );
  3268       if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset);
  3106       // else fall through to AnyNull
  3269       // else fall through to AnyNull
  3107     case TopPTR:
  3270     case TopPTR:
  3108     case AnyNull: {
  3271     case AnyNull: {
  3109       int instance_id = meet_instance_id(InstanceTop);
  3272       int instance_id = meet_instance_id(InstanceTop);
  3110       return make( ptr, klass(), klass_is_exact(),
  3273       const TypeOopPtr* speculative = _speculative;
  3111                    (ptr == Constant ? const_oop() : NULL), offset, instance_id);
  3274       return make(ptr, klass(), klass_is_exact(),
       
  3275                   (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative);
  3112     }
  3276     }
  3113     case NotNull:
  3277     case NotNull:
  3114     case BotPTR:
  3278     case BotPTR:
  3115       return TypePtr::make( AnyPtr, ptr, offset );
  3279       return TypePtr::make(AnyPtr, ptr, offset);
  3116     default: typerr(t);
  3280     default: typerr(t);
  3117     }
  3281     }
  3118   }
  3282   }
  3119 
  3283 
  3120   /*
  3284   /*
  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();
  3165 #endif
  3330 #endif
  3166       return unloaded_meet;
  3331       return unloaded_meet;
  3167     }
  3332     }
  3168 
  3333 
  3169     // Handle mixing oops and interfaces first.
  3334     // Handle mixing oops and interfaces first.
  3170     if( this_klass->is_interface() && !tinst_klass->is_interface() ) {
  3335     if( this_klass->is_interface() && !(tinst_klass->is_interface() ||
       
  3336                                         tinst_klass == ciEnv::current()->Object_klass())) {
  3171       ciKlass *tmp = tinst_klass; // Swap interface around
  3337       ciKlass *tmp = tinst_klass; // Swap interface around
  3172       tinst_klass = this_klass;
  3338       tinst_klass = this_klass;
  3173       this_klass = tmp;
  3339       this_klass = tmp;
  3174       bool tmp2 = tinst_xk;
  3340       bool tmp2 = tinst_xk;
  3175       tinst_xk = this_xk;
  3341       tinst_xk = this_xk;
  3206       ciObject* o = NULL;  // the Constant value, if any
  3372       ciObject* o = NULL;  // the Constant value, if any
  3207       if (ptr == Constant) {
  3373       if (ptr == Constant) {
  3208         // Find out which constant.
  3374         // Find out which constant.
  3209         o = (this_klass == klass()) ? const_oop() : tinst->const_oop();
  3375         o = (this_klass == klass()) ? const_oop() : tinst->const_oop();
  3210       }
  3376       }
  3211       return make( ptr, k, xk, o, off, instance_id );
  3377       return make(ptr, k, xk, o, off, instance_id, speculative);
  3212     }
  3378     }
  3213 
  3379 
  3214     // Either oop vs oop or interface vs interface or interface vs Object
  3380     // Either oop vs oop or interface vs interface or interface vs Object
  3215 
  3381 
  3216     // !!! Here's how the symmetry requirement breaks down into invariants:
  3382     // !!! Here's how the symmetry requirement breaks down into invariants:
  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 }
  3318 
  3484 
  3319 //------------------------------xdual------------------------------------------
  3485 //------------------------------xdual------------------------------------------
  3320 // Dual: do NOT dual on klasses.  This means I do NOT understand the Java
  3486 // Dual: do NOT dual on klasses.  This means I do NOT understand the Java
  3321 // inheritance mechanism.
  3487 // inheritance mechanism.
  3322 const Type *TypeInstPtr::xdual() const {
  3488 const Type *TypeInstPtr::xdual() const {
  3323   return new TypeInstPtr( dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id()  );
  3489   return new TypeInstPtr(dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative());
  3324 }
  3490 }
  3325 
  3491 
  3326 //------------------------------eq---------------------------------------------
  3492 //------------------------------eq---------------------------------------------
  3327 // Structural equality check for Type representations
  3493 // Structural equality check for Type representations
  3328 bool TypeInstPtr::eq( const Type *t ) const {
  3494 bool TypeInstPtr::eq( const Type *t ) const {
  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).
  3497 const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const {
  3669 const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const {
  3498   assert(new_size != NULL, "");
  3670   assert(new_size != NULL, "");
  3499   new_size = narrow_size_type(new_size);
  3671   new_size = narrow_size_type(new_size);
  3500   if (new_size == size())  return this;
  3672   if (new_size == size())  return this;
  3501   const TypeAry* new_ary = TypeAry::make(elem(), new_size, is_stable());
  3673   const TypeAry* new_ary = TypeAry::make(elem(), new_size, is_stable());
  3502   return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id);
  3674   return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative);
  3503 }
  3675 }
  3504 
  3676 
  3505 
  3677 
  3506 //------------------------------cast_to_stable---------------------------------
  3678 //------------------------------cast_to_stable---------------------------------
  3507 const TypeAryPtr* TypeAryPtr::cast_to_stable(bool stable, int stable_dimension) const {
  3679 const TypeAryPtr* TypeAryPtr::cast_to_stable(bool stable, int stable_dimension) const {
  3546   return (intptr_t)_ary + TypeOopPtr::hash();
  3718   return (intptr_t)_ary + TypeOopPtr::hash();
  3547 }
  3719 }
  3548 
  3720 
  3549 //------------------------------meet-------------------------------------------
  3721 //------------------------------meet-------------------------------------------
  3550 // Compute the MEET of two types.  It returns a new Type object.
  3722 // Compute the MEET of two types.  It returns a new Type object.
  3551 const Type *TypeAryPtr::xmeet( const Type *t ) const {
  3723 const Type *TypeAryPtr::xmeet_helper(const Type *t) const {
  3552   // Perform a fast test for common case; meeting the same types together.
  3724   // Perform a fast test for common case; meeting the same types together.
  3553   if( this == t ) return this;  // Meeting same type-rep?
  3725   if( this == t ) return this;  // Meeting same type-rep?
  3554   // Current "this->_base" is Pointer
  3726   // Current "this->_base" is Pointer
  3555   switch (t->base()) {          // switch on original type
  3727   switch (t->base()) {          // switch on original type
  3556 
  3728 
  3580     PTR ptr = meet_ptr(tp->ptr());
  3752     PTR ptr = meet_ptr(tp->ptr());
  3581     switch (tp->ptr()) {
  3753     switch (tp->ptr()) {
  3582     case TopPTR:
  3754     case TopPTR:
  3583     case AnyNull: {
  3755     case AnyNull: {
  3584       int instance_id = meet_instance_id(InstanceTop);
  3756       int instance_id = meet_instance_id(InstanceTop);
       
  3757       const TypeOopPtr* speculative = meet_speculative(tp);
  3585       return make(ptr, (ptr == Constant ? const_oop() : NULL),
  3758       return make(ptr, (ptr == Constant ? const_oop() : NULL),
  3586                   _ary, _klass, _klass_is_exact, offset, instance_id);
  3759                   _ary, _klass, _klass_is_exact, offset, instance_id, speculative);
  3587     }
  3760     }
  3588     case BotPTR:
  3761     case BotPTR:
  3589     case NotNull: {
  3762     case NotNull: {
  3590       int instance_id = meet_instance_id(tp->instance_id());
  3763       int instance_id = meet_instance_id(tp->instance_id());
  3591       return TypeOopPtr::make(ptr, offset, instance_id);
  3764       const TypeOopPtr* speculative = meet_speculative(tp);
       
  3765       return TypeOopPtr::make(ptr, offset, instance_id, speculative);
  3592     }
  3766     }
  3593     default: ShouldNotReachHere();
  3767     default: ShouldNotReachHere();
  3594     }
  3768     }
  3595   }
  3769   }
  3596 
  3770 
  3608     case Null:
  3782     case Null:
  3609       if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset);
  3783       if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset);
  3610       // else fall through to AnyNull
  3784       // else fall through to AnyNull
  3611     case AnyNull: {
  3785     case AnyNull: {
  3612       int instance_id = meet_instance_id(InstanceTop);
  3786       int instance_id = meet_instance_id(InstanceTop);
  3613       return make( ptr, (ptr == Constant ? const_oop() : NULL),
  3787       const TypeOopPtr* speculative = _speculative;
  3614                   _ary, _klass, _klass_is_exact, offset, instance_id);
  3788       return make(ptr, (ptr == Constant ? const_oop() : NULL),
       
  3789                   _ary, _klass, _klass_is_exact, offset, instance_id, speculative);
  3615     }
  3790     }
  3616     default: ShouldNotReachHere();
  3791     default: ShouldNotReachHere();
  3617     }
  3792     }
  3618   }
  3793   }
  3619 
  3794 
  3625     const TypeAryPtr *tap = t->is_aryptr();
  3800     const TypeAryPtr *tap = t->is_aryptr();
  3626     int off = meet_offset(tap->offset());
  3801     int off = meet_offset(tap->offset());
  3627     const TypeAry *tary = _ary->meet(tap->_ary)->is_ary();
  3802     const TypeAry *tary = _ary->meet(tap->_ary)->is_ary();
  3628     PTR ptr = meet_ptr(tap->ptr());
  3803     PTR ptr = meet_ptr(tap->ptr());
  3629     int instance_id = meet_instance_id(tap->instance_id());
  3804     int instance_id = meet_instance_id(tap->instance_id());
       
  3805     const TypeOopPtr* speculative = meet_speculative(tap);
  3630     ciKlass* lazy_klass = NULL;
  3806     ciKlass* lazy_klass = NULL;
  3631     if (tary->_elem->isa_int()) {
  3807     if (tary->_elem->isa_int()) {
  3632       // Integral array element types have irrelevant lattice relations.
  3808       // Integral array element types have irrelevant lattice relations.
  3633       // It is the klass that determines array layout, not the element type.
  3809       // It is the klass that determines array layout, not the element type.
  3634       if (_klass == NULL)
  3810       if (_klass == NULL)
  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.