< prev index next >

src/hotspot/share/opto/type.hpp

Print this page

   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_OPTO_TYPE_HPP
  26 #define SHARE_OPTO_TYPE_HPP
  27 

  28 #include "opto/adlcVMDeps.hpp"
  29 #include "runtime/handles.hpp"

  30 
  31 // Portions of code courtesy of Clifford Click
  32 
  33 // Optimization - Graph Style
  34 
  35 
  36 // This class defines a Type lattice.  The lattice is used in the constant
  37 // propagation algorithms, and for some type-checking of the iloc code.
  38 // Basic types include RSD's (lower bound, upper bound, stride for integers),
  39 // float & double precision constants, sets of data-labels and code-labels.
  40 // The complete lattice is described below.  Subtypes have no relationship to
  41 // up or down in the lattice; that is entirely determined by the behavior of
  42 // the MEET/JOIN functions.
  43 
  44 class Dict;
  45 class Type;
  46 class   TypeD;
  47 class   TypeF;
  48 class   TypeH;
  49 class   TypeInteger;

 122     Memory,                     // Abstract store
 123     HalfFloatTop,               // No float value
 124     HalfFloatCon,               // Floating point constant
 125     HalfFloatBot,               // Any float value
 126     FloatTop,                   // No float value
 127     FloatCon,                   // Floating point constant
 128     FloatBot,                   // Any float value
 129     DoubleTop,                  // No double value
 130     DoubleCon,                  // Double precision constant
 131     DoubleBot,                  // Any double value
 132     Bottom,                     // Bottom of lattice
 133     lastype                     // Bogus ending type (not in lattice)
 134   };
 135 
 136   // Signal values for offsets from a base pointer
 137   enum OFFSET_SIGNALS {
 138     OffsetTop = -2000000000,    // undefined offset
 139     OffsetBot = -2000000001     // any possible offset
 140   };
 141 
























 142   // Min and max WIDEN values.
 143   enum WIDEN {
 144     WidenMin = 0,
 145     WidenMax = 3
 146   };
 147 
 148 private:
 149   typedef struct {
 150     TYPES                dual_type;
 151     BasicType            basic_type;
 152     const char*          msg;
 153     bool                 isa_oop;
 154     uint                 ideal_reg;
 155     relocInfo::relocType reloc;
 156   } TypeInfo;
 157 
 158   // Dictionary of types shared among compilations.
 159   static Dict* _shared_type_dict;
 160   static const TypeInfo _type_info[];
 161 

 319   const TypeInstPtr  *isa_instptr() const;       // Returns null if not InstPtr
 320   const TypeInstPtr  *is_instptr() const;        // Instance
 321   const TypeAryPtr   *isa_aryptr() const;        // Returns null if not AryPtr
 322   const TypeAryPtr   *is_aryptr() const;         // Array oop
 323 
 324   template <typename TypeClass>
 325   const TypeClass* cast() const;
 326 
 327   const TypeMetadataPtr   *isa_metadataptr() const;   // Returns null if not oop ptr type
 328   const TypeMetadataPtr   *is_metadataptr() const;    // Java-style GC'd pointer
 329   const TypeKlassPtr      *isa_klassptr() const;      // Returns null if not KlassPtr
 330   const TypeKlassPtr      *is_klassptr() const;       // assert if not KlassPtr
 331   const TypeInstKlassPtr  *isa_instklassptr() const;  // Returns null if not IntKlassPtr
 332   const TypeInstKlassPtr  *is_instklassptr() const;   // assert if not IntKlassPtr
 333   const TypeAryKlassPtr   *isa_aryklassptr() const;   // Returns null if not AryKlassPtr
 334   const TypeAryKlassPtr   *is_aryklassptr() const;    // assert if not AryKlassPtr
 335 
 336   virtual bool      is_finite() const;           // Has a finite value
 337   virtual bool      is_nan()    const;           // Is not a number (NaN)
 338 



 339   // Returns this ptr type or the equivalent ptr type for this compressed pointer.
 340   const TypePtr* make_ptr() const;
 341 
 342   // Returns this oopptr type or the equivalent oopptr type for this compressed pointer.
 343   // Asserts if the underlying type is not an oopptr or narrowoop.
 344   const TypeOopPtr* make_oopptr() const;
 345 
 346   // Returns this compressed pointer or the equivalent compressed version
 347   // of this pointer type.
 348   const TypeNarrowOop* make_narrowoop() const;
 349 
 350   // Returns this compressed klass pointer or the equivalent
 351   // compressed version of this pointer type.
 352   const TypeNarrowKlass* make_narrowklass() const;
 353 
 354   // Special test for register pressure heuristic
 355   bool is_floatingpoint() const;        // True if Float or Double base type
 356 
 357   // Do you have memory, directly or through a tuple?
 358   bool has_memory( ) const;

 750   const Type ** const _fields;           // Array of field types
 751 
 752 public:
 753   virtual bool eq( const Type *t ) const;
 754   virtual uint hash() const;             // Type specific hashing
 755   virtual bool singleton(void) const;    // TRUE if type is a singleton
 756   virtual bool empty(void) const;        // TRUE if type is vacuous
 757 
 758   // Accessors:
 759   uint cnt() const { return _cnt; }
 760   const Type* field_at(uint i) const {
 761     assert(i < _cnt, "oob");
 762     return _fields[i];
 763   }
 764   void set_field_at(uint i, const Type* t) {
 765     assert(i < _cnt, "oob");
 766     _fields[i] = t;
 767   }
 768 
 769   static const TypeTuple *make( uint cnt, const Type **fields );
 770   static const TypeTuple *make_range(ciSignature *sig, InterfaceHandling interface_handling = ignore_interfaces);
 771   static const TypeTuple *make_domain(ciInstanceKlass* recv, ciSignature *sig, InterfaceHandling interface_handling);
 772 
 773   // Subroutine call type with space allocated for argument types
 774   // Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly
 775   static const Type **fields( uint arg_cnt );
 776 
 777   virtual const Type *xmeet( const Type *t ) const;
 778   virtual const Type *xdual() const;    // Compute dual right now.
 779   // Convenience common pre-built types.
 780   static const TypeTuple *IFBOTH;
 781   static const TypeTuple *IFFALSE;
 782   static const TypeTuple *IFTRUE;
 783   static const TypeTuple *IFNEITHER;
 784   static const TypeTuple *LOOPBODY;
 785   static const TypeTuple *MEMBAR;
 786   static const TypeTuple *STORECONDITIONAL;
 787   static const TypeTuple *START_I2C;
 788   static const TypeTuple *INT_PAIR;
 789   static const TypeTuple *LONG_PAIR;
 790   static const TypeTuple *INT_CC_PAIR;
 791   static const TypeTuple *LONG_CC_PAIR;
 792 #ifndef PRODUCT
 793   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 794 #endif
 795 };
 796 
 797 //------------------------------TypeAry----------------------------------------
 798 // Class of Array Types
 799 class TypeAry : public Type {
 800   TypeAry(const Type* elem, const TypeInt* size, bool stable) : Type(Array),
 801       _elem(elem), _size(size), _stable(stable) {}
 802 public:
 803   virtual bool eq( const Type *t ) const;
 804   virtual uint hash() const;             // Type specific hashing
 805   virtual bool singleton(void) const;    // TRUE if type is a singleton
 806   virtual bool empty(void) const;        // TRUE if type is vacuous
 807 
 808 private:
 809   const Type *_elem;            // Element type of array
 810   const TypeInt *_size;         // Elements in array
 811   const bool _stable;           // Are elements @Stable?






 812   friend class TypeAryPtr;
 813 
 814 public:
 815   static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false);

 816 
 817   virtual const Type *xmeet( const Type *t ) const;
 818   virtual const Type *xdual() const;    // Compute dual right now.
 819   bool ary_must_be_exact() const;  // true if arrays of such are never generic
 820   virtual const TypeAry* remove_speculative() const;
 821   virtual const Type* cleanup_speculative() const;
 822 #ifndef PRODUCT
 823   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 824 #endif
 825 };
 826 
 827 //------------------------------TypeVect---------------------------------------
 828 // Class of Vector Types
 829 class TypeVect : public Type {
 830   const BasicType _elem_bt;  // Vector's element type
 831   const uint _length;  // Elements in vector (power of 2)
 832 
 833 protected:
 834   TypeVect(TYPES t, BasicType elem_bt, uint length) : Type(t),
 835     _elem_bt(elem_bt), _length(length) {}

 941 
 942   const Type* xmeet(const Type* t) const;
 943 
 944   bool singleton(void) const;
 945 };
 946 
 947 //------------------------------TypePtr----------------------------------------
 948 // Class of machine Pointer Types: raw data, instances or arrays.
 949 // If the _base enum is AnyPtr, then this refers to all of the above.
 950 // Otherwise the _base will indicate which subset of pointers is affected,
 951 // and the class will be inherited from.
 952 class TypePtr : public Type {
 953   friend class TypeNarrowPtr;
 954   friend class Type;
 955 protected:
 956   static const TypeInterfaces* interfaces(ciKlass*& k, bool klass, bool interface, bool array, InterfaceHandling interface_handling);
 957 
 958 public:
 959   enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
 960 protected:
 961   TypePtr(TYPES t, PTR ptr, int offset,
 962           const TypePtr* speculative = nullptr,
 963           int inline_depth = InlineDepthBottom) :
 964     Type(t), _speculative(speculative), _inline_depth(inline_depth), _offset(offset),
 965     _ptr(ptr) {}
 966   static const PTR ptr_meet[lastPTR][lastPTR];
 967   static const PTR ptr_dual[lastPTR];
 968   static const char * const ptr_msg[lastPTR];
 969 
 970   enum {
 971     InlineDepthBottom = INT_MAX,
 972     InlineDepthTop = -InlineDepthBottom
 973   };
 974 
 975   // Extra type information profiling gave us. We propagate it the
 976   // same way the rest of the type info is propagated. If we want to
 977   // use it, then we have to emit a guard: this part of the type is
 978   // not something we know but something we speculate about the type.
 979   const TypePtr*   _speculative;
 980   // For speculative types, we record at what inlining depth the
 981   // profiling point that provided the data is. We want to favor

 997   // utility methods to work on the inline depth of the type
 998   int dual_inline_depth() const;
 999   int meet_inline_depth(int depth) const;
1000 #ifndef PRODUCT
1001   void dump_inline_depth(outputStream *st) const;
1002 #endif
1003 
1004   // TypeInstPtr (TypeAryPtr resp.) and TypeInstKlassPtr (TypeAryKlassPtr resp.) implement very similar meet logic.
1005   // The logic for meeting 2 instances (2 arrays resp.) is shared in the 2 utility methods below. However the logic for
1006   // the oop and klass versions can be slightly different and extra logic may have to be executed depending on what
1007   // exact case the meet falls into. The MeetResult struct is used by the utility methods to communicate what case was
1008   // encountered so the right logic specific to klasses or oops can be executed.,
1009   enum MeetResult {
1010     QUICK,
1011     UNLOADED,
1012     SUBTYPE,
1013     NOT_SUBTYPE,
1014     LCA
1015   };
1016   template<class T> static TypePtr::MeetResult meet_instptr(PTR& ptr, const TypeInterfaces*& interfaces, const T* this_type,
1017                                                             const T* other_type, ciKlass*& res_klass, bool& res_xk);



1018 
1019   template<class T> static MeetResult meet_aryptr(PTR& ptr, const Type*& elem, const T* this_ary, const T* other_ary,
1020                                                   ciKlass*& res_klass, bool& res_xk);
1021 
1022   template <class T1, class T2> static bool is_java_subtype_of_helper_for_instance(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1023   template <class T1, class T2> static bool is_same_java_type_as_helper_for_instance(const T1* this_one, const T2* other);
1024   template <class T1, class T2> static bool maybe_java_subtype_of_helper_for_instance(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1025   template <class T1, class T2> static bool is_java_subtype_of_helper_for_array(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1026   template <class T1, class T2> static bool is_same_java_type_as_helper_for_array(const T1* this_one, const T2* other);
1027   template <class T1, class T2> static bool maybe_java_subtype_of_helper_for_array(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1028   template <class T1, class T2> static bool is_meet_subtype_of_helper_for_instance(const T1* this_one, const T2* other, bool this_xk, bool other_xk);
1029   template <class T1, class T2> static bool is_meet_subtype_of_helper_for_array(const T1* this_one, const T2* other, bool this_xk, bool other_xk);
1030 public:
1031   const int _offset;            // Offset into oop, with TOP & BOT
1032   const PTR _ptr;               // Pointer equivalence class
1033 
1034   int offset() const { return _offset; }
1035   PTR ptr()    const { return _ptr; }
1036 
1037   static const TypePtr *make(TYPES t, PTR ptr, int offset,
1038                              const TypePtr* speculative = nullptr,
1039                              int inline_depth = InlineDepthBottom);
1040 
1041   // Return a 'ptr' version of this type
1042   virtual const TypePtr* cast_to_ptr_type(PTR ptr) const;
1043 
1044   virtual intptr_t get_con() const;
1045 
1046   int xadd_offset( intptr_t offset ) const;
1047   virtual const TypePtr* add_offset(intptr_t offset) const;
1048   virtual const TypePtr* with_offset(intptr_t offset) const;

1049   virtual bool eq(const Type *t) const;
1050   virtual uint hash() const;             // Type specific hashing
1051 
1052   virtual bool singleton(void) const;    // TRUE if type is a singleton
1053   virtual bool empty(void) const;        // TRUE if type is vacuous
1054   virtual const Type *xmeet( const Type *t ) const;
1055   virtual const Type *xmeet_helper( const Type *t ) const;
1056   int meet_offset( int offset ) const;
1057   int dual_offset( ) const;
1058   virtual const Type *xdual() const;    // Compute dual right now.
1059 
1060   // meet, dual and join over pointer equivalence sets
1061   PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
1062   PTR dual_ptr()                   const { return ptr_dual[ptr()];      }
1063 
1064   // This is textually confusing unless one recalls that
1065   // join(t) == dual()->meet(t->dual())->dual().
1066   PTR join_ptr( const PTR in_ptr ) const {
1067     return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
1068   }
1069 
1070   // Speculative type helper methods.
1071   virtual const TypePtr* speculative() const { return _speculative; }
1072   int inline_depth() const                   { return _inline_depth; }
1073   virtual ciKlass* speculative_type() const;
1074   virtual ciKlass* speculative_type_not_null() const;
1075   virtual bool speculative_maybe_null() const;
1076   virtual bool speculative_always_null() const;
1077   virtual const TypePtr* remove_speculative() const;
1078   virtual const Type* cleanup_speculative() const;
1079   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1080   virtual bool would_improve_ptr(ProfilePtrKind maybe_null) const;
1081   virtual const TypePtr* with_inline_depth(int depth) const;
1082 
1083   virtual bool maybe_null() const { return meet_ptr(Null) == ptr(); }
1084 








1085   // Tests for relation to centerline of type lattice:
1086   static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
1087   static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
1088   // Convenience common pre-built types.
1089   static const TypePtr *NULL_PTR;
1090   static const TypePtr *NOTNULL;
1091   static const TypePtr *BOTTOM;
1092 #ifndef PRODUCT
1093   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1094 #endif
1095 };
1096 
1097 //------------------------------TypeRawPtr-------------------------------------
1098 // Class of raw pointers, pointers to things other than Oops.  Examples
1099 // include the stack pointer, top of heap, card-marking area, handles, etc.
1100 class TypeRawPtr : public TypePtr {
1101 protected:
1102   TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){}
1103 public:
1104   virtual bool eq( const Type *t ) const;
1105   virtual uint hash() const;    // Type specific hashing
1106 
1107   const address _bits;          // Constant value, if applicable
1108 
1109   static const TypeRawPtr *make( PTR ptr );
1110   static const TypeRawPtr *make( address bits );
1111 
1112   // Return a 'ptr' version of this type
1113   virtual const TypeRawPtr* cast_to_ptr_type(PTR ptr) const;
1114 
1115   virtual intptr_t get_con() const;
1116 
1117   virtual const TypePtr* add_offset(intptr_t offset) const;
1118   virtual const TypeRawPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr;}
1119 
1120   virtual const Type *xmeet( const Type *t ) const;
1121   virtual const Type *xdual() const;    // Compute dual right now.
1122   // Convenience common pre-built types.
1123   static const TypeRawPtr *BOTTOM;
1124   static const TypeRawPtr *NOTNULL;
1125 #ifndef PRODUCT
1126   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1127 #endif
1128 };
1129 
1130 //------------------------------TypeOopPtr-------------------------------------
1131 // Some kind of oop (Java pointer), either instance or array.
1132 class TypeOopPtr : public TypePtr {
1133   friend class TypeAry;
1134   friend class TypePtr;
1135   friend class TypeInstPtr;
1136   friend class TypeAryPtr;
1137 protected:
1138  TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, int offset, int instance_id,
1139             const TypePtr* speculative, int inline_depth);
1140 public:
1141   virtual bool eq( const Type *t ) const;
1142   virtual uint hash() const;             // Type specific hashing
1143   virtual bool singleton(void) const;    // TRUE if type is a singleton
1144   enum {
1145    InstanceTop = -1,   // undefined instance
1146    InstanceBot = 0     // any possible instance
1147   };
1148 protected:
1149 
1150   // Oop is null, unless this is a constant oop.
1151   ciObject*     _const_oop;   // Constant oop
1152   // If _klass is null, then so is _sig.  This is an unloaded klass.
1153   ciKlass*      _klass;       // Klass object
1154 
1155   const TypeInterfaces* _interfaces;
1156 
1157   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
1158   bool          _klass_is_exact;
1159   bool          _is_ptr_to_narrowoop;
1160   bool          _is_ptr_to_narrowklass;
1161   bool          _is_ptr_to_boxed_value;
1162 
1163   // If not InstanceTop or InstanceBot, indicates that this is
1164   // a particular instance of this type which is distinct.
1165   // This is the node index of the allocation node creating this instance.
1166   int           _instance_id;
1167 
1168   static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact, InterfaceHandling interface_handling);
1169 
1170   int dual_instance_id() const;
1171   int meet_instance_id(int uid) const;
1172 
1173   const TypeInterfaces* meet_interfaces(const TypeOopPtr* other) const;
1174 
1175   // Do not allow interface-vs.-noninterface joins to collapse to top.
1176   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1177 
1178   virtual ciKlass* exact_klass_helper() const { return nullptr; }
1179   virtual ciKlass* klass() const { return _klass;     }
1180 
1181 public:
1182 
1183   bool is_java_subtype_of(const TypeOopPtr* other) const {
1184     return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1185   }
1186 
1187   bool is_same_java_type_as(const TypePtr* other) const {
1188     return is_same_java_type_as_helper(other->is_oopptr());
1189   }
1190 
1191   virtual bool is_same_java_type_as_helper(const TypeOopPtr* other) const {
1192     ShouldNotReachHere(); return false;
1193   }
1194 
1195   bool maybe_java_subtype_of(const TypeOopPtr* other) const {
1196     return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1197   }
1198   virtual bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1199   virtual bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }

1206     return make_from_klass_common(klass, true, false, interface_handling);
1207   }
1208   // Same as before, but will produce an exact type, even if
1209   // the klass is not final, as long as it has exactly one implementation.
1210   static const TypeOopPtr* make_from_klass_unique(ciKlass* klass, InterfaceHandling interface_handling= ignore_interfaces) {
1211     return make_from_klass_common(klass, true, true, interface_handling);
1212   }
1213   // Same as before, but does not respects UseUniqueSubclasses.
1214   // Use this only for creating array element types.
1215   static const TypeOopPtr* make_from_klass_raw(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1216     return make_from_klass_common(klass, false, false, interface_handling);
1217   }
1218   // Creates a singleton type given an object.
1219   // If the object cannot be rendered as a constant,
1220   // may return a non-singleton type.
1221   // If require_constant, produce a null if a singleton is not possible.
1222   static const TypeOopPtr* make_from_constant(ciObject* o,
1223                                               bool require_constant = false);
1224 
1225   // Make a generic (unclassed) pointer to an oop.
1226   static const TypeOopPtr* make(PTR ptr, int offset, int instance_id,
1227                                 const TypePtr* speculative = nullptr,
1228                                 int inline_depth = InlineDepthBottom);
1229 
1230   ciObject* const_oop()    const { return _const_oop; }
1231   // Exact klass, possibly an interface or an array of interface
1232   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k;  }
1233   ciKlass* unloaded_klass() const { assert(!is_loaded(), "only for unloaded types"); return klass(); }
1234 
1235   virtual bool  is_loaded() const { return klass()->is_loaded(); }
1236   virtual bool klass_is_exact()    const { return _klass_is_exact; }
1237 
1238   // Returns true if this pointer points at memory which contains a
1239   // compressed oop references.
1240   bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
1241   bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
1242   bool is_ptr_to_boxed_value()   const { return _is_ptr_to_boxed_value; }
1243   bool is_known_instance()       const { return _instance_id > 0; }
1244   int  instance_id()             const { return _instance_id; }
1245   bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }



1246 
1247   virtual intptr_t get_con() const;
1248 
1249   virtual const TypeOopPtr* cast_to_ptr_type(PTR ptr) const;
1250 
1251   virtual const TypeOopPtr* cast_to_exactness(bool klass_is_exact) const;
1252 
1253   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1254 
1255   // corresponding pointer to klass, for a given instance
1256   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1257 
1258   virtual const TypeOopPtr* with_offset(intptr_t offset) const;
1259   virtual const TypePtr* add_offset(intptr_t offset) const;
1260 
1261   // Speculative type helper methods.
1262   virtual const TypeOopPtr* remove_speculative() const;
1263   virtual const Type* cleanup_speculative() const;
1264   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1265   virtual const TypePtr* with_inline_depth(int depth) const;

1288     return _interfaces;
1289   };
1290 
1291   const TypeOopPtr* is_reference_type(const Type* other) const {
1292     return other->isa_oopptr();
1293   }
1294 
1295   const TypeAryPtr* is_array_type(const TypeOopPtr* other) const {
1296     return other->isa_aryptr();
1297   }
1298 
1299   const TypeInstPtr* is_instance_type(const TypeOopPtr* other) const {
1300     return other->isa_instptr();
1301   }
1302 };
1303 
1304 //------------------------------TypeInstPtr------------------------------------
1305 // Class of Java object pointers, pointing either to non-array Java instances
1306 // or to a Klass* (including array klasses).
1307 class TypeInstPtr : public TypeOopPtr {
1308   TypeInstPtr(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, int off, int instance_id,
1309               const TypePtr* speculative, int inline_depth);

1310   virtual bool eq( const Type *t ) const;
1311   virtual uint hash() const;             // Type specific hashing
1312 
1313   ciKlass* exact_klass_helper() const;
1314 
1315 public:
1316 
1317   // Instance klass, ignoring any interface
1318   ciInstanceKlass* instance_klass() const {
1319     assert(!(klass()->is_loaded() && klass()->is_interface()), "");
1320     return klass()->as_instance_klass();
1321   }
1322 
1323   bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1324   bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1325   bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1326 
1327   // Make a pointer to a constant oop.
1328   static const TypeInstPtr *make(ciObject* o) {
1329     ciKlass* k = o->klass();
1330     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1331     return make(TypePtr::Constant, k, interfaces, true, o, 0, InstanceBot);
1332   }
1333   // Make a pointer to a constant oop with offset.
1334   static const TypeInstPtr *make(ciObject* o, int offset) {
1335     ciKlass* k = o->klass();
1336     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1337     return make(TypePtr::Constant, k, interfaces, true, o, offset, InstanceBot);
1338   }
1339 
1340   // Make a pointer to some value of type klass.
1341   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1342     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, true, false, interface_handling);
1343     return make(ptr, klass, interfaces, false, nullptr, 0, InstanceBot);
1344   }
1345 
1346   // Make a pointer to some non-polymorphic value of exactly type klass.
1347   static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
1348     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1349     return make(ptr, klass, interfaces, true, nullptr, 0, InstanceBot);
1350   }
1351 
1352   // Make a pointer to some value of type klass with offset.
1353   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
1354     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1355     return make(ptr, klass, interfaces, false, nullptr, offset, InstanceBot);
1356   }
1357 
1358   static const TypeInstPtr *make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, int offset,


1359                                  int instance_id = InstanceBot,
1360                                  const TypePtr* speculative = nullptr,
1361                                  int inline_depth = InlineDepthBottom);
1362 
1363   static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot) {
1364     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1365     return make(ptr, k, interfaces, xk, o, offset, instance_id);
1366   }
1367 
1368   /** Create constant type for a constant boxed value */
1369   const Type* get_const_boxed_value() const;
1370 
1371   // If this is a java.lang.Class constant, return the type for it or null.
1372   // Pass to Type::get_const_type to turn it to a type, which will usually
1373   // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
1374   ciType* java_mirror_type() const;
1375 
1376   virtual const TypeInstPtr* cast_to_ptr_type(PTR ptr) const;
1377 
1378   virtual const TypeInstPtr* cast_to_exactness(bool klass_is_exact) const;
1379 
1380   virtual const TypeInstPtr* cast_to_instance_id(int instance_id) const;
1381 
1382   virtual const TypePtr* add_offset(intptr_t offset) const;
1383   virtual const TypeInstPtr* with_offset(intptr_t offset) const;
1384 
1385   // Speculative type helper methods.
1386   virtual const TypeInstPtr* remove_speculative() const;
1387   const TypeInstPtr* with_speculative(const TypePtr* speculative) const;
1388   virtual const TypePtr* with_inline_depth(int depth) const;
1389   virtual const TypePtr* with_instance_id(int instance_id) const;
1390 




1391   // the core of the computation of the meet of 2 types
1392   virtual const Type *xmeet_helper(const Type *t) const;
1393   virtual const TypeInstPtr *xmeet_unloaded(const TypeInstPtr *tinst, const TypeInterfaces* interfaces) const;
1394   virtual const Type *xdual() const;    // Compute dual right now.
1395 
1396   const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1397 


1398   // Convenience common pre-built types.
1399   static const TypeInstPtr *NOTNULL;
1400   static const TypeInstPtr *BOTTOM;
1401   static const TypeInstPtr *MIRROR;
1402   static const TypeInstPtr *MARK;
1403   static const TypeInstPtr *KLASS;
1404 #ifndef PRODUCT
1405   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1406 #endif
1407 
1408 private:
1409   virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1410 
1411   virtual bool is_meet_same_type_as(const TypePtr* other) const {
1412     return _klass->equals(other->is_instptr()->_klass) && _interfaces->eq(other->is_instptr()->_interfaces);
1413   }
1414 
1415 };
1416 
1417 //------------------------------TypeAryPtr-------------------------------------
1418 // Class of Java array pointers
1419 class TypeAryPtr : public TypeOopPtr {
1420   friend class Type;
1421   friend class TypePtr;

1422 
1423   TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1424               int offset, int instance_id, bool is_autobox_cache,
1425               const TypePtr* speculative, int inline_depth)
1426     : TypeOopPtr(AryPtr,ptr,k,_array_interfaces,xk,o,offset, instance_id, speculative, inline_depth),
1427     _ary(ary),
1428     _is_autobox_cache(is_autobox_cache)

1429  {
1430     int dummy;
1431     bool top_or_bottom = (base_element_type(dummy) == Type::TOP || base_element_type(dummy) == Type::BOTTOM);
1432 
1433     if (UseCompressedOops && (elem()->make_oopptr() != nullptr && !top_or_bottom) &&
1434         _offset != 0 && _offset != arrayOopDesc::length_offset_in_bytes() &&
1435         _offset != arrayOopDesc::klass_offset_in_bytes()) {
1436       _is_ptr_to_narrowoop = true;
1437     }
1438 
1439   }
1440   virtual bool eq( const Type *t ) const;
1441   virtual uint hash() const;    // Type specific hashing
1442   const TypeAry *_ary;          // Array we point into
1443   const bool     _is_autobox_cache;






1444 
1445   ciKlass* compute_klass() const;
1446 
1447   // A pointer to delay allocation to Type::Initialize_shared()
1448 
1449   static const TypeInterfaces* _array_interfaces;
1450   ciKlass* exact_klass_helper() const;
1451   // Only guaranteed non null for array of basic types
1452   ciKlass* klass() const;
1453 
1454 public:
1455 
1456   bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1457   bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1458   bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1459 
1460   // returns base element type, an instance klass (and not interface) for object arrays
1461   const Type* base_element_type(int& dims) const;
1462 
1463   // Accessors
1464   bool  is_loaded() const { return (_ary->_elem->make_oopptr() ? _ary->_elem->make_oopptr()->is_loaded() : true); }
1465 
1466   const TypeAry* ary() const  { return _ary; }
1467   const Type*    elem() const { return _ary->_elem; }
1468   const TypeInt* size() const { return _ary->_size; }
1469   bool      is_stable() const { return _ary->_stable; }
1470 






1471   bool is_autobox_cache() const { return _is_autobox_cache; }
1472 
1473   static const TypeAryPtr *make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset,

1474                                 int instance_id = InstanceBot,
1475                                 const TypePtr* speculative = nullptr,
1476                                 int inline_depth = InlineDepthBottom);
1477   // Constant pointer to array
1478   static const TypeAryPtr *make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset,

1479                                 int instance_id = InstanceBot,
1480                                 const TypePtr* speculative = nullptr,
1481                                 int inline_depth = InlineDepthBottom, bool is_autobox_cache = false);

1482 
1483   // Return a 'ptr' version of this type
1484   virtual const TypeAryPtr* cast_to_ptr_type(PTR ptr) const;
1485 
1486   virtual const TypeAryPtr* cast_to_exactness(bool klass_is_exact) const;
1487 
1488   virtual const TypeAryPtr* cast_to_instance_id(int instance_id) const;
1489 
1490   virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1491   virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1492 
1493   virtual bool empty(void) const;        // TRUE if type is vacuous
1494   virtual const TypePtr *add_offset( intptr_t offset ) const;
1495   virtual const TypeAryPtr *with_offset( intptr_t offset ) const;
1496   const TypeAryPtr* with_ary(const TypeAry* ary) const;
1497 
1498   // Speculative type helper methods.
1499   virtual const TypeAryPtr* remove_speculative() const;

1500   virtual const TypePtr* with_inline_depth(int depth) const;
1501   virtual const TypePtr* with_instance_id(int instance_id) const;
1502 
1503   // the core of the computation of the meet of 2 types
1504   virtual const Type *xmeet_helper(const Type *t) const;
1505   virtual const Type *xdual() const;    // Compute dual right now.
1506 








1507   const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1508   int stable_dimension() const;
1509 
1510   const TypeAryPtr* cast_to_autobox_cache() const;
1511 
1512   static jint max_array_length(BasicType etype) ;







1513   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1514 


1515   // Convenience common pre-built types.
1516   static const TypeAryPtr* BOTTOM;
1517   static const TypeAryPtr* RANGE;
1518   static const TypeAryPtr* OOPS;
1519   static const TypeAryPtr* NARROWOOPS;
1520   static const TypeAryPtr* BYTES;
1521   static const TypeAryPtr* SHORTS;
1522   static const TypeAryPtr* CHARS;
1523   static const TypeAryPtr* INTS;
1524   static const TypeAryPtr* LONGS;
1525   static const TypeAryPtr* FLOATS;
1526   static const TypeAryPtr* DOUBLES;

1527   // selects one of the above:
1528   static const TypeAryPtr *get_array_body_type(BasicType elem) {
1529     assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != nullptr, "bad elem type");
1530     return _array_body_type[elem];
1531   }
1532   static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1533   // sharpen the type of an int which is used as an array size
1534 #ifndef PRODUCT
1535   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1536 #endif
1537 private:
1538   virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1539 };
1540 
1541 //------------------------------TypeMetadataPtr-------------------------------------
1542 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
1543 class TypeMetadataPtr : public TypePtr {
1544 protected:
1545   TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset);
1546   // Do not allow interface-vs.-noninterface joins to collapse to top.
1547   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1548 public:
1549   virtual bool eq( const Type *t ) const;
1550   virtual uint hash() const;             // Type specific hashing
1551   virtual bool singleton(void) const;    // TRUE if type is a singleton
1552 
1553 private:
1554   ciMetadata*   _metadata;
1555 
1556 public:
1557   static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, int offset);
1558 
1559   static const TypeMetadataPtr* make(ciMethod* m);
1560   static const TypeMetadataPtr* make(ciMethodData* m);
1561 
1562   ciMetadata* metadata() const { return _metadata; }
1563 
1564   virtual const TypeMetadataPtr* cast_to_ptr_type(PTR ptr) const;
1565 
1566   virtual const TypePtr *add_offset( intptr_t offset ) const;
1567 
1568   virtual const Type *xmeet( const Type *t ) const;
1569   virtual const Type *xdual() const;    // Compute dual right now.
1570 
1571   virtual intptr_t get_con() const;
1572 
1573   // Convenience common pre-built types.
1574   static const TypeMetadataPtr *BOTTOM;
1575 
1576 #ifndef PRODUCT
1577   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1578 #endif
1579 };
1580 
1581 //------------------------------TypeKlassPtr-----------------------------------
1582 // Class of Java Klass pointers
1583 class TypeKlassPtr : public TypePtr {
1584   friend class TypeInstKlassPtr;
1585   friend class TypeAryKlassPtr;
1586   friend class TypePtr;
1587 protected:
1588   TypeKlassPtr(TYPES t, PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, int offset);
1589 
1590   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1591 
1592 public:
1593   virtual bool eq( const Type *t ) const;
1594   virtual uint hash() const;
1595   virtual bool singleton(void) const;    // TRUE if type is a singleton
1596 
1597 protected:
1598 
1599   ciKlass* _klass;
1600   const TypeInterfaces* _interfaces;
1601   const TypeInterfaces* meet_interfaces(const TypeKlassPtr* other) const;
1602   virtual bool must_be_exact() const { ShouldNotReachHere(); return false; }
1603   virtual ciKlass* exact_klass_helper() const;
1604   virtual ciKlass* klass() const { return  _klass; }
1605 
1606 public:
1607 
1608   bool is_java_subtype_of(const TypeKlassPtr* other) const {
1609     return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1610   }
1611   bool is_same_java_type_as(const TypePtr* other) const {
1612     return is_same_java_type_as_helper(other->is_klassptr());
1613   }
1614 
1615   bool maybe_java_subtype_of(const TypeKlassPtr* other) const {
1616     return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1617   }
1618   virtual bool is_same_java_type_as_helper(const TypeKlassPtr* other) const { ShouldNotReachHere(); return false; }
1619   virtual bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1620   virtual bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1621 
1622   // Exact klass, possibly an interface or an array of interface
1623   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k;  }
1624   virtual bool klass_is_exact()    const { return _ptr == Constant; }
1625 
1626   static const TypeKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces);
1627   static const TypeKlassPtr *make(PTR ptr, ciKlass* klass, int offset, InterfaceHandling interface_handling = ignore_interfaces);
1628 
1629   virtual bool  is_loaded() const { return _klass->is_loaded(); }
1630 
1631   virtual const TypeKlassPtr* cast_to_ptr_type(PTR ptr) const { ShouldNotReachHere(); return nullptr; }
1632 
1633   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const { ShouldNotReachHere(); return nullptr; }
1634 
1635   // corresponding pointer to instance, for a given class
1636   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const { ShouldNotReachHere(); return nullptr; }
1637 
1638   virtual const TypePtr *add_offset( intptr_t offset ) const { ShouldNotReachHere(); return nullptr; }
1639   virtual const Type    *xmeet( const Type *t ) const { ShouldNotReachHere(); return nullptr; }
1640   virtual const Type    *xdual() const { ShouldNotReachHere(); return nullptr; }
1641 
1642   virtual intptr_t get_con() const;
1643 
1644   virtual const TypeKlassPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr; }
1645 






1646   virtual const TypeKlassPtr* try_improve() const { return this; }
1647 
1648 #ifndef PRODUCT
1649   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1650 #endif
1651 private:
1652   virtual bool is_meet_subtype_of(const TypePtr* other) const {
1653     return is_meet_subtype_of_helper(other->is_klassptr(), klass_is_exact(), other->is_klassptr()->klass_is_exact());
1654   }
1655 
1656   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const {
1657     ShouldNotReachHere(); return false;
1658   }
1659 
1660   virtual const TypeInterfaces* interfaces() const {
1661     return _interfaces;
1662   };
1663 
1664   const TypeKlassPtr* is_reference_type(const Type* other) const {
1665     return other->isa_klassptr();
1666   }
1667 
1668   const TypeAryKlassPtr* is_array_type(const TypeKlassPtr* other) const {
1669     return other->isa_aryklassptr();
1670   }
1671 
1672   const TypeInstKlassPtr* is_instance_type(const TypeKlassPtr* other) const {
1673     return other->isa_instklassptr();
1674   }
1675 };
1676 
1677 // Instance klass pointer, mirrors TypeInstPtr
1678 class TypeInstKlassPtr : public TypeKlassPtr {
1679 
1680   TypeInstKlassPtr(PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, int offset)
1681     : TypeKlassPtr(InstKlassPtr, ptr, klass, interfaces, offset) {
1682     assert(klass->is_instance_klass() && (!klass->is_loaded() || !klass->is_interface()), "");
1683   }
1684 
1685   virtual bool must_be_exact() const;
1686 


1687 public:
1688   // Instance klass ignoring any interface
1689   ciInstanceKlass* instance_klass() const {
1690     assert(!klass()->is_interface(), "");
1691     return klass()->as_instance_klass();
1692   }
1693 
1694   bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
1695   bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1696   bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1697 


1698   static const TypeInstKlassPtr *make(ciKlass* k, InterfaceHandling interface_handling) {
1699     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, true, false, interface_handling);
1700     return make(TypePtr::Constant, k, interfaces, 0);
1701   }
1702   static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, int offset);
1703 
1704   static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, int offset) {
1705     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1706     return make(ptr, k, interfaces, offset);
1707   }
1708 
1709   virtual const TypeInstKlassPtr* cast_to_ptr_type(PTR ptr) const;
1710 
1711   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1712 
1713   // corresponding pointer to instance, for a given class
1714   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
1715   virtual uint hash() const;
1716   virtual bool eq(const Type *t) const;
1717 
1718   virtual const TypePtr *add_offset( intptr_t offset ) const;
1719   virtual const Type    *xmeet( const Type *t ) const;
1720   virtual const Type    *xdual() const;
1721   virtual const TypeInstKlassPtr* with_offset(intptr_t offset) const;
1722 
1723   virtual const TypeKlassPtr* try_improve() const;
1724 





















1725   // Convenience common pre-built types.
1726   static const TypeInstKlassPtr* OBJECT; // Not-null object klass or below
1727   static const TypeInstKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
1728 private:
1729   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
1730 };
1731 
1732 // Array klass pointer, mirrors TypeAryPtr
1733 class TypeAryKlassPtr : public TypeKlassPtr {
1734   friend class TypeInstKlassPtr;
1735   friend class Type;
1736   friend class TypePtr;
1737 
1738   const Type *_elem;




1739 
1740   static const TypeInterfaces* _array_interfaces;
1741   TypeAryKlassPtr(PTR ptr, const Type *elem, ciKlass* klass, int offset)
1742     : TypeKlassPtr(AryKlassPtr, ptr, klass, _array_interfaces, offset), _elem(elem) {
1743     assert(klass == nullptr || klass->is_type_array_klass() || !klass->as_obj_array_klass()->base_element_klass()->is_interface(), "");
1744   }
1745 
1746   virtual ciKlass* exact_klass_helper() const;
1747   // Only guaranteed non null for array of basic types
1748   virtual ciKlass* klass() const;
1749 
1750   virtual bool must_be_exact() const;
1751 
















1752 public:
1753 
1754   // returns base element type, an instance klass (and not interface) for object arrays
1755   const Type* base_element_type(int& dims) const;
1756 
1757   static const TypeAryKlassPtr *make(PTR ptr, ciKlass* k, int offset, InterfaceHandling interface_handling);
1758 
1759   bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
1760   bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1761   bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1762 
1763   bool  is_loaded() const { return (_elem->isa_klassptr() ? _elem->is_klassptr()->is_loaded() : true); }
1764 
1765   static const TypeAryKlassPtr *make(PTR ptr, const Type *elem, ciKlass* k, int offset);

1766   static const TypeAryKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling);
1767 
1768   const Type *elem() const { return _elem; }
1769 
1770   virtual bool eq(const Type *t) const;
1771   virtual uint hash() const;             // Type specific hashing
1772 
1773   virtual const TypeAryKlassPtr* cast_to_ptr_type(PTR ptr) const;
1774 
1775   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1776 


1777   // corresponding pointer to instance, for a given class
1778   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
1779 
1780   virtual const TypePtr *add_offset( intptr_t offset ) const;
1781   virtual const Type    *xmeet( const Type *t ) const;
1782   virtual const Type    *xdual() const;      // Compute dual right now.
1783 
1784   virtual const TypeAryKlassPtr* with_offset(intptr_t offset) const;
1785 
1786   virtual bool empty(void) const {
1787     return TypeKlassPtr::empty() || _elem->empty();
1788   }
1789 






1790 #ifndef PRODUCT
1791   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1792 #endif
1793 private:
1794   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
1795 };
1796 
1797 class TypeNarrowPtr : public Type {
1798 protected:
1799   const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
1800 
1801   TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): Type(t),
1802                                                   _ptrtype(ptrtype) {
1803     assert(ptrtype->offset() == 0 ||
1804            ptrtype->offset() == OffsetBot ||
1805            ptrtype->offset() == OffsetTop, "no real offsets");
1806   }
1807 
1808   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
1809   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;

1905   }
1906 
1907   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
1908     return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
1909   }
1910 
1911 public:
1912   static const TypeNarrowKlass *make( const TypePtr* type);
1913 
1914   // static const TypeNarrowKlass *BOTTOM;
1915   static const TypeNarrowKlass *NULL_PTR;
1916 
1917 #ifndef PRODUCT
1918   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1919 #endif
1920 };
1921 
1922 //------------------------------TypeFunc---------------------------------------
1923 // Class of Array Types
1924 class TypeFunc : public Type {
1925   TypeFunc( const TypeTuple *domain, const TypeTuple *range ) : Type(Function),  _domain(domain), _range(range) {}

1926   virtual bool eq( const Type *t ) const;
1927   virtual uint hash() const;             // Type specific hashing
1928   virtual bool singleton(void) const;    // TRUE if type is a singleton
1929   virtual bool empty(void) const;        // TRUE if type is vacuous
1930 
1931   const TypeTuple* const _domain;     // Domain of inputs
1932   const TypeTuple* const _range;      // Range of results











1933 
1934 public:
1935   // Constants are shared among ADLC and VM
1936   enum { Control    = AdlcVMDeps::Control,
1937          I_O        = AdlcVMDeps::I_O,
1938          Memory     = AdlcVMDeps::Memory,
1939          FramePtr   = AdlcVMDeps::FramePtr,
1940          ReturnAdr  = AdlcVMDeps::ReturnAdr,
1941          Parms      = AdlcVMDeps::Parms
1942   };
1943 
1944 
1945   // Accessors:
1946   const TypeTuple* domain() const { return _domain; }
1947   const TypeTuple* range()  const { return _range; }
1948 
1949   static const TypeFunc *make(ciMethod* method);
1950   static const TypeFunc *make(ciSignature signature, const Type* extra);



1951   static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
1952 
1953   virtual const Type *xmeet( const Type *t ) const;
1954   virtual const Type *xdual() const;    // Compute dual right now.
1955 
1956   BasicType return_type() const;
1957 


1958 #ifndef PRODUCT
1959   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1960 #endif
1961   // Convenience common pre-built types.
1962 };
1963 
1964 //------------------------------accessors--------------------------------------
1965 inline bool Type::is_ptr_to_narrowoop() const {
1966 #ifdef _LP64
1967   return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowoop_nv());
1968 #else
1969   return false;
1970 #endif
1971 }
1972 
1973 inline bool Type::is_ptr_to_narrowklass() const {
1974 #ifdef _LP64
1975   return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowklass_nv());
1976 #else
1977   return false;

2214 }
2215 
2216 inline const TypeNarrowOop* Type::make_narrowoop() const {
2217   return (_base == NarrowOop) ? is_narrowoop() :
2218                                 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : nullptr);
2219 }
2220 
2221 inline const TypeNarrowKlass* Type::make_narrowklass() const {
2222   return (_base == NarrowKlass) ? is_narrowklass() :
2223                                   (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : nullptr);
2224 }
2225 
2226 inline bool Type::is_floatingpoint() const {
2227   if( (_base == HalfFloatCon)  || (_base == HalfFloatBot) ||
2228       (_base == FloatCon)  || (_base == FloatBot) ||
2229       (_base == DoubleCon) || (_base == DoubleBot) )
2230     return true;
2231   return false;
2232 }
2233 








2234 template <>
2235 inline const TypeInt* Type::cast<TypeInt>() const {
2236   return is_int();
2237 }
2238 
2239 template <>
2240 inline const TypeLong* Type::cast<TypeLong>() const {
2241   return is_long();
2242 }
2243 
2244 // ===============================================================
2245 // Things that need to be 64-bits in the 64-bit build but
2246 // 32-bits in the 32-bit build.  Done this way to get full
2247 // optimization AND strong typing.
2248 #ifdef _LP64
2249 
2250 // For type queries and asserts
2251 #define is_intptr_t  is_long
2252 #define isa_intptr_t isa_long
2253 #define find_intptr_t_type find_long_type
2254 #define find_intptr_t_con  find_long_con
2255 #define TypeX        TypeLong
2256 #define Type_X       Type::Long
2257 #define TypeX_X      TypeLong::LONG
2258 #define TypeX_ZERO   TypeLong::ZERO
2259 // For 'ideal_reg' machine registers
2260 #define Op_RegX      Op_RegL
2261 // For phase->intcon variants
2262 #define MakeConX     longcon
2263 #define ConXNode     ConLNode
2264 // For array index arithmetic
2265 #define MulXNode     MulLNode
2266 #define AndXNode     AndLNode
2267 #define OrXNode      OrLNode
2268 #define CmpXNode     CmpLNode

2269 #define SubXNode     SubLNode
2270 #define LShiftXNode  LShiftLNode
2271 // For object size computation:
2272 #define AddXNode     AddLNode
2273 #define RShiftXNode  RShiftLNode
2274 // For card marks and hashcodes
2275 #define URShiftXNode URShiftLNode
2276 // For shenandoahSupport
2277 #define LoadXNode    LoadLNode
2278 #define StoreXNode   StoreLNode
2279 // Opcodes
2280 #define Op_LShiftX   Op_LShiftL
2281 #define Op_AndX      Op_AndL
2282 #define Op_AddX      Op_AddL
2283 #define Op_SubX      Op_SubL
2284 #define Op_XorX      Op_XorL
2285 #define Op_URShiftX  Op_URShiftL
2286 #define Op_LoadX     Op_LoadL

2287 // conversions
2288 #define ConvI2X(x)   ConvI2L(x)
2289 #define ConvL2X(x)   (x)
2290 #define ConvX2I(x)   ConvL2I(x)
2291 #define ConvX2L(x)   (x)
2292 #define ConvX2UL(x)  (x)
2293 
2294 #else
2295 
2296 // For type queries and asserts
2297 #define is_intptr_t  is_int
2298 #define isa_intptr_t isa_int
2299 #define find_intptr_t_type find_int_type
2300 #define find_intptr_t_con  find_int_con
2301 #define TypeX        TypeInt
2302 #define Type_X       Type::Int
2303 #define TypeX_X      TypeInt::INT
2304 #define TypeX_ZERO   TypeInt::ZERO
2305 // For 'ideal_reg' machine registers
2306 #define Op_RegX      Op_RegI
2307 // For phase->intcon variants
2308 #define MakeConX     intcon
2309 #define ConXNode     ConINode
2310 // For array index arithmetic
2311 #define MulXNode     MulINode
2312 #define AndXNode     AndINode
2313 #define OrXNode      OrINode
2314 #define CmpXNode     CmpINode

2315 #define SubXNode     SubINode
2316 #define LShiftXNode  LShiftINode
2317 // For object size computation:
2318 #define AddXNode     AddINode
2319 #define RShiftXNode  RShiftINode
2320 // For card marks and hashcodes
2321 #define URShiftXNode URShiftINode
2322 // For shenandoahSupport
2323 #define LoadXNode    LoadINode
2324 #define StoreXNode   StoreINode
2325 // Opcodes
2326 #define Op_LShiftX   Op_LShiftI
2327 #define Op_AndX      Op_AndI
2328 #define Op_AddX      Op_AddI
2329 #define Op_SubX      Op_SubI
2330 #define Op_XorX      Op_XorI
2331 #define Op_URShiftX  Op_URShiftI
2332 #define Op_LoadX     Op_LoadI

2333 // conversions
2334 #define ConvI2X(x)   (x)
2335 #define ConvL2X(x)   ConvL2I(x)
2336 #define ConvX2I(x)   (x)
2337 #define ConvX2L(x)   ConvI2L(x)
2338 #define ConvX2UL(x)  ConvI2UL(x)
2339 
2340 #endif
2341 
2342 #endif // SHARE_OPTO_TYPE_HPP

   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_OPTO_TYPE_HPP
  26 #define SHARE_OPTO_TYPE_HPP
  27 
  28 #include "ci/ciInlineKlass.hpp"
  29 #include "opto/adlcVMDeps.hpp"
  30 #include "runtime/handles.hpp"
  31 #include "runtime/sharedRuntime.hpp"
  32 
  33 // Portions of code courtesy of Clifford Click
  34 
  35 // Optimization - Graph Style
  36 
  37 
  38 // This class defines a Type lattice.  The lattice is used in the constant
  39 // propagation algorithms, and for some type-checking of the iloc code.
  40 // Basic types include RSD's (lower bound, upper bound, stride for integers),
  41 // float & double precision constants, sets of data-labels and code-labels.
  42 // The complete lattice is described below.  Subtypes have no relationship to
  43 // up or down in the lattice; that is entirely determined by the behavior of
  44 // the MEET/JOIN functions.
  45 
  46 class Dict;
  47 class Type;
  48 class   TypeD;
  49 class   TypeF;
  50 class   TypeH;
  51 class   TypeInteger;

 124     Memory,                     // Abstract store
 125     HalfFloatTop,               // No float value
 126     HalfFloatCon,               // Floating point constant
 127     HalfFloatBot,               // Any float value
 128     FloatTop,                   // No float value
 129     FloatCon,                   // Floating point constant
 130     FloatBot,                   // Any float value
 131     DoubleTop,                  // No double value
 132     DoubleCon,                  // Double precision constant
 133     DoubleBot,                  // Any double value
 134     Bottom,                     // Bottom of lattice
 135     lastype                     // Bogus ending type (not in lattice)
 136   };
 137 
 138   // Signal values for offsets from a base pointer
 139   enum OFFSET_SIGNALS {
 140     OffsetTop = -2000000000,    // undefined offset
 141     OffsetBot = -2000000001     // any possible offset
 142   };
 143 
 144   class Offset {
 145   private:
 146     int _offset;
 147 
 148   public:
 149     explicit Offset(int offset) : _offset(offset) {}
 150 
 151     const Offset meet(const Offset other) const;
 152     const Offset dual() const;
 153     const Offset add(intptr_t offset) const;
 154     bool operator==(const Offset& other) const {
 155       return _offset == other._offset;
 156     }
 157     bool operator!=(const Offset& other) const {
 158       return _offset != other._offset;
 159     }
 160     int get() const { return _offset; }
 161 
 162     void dump2(outputStream *st) const;
 163 
 164     static const Offset top;
 165     static const Offset bottom;
 166   };
 167 
 168   // Min and max WIDEN values.
 169   enum WIDEN {
 170     WidenMin = 0,
 171     WidenMax = 3
 172   };
 173 
 174 private:
 175   typedef struct {
 176     TYPES                dual_type;
 177     BasicType            basic_type;
 178     const char*          msg;
 179     bool                 isa_oop;
 180     uint                 ideal_reg;
 181     relocInfo::relocType reloc;
 182   } TypeInfo;
 183 
 184   // Dictionary of types shared among compilations.
 185   static Dict* _shared_type_dict;
 186   static const TypeInfo _type_info[];
 187 

 345   const TypeInstPtr  *isa_instptr() const;       // Returns null if not InstPtr
 346   const TypeInstPtr  *is_instptr() const;        // Instance
 347   const TypeAryPtr   *isa_aryptr() const;        // Returns null if not AryPtr
 348   const TypeAryPtr   *is_aryptr() const;         // Array oop
 349 
 350   template <typename TypeClass>
 351   const TypeClass* cast() const;
 352 
 353   const TypeMetadataPtr   *isa_metadataptr() const;   // Returns null if not oop ptr type
 354   const TypeMetadataPtr   *is_metadataptr() const;    // Java-style GC'd pointer
 355   const TypeKlassPtr      *isa_klassptr() const;      // Returns null if not KlassPtr
 356   const TypeKlassPtr      *is_klassptr() const;       // assert if not KlassPtr
 357   const TypeInstKlassPtr  *isa_instklassptr() const;  // Returns null if not IntKlassPtr
 358   const TypeInstKlassPtr  *is_instklassptr() const;   // assert if not IntKlassPtr
 359   const TypeAryKlassPtr   *isa_aryklassptr() const;   // Returns null if not AryKlassPtr
 360   const TypeAryKlassPtr   *is_aryklassptr() const;    // assert if not AryKlassPtr
 361 
 362   virtual bool      is_finite() const;           // Has a finite value
 363   virtual bool      is_nan()    const;           // Is not a number (NaN)
 364 
 365   bool is_inlinetypeptr() const;
 366   virtual ciInlineKlass* inline_klass() const;
 367 
 368   // Returns this ptr type or the equivalent ptr type for this compressed pointer.
 369   const TypePtr* make_ptr() const;
 370 
 371   // Returns this oopptr type or the equivalent oopptr type for this compressed pointer.
 372   // Asserts if the underlying type is not an oopptr or narrowoop.
 373   const TypeOopPtr* make_oopptr() const;
 374 
 375   // Returns this compressed pointer or the equivalent compressed version
 376   // of this pointer type.
 377   const TypeNarrowOop* make_narrowoop() const;
 378 
 379   // Returns this compressed klass pointer or the equivalent
 380   // compressed version of this pointer type.
 381   const TypeNarrowKlass* make_narrowklass() const;
 382 
 383   // Special test for register pressure heuristic
 384   bool is_floatingpoint() const;        // True if Float or Double base type
 385 
 386   // Do you have memory, directly or through a tuple?
 387   bool has_memory( ) const;

 779   const Type ** const _fields;           // Array of field types
 780 
 781 public:
 782   virtual bool eq( const Type *t ) const;
 783   virtual uint hash() const;             // Type specific hashing
 784   virtual bool singleton(void) const;    // TRUE if type is a singleton
 785   virtual bool empty(void) const;        // TRUE if type is vacuous
 786 
 787   // Accessors:
 788   uint cnt() const { return _cnt; }
 789   const Type* field_at(uint i) const {
 790     assert(i < _cnt, "oob");
 791     return _fields[i];
 792   }
 793   void set_field_at(uint i, const Type* t) {
 794     assert(i < _cnt, "oob");
 795     _fields[i] = t;
 796   }
 797 
 798   static const TypeTuple *make( uint cnt, const Type **fields );
 799   static const TypeTuple *make_range(ciSignature* sig, InterfaceHandling interface_handling = ignore_interfaces, bool ret_vt_fields = false);
 800   static const TypeTuple *make_domain(ciMethod* method, InterfaceHandling interface_handling, bool vt_fields_as_args = false);
 801 
 802   // Subroutine call type with space allocated for argument types
 803   // Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly
 804   static const Type **fields( uint arg_cnt );
 805 
 806   virtual const Type *xmeet( const Type *t ) const;
 807   virtual const Type *xdual() const;    // Compute dual right now.
 808   // Convenience common pre-built types.
 809   static const TypeTuple *IFBOTH;
 810   static const TypeTuple *IFFALSE;
 811   static const TypeTuple *IFTRUE;
 812   static const TypeTuple *IFNEITHER;
 813   static const TypeTuple *LOOPBODY;
 814   static const TypeTuple *MEMBAR;
 815   static const TypeTuple *STORECONDITIONAL;
 816   static const TypeTuple *START_I2C;
 817   static const TypeTuple *INT_PAIR;
 818   static const TypeTuple *LONG_PAIR;
 819   static const TypeTuple *INT_CC_PAIR;
 820   static const TypeTuple *LONG_CC_PAIR;
 821 #ifndef PRODUCT
 822   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 823 #endif
 824 };
 825 
 826 //------------------------------TypeAry----------------------------------------
 827 // Class of Array Types
 828 class TypeAry : public Type {
 829   TypeAry(const Type* elem, const TypeInt* size, bool stable, bool flat, bool not_flat, bool not_null_free) : Type(Array),
 830       _elem(elem), _size(size), _stable(stable), _flat(flat), _not_flat(not_flat), _not_null_free(not_null_free) {}
 831 public:
 832   virtual bool eq( const Type *t ) const;
 833   virtual uint hash() const;             // Type specific hashing
 834   virtual bool singleton(void) const;    // TRUE if type is a singleton
 835   virtual bool empty(void) const;        // TRUE if type is vacuous
 836 
 837 private:
 838   const Type *_elem;            // Element type of array
 839   const TypeInt *_size;         // Elements in array
 840   const bool _stable;           // Are elements @Stable?
 841 
 842   // Inline type array properties
 843   const bool _flat;             // Array is flat
 844   const bool _not_flat;         // Array is never flat
 845   const bool _not_null_free;    // Array is never null-free
 846 
 847   friend class TypeAryPtr;
 848 
 849 public:
 850   static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false,
 851                              bool flat = false, bool not_flat = false, bool not_null_free = false);
 852 
 853   virtual const Type *xmeet( const Type *t ) const;
 854   virtual const Type *xdual() const;    // Compute dual right now.
 855   bool ary_must_be_exact() const;  // true if arrays of such are never generic
 856   virtual const TypeAry* remove_speculative() const;
 857   virtual const Type* cleanup_speculative() const;
 858 #ifndef PRODUCT
 859   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 860 #endif
 861 };
 862 
 863 //------------------------------TypeVect---------------------------------------
 864 // Class of Vector Types
 865 class TypeVect : public Type {
 866   const BasicType _elem_bt;  // Vector's element type
 867   const uint _length;  // Elements in vector (power of 2)
 868 
 869 protected:
 870   TypeVect(TYPES t, BasicType elem_bt, uint length) : Type(t),
 871     _elem_bt(elem_bt), _length(length) {}

 977 
 978   const Type* xmeet(const Type* t) const;
 979 
 980   bool singleton(void) const;
 981 };
 982 
 983 //------------------------------TypePtr----------------------------------------
 984 // Class of machine Pointer Types: raw data, instances or arrays.
 985 // If the _base enum is AnyPtr, then this refers to all of the above.
 986 // Otherwise the _base will indicate which subset of pointers is affected,
 987 // and the class will be inherited from.
 988 class TypePtr : public Type {
 989   friend class TypeNarrowPtr;
 990   friend class Type;
 991 protected:
 992   static const TypeInterfaces* interfaces(ciKlass*& k, bool klass, bool interface, bool array, InterfaceHandling interface_handling);
 993 
 994 public:
 995   enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
 996 protected:
 997   TypePtr(TYPES t, PTR ptr, Offset offset,
 998           const TypePtr* speculative = nullptr,
 999           int inline_depth = InlineDepthBottom) :
1000     Type(t), _speculative(speculative), _inline_depth(inline_depth), _offset(offset),
1001     _ptr(ptr) {}
1002   static const PTR ptr_meet[lastPTR][lastPTR];
1003   static const PTR ptr_dual[lastPTR];
1004   static const char * const ptr_msg[lastPTR];
1005 
1006   enum {
1007     InlineDepthBottom = INT_MAX,
1008     InlineDepthTop = -InlineDepthBottom
1009   };
1010 
1011   // Extra type information profiling gave us. We propagate it the
1012   // same way the rest of the type info is propagated. If we want to
1013   // use it, then we have to emit a guard: this part of the type is
1014   // not something we know but something we speculate about the type.
1015   const TypePtr*   _speculative;
1016   // For speculative types, we record at what inlining depth the
1017   // profiling point that provided the data is. We want to favor

1033   // utility methods to work on the inline depth of the type
1034   int dual_inline_depth() const;
1035   int meet_inline_depth(int depth) const;
1036 #ifndef PRODUCT
1037   void dump_inline_depth(outputStream *st) const;
1038 #endif
1039 
1040   // TypeInstPtr (TypeAryPtr resp.) and TypeInstKlassPtr (TypeAryKlassPtr resp.) implement very similar meet logic.
1041   // The logic for meeting 2 instances (2 arrays resp.) is shared in the 2 utility methods below. However the logic for
1042   // the oop and klass versions can be slightly different and extra logic may have to be executed depending on what
1043   // exact case the meet falls into. The MeetResult struct is used by the utility methods to communicate what case was
1044   // encountered so the right logic specific to klasses or oops can be executed.,
1045   enum MeetResult {
1046     QUICK,
1047     UNLOADED,
1048     SUBTYPE,
1049     NOT_SUBTYPE,
1050     LCA
1051   };
1052   template<class T> static TypePtr::MeetResult meet_instptr(PTR& ptr, const TypeInterfaces*& interfaces, const T* this_type,
1053                                                             const T* other_type, ciKlass*& res_klass, bool& res_xk, bool& res_flat_array);
1054  private:
1055   template<class T> static bool is_meet_subtype_of(const T* sub_type, const T* super_type);
1056  protected:
1057 
1058   template<class T> static MeetResult meet_aryptr(PTR& ptr, const Type*& elem, const T* this_ary, const T* other_ary,
1059                                                   ciKlass*& res_klass, bool& res_xk, bool &res_flat, bool &res_not_flat, bool &res_not_null_free);
1060 
1061   template <class T1, class T2> static bool is_java_subtype_of_helper_for_instance(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1062   template <class T1, class T2> static bool is_same_java_type_as_helper_for_instance(const T1* this_one, const T2* other);
1063   template <class T1, class T2> static bool maybe_java_subtype_of_helper_for_instance(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1064   template <class T1, class T2> static bool is_java_subtype_of_helper_for_array(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1065   template <class T1, class T2> static bool is_same_java_type_as_helper_for_array(const T1* this_one, const T2* other);
1066   template <class T1, class T2> static bool maybe_java_subtype_of_helper_for_array(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1067   template <class T1, class T2> static bool is_meet_subtype_of_helper_for_instance(const T1* this_one, const T2* other, bool this_xk, bool other_xk);
1068   template <class T1, class T2> static bool is_meet_subtype_of_helper_for_array(const T1* this_one, const T2* other, bool this_xk, bool other_xk);
1069 public:
1070   const Offset _offset;         // Offset into oop, with TOP & BOT
1071   const PTR _ptr;               // Pointer equivalence class
1072 
1073   int offset() const { return _offset.get(); }
1074   PTR ptr()    const { return _ptr; }
1075 
1076   static const TypePtr* make(TYPES t, PTR ptr, Offset offset,
1077                              const TypePtr* speculative = nullptr,
1078                              int inline_depth = InlineDepthBottom);
1079 
1080   // Return a 'ptr' version of this type
1081   virtual const TypePtr* cast_to_ptr_type(PTR ptr) const;
1082 
1083   virtual intptr_t get_con() const;
1084 
1085   Type::Offset xadd_offset(intptr_t offset) const;
1086   virtual const TypePtr* add_offset(intptr_t offset) const;
1087   virtual const TypePtr* with_offset(intptr_t offset) const;
1088   virtual int flat_offset() const { return offset(); }
1089   virtual bool eq(const Type *t) const;
1090   virtual uint hash() const;             // Type specific hashing
1091 
1092   virtual bool singleton(void) const;    // TRUE if type is a singleton
1093   virtual bool empty(void) const;        // TRUE if type is vacuous
1094   virtual const Type *xmeet( const Type *t ) const;
1095   virtual const Type *xmeet_helper( const Type *t ) const;
1096   Offset meet_offset(int offset) const;
1097   Offset dual_offset() const;
1098   virtual const Type *xdual() const;    // Compute dual right now.
1099 
1100   // meet, dual and join over pointer equivalence sets
1101   PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
1102   PTR dual_ptr()                   const { return ptr_dual[ptr()];      }
1103 
1104   // This is textually confusing unless one recalls that
1105   // join(t) == dual()->meet(t->dual())->dual().
1106   PTR join_ptr( const PTR in_ptr ) const {
1107     return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
1108   }
1109 
1110   // Speculative type helper methods.
1111   virtual const TypePtr* speculative() const { return _speculative; }
1112   int inline_depth() const                   { return _inline_depth; }
1113   virtual ciKlass* speculative_type() const;
1114   virtual ciKlass* speculative_type_not_null() const;
1115   virtual bool speculative_maybe_null() const;
1116   virtual bool speculative_always_null() const;
1117   virtual const TypePtr* remove_speculative() const;
1118   virtual const Type* cleanup_speculative() const;
1119   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1120   virtual bool would_improve_ptr(ProfilePtrKind maybe_null) const;
1121   virtual const TypePtr* with_inline_depth(int depth) const;
1122 
1123   virtual bool maybe_null() const { return meet_ptr(Null) == ptr(); }
1124 
1125   virtual bool can_be_inline_type() const { return false; }
1126   virtual bool flat_in_array()      const { return false; }
1127   virtual bool not_flat_in_array()  const { return true; }
1128   virtual bool is_flat()            const { return false; }
1129   virtual bool is_not_flat()        const { return false; }
1130   virtual bool is_null_free()       const { return false; }
1131   virtual bool is_not_null_free()   const { return false; }
1132 
1133   // Tests for relation to centerline of type lattice:
1134   static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
1135   static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
1136   // Convenience common pre-built types.
1137   static const TypePtr *NULL_PTR;
1138   static const TypePtr *NOTNULL;
1139   static const TypePtr *BOTTOM;
1140 #ifndef PRODUCT
1141   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1142 #endif
1143 };
1144 
1145 //------------------------------TypeRawPtr-------------------------------------
1146 // Class of raw pointers, pointers to things other than Oops.  Examples
1147 // include the stack pointer, top of heap, card-marking area, handles, etc.
1148 class TypeRawPtr : public TypePtr {
1149 protected:
1150   TypeRawPtr(PTR ptr, address bits) : TypePtr(RawPtr,ptr,Offset(0)), _bits(bits){}
1151 public:
1152   virtual bool eq( const Type *t ) const;
1153   virtual uint hash() const;    // Type specific hashing
1154 
1155   const address _bits;          // Constant value, if applicable
1156 
1157   static const TypeRawPtr *make( PTR ptr );
1158   static const TypeRawPtr *make( address bits );
1159 
1160   // Return a 'ptr' version of this type
1161   virtual const TypeRawPtr* cast_to_ptr_type(PTR ptr) const;
1162 
1163   virtual intptr_t get_con() const;
1164 
1165   virtual const TypePtr* add_offset(intptr_t offset) const;
1166   virtual const TypeRawPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr;}
1167 
1168   virtual const Type *xmeet( const Type *t ) const;
1169   virtual const Type *xdual() const;    // Compute dual right now.
1170   // Convenience common pre-built types.
1171   static const TypeRawPtr *BOTTOM;
1172   static const TypeRawPtr *NOTNULL;
1173 #ifndef PRODUCT
1174   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1175 #endif
1176 };
1177 
1178 //------------------------------TypeOopPtr-------------------------------------
1179 // Some kind of oop (Java pointer), either instance or array.
1180 class TypeOopPtr : public TypePtr {
1181   friend class TypeAry;
1182   friend class TypePtr;
1183   friend class TypeInstPtr;
1184   friend class TypeAryPtr;
1185 protected:
1186  TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, Offset offset, Offset field_offset, int instance_id,
1187             const TypePtr* speculative, int inline_depth);
1188 public:
1189   virtual bool eq( const Type *t ) const;
1190   virtual uint hash() const;             // Type specific hashing
1191   virtual bool singleton(void) const;    // TRUE if type is a singleton
1192   enum {
1193    InstanceTop = -1,   // undefined instance
1194    InstanceBot = 0     // any possible instance
1195   };
1196 protected:
1197 
1198   // Oop is null, unless this is a constant oop.
1199   ciObject*     _const_oop;   // Constant oop
1200   // If _klass is null, then so is _sig.  This is an unloaded klass.
1201   ciKlass*      _klass;       // Klass object
1202 
1203   const TypeInterfaces* _interfaces;
1204 
1205   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
1206   bool          _klass_is_exact;
1207   bool          _is_ptr_to_narrowoop;
1208   bool          _is_ptr_to_narrowklass;
1209   bool          _is_ptr_to_boxed_value;
1210 
1211   // If not InstanceTop or InstanceBot, indicates that this is
1212   // a particular instance of this type which is distinct.
1213   // This is the node index of the allocation node creating this instance.
1214   int           _instance_id;
1215 
1216   static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact, InterfaceHandling interface_handling);
1217 
1218   int dual_instance_id() const;
1219   int meet_instance_id(int uid) const;
1220 
1221   const TypeInterfaces* meet_interfaces(const TypeOopPtr* other) const;
1222 
1223   // Do not allow interface-vs.-noninterface joins to collapse to top.
1224   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1225 
1226   virtual ciKlass* exact_klass_helper() const { return nullptr; }
1227   virtual ciKlass* klass() const { return _klass; }
1228 
1229 public:
1230 
1231   bool is_java_subtype_of(const TypeOopPtr* other) const {
1232     return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1233   }
1234 
1235   bool is_same_java_type_as(const TypePtr* other) const {
1236     return is_same_java_type_as_helper(other->is_oopptr());
1237   }
1238 
1239   virtual bool is_same_java_type_as_helper(const TypeOopPtr* other) const {
1240     ShouldNotReachHere(); return false;
1241   }
1242 
1243   bool maybe_java_subtype_of(const TypeOopPtr* other) const {
1244     return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1245   }
1246   virtual bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1247   virtual bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }

1254     return make_from_klass_common(klass, true, false, interface_handling);
1255   }
1256   // Same as before, but will produce an exact type, even if
1257   // the klass is not final, as long as it has exactly one implementation.
1258   static const TypeOopPtr* make_from_klass_unique(ciKlass* klass, InterfaceHandling interface_handling= ignore_interfaces) {
1259     return make_from_klass_common(klass, true, true, interface_handling);
1260   }
1261   // Same as before, but does not respects UseUniqueSubclasses.
1262   // Use this only for creating array element types.
1263   static const TypeOopPtr* make_from_klass_raw(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1264     return make_from_klass_common(klass, false, false, interface_handling);
1265   }
1266   // Creates a singleton type given an object.
1267   // If the object cannot be rendered as a constant,
1268   // may return a non-singleton type.
1269   // If require_constant, produce a null if a singleton is not possible.
1270   static const TypeOopPtr* make_from_constant(ciObject* o,
1271                                               bool require_constant = false);
1272 
1273   // Make a generic (unclassed) pointer to an oop.
1274   static const TypeOopPtr* make(PTR ptr, Offset offset, int instance_id,
1275                                 const TypePtr* speculative = nullptr,
1276                                 int inline_depth = InlineDepthBottom);
1277 
1278   ciObject* const_oop()    const { return _const_oop; }
1279   // Exact klass, possibly an interface or an array of interface
1280   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k;  }
1281   ciKlass* unloaded_klass() const { assert(!is_loaded(), "only for unloaded types"); return klass(); }
1282 
1283   virtual bool  is_loaded() const { return klass()->is_loaded(); }
1284   virtual bool klass_is_exact()    const { return _klass_is_exact; }
1285 
1286   // Returns true if this pointer points at memory which contains a
1287   // compressed oop references.
1288   bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
1289   bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
1290   bool is_ptr_to_boxed_value()   const { return _is_ptr_to_boxed_value; }
1291   bool is_known_instance()       const { return _instance_id > 0; }
1292   int  instance_id()             const { return _instance_id; }
1293   bool is_known_instance_field() const { return is_known_instance() && _offset.get() >= 0; }
1294 
1295   virtual bool can_be_inline_type() const { return (_klass == nullptr || _klass->can_be_inline_klass(_klass_is_exact)); }
1296   virtual bool can_be_inline_array() const { ShouldNotReachHere(); return false; }
1297 
1298   virtual intptr_t get_con() const;
1299 
1300   virtual const TypeOopPtr* cast_to_ptr_type(PTR ptr) const;
1301 
1302   virtual const TypeOopPtr* cast_to_exactness(bool klass_is_exact) const;
1303 
1304   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1305 
1306   // corresponding pointer to klass, for a given instance
1307   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1308 
1309   virtual const TypeOopPtr* with_offset(intptr_t offset) const;
1310   virtual const TypePtr* add_offset(intptr_t offset) const;
1311 
1312   // Speculative type helper methods.
1313   virtual const TypeOopPtr* remove_speculative() const;
1314   virtual const Type* cleanup_speculative() const;
1315   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1316   virtual const TypePtr* with_inline_depth(int depth) const;

1339     return _interfaces;
1340   };
1341 
1342   const TypeOopPtr* is_reference_type(const Type* other) const {
1343     return other->isa_oopptr();
1344   }
1345 
1346   const TypeAryPtr* is_array_type(const TypeOopPtr* other) const {
1347     return other->isa_aryptr();
1348   }
1349 
1350   const TypeInstPtr* is_instance_type(const TypeOopPtr* other) const {
1351     return other->isa_instptr();
1352   }
1353 };
1354 
1355 //------------------------------TypeInstPtr------------------------------------
1356 // Class of Java object pointers, pointing either to non-array Java instances
1357 // or to a Klass* (including array klasses).
1358 class TypeInstPtr : public TypeOopPtr {
1359   TypeInstPtr(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, Offset offset,
1360               bool flat_in_array, int instance_id, const TypePtr* speculative,
1361               int inline_depth);
1362   virtual bool eq( const Type *t ) const;
1363   virtual uint hash() const;             // Type specific hashing
1364   bool _flat_in_array; // Type is flat in arrays
1365   ciKlass* exact_klass_helper() const;
1366 
1367 public:
1368 
1369   // Instance klass, ignoring any interface
1370   ciInstanceKlass* instance_klass() const {
1371     assert(!(klass()->is_loaded() && klass()->is_interface()), "");
1372     return klass()->as_instance_klass();
1373   }
1374 
1375   bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1376   bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1377   bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1378 
1379   // Make a pointer to a constant oop.
1380   static const TypeInstPtr *make(ciObject* o) {
1381     ciKlass* k = o->klass();
1382     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1383     return make(TypePtr::Constant, k, interfaces, true, o, Offset(0));
1384   }
1385   // Make a pointer to a constant oop with offset.
1386   static const TypeInstPtr *make(ciObject* o, Offset offset) {
1387     ciKlass* k = o->klass();
1388     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1389     return make(TypePtr::Constant, k, interfaces, true, o, offset);
1390   }
1391 
1392   // Make a pointer to some value of type klass.
1393   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1394     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, true, false, interface_handling);
1395     return make(ptr, klass, interfaces, false, nullptr, Offset(0));
1396   }
1397 
1398   // Make a pointer to some non-polymorphic value of exactly type klass.
1399   static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
1400     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1401     return make(ptr, klass, interfaces, true, nullptr, Offset(0));
1402   }
1403 
1404   // Make a pointer to some value of type klass with offset.
1405   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, Offset offset) {
1406     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1407     return make(ptr, klass, interfaces, false, nullptr, offset);
1408   }
1409 
1410   // Make a pointer to an oop.
1411   static const TypeInstPtr* make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, Offset offset,
1412                                  bool flat_in_array = false,
1413                                  int instance_id = InstanceBot,
1414                                  const TypePtr* speculative = nullptr,
1415                                  int inline_depth = InlineDepthBottom);
1416 
1417   static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset offset, int instance_id = InstanceBot) {
1418     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1419     return make(ptr, k, interfaces, xk, o, offset, false, instance_id);
1420   }
1421 
1422   /** Create constant type for a constant boxed value */
1423   const Type* get_const_boxed_value() const;
1424 
1425   // If this is a java.lang.Class constant, return the type for it or null.
1426   // Pass to Type::get_const_type to turn it to a type, which will usually
1427   // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
1428   ciType* java_mirror_type(bool* is_null_free_array = nullptr) const;
1429 
1430   virtual const TypeInstPtr* cast_to_ptr_type(PTR ptr) const;
1431 
1432   virtual const TypeInstPtr* cast_to_exactness(bool klass_is_exact) const;
1433 
1434   virtual const TypeInstPtr* cast_to_instance_id(int instance_id) const;
1435 
1436   virtual const TypePtr* add_offset(intptr_t offset) const;
1437   virtual const TypeInstPtr* with_offset(intptr_t offset) const;
1438 
1439   // Speculative type helper methods.
1440   virtual const TypeInstPtr* remove_speculative() const;
1441   const TypeInstPtr* with_speculative(const TypePtr* speculative) const;
1442   virtual const TypePtr* with_inline_depth(int depth) const;
1443   virtual const TypePtr* with_instance_id(int instance_id) const;
1444 
1445   virtual const TypeInstPtr* cast_to_flat_in_array() const;
1446   virtual bool flat_in_array() const { return _flat_in_array; }
1447   virtual bool not_flat_in_array() const { return !can_be_inline_type() || (_klass->is_inlinetype() && !flat_in_array()); }
1448 
1449   // the core of the computation of the meet of 2 types
1450   virtual const Type *xmeet_helper(const Type *t) const;
1451   virtual const TypeInstPtr *xmeet_unloaded(const TypeInstPtr *tinst, const TypeInterfaces* interfaces) const;
1452   virtual const Type *xdual() const;    // Compute dual right now.
1453 
1454   const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1455 
1456   virtual bool can_be_inline_array() const;
1457 
1458   // Convenience common pre-built types.
1459   static const TypeInstPtr *NOTNULL;
1460   static const TypeInstPtr *BOTTOM;
1461   static const TypeInstPtr *MIRROR;
1462   static const TypeInstPtr *MARK;
1463   static const TypeInstPtr *KLASS;
1464 #ifndef PRODUCT
1465   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1466 #endif
1467 
1468 private:
1469   virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1470 
1471   virtual bool is_meet_same_type_as(const TypePtr* other) const {
1472     return _klass->equals(other->is_instptr()->_klass) && _interfaces->eq(other->is_instptr()->_interfaces);
1473   }
1474 
1475 };
1476 
1477 //------------------------------TypeAryPtr-------------------------------------
1478 // Class of Java array pointers
1479 class TypeAryPtr : public TypeOopPtr {
1480   friend class Type;
1481   friend class TypePtr;
1482   friend class TypeInstPtr;
1483 
1484   TypeAryPtr(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1485              Offset offset, Offset field_offset, int instance_id, bool is_autobox_cache,
1486              const TypePtr* speculative, int inline_depth)
1487     : TypeOopPtr(AryPtr, ptr, k, _array_interfaces, xk, o, offset, field_offset, instance_id, speculative, inline_depth),
1488     _ary(ary),
1489     _is_autobox_cache(is_autobox_cache),
1490     _field_offset(field_offset)
1491  {
1492     int dummy;
1493     bool top_or_bottom = (base_element_type(dummy) == Type::TOP || base_element_type(dummy) == Type::BOTTOM);
1494 
1495     if (UseCompressedOops && (elem()->make_oopptr() != nullptr && !top_or_bottom) &&
1496         _offset.get() != 0 && _offset.get() != arrayOopDesc::length_offset_in_bytes() &&
1497         _offset.get() != arrayOopDesc::klass_offset_in_bytes()) {
1498       _is_ptr_to_narrowoop = true;
1499     }
1500 
1501   }
1502   virtual bool eq( const Type *t ) const;
1503   virtual uint hash() const;    // Type specific hashing
1504   const TypeAry *_ary;          // Array we point into
1505   const bool     _is_autobox_cache;
1506   // For flat inline type arrays, each field of the inline type in
1507   // the array has its own memory slice so we need to keep track of
1508   // which field is accessed
1509   const Offset _field_offset;
1510   Offset meet_field_offset(const Type::Offset offset) const;
1511   Offset dual_field_offset() const;
1512 
1513   ciKlass* compute_klass() const;
1514 
1515   // A pointer to delay allocation to Type::Initialize_shared()
1516 
1517   static const TypeInterfaces* _array_interfaces;
1518   ciKlass* exact_klass_helper() const;
1519   // Only guaranteed non null for array of basic types
1520   ciKlass* klass() const;
1521 
1522 public:
1523 
1524   bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1525   bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1526   bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1527 
1528   // returns base element type, an instance klass (and not interface) for object arrays
1529   const Type* base_element_type(int& dims) const;
1530 
1531   // Accessors
1532   bool  is_loaded() const { return (_ary->_elem->make_oopptr() ? _ary->_elem->make_oopptr()->is_loaded() : true); }
1533 
1534   const TypeAry* ary() const  { return _ary; }
1535   const Type*    elem() const { return _ary->_elem; }
1536   const TypeInt* size() const { return _ary->_size; }
1537   bool      is_stable() const { return _ary->_stable; }
1538 
1539   // Inline type array properties
1540   bool is_flat()          const { return _ary->_flat; }
1541   bool is_not_flat()      const { return _ary->_not_flat; }
1542   bool is_null_free()     const { return _ary->_elem->make_ptr() != nullptr && (_ary->_elem->make_ptr()->ptr() == NotNull || _ary->_elem->make_ptr()->ptr() == AnyNull); }
1543   bool is_not_null_free() const { return _ary->_not_null_free; }
1544 
1545   bool is_autobox_cache() const { return _is_autobox_cache; }
1546 
1547   static const TypeAryPtr* make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1548                                 Offset field_offset = Offset::bottom,
1549                                 int instance_id = InstanceBot,
1550                                 const TypePtr* speculative = nullptr,
1551                                 int inline_depth = InlineDepthBottom);
1552   // Constant pointer to array
1553   static const TypeAryPtr* make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1554                                 Offset field_offset = Offset::bottom,
1555                                 int instance_id = InstanceBot,
1556                                 const TypePtr* speculative = nullptr,
1557                                 int inline_depth = InlineDepthBottom,
1558                                 bool is_autobox_cache = false);
1559 
1560   // Return a 'ptr' version of this type
1561   virtual const TypeAryPtr* cast_to_ptr_type(PTR ptr) const;
1562 
1563   virtual const TypeAryPtr* cast_to_exactness(bool klass_is_exact) const;
1564 
1565   virtual const TypeAryPtr* cast_to_instance_id(int instance_id) const;
1566 
1567   virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1568   virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1569 
1570   virtual bool empty(void) const;        // TRUE if type is vacuous
1571   virtual const TypePtr *add_offset( intptr_t offset ) const;
1572   virtual const TypeAryPtr *with_offset( intptr_t offset ) const;
1573   const TypeAryPtr* with_ary(const TypeAry* ary) const;
1574 
1575   // Speculative type helper methods.
1576   virtual const TypeAryPtr* remove_speculative() const;
1577   virtual const Type* cleanup_speculative() const;
1578   virtual const TypePtr* with_inline_depth(int depth) const;
1579   virtual const TypePtr* with_instance_id(int instance_id) const;
1580 
1581   // the core of the computation of the meet of 2 types
1582   virtual const Type *xmeet_helper(const Type *t) const;
1583   virtual const Type *xdual() const;    // Compute dual right now.
1584 
1585   // Inline type array properties
1586   const TypeAryPtr* cast_to_not_flat(bool not_flat = true) const;
1587   const TypeAryPtr* cast_to_not_null_free(bool not_null_free = true) const;
1588   const TypeAryPtr* update_properties(const TypeAryPtr* new_type) const;
1589   jint flat_layout_helper() const;
1590   int flat_elem_size() const;
1591   int flat_log_elem_size() const;
1592 
1593   const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1594   int stable_dimension() const;
1595 
1596   const TypeAryPtr* cast_to_autobox_cache() const;
1597 
1598   static jint max_array_length(BasicType etype);
1599 
1600   int flat_offset() const;
1601   const Offset field_offset() const { return _field_offset; }
1602   const TypeAryPtr* with_field_offset(int offset) const;
1603   const TypePtr* add_field_offset_and_offset(intptr_t offset) const;
1604 
1605   virtual bool can_be_inline_type() const { return false; }
1606   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1607 
1608   virtual bool can_be_inline_array() const;
1609 
1610   // Convenience common pre-built types.
1611   static const TypeAryPtr* BOTTOM;
1612   static const TypeAryPtr *RANGE;
1613   static const TypeAryPtr *OOPS;
1614   static const TypeAryPtr *NARROWOOPS;
1615   static const TypeAryPtr *BYTES;
1616   static const TypeAryPtr *SHORTS;
1617   static const TypeAryPtr *CHARS;
1618   static const TypeAryPtr *INTS;
1619   static const TypeAryPtr *LONGS;
1620   static const TypeAryPtr *FLOATS;
1621   static const TypeAryPtr *DOUBLES;
1622   static const TypeAryPtr *INLINES;
1623   // selects one of the above:
1624   static const TypeAryPtr *get_array_body_type(BasicType elem) {
1625     assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != nullptr, "bad elem type");
1626     return _array_body_type[elem];
1627   }
1628   static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1629   // sharpen the type of an int which is used as an array size
1630 #ifndef PRODUCT
1631   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1632 #endif
1633 private:
1634   virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1635 };
1636 
1637 //------------------------------TypeMetadataPtr-------------------------------------
1638 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
1639 class TypeMetadataPtr : public TypePtr {
1640 protected:
1641   TypeMetadataPtr(PTR ptr, ciMetadata* metadata, Offset offset);
1642   // Do not allow interface-vs.-noninterface joins to collapse to top.
1643   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1644 public:
1645   virtual bool eq( const Type *t ) const;
1646   virtual uint hash() const;             // Type specific hashing
1647   virtual bool singleton(void) const;    // TRUE if type is a singleton
1648 
1649 private:
1650   ciMetadata*   _metadata;
1651 
1652 public:
1653   static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, Offset offset);
1654 
1655   static const TypeMetadataPtr* make(ciMethod* m);
1656   static const TypeMetadataPtr* make(ciMethodData* m);
1657 
1658   ciMetadata* metadata() const { return _metadata; }
1659 
1660   virtual const TypeMetadataPtr* cast_to_ptr_type(PTR ptr) const;
1661 
1662   virtual const TypePtr *add_offset( intptr_t offset ) const;
1663 
1664   virtual const Type *xmeet( const Type *t ) const;
1665   virtual const Type *xdual() const;    // Compute dual right now.
1666 
1667   virtual intptr_t get_con() const;
1668 
1669   // Convenience common pre-built types.
1670   static const TypeMetadataPtr *BOTTOM;
1671 
1672 #ifndef PRODUCT
1673   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1674 #endif
1675 };
1676 
1677 //------------------------------TypeKlassPtr-----------------------------------
1678 // Class of Java Klass pointers
1679 class TypeKlassPtr : public TypePtr {
1680   friend class TypeInstKlassPtr;
1681   friend class TypeAryKlassPtr;
1682   friend class TypePtr;
1683 protected:
1684   TypeKlassPtr(TYPES t, PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, Offset offset);
1685 
1686   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1687 
1688 public:
1689   virtual bool eq( const Type *t ) const;
1690   virtual uint hash() const;
1691   virtual bool singleton(void) const;    // TRUE if type is a singleton
1692 
1693 protected:
1694 
1695   ciKlass* _klass;
1696   const TypeInterfaces* _interfaces;
1697   const TypeInterfaces* meet_interfaces(const TypeKlassPtr* other) const;
1698   virtual bool must_be_exact() const { ShouldNotReachHere(); return false; }
1699   virtual ciKlass* exact_klass_helper() const;
1700   virtual ciKlass* klass() const { return  _klass; }
1701 
1702 public:
1703 
1704   bool is_java_subtype_of(const TypeKlassPtr* other) const {
1705     return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1706   }
1707   bool is_same_java_type_as(const TypePtr* other) const {
1708     return is_same_java_type_as_helper(other->is_klassptr());
1709   }
1710 
1711   bool maybe_java_subtype_of(const TypeKlassPtr* other) const {
1712     return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1713   }
1714   virtual bool is_same_java_type_as_helper(const TypeKlassPtr* other) const { ShouldNotReachHere(); return false; }
1715   virtual bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1716   virtual bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1717 
1718   // Exact klass, possibly an interface or an array of interface
1719   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k;  }
1720   virtual bool klass_is_exact()    const { return _ptr == Constant; }
1721 
1722   static const TypeKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces);
1723   static const TypeKlassPtr *make(PTR ptr, ciKlass* klass, Offset offset, InterfaceHandling interface_handling = ignore_interfaces);
1724 
1725   virtual bool  is_loaded() const { return _klass->is_loaded(); }
1726 
1727   virtual const TypeKlassPtr* cast_to_ptr_type(PTR ptr) const { ShouldNotReachHere(); return nullptr; }
1728 
1729   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const { ShouldNotReachHere(); return nullptr; }
1730 
1731   // corresponding pointer to instance, for a given class
1732   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const { ShouldNotReachHere(); return nullptr; }
1733 
1734   virtual const TypePtr *add_offset( intptr_t offset ) const { ShouldNotReachHere(); return nullptr; }
1735   virtual const Type    *xmeet( const Type *t ) const { ShouldNotReachHere(); return nullptr; }
1736   virtual const Type    *xdual() const { ShouldNotReachHere(); return nullptr; }
1737 
1738   virtual intptr_t get_con() const;
1739 
1740   virtual const TypeKlassPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr; }
1741 
1742   virtual bool can_be_inline_array() const { ShouldNotReachHere(); return false; }
1743 
1744   virtual bool not_flat_in_array_inexact() const {
1745     return true;
1746   }
1747 
1748   virtual const TypeKlassPtr* try_improve() const { return this; }
1749 
1750 #ifndef PRODUCT
1751   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1752 #endif
1753 private:
1754   virtual bool is_meet_subtype_of(const TypePtr* other) const {
1755     return is_meet_subtype_of_helper(other->is_klassptr(), klass_is_exact(), other->is_klassptr()->klass_is_exact());
1756   }
1757 
1758   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const {
1759     ShouldNotReachHere(); return false;
1760   }
1761 
1762   virtual const TypeInterfaces* interfaces() const {
1763     return _interfaces;
1764   };
1765 
1766   const TypeKlassPtr* is_reference_type(const Type* other) const {
1767     return other->isa_klassptr();
1768   }
1769 
1770   const TypeAryKlassPtr* is_array_type(const TypeKlassPtr* other) const {
1771     return other->isa_aryklassptr();
1772   }
1773 
1774   const TypeInstKlassPtr* is_instance_type(const TypeKlassPtr* other) const {
1775     return other->isa_instklassptr();
1776   }
1777 };
1778 
1779 // Instance klass pointer, mirrors TypeInstPtr
1780 class TypeInstKlassPtr : public TypeKlassPtr {
1781 
1782   TypeInstKlassPtr(PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, Offset offset, bool flat_in_array)
1783     : TypeKlassPtr(InstKlassPtr, ptr, klass, interfaces, offset), _flat_in_array(flat_in_array) {
1784     assert(klass->is_instance_klass() && (!klass->is_loaded() || !klass->is_interface()), "");
1785   }
1786 
1787   virtual bool must_be_exact() const;
1788 
1789   const bool _flat_in_array; // Type is flat in arrays
1790 
1791 public:
1792   // Instance klass ignoring any interface
1793   ciInstanceKlass* instance_klass() const {
1794     assert(!klass()->is_interface(), "");
1795     return klass()->as_instance_klass();
1796   }
1797 
1798   bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
1799   bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1800   bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1801 
1802   virtual bool can_be_inline_type() const { return (_klass == nullptr || _klass->can_be_inline_klass(klass_is_exact())); }
1803 
1804   static const TypeInstKlassPtr *make(ciKlass* k, InterfaceHandling interface_handling) {
1805     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, true, false, interface_handling);
1806     return make(TypePtr::Constant, k, interfaces, Offset(0));
1807   }
1808   static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, Offset offset, bool flat_in_array = false);
1809 
1810   static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, Offset offset) {
1811     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1812     return make(ptr, k, interfaces, offset);
1813   }
1814 
1815   virtual const TypeInstKlassPtr* cast_to_ptr_type(PTR ptr) const;
1816 
1817   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1818 
1819   // corresponding pointer to instance, for a given class
1820   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
1821   virtual uint hash() const;
1822   virtual bool eq(const Type *t) const;
1823 
1824   virtual const TypePtr *add_offset( intptr_t offset ) const;
1825   virtual const Type    *xmeet( const Type *t ) const;
1826   virtual const Type    *xdual() const;
1827   virtual const TypeInstKlassPtr* with_offset(intptr_t offset) const;
1828 
1829   virtual const TypeKlassPtr* try_improve() const;
1830 
1831   virtual bool flat_in_array() const { return _flat_in_array; }
1832 
1833   // Checks if this klass pointer is not flat in array by also considering exactness information.
1834   virtual bool not_flat_in_array() const {
1835     return !_klass->can_be_inline_klass(klass_is_exact()) || (_klass->is_inlinetype() && !flat_in_array());
1836   }
1837 
1838   // not_flat_in_array() version that assumes that the klass is inexact. This is used for sub type checks where the
1839   // super klass is always an exact klass constant (and thus possibly known to be not flat in array), while a sub
1840   // klass could very well be flat in array:
1841   //
1842   //           MyValue       <:       Object
1843   //        flat in array       not flat in array
1844   //
1845   // Thus, this version checks if we know that the klass is not flat in array even if it's not exact.
1846   virtual bool not_flat_in_array_inexact() const {
1847     return !_klass->can_be_inline_klass() || (_klass->is_inlinetype() && !flat_in_array());
1848   }
1849 
1850   virtual bool can_be_inline_array() const;
1851 
1852   // Convenience common pre-built types.
1853   static const TypeInstKlassPtr* OBJECT; // Not-null object klass or below
1854   static const TypeInstKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
1855 private:
1856   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
1857 };
1858 
1859 // Array klass pointer, mirrors TypeAryPtr
1860 class TypeAryKlassPtr : public TypeKlassPtr {
1861   friend class TypeInstKlassPtr;
1862   friend class Type;
1863   friend class TypePtr;
1864 
1865   const Type *_elem;
1866   const bool _not_flat;      // Array is never flat
1867   const bool _not_null_free; // Array is never null-free
1868   const bool _flat;
1869   const bool _null_free;
1870 
1871   static const TypeInterfaces* _array_interfaces;
1872   TypeAryKlassPtr(PTR ptr, const Type *elem, ciKlass* klass, Offset offset, bool not_flat, int not_null_free, bool flat, bool null_free)
1873     : TypeKlassPtr(AryKlassPtr, ptr, klass, _array_interfaces, offset), _elem(elem), _not_flat(not_flat), _not_null_free(not_null_free), _flat(flat), _null_free(null_free) {
1874     assert(klass == nullptr || klass->is_type_array_klass() || klass->is_flat_array_klass() || !klass->as_obj_array_klass()->base_element_klass()->is_interface(), "");
1875   }
1876 
1877   virtual ciKlass* exact_klass_helper() const;
1878   // Only guaranteed non null for array of basic types
1879   virtual ciKlass* klass() const;
1880 
1881   virtual bool must_be_exact() const;
1882 
1883   bool dual_flat() const {
1884     return _flat;
1885   }
1886 
1887   bool meet_flat(bool other) const {
1888     return _flat && other;
1889   }
1890 
1891   bool dual_null_free() const {
1892     return _null_free;
1893   }
1894 
1895   bool meet_null_free(bool other) const {
1896     return _null_free && other;
1897   }
1898 
1899 public:
1900 
1901   // returns base element type, an instance klass (and not interface) for object arrays
1902   const Type* base_element_type(int& dims) const;
1903 
1904   static const TypeAryKlassPtr* make(PTR ptr, ciKlass* k, Offset offset, InterfaceHandling interface_handling, bool not_flat, bool not_null_free, bool flat, bool null_free);
1905 
1906   bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
1907   bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1908   bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1909 
1910   bool  is_loaded() const { return (_elem->isa_klassptr() ? _elem->is_klassptr()->is_loaded() : true); }
1911 
1912   static const TypeAryKlassPtr* make(PTR ptr, const Type* elem, ciKlass* k, Offset offset, bool not_flat, bool not_null_free, bool flat, bool null_free);
1913   static const TypeAryKlassPtr* make(PTR ptr, ciKlass* k, Offset offset, InterfaceHandling interface_handling);
1914   static const TypeAryKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling);
1915 
1916   const Type *elem() const { return _elem; }
1917 
1918   virtual bool eq(const Type *t) const;
1919   virtual uint hash() const;             // Type specific hashing
1920 
1921   virtual const TypeAryKlassPtr* cast_to_ptr_type(PTR ptr) const;
1922 
1923   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1924 
1925   const TypeAryKlassPtr* cast_to_null_free() const;
1926 
1927   // corresponding pointer to instance, for a given class
1928   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
1929 
1930   virtual const TypePtr *add_offset( intptr_t offset ) const;
1931   virtual const Type    *xmeet( const Type *t ) const;
1932   virtual const Type    *xdual() const;      // Compute dual right now.
1933 
1934   virtual const TypeAryKlassPtr* with_offset(intptr_t offset) const;
1935 
1936   virtual bool empty(void) const {
1937     return TypeKlassPtr::empty() || _elem->empty();
1938   }
1939 
1940   bool is_flat()          const { return _flat; }
1941   bool is_not_flat()      const { return _not_flat; }
1942   bool is_null_free()     const { return _null_free; }
1943   bool is_not_null_free() const { return _not_null_free; }
1944   virtual bool can_be_inline_array() const;
1945 
1946 #ifndef PRODUCT
1947   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1948 #endif
1949 private:
1950   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
1951 };
1952 
1953 class TypeNarrowPtr : public Type {
1954 protected:
1955   const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
1956 
1957   TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): Type(t),
1958                                                   _ptrtype(ptrtype) {
1959     assert(ptrtype->offset() == 0 ||
1960            ptrtype->offset() == OffsetBot ||
1961            ptrtype->offset() == OffsetTop, "no real offsets");
1962   }
1963 
1964   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
1965   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;

2061   }
2062 
2063   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
2064     return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
2065   }
2066 
2067 public:
2068   static const TypeNarrowKlass *make( const TypePtr* type);
2069 
2070   // static const TypeNarrowKlass *BOTTOM;
2071   static const TypeNarrowKlass *NULL_PTR;
2072 
2073 #ifndef PRODUCT
2074   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
2075 #endif
2076 };
2077 
2078 //------------------------------TypeFunc---------------------------------------
2079 // Class of Array Types
2080 class TypeFunc : public Type {
2081   TypeFunc(const TypeTuple *domain_sig, const TypeTuple *domain_cc, const TypeTuple *range_sig, const TypeTuple *range_cc)
2082     : Type(Function), _domain_sig(domain_sig), _domain_cc(domain_cc), _range_sig(range_sig), _range_cc(range_cc) {}
2083   virtual bool eq( const Type *t ) const;
2084   virtual uint hash() const;             // Type specific hashing
2085   virtual bool singleton(void) const;    // TRUE if type is a singleton
2086   virtual bool empty(void) const;        // TRUE if type is vacuous
2087 
2088   // Domains of inputs: inline type arguments are not passed by
2089   // reference, instead each field of the inline type is passed as an
2090   // argument. We maintain 2 views of the argument list here: one
2091   // based on the signature (with an inline type argument as a single
2092   // slot), one based on the actual calling convention (with a value
2093   // type argument as a list of its fields).
2094   const TypeTuple* const _domain_sig;
2095   const TypeTuple* const _domain_cc;
2096   // Range of results. Similar to domains: an inline type result can be
2097   // returned in registers in which case range_cc lists all fields and
2098   // is the actual calling convention.
2099   const TypeTuple* const _range_sig;
2100   const TypeTuple* const _range_cc;
2101 
2102 public:
2103   // Constants are shared among ADLC and VM
2104   enum { Control    = AdlcVMDeps::Control,
2105          I_O        = AdlcVMDeps::I_O,
2106          Memory     = AdlcVMDeps::Memory,
2107          FramePtr   = AdlcVMDeps::FramePtr,
2108          ReturnAdr  = AdlcVMDeps::ReturnAdr,
2109          Parms      = AdlcVMDeps::Parms
2110   };
2111 
2112 
2113   // Accessors:
2114   const TypeTuple* domain_sig() const { return _domain_sig; }
2115   const TypeTuple* domain_cc()  const { return _domain_cc; }
2116   const TypeTuple* range_sig()  const { return _range_sig; }
2117   const TypeTuple* range_cc()   const { return _range_cc; }
2118 
2119   static const TypeFunc* make(ciMethod* method, bool is_osr_compilation = false);
2120   static const TypeFunc *make(const TypeTuple* domain_sig, const TypeTuple* domain_cc,
2121                               const TypeTuple* range_sig, const TypeTuple* range_cc);
2122   static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
2123 
2124   virtual const Type *xmeet( const Type *t ) const;
2125   virtual const Type *xdual() const;    // Compute dual right now.
2126 
2127   BasicType return_type() const;
2128 
2129   bool returns_inline_type_as_fields() const { return range_sig() != range_cc(); }
2130 
2131 #ifndef PRODUCT
2132   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
2133 #endif
2134   // Convenience common pre-built types.
2135 };
2136 
2137 //------------------------------accessors--------------------------------------
2138 inline bool Type::is_ptr_to_narrowoop() const {
2139 #ifdef _LP64
2140   return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowoop_nv());
2141 #else
2142   return false;
2143 #endif
2144 }
2145 
2146 inline bool Type::is_ptr_to_narrowklass() const {
2147 #ifdef _LP64
2148   return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowklass_nv());
2149 #else
2150   return false;

2387 }
2388 
2389 inline const TypeNarrowOop* Type::make_narrowoop() const {
2390   return (_base == NarrowOop) ? is_narrowoop() :
2391                                 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : nullptr);
2392 }
2393 
2394 inline const TypeNarrowKlass* Type::make_narrowklass() const {
2395   return (_base == NarrowKlass) ? is_narrowklass() :
2396                                   (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : nullptr);
2397 }
2398 
2399 inline bool Type::is_floatingpoint() const {
2400   if( (_base == HalfFloatCon)  || (_base == HalfFloatBot) ||
2401       (_base == FloatCon)  || (_base == FloatBot) ||
2402       (_base == DoubleCon) || (_base == DoubleBot) )
2403     return true;
2404   return false;
2405 }
2406 
2407 inline bool Type::is_inlinetypeptr() const {
2408   return isa_instptr() != nullptr && is_instptr()->instance_klass()->is_inlinetype();
2409 }
2410 
2411 inline ciInlineKlass* Type::inline_klass() const {
2412   return make_ptr()->is_instptr()->instance_klass()->as_inline_klass();
2413 }
2414 
2415 template <>
2416 inline const TypeInt* Type::cast<TypeInt>() const {
2417   return is_int();
2418 }
2419 
2420 template <>
2421 inline const TypeLong* Type::cast<TypeLong>() const {
2422   return is_long();
2423 }
2424 
2425 // ===============================================================
2426 // Things that need to be 64-bits in the 64-bit build but
2427 // 32-bits in the 32-bit build.  Done this way to get full
2428 // optimization AND strong typing.
2429 #ifdef _LP64
2430 
2431 // For type queries and asserts
2432 #define is_intptr_t  is_long
2433 #define isa_intptr_t isa_long
2434 #define find_intptr_t_type find_long_type
2435 #define find_intptr_t_con  find_long_con
2436 #define TypeX        TypeLong
2437 #define Type_X       Type::Long
2438 #define TypeX_X      TypeLong::LONG
2439 #define TypeX_ZERO   TypeLong::ZERO
2440 // For 'ideal_reg' machine registers
2441 #define Op_RegX      Op_RegL
2442 // For phase->intcon variants
2443 #define MakeConX     longcon
2444 #define ConXNode     ConLNode
2445 // For array index arithmetic
2446 #define MulXNode     MulLNode
2447 #define AndXNode     AndLNode
2448 #define OrXNode      OrLNode
2449 #define CmpXNode     CmpLNode
2450 #define CmpUXNode    CmpULNode
2451 #define SubXNode     SubLNode
2452 #define LShiftXNode  LShiftLNode
2453 // For object size computation:
2454 #define AddXNode     AddLNode
2455 #define RShiftXNode  RShiftLNode
2456 // For card marks and hashcodes
2457 #define URShiftXNode URShiftLNode
2458 // For shenandoahSupport
2459 #define LoadXNode    LoadLNode
2460 #define StoreXNode   StoreLNode
2461 // Opcodes
2462 #define Op_LShiftX   Op_LShiftL
2463 #define Op_AndX      Op_AndL
2464 #define Op_AddX      Op_AddL
2465 #define Op_SubX      Op_SubL
2466 #define Op_XorX      Op_XorL
2467 #define Op_URShiftX  Op_URShiftL
2468 #define Op_LoadX     Op_LoadL
2469 #define Op_StoreX    Op_StoreL
2470 // conversions
2471 #define ConvI2X(x)   ConvI2L(x)
2472 #define ConvL2X(x)   (x)
2473 #define ConvX2I(x)   ConvL2I(x)
2474 #define ConvX2L(x)   (x)
2475 #define ConvX2UL(x)  (x)
2476 
2477 #else
2478 
2479 // For type queries and asserts
2480 #define is_intptr_t  is_int
2481 #define isa_intptr_t isa_int
2482 #define find_intptr_t_type find_int_type
2483 #define find_intptr_t_con  find_int_con
2484 #define TypeX        TypeInt
2485 #define Type_X       Type::Int
2486 #define TypeX_X      TypeInt::INT
2487 #define TypeX_ZERO   TypeInt::ZERO
2488 // For 'ideal_reg' machine registers
2489 #define Op_RegX      Op_RegI
2490 // For phase->intcon variants
2491 #define MakeConX     intcon
2492 #define ConXNode     ConINode
2493 // For array index arithmetic
2494 #define MulXNode     MulINode
2495 #define AndXNode     AndINode
2496 #define OrXNode      OrINode
2497 #define CmpXNode     CmpINode
2498 #define CmpUXNode    CmpUNode
2499 #define SubXNode     SubINode
2500 #define LShiftXNode  LShiftINode
2501 // For object size computation:
2502 #define AddXNode     AddINode
2503 #define RShiftXNode  RShiftINode
2504 // For card marks and hashcodes
2505 #define URShiftXNode URShiftINode
2506 // For shenandoahSupport
2507 #define LoadXNode    LoadINode
2508 #define StoreXNode   StoreINode
2509 // Opcodes
2510 #define Op_LShiftX   Op_LShiftI
2511 #define Op_AndX      Op_AndI
2512 #define Op_AddX      Op_AddI
2513 #define Op_SubX      Op_SubI
2514 #define Op_XorX      Op_XorI
2515 #define Op_URShiftX  Op_URShiftI
2516 #define Op_LoadX     Op_LoadI
2517 #define Op_StoreX    Op_StoreI
2518 // conversions
2519 #define ConvI2X(x)   (x)
2520 #define ConvL2X(x)   ConvL2I(x)
2521 #define ConvX2I(x)   (x)
2522 #define ConvX2L(x)   ConvI2L(x)
2523 #define ConvX2UL(x)  ConvI2UL(x)
2524 
2525 #endif
2526 
2527 #endif // SHARE_OPTO_TYPE_HPP
< prev index next >