< 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 "opto/compile.hpp"
  30 #include "opto/rangeinference.hpp"
  31 #include "runtime/handles.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;

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
























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

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



 348   // Returns this ptr type or the equivalent ptr type for this compressed pointer.
 349   const TypePtr* make_ptr() const;
 350 
 351   // Returns this oopptr type or the equivalent oopptr type for this compressed pointer.
 352   // Asserts if the underlying type is not an oopptr or narrowoop.
 353   const TypeOopPtr* make_oopptr() const;
 354 
 355   // Returns this compressed pointer or the equivalent compressed version
 356   // of this pointer type.
 357   const TypeNarrowOop* make_narrowoop() const;
 358 
 359   // Returns this compressed klass pointer or the equivalent
 360   // compressed version of this pointer type.
 361   const TypeNarrowKlass* make_narrowklass() const;
 362 
 363   // Special test for register pressure heuristic
 364   bool is_floatingpoint() const;        // True if Float or Double base type
 365 
 366   // Do you have memory, directly or through a tuple?
 367   bool has_memory( ) const;

 935   const Type ** const _fields;           // Array of field types
 936 
 937 public:
 938   virtual bool eq( const Type *t ) const;
 939   virtual uint hash() const;             // Type specific hashing
 940   virtual bool singleton(void) const;    // TRUE if type is a singleton
 941   virtual bool empty(void) const;        // TRUE if type is vacuous
 942 
 943   // Accessors:
 944   uint cnt() const { return _cnt; }
 945   const Type* field_at(uint i) const {
 946     assert(i < _cnt, "oob");
 947     return _fields[i];
 948   }
 949   void set_field_at(uint i, const Type* t) {
 950     assert(i < _cnt, "oob");
 951     _fields[i] = t;
 952   }
 953 
 954   static const TypeTuple *make( uint cnt, const Type **fields );
 955   static const TypeTuple *make_range(ciSignature *sig, InterfaceHandling interface_handling = ignore_interfaces);
 956   static const TypeTuple *make_domain(ciInstanceKlass* recv, ciSignature *sig, InterfaceHandling interface_handling);
 957 
 958   // Subroutine call type with space allocated for argument types
 959   // Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly
 960   static const Type **fields( uint arg_cnt );
 961 
 962   virtual const Type *xmeet( const Type *t ) const;
 963   virtual const Type *xdual() const;    // Compute dual right now.
 964   // Convenience common pre-built types.
 965   static const TypeTuple *IFBOTH;
 966   static const TypeTuple *IFFALSE;
 967   static const TypeTuple *IFTRUE;
 968   static const TypeTuple *IFNEITHER;
 969   static const TypeTuple *LOOPBODY;
 970   static const TypeTuple *MEMBAR;
 971   static const TypeTuple *STORECONDITIONAL;
 972   static const TypeTuple *START_I2C;
 973   static const TypeTuple *INT_PAIR;
 974   static const TypeTuple *LONG_PAIR;
 975   static const TypeTuple *INT_CC_PAIR;
 976   static const TypeTuple *LONG_CC_PAIR;
 977 #ifndef PRODUCT
 978   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 979 #endif
 980 };
 981 
 982 //------------------------------TypeAry----------------------------------------
 983 // Class of Array Types
 984 class TypeAry : public Type {
 985   TypeAry(const Type* elem, const TypeInt* size, bool stable) : Type(Array),
 986       _elem(elem), _size(size), _stable(stable) {}
 987 public:
 988   virtual bool eq( const Type *t ) const;
 989   virtual uint hash() const;             // Type specific hashing
 990   virtual bool singleton(void) const;    // TRUE if type is a singleton
 991   virtual bool empty(void) const;        // TRUE if type is vacuous
 992 
 993 private:
 994   const Type *_elem;            // Element type of array
 995   const TypeInt *_size;         // Elements in array
 996   const bool _stable;           // Are elements @Stable?







 997   friend class TypeAryPtr;
 998 
 999 public:
1000   static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false);

1001 
1002   virtual const Type *xmeet( const Type *t ) const;
1003   virtual const Type *xdual() const;    // Compute dual right now.
1004   bool ary_must_be_exact() const;  // true if arrays of such are never generic
1005   virtual const TypeAry* remove_speculative() const;
1006   virtual const Type* cleanup_speculative() const;
1007 #ifndef PRODUCT
1008   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
1009 #endif
1010 };
1011 
1012 //------------------------------TypeVect---------------------------------------
1013 // Class of Vector Types
1014 class TypeVect : public Type {
1015   const BasicType _elem_bt;  // Vector's element type
1016   const uint _length;  // Elements in vector (power of 2)
1017 
1018 protected:
1019   TypeVect(TYPES t, BasicType elem_bt, uint length) : Type(t),
1020     _elem_bt(elem_bt), _length(length) {}

1127   const Type* xmeet(const Type* t) const;
1128 
1129   bool singleton(void) const;
1130   bool has_non_array_interface() const;
1131 };
1132 
1133 //------------------------------TypePtr----------------------------------------
1134 // Class of machine Pointer Types: raw data, instances or arrays.
1135 // If the _base enum is AnyPtr, then this refers to all of the above.
1136 // Otherwise the _base will indicate which subset of pointers is affected,
1137 // and the class will be inherited from.
1138 class TypePtr : public Type {
1139   friend class TypeNarrowPtr;
1140   friend class Type;
1141 protected:
1142   static const TypeInterfaces* interfaces(ciKlass*& k, bool klass, bool interface, bool array, InterfaceHandling interface_handling);
1143 
1144 public:
1145   enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
1146 protected:
1147   TypePtr(TYPES t, PTR ptr, int offset,
1148           const TypePtr* speculative = nullptr,
1149           int inline_depth = InlineDepthBottom) :
1150     Type(t), _speculative(speculative), _inline_depth(inline_depth), _offset(offset),
1151     _ptr(ptr) {}
1152   static const PTR ptr_meet[lastPTR][lastPTR];
1153   static const PTR ptr_dual[lastPTR];
1154   static const char * const ptr_msg[lastPTR];
1155 
1156   enum {
1157     InlineDepthBottom = INT_MAX,
1158     InlineDepthTop = -InlineDepthBottom
1159   };
1160 
1161   // Extra type information profiling gave us. We propagate it the
1162   // same way the rest of the type info is propagated. If we want to
1163   // use it, then we have to emit a guard: this part of the type is
1164   // not something we know but something we speculate about the type.
1165   const TypePtr*   _speculative;
1166   // For speculative types, we record at what inlining depth the
1167   // profiling point that provided the data is. We want to favor

1183   // utility methods to work on the inline depth of the type
1184   int dual_inline_depth() const;
1185   int meet_inline_depth(int depth) const;
1186 #ifndef PRODUCT
1187   void dump_inline_depth(outputStream *st) const;
1188 #endif
1189 
1190   // TypeInstPtr (TypeAryPtr resp.) and TypeInstKlassPtr (TypeAryKlassPtr resp.) implement very similar meet logic.
1191   // The logic for meeting 2 instances (2 arrays resp.) is shared in the 2 utility methods below. However the logic for
1192   // the oop and klass versions can be slightly different and extra logic may have to be executed depending on what
1193   // exact case the meet falls into. The MeetResult struct is used by the utility methods to communicate what case was
1194   // encountered so the right logic specific to klasses or oops can be executed.,
1195   enum MeetResult {
1196     QUICK,
1197     UNLOADED,
1198     SUBTYPE,
1199     NOT_SUBTYPE,
1200     LCA
1201   };
1202   template<class T> static TypePtr::MeetResult meet_instptr(PTR& ptr, const TypeInterfaces*& interfaces, const T* this_type,
1203                                                             const T* other_type, ciKlass*& res_klass, bool& res_xk);



1204 
1205   template<class T> static MeetResult meet_aryptr(PTR& ptr, const Type*& elem, const T* this_ary, const T* other_ary,
1206                                                   ciKlass*& res_klass, bool& res_xk);
1207 
1208   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);
1209   template <class T1, class T2> static bool is_same_java_type_as_helper_for_instance(const T1* this_one, const T2* other);
1210   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);
1211   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);
1212   template <class T1, class T2> static bool is_same_java_type_as_helper_for_array(const T1* this_one, const T2* other);
1213   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);
1214   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);
1215   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);
1216 public:
1217   const int _offset;            // Offset into oop, with TOP & BOT
1218   const PTR _ptr;               // Pointer equivalence class
1219 
1220   int offset() const { return _offset; }
1221   PTR ptr()    const { return _ptr; }
1222 
1223   static const TypePtr *make(TYPES t, PTR ptr, int offset,
1224                              const TypePtr* speculative = nullptr,
1225                              int inline_depth = InlineDepthBottom);
1226 
1227   // Return a 'ptr' version of this type
1228   virtual const TypePtr* cast_to_ptr_type(PTR ptr) const;
1229 
1230   virtual intptr_t get_con() const;
1231 
1232   int xadd_offset( intptr_t offset ) const;
1233   virtual const TypePtr* add_offset(intptr_t offset) const;
1234   virtual const TypePtr* with_offset(intptr_t offset) const;

1235   virtual bool eq(const Type *t) const;
1236   virtual uint hash() const;             // Type specific hashing
1237 
1238   virtual bool singleton(void) const;    // TRUE if type is a singleton
1239   virtual bool empty(void) const;        // TRUE if type is vacuous
1240   virtual const Type *xmeet( const Type *t ) const;
1241   virtual const Type *xmeet_helper( const Type *t ) const;
1242   int meet_offset( int offset ) const;
1243   int dual_offset( ) const;
1244   virtual const Type *xdual() const;    // Compute dual right now.
1245 
1246   // meet, dual and join over pointer equivalence sets
1247   PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
1248   PTR dual_ptr()                   const { return ptr_dual[ptr()];      }
1249 
1250   // This is textually confusing unless one recalls that
1251   // join(t) == dual()->meet(t->dual())->dual().
1252   PTR join_ptr( const PTR in_ptr ) const {
1253     return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
1254   }
1255 
1256   // Speculative type helper methods.
1257   virtual const TypePtr* speculative() const { return _speculative; }
1258   int inline_depth() const                   { return _inline_depth; }
1259   virtual ciKlass* speculative_type() const;
1260   virtual ciKlass* speculative_type_not_null() const;
1261   virtual bool speculative_maybe_null() const;
1262   virtual bool speculative_always_null() const;
1263   virtual const TypePtr* remove_speculative() const;
1264   virtual const Type* cleanup_speculative() const;
1265   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1266   virtual bool would_improve_ptr(ProfilePtrKind maybe_null) const;
1267   virtual const TypePtr* with_inline_depth(int depth) const;
1268 
1269   virtual bool maybe_null() const { return meet_ptr(Null) == ptr(); }
1270 









1271   // Tests for relation to centerline of type lattice:
1272   static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
1273   static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
1274   // Convenience common pre-built types.
1275   static const TypePtr *NULL_PTR;
1276   static const TypePtr *NOTNULL;
1277   static const TypePtr *BOTTOM;
1278 #ifndef PRODUCT
1279   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1280 #endif
1281 };
1282 
1283 //------------------------------TypeRawPtr-------------------------------------
1284 // Class of raw pointers, pointers to things other than Oops.  Examples
1285 // include the stack pointer, top of heap, card-marking area, handles, etc.
1286 class TypeRawPtr : public TypePtr {
1287 protected:
1288   TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){}
1289 public:
1290   virtual bool eq( const Type *t ) const;
1291   virtual uint hash() const;    // Type specific hashing
1292 
1293   const address _bits;          // Constant value, if applicable
1294 
1295   static const TypeRawPtr *make( PTR ptr );
1296   static const TypeRawPtr *make( address bits );
1297 
1298   // Return a 'ptr' version of this type
1299   virtual const TypeRawPtr* cast_to_ptr_type(PTR ptr) const;
1300 
1301   virtual intptr_t get_con() const;
1302 
1303   virtual const TypePtr* add_offset(intptr_t offset) const;
1304   virtual const TypeRawPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr;}
1305 
1306   virtual const Type *xmeet( const Type *t ) const;
1307   virtual const Type *xdual() const;    // Compute dual right now.
1308   // Convenience common pre-built types.
1309   static const TypeRawPtr *BOTTOM;
1310   static const TypeRawPtr *NOTNULL;
1311 #ifndef PRODUCT
1312   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1313 #endif
1314 };
1315 
1316 //------------------------------TypeOopPtr-------------------------------------
1317 // Some kind of oop (Java pointer), either instance or array.
1318 class TypeOopPtr : public TypePtr {
1319   friend class TypeAry;
1320   friend class TypePtr;
1321   friend class TypeInstPtr;
1322   friend class TypeAryPtr;
1323 protected:
1324  TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, int offset, int instance_id,
1325             const TypePtr* speculative, int inline_depth);
1326 public:
1327   virtual bool eq( const Type *t ) const;
1328   virtual uint hash() const;             // Type specific hashing
1329   virtual bool singleton(void) const;    // TRUE if type is a singleton
1330   enum {
1331    InstanceTop = -1,   // undefined instance
1332    InstanceBot = 0     // any possible instance
1333   };
1334 protected:
1335 
1336   // Oop is null, unless this is a constant oop.
1337   ciObject*     _const_oop;   // Constant oop
1338   // If _klass is null, then so is _sig.  This is an unloaded klass.
1339   ciKlass*      _klass;       // Klass object
1340 
1341   const TypeInterfaces* _interfaces;
1342 
1343   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
1344   bool          _klass_is_exact;
1345   bool          _is_ptr_to_narrowoop;
1346   bool          _is_ptr_to_narrowklass;
1347   bool          _is_ptr_to_boxed_value;
1348 
1349   // If not InstanceTop or InstanceBot, indicates that this is
1350   // a particular instance of this type which is distinct.
1351   // This is the node index of the allocation node creating this instance.
1352   int           _instance_id;
1353 
1354   static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact, InterfaceHandling interface_handling);
1355 
1356   int dual_instance_id() const;
1357   int meet_instance_id(int uid) const;
1358 
1359   const TypeInterfaces* meet_interfaces(const TypeOopPtr* other) const;
1360 
1361   // Do not allow interface-vs.-noninterface joins to collapse to top.
1362   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1363 
1364   virtual ciKlass* exact_klass_helper() const { return nullptr; }
1365   virtual ciKlass* klass() const { return _klass;     }
1366 
1367 public:
1368 
1369   bool is_java_subtype_of(const TypeOopPtr* other) const {
1370     return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1371   }
1372 
1373   bool is_same_java_type_as(const TypePtr* other) const {
1374     return is_same_java_type_as_helper(other->is_oopptr());
1375   }
1376 
1377   virtual bool is_same_java_type_as_helper(const TypeOopPtr* other) const {
1378     ShouldNotReachHere(); return false;
1379   }
1380 
1381   bool maybe_java_subtype_of(const TypeOopPtr* other) const {
1382     return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1383   }
1384   virtual bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1385   virtual bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }

1392     return make_from_klass_common(klass, true, false, interface_handling);
1393   }
1394   // Same as before, but will produce an exact type, even if
1395   // the klass is not final, as long as it has exactly one implementation.
1396   static const TypeOopPtr* make_from_klass_unique(ciKlass* klass, InterfaceHandling interface_handling= ignore_interfaces) {
1397     return make_from_klass_common(klass, true, true, interface_handling);
1398   }
1399   // Same as before, but does not respects UseUniqueSubclasses.
1400   // Use this only for creating array element types.
1401   static const TypeOopPtr* make_from_klass_raw(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1402     return make_from_klass_common(klass, false, false, interface_handling);
1403   }
1404   // Creates a singleton type given an object.
1405   // If the object cannot be rendered as a constant,
1406   // may return a non-singleton type.
1407   // If require_constant, produce a null if a singleton is not possible.
1408   static const TypeOopPtr* make_from_constant(ciObject* o,
1409                                               bool require_constant = false);
1410 
1411   // Make a generic (unclassed) pointer to an oop.
1412   static const TypeOopPtr* make(PTR ptr, int offset, int instance_id,
1413                                 const TypePtr* speculative = nullptr,
1414                                 int inline_depth = InlineDepthBottom);
1415 
1416   ciObject* const_oop()    const { return _const_oop; }
1417   // Exact klass, possibly an interface or an array of interface
1418   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k;  }
1419   ciKlass* unloaded_klass() const { assert(!is_loaded(), "only for unloaded types"); return klass(); }
1420 
1421   virtual bool  is_loaded() const { return klass()->is_loaded(); }
1422   virtual bool klass_is_exact()    const { return _klass_is_exact; }
1423 
1424   // Returns true if this pointer points at memory which contains a
1425   // compressed oop references.
1426   bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
1427   bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
1428   bool is_ptr_to_boxed_value()   const { return _is_ptr_to_boxed_value; }
1429   bool is_known_instance()       const { return _instance_id > 0; }
1430   int  instance_id()             const { return _instance_id; }
1431   bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }



1432 
1433   virtual intptr_t get_con() const;
1434 
1435   virtual const TypeOopPtr* cast_to_ptr_type(PTR ptr) const;
1436 
1437   virtual const TypeOopPtr* cast_to_exactness(bool klass_is_exact) const;
1438 
1439   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1440 
1441   // corresponding pointer to klass, for a given instance
1442   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1443 
1444   virtual const TypeOopPtr* with_offset(intptr_t offset) const;
1445   virtual const TypePtr* add_offset(intptr_t offset) const;
1446 
1447   // Speculative type helper methods.
1448   virtual const TypeOopPtr* remove_speculative() const;
1449   virtual const Type* cleanup_speculative() const;
1450   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1451   virtual const TypePtr* with_inline_depth(int depth) const;

1474     return _interfaces;
1475   };
1476 
1477   const TypeOopPtr* is_reference_type(const Type* other) const {
1478     return other->isa_oopptr();
1479   }
1480 
1481   const TypeAryPtr* is_array_type(const TypeOopPtr* other) const {
1482     return other->isa_aryptr();
1483   }
1484 
1485   const TypeInstPtr* is_instance_type(const TypeOopPtr* other) const {
1486     return other->isa_instptr();
1487   }
1488 };
1489 
1490 //------------------------------TypeInstPtr------------------------------------
1491 // Class of Java object pointers, pointing either to non-array Java instances
1492 // or to a Klass* (including array klasses).
1493 class TypeInstPtr : public TypeOopPtr {
1494   TypeInstPtr(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, int off, int instance_id,
1495               const TypePtr* speculative, int inline_depth);

1496   virtual bool eq( const Type *t ) const;
1497   virtual uint hash() const;             // Type specific hashing
1498 
1499   ciKlass* exact_klass_helper() const;
1500 
1501 public:
1502 
1503   // Instance klass, ignoring any interface
1504   ciInstanceKlass* instance_klass() const {
1505     assert(!(klass()->is_loaded() && klass()->is_interface()), "");
1506     return klass()->as_instance_klass();
1507   }
1508 
1509   bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1510   bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1511   bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1512 
1513   // Make a pointer to a constant oop.
1514   static const TypeInstPtr *make(ciObject* o) {
1515     ciKlass* k = o->klass();
1516     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1517     return make(TypePtr::Constant, k, interfaces, true, o, 0, InstanceBot);
1518   }
1519   // Make a pointer to a constant oop with offset.
1520   static const TypeInstPtr *make(ciObject* o, int offset) {
1521     ciKlass* k = o->klass();
1522     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1523     return make(TypePtr::Constant, k, interfaces, true, o, offset, InstanceBot);
1524   }
1525 
1526   // Make a pointer to some value of type klass.
1527   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1528     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, true, false, interface_handling);
1529     return make(ptr, klass, interfaces, false, nullptr, 0, InstanceBot);
1530   }
1531 
1532   // Make a pointer to some non-polymorphic value of exactly type klass.
1533   static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
1534     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1535     return make(ptr, klass, interfaces, true, nullptr, 0, InstanceBot);
1536   }
1537 
1538   // Make a pointer to some value of type klass with offset.
1539   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
1540     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1541     return make(ptr, klass, interfaces, false, nullptr, offset, InstanceBot);
1542   }
1543 
1544   static const TypeInstPtr *make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, int offset,


1545                                  int instance_id = InstanceBot,
1546                                  const TypePtr* speculative = nullptr,
1547                                  int inline_depth = InlineDepthBottom);
1548 
1549   static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot) {
1550     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1551     return make(ptr, k, interfaces, xk, o, offset, instance_id);
1552   }
1553 
1554   /** Create constant type for a constant boxed value */
1555   const Type* get_const_boxed_value() const;
1556 
1557   // If this is a java.lang.Class constant, return the type for it or null.
1558   // Pass to Type::get_const_type to turn it to a type, which will usually
1559   // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
1560   ciType* java_mirror_type() const;
1561 
1562   virtual const TypeInstPtr* cast_to_ptr_type(PTR ptr) const;
1563 
1564   virtual const TypeInstPtr* cast_to_exactness(bool klass_is_exact) const;
1565 
1566   virtual const TypeInstPtr* cast_to_instance_id(int instance_id) const;
1567 
1568   virtual const TypePtr* add_offset(intptr_t offset) const;
1569   virtual const TypeInstPtr* with_offset(intptr_t offset) const;
1570 
1571   // Speculative type helper methods.
1572   virtual const TypeInstPtr* remove_speculative() const;
1573   const TypeInstPtr* with_speculative(const TypePtr* speculative) const;
1574   virtual const TypePtr* with_inline_depth(int depth) const;
1575   virtual const TypePtr* with_instance_id(int instance_id) const;
1576 




1577   // the core of the computation of the meet of 2 types
1578   virtual const Type *xmeet_helper(const Type *t) const;
1579   virtual const TypeInstPtr *xmeet_unloaded(const TypeInstPtr *tinst, const TypeInterfaces* interfaces) const;
1580   virtual const Type *xdual() const;    // Compute dual right now.
1581 
1582   const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1583 


1584   // Convenience common pre-built types.
1585   static const TypeInstPtr *NOTNULL;
1586   static const TypeInstPtr *BOTTOM;
1587   static const TypeInstPtr *MIRROR;
1588   static const TypeInstPtr *MARK;
1589   static const TypeInstPtr *KLASS;
1590 #ifndef PRODUCT
1591   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1592 #endif
1593 
1594 private:
1595   virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1596 
1597   virtual bool is_meet_same_type_as(const TypePtr* other) const {
1598     return _klass->equals(other->is_instptr()->_klass) && _interfaces->eq(other->is_instptr()->_interfaces);
1599   }
1600 
1601 };
1602 
1603 //------------------------------TypeAryPtr-------------------------------------
1604 // Class of Java array pointers
1605 class TypeAryPtr : public TypeOopPtr {
1606   friend class Type;
1607   friend class TypePtr;

1608   friend class TypeInterfaces;
1609 
1610   TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1611               int offset, int instance_id, bool is_autobox_cache,
1612               const TypePtr* speculative, int inline_depth)
1613     : TypeOopPtr(AryPtr,ptr,k,_array_interfaces,xk,o,offset, instance_id, speculative, inline_depth),
1614     _ary(ary),
1615     _is_autobox_cache(is_autobox_cache)

1616  {
1617     int dummy;
1618     bool top_or_bottom = (base_element_type(dummy) == Type::TOP || base_element_type(dummy) == Type::BOTTOM);
1619 
1620     if (UseCompressedOops && (elem()->make_oopptr() != nullptr && !top_or_bottom) &&
1621         _offset != 0 && _offset != arrayOopDesc::length_offset_in_bytes() &&
1622         _offset != arrayOopDesc::klass_offset_in_bytes()) {
1623       _is_ptr_to_narrowoop = true;
1624     }
1625 
1626   }
1627   virtual bool eq( const Type *t ) const;
1628   virtual uint hash() const;    // Type specific hashing
1629   const TypeAry *_ary;          // Array we point into
1630   const bool     _is_autobox_cache;






1631 
1632   ciKlass* compute_klass() const;
1633 
1634   // A pointer to delay allocation to Type::Initialize_shared()
1635 
1636   static const TypeInterfaces* _array_interfaces;
1637   ciKlass* exact_klass_helper() const;
1638   // Only guaranteed non null for array of basic types
1639   ciKlass* klass() const;
1640 
1641 public:
1642 
1643   bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1644   bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1645   bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1646 
1647   // returns base element type, an instance klass (and not interface) for object arrays
1648   const Type* base_element_type(int& dims) const;
1649 
1650   // Accessors
1651   bool  is_loaded() const { return (_ary->_elem->make_oopptr() ? _ary->_elem->make_oopptr()->is_loaded() : true); }
1652 
1653   const TypeAry* ary() const  { return _ary; }
1654   const Type*    elem() const { return _ary->_elem; }
1655   const TypeInt* size() const { return _ary->_size; }
1656   bool      is_stable() const { return _ary->_stable; }
1657 







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

1661                                 int instance_id = InstanceBot,
1662                                 const TypePtr* speculative = nullptr,
1663                                 int inline_depth = InlineDepthBottom);
1664   // Constant pointer to array
1665   static const TypeAryPtr *make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset,

1666                                 int instance_id = InstanceBot,
1667                                 const TypePtr* speculative = nullptr,
1668                                 int inline_depth = InlineDepthBottom, bool is_autobox_cache = false);

1669 
1670   // Return a 'ptr' version of this type
1671   virtual const TypeAryPtr* cast_to_ptr_type(PTR ptr) const;
1672 
1673   virtual const TypeAryPtr* cast_to_exactness(bool klass_is_exact) const;
1674 
1675   virtual const TypeAryPtr* cast_to_instance_id(int instance_id) const;
1676 
1677   virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1678   virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1679 
1680   virtual bool empty(void) const;        // TRUE if type is vacuous
1681   virtual const TypePtr *add_offset( intptr_t offset ) const;
1682   virtual const TypeAryPtr *with_offset( intptr_t offset ) const;
1683   const TypeAryPtr* with_ary(const TypeAry* ary) const;
1684 
1685   // Speculative type helper methods.
1686   virtual const TypeAryPtr* remove_speculative() const;

1687   virtual const TypePtr* with_inline_depth(int depth) const;
1688   virtual const TypePtr* with_instance_id(int instance_id) const;
1689 
1690   // the core of the computation of the meet of 2 types
1691   virtual const Type *xmeet_helper(const Type *t) const;
1692   virtual const Type *xdual() const;    // Compute dual right now.
1693 








1694   const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1695   int stable_dimension() const;
1696 
1697   const TypeAryPtr* cast_to_autobox_cache() const;
1698 
1699   static jint max_array_length(BasicType etype) ;







1700   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1701 


1702   // Convenience common pre-built types.
1703   static const TypeAryPtr* BOTTOM;
1704   static const TypeAryPtr* RANGE;
1705   static const TypeAryPtr* OOPS;
1706   static const TypeAryPtr* NARROWOOPS;
1707   static const TypeAryPtr* BYTES;
1708   static const TypeAryPtr* SHORTS;
1709   static const TypeAryPtr* CHARS;
1710   static const TypeAryPtr* INTS;
1711   static const TypeAryPtr* LONGS;
1712   static const TypeAryPtr* FLOATS;
1713   static const TypeAryPtr* DOUBLES;

1714   // selects one of the above:
1715   static const TypeAryPtr *get_array_body_type(BasicType elem) {
1716     assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != nullptr, "bad elem type");
1717     return _array_body_type[elem];
1718   }
1719   static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1720   // sharpen the type of an int which is used as an array size
1721 #ifndef PRODUCT
1722   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1723 #endif
1724 private:
1725   virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1726 };
1727 
1728 //------------------------------TypeMetadataPtr-------------------------------------
1729 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
1730 class TypeMetadataPtr : public TypePtr {
1731 protected:
1732   TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset);
1733   // Do not allow interface-vs.-noninterface joins to collapse to top.
1734   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1735 public:
1736   virtual bool eq( const Type *t ) const;
1737   virtual uint hash() const;             // Type specific hashing
1738   virtual bool singleton(void) const;    // TRUE if type is a singleton
1739 
1740 private:
1741   ciMetadata*   _metadata;
1742 
1743 public:
1744   static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, int offset);
1745 
1746   static const TypeMetadataPtr* make(ciMethod* m);
1747   static const TypeMetadataPtr* make(ciMethodData* m);
1748 
1749   ciMetadata* metadata() const { return _metadata; }
1750 
1751   virtual const TypeMetadataPtr* cast_to_ptr_type(PTR ptr) const;
1752 
1753   virtual const TypePtr *add_offset( intptr_t offset ) const;
1754 
1755   virtual const Type *xmeet( const Type *t ) const;
1756   virtual const Type *xdual() const;    // Compute dual right now.
1757 
1758   virtual intptr_t get_con() const;
1759 
1760   // Convenience common pre-built types.
1761   static const TypeMetadataPtr *BOTTOM;
1762 
1763 #ifndef PRODUCT
1764   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1765 #endif
1766 };
1767 
1768 //------------------------------TypeKlassPtr-----------------------------------
1769 // Class of Java Klass pointers
1770 class TypeKlassPtr : public TypePtr {
1771   friend class TypeInstKlassPtr;
1772   friend class TypeAryKlassPtr;
1773   friend class TypePtr;
1774 protected:
1775   TypeKlassPtr(TYPES t, PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, int offset);
1776 
1777   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1778 
1779 public:
1780   virtual bool eq( const Type *t ) const;
1781   virtual uint hash() const;
1782   virtual bool singleton(void) const;    // TRUE if type is a singleton
1783 
1784 protected:
1785 
1786   ciKlass* _klass;
1787   const TypeInterfaces* _interfaces;
1788   const TypeInterfaces* meet_interfaces(const TypeKlassPtr* other) const;
1789   virtual bool must_be_exact() const { ShouldNotReachHere(); return false; }
1790   virtual ciKlass* exact_klass_helper() const;
1791   virtual ciKlass* klass() const { return  _klass; }
1792 
1793 public:
1794 
1795   bool is_java_subtype_of(const TypeKlassPtr* other) const {
1796     return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1797   }
1798   bool is_same_java_type_as(const TypePtr* other) const {
1799     return is_same_java_type_as_helper(other->is_klassptr());
1800   }
1801 
1802   bool maybe_java_subtype_of(const TypeKlassPtr* other) const {
1803     return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1804   }
1805   virtual bool is_same_java_type_as_helper(const TypeKlassPtr* other) const { ShouldNotReachHere(); return false; }
1806   virtual bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1807   virtual bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1808 
1809   // Exact klass, possibly an interface or an array of interface
1810   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k;  }
1811   virtual bool klass_is_exact()    const { return _ptr == Constant; }
1812 
1813   static const TypeKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces);
1814   static const TypeKlassPtr *make(PTR ptr, ciKlass* klass, int offset, InterfaceHandling interface_handling = ignore_interfaces);
1815 
1816   virtual bool  is_loaded() const { return _klass->is_loaded(); }
1817 
1818   virtual const TypeKlassPtr* cast_to_ptr_type(PTR ptr) const { ShouldNotReachHere(); return nullptr; }
1819 
1820   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const { ShouldNotReachHere(); return nullptr; }
1821 
1822   // corresponding pointer to instance, for a given class
1823   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const { ShouldNotReachHere(); return nullptr; }
1824 
1825   virtual const TypePtr *add_offset( intptr_t offset ) const { ShouldNotReachHere(); return nullptr; }
1826   virtual const Type    *xmeet( const Type *t ) const { ShouldNotReachHere(); return nullptr; }
1827   virtual const Type    *xdual() const { ShouldNotReachHere(); return nullptr; }
1828 
1829   virtual intptr_t get_con() const;
1830 
1831   virtual const TypeKlassPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr; }
1832 






1833   virtual const TypeKlassPtr* try_improve() const { return this; }
1834 
1835 #ifndef PRODUCT
1836   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1837 #endif
1838 private:
1839   virtual bool is_meet_subtype_of(const TypePtr* other) const {
1840     return is_meet_subtype_of_helper(other->is_klassptr(), klass_is_exact(), other->is_klassptr()->klass_is_exact());
1841   }
1842 
1843   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const {
1844     ShouldNotReachHere(); return false;
1845   }
1846 
1847   virtual const TypeInterfaces* interfaces() const {
1848     return _interfaces;
1849   };
1850 
1851   const TypeKlassPtr* is_reference_type(const Type* other) const {
1852     return other->isa_klassptr();
1853   }
1854 
1855   const TypeAryKlassPtr* is_array_type(const TypeKlassPtr* other) const {
1856     return other->isa_aryklassptr();
1857   }
1858 
1859   const TypeInstKlassPtr* is_instance_type(const TypeKlassPtr* other) const {
1860     return other->isa_instklassptr();
1861   }
1862 };
1863 
1864 // Instance klass pointer, mirrors TypeInstPtr
1865 class TypeInstKlassPtr : public TypeKlassPtr {
1866 
1867   TypeInstKlassPtr(PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, int offset)
1868     : TypeKlassPtr(InstKlassPtr, ptr, klass, interfaces, offset) {
1869     assert(klass->is_instance_klass() && (!klass->is_loaded() || !klass->is_interface()), "");
1870   }
1871 
1872   virtual bool must_be_exact() const;
1873 


1874 public:
1875   // Instance klass ignoring any interface
1876   ciInstanceKlass* instance_klass() const {
1877     assert(!klass()->is_interface(), "");
1878     return klass()->as_instance_klass();
1879   }
1880 
1881   bool might_be_an_array() const;
1882 
1883   bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
1884   bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1885   bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1886 


1887   static const TypeInstKlassPtr *make(ciKlass* k, InterfaceHandling interface_handling) {
1888     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, true, false, interface_handling);
1889     return make(TypePtr::Constant, k, interfaces, 0);
1890   }
1891   static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, int offset);
1892 
1893   static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, int offset) {
1894     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1895     return make(ptr, k, interfaces, offset);
1896   }
1897 
1898   virtual const TypeInstKlassPtr* cast_to_ptr_type(PTR ptr) const;
1899 
1900   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1901 
1902   // corresponding pointer to instance, for a given class
1903   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
1904   virtual uint hash() const;
1905   virtual bool eq(const Type *t) const;
1906 
1907   virtual const TypePtr *add_offset( intptr_t offset ) const;
1908   virtual const Type    *xmeet( const Type *t ) const;
1909   virtual const Type    *xdual() const;
1910   virtual const TypeInstKlassPtr* with_offset(intptr_t offset) const;
1911 
1912   virtual const TypeKlassPtr* try_improve() const;
1913 





















1914   // Convenience common pre-built types.
1915   static const TypeInstKlassPtr* OBJECT; // Not-null object klass or below
1916   static const TypeInstKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
1917 private:
1918   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
1919 };
1920 
1921 // Array klass pointer, mirrors TypeAryPtr
1922 class TypeAryKlassPtr : public TypeKlassPtr {
1923   friend class TypeInstKlassPtr;
1924   friend class Type;
1925   friend class TypePtr;
1926 
1927   const Type *_elem;






1928 
1929   static const TypeInterfaces* _array_interfaces;
1930   TypeAryKlassPtr(PTR ptr, const Type *elem, ciKlass* klass, int offset)
1931     : TypeKlassPtr(AryKlassPtr, ptr, klass, _array_interfaces, offset), _elem(elem) {
1932     assert(klass == nullptr || klass->is_type_array_klass() || !klass->as_obj_array_klass()->base_element_klass()->is_interface(), "");
1933   }
1934 
1935   virtual ciKlass* exact_klass_helper() const;
1936   // Only guaranteed non null for array of basic types
1937   virtual ciKlass* klass() const;
1938 
1939   virtual bool must_be_exact() const;
1940 
























1941 public:
1942 
1943   // returns base element type, an instance klass (and not interface) for object arrays
1944   const Type* base_element_type(int& dims) const;
1945 
1946   static const TypeAryKlassPtr *make(PTR ptr, ciKlass* k, int offset, InterfaceHandling interface_handling);
1947 
1948   bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
1949   bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1950   bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1951 
1952   bool  is_loaded() const { return (_elem->isa_klassptr() ? _elem->is_klassptr()->is_loaded() : true); }
1953 
1954   static const TypeAryKlassPtr *make(PTR ptr, const Type *elem, ciKlass* k, int offset);
1955   static const TypeAryKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling);



1956 
1957   const Type *elem() const { return _elem; }
1958 
1959   virtual bool eq(const Type *t) const;
1960   virtual uint hash() const;             // Type specific hashing
1961 
1962   virtual const TypeAryKlassPtr* cast_to_ptr_type(PTR ptr) const;
1963 
1964   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1965 
1966   // corresponding pointer to instance, for a given class
1967   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
1968 
1969   virtual const TypePtr *add_offset( intptr_t offset ) const;
1970   virtual const Type    *xmeet( const Type *t ) const;
1971   virtual const Type    *xdual() const;      // Compute dual right now.
1972 
1973   virtual const TypeAryKlassPtr* with_offset(intptr_t offset) const;
1974 
1975   virtual bool empty(void) const {
1976     return TypeKlassPtr::empty() || _elem->empty();
1977   }
1978 








1979 #ifndef PRODUCT
1980   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1981 #endif
1982 private:
1983   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
1984 };
1985 
1986 class TypeNarrowPtr : public Type {
1987 protected:
1988   const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
1989 
1990   TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): Type(t),
1991                                                   _ptrtype(ptrtype) {
1992     assert(ptrtype->offset() == 0 ||
1993            ptrtype->offset() == OffsetBot ||
1994            ptrtype->offset() == OffsetTop, "no real offsets");
1995   }
1996 
1997   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
1998   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;

2094   }
2095 
2096   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
2097     return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
2098   }
2099 
2100 public:
2101   static const TypeNarrowKlass *make( const TypePtr* type);
2102 
2103   // static const TypeNarrowKlass *BOTTOM;
2104   static const TypeNarrowKlass *NULL_PTR;
2105 
2106 #ifndef PRODUCT
2107   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
2108 #endif
2109 };
2110 
2111 //------------------------------TypeFunc---------------------------------------
2112 // Class of Array Types
2113 class TypeFunc : public Type {
2114   TypeFunc( const TypeTuple *domain, const TypeTuple *range ) : Type(Function),  _domain(domain), _range(range) {}

2115   virtual bool eq( const Type *t ) const;
2116   virtual uint hash() const;             // Type specific hashing
2117   virtual bool singleton(void) const;    // TRUE if type is a singleton
2118   virtual bool empty(void) const;        // TRUE if type is vacuous
2119 
2120   const TypeTuple* const _domain;     // Domain of inputs
2121   const TypeTuple* const _range;      // Range of results











2122 
2123 public:
2124   // Constants are shared among ADLC and VM
2125   enum { Control    = AdlcVMDeps::Control,
2126          I_O        = AdlcVMDeps::I_O,
2127          Memory     = AdlcVMDeps::Memory,
2128          FramePtr   = AdlcVMDeps::FramePtr,
2129          ReturnAdr  = AdlcVMDeps::ReturnAdr,
2130          Parms      = AdlcVMDeps::Parms
2131   };
2132 
2133 
2134   // Accessors:
2135   const TypeTuple* domain() const { return _domain; }
2136   const TypeTuple* range()  const { return _range; }
2137 
2138   static const TypeFunc *make(ciMethod* method);
2139   static const TypeFunc *make(ciSignature signature, const Type* extra);



2140   static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
2141 
2142   virtual const Type *xmeet( const Type *t ) const;
2143   virtual const Type *xdual() const;    // Compute dual right now.
2144 
2145   BasicType return_type() const;
2146 


2147 #ifndef PRODUCT
2148   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
2149 #endif
2150   // Convenience common pre-built types.
2151 };
2152 
2153 //------------------------------accessors--------------------------------------
2154 inline bool Type::is_ptr_to_narrowoop() const {
2155 #ifdef _LP64
2156   return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowoop_nv());
2157 #else
2158   return false;
2159 #endif
2160 }
2161 
2162 inline bool Type::is_ptr_to_narrowklass() const {
2163 #ifdef _LP64
2164   return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowklass_nv());
2165 #else
2166   return false;

2403 }
2404 
2405 inline const TypeNarrowOop* Type::make_narrowoop() const {
2406   return (_base == NarrowOop) ? is_narrowoop() :
2407                                 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : nullptr);
2408 }
2409 
2410 inline const TypeNarrowKlass* Type::make_narrowklass() const {
2411   return (_base == NarrowKlass) ? is_narrowklass() :
2412                                   (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : nullptr);
2413 }
2414 
2415 inline bool Type::is_floatingpoint() const {
2416   if( (_base == HalfFloatCon)  || (_base == HalfFloatBot) ||
2417       (_base == FloatCon)  || (_base == FloatBot) ||
2418       (_base == DoubleCon) || (_base == DoubleBot) )
2419     return true;
2420   return false;
2421 }
2422 








2423 template <>
2424 inline const TypeInt* Type::cast<TypeInt>() const {
2425   return is_int();
2426 }
2427 
2428 template <>
2429 inline const TypeLong* Type::cast<TypeLong>() const {
2430   return is_long();
2431 }
2432 
2433 template <>
2434 inline const TypeInt* Type::try_cast<TypeInt>() const {
2435   return isa_int();
2436 }
2437 
2438 template <>
2439 inline const TypeLong* Type::try_cast<TypeLong>() const {
2440   return isa_long();
2441 }
2442 

2448 
2449 // For type queries and asserts
2450 #define is_intptr_t  is_long
2451 #define isa_intptr_t isa_long
2452 #define find_intptr_t_type find_long_type
2453 #define find_intptr_t_con  find_long_con
2454 #define TypeX        TypeLong
2455 #define Type_X       Type::Long
2456 #define TypeX_X      TypeLong::LONG
2457 #define TypeX_ZERO   TypeLong::ZERO
2458 // For 'ideal_reg' machine registers
2459 #define Op_RegX      Op_RegL
2460 // For phase->intcon variants
2461 #define MakeConX     longcon
2462 #define ConXNode     ConLNode
2463 // For array index arithmetic
2464 #define MulXNode     MulLNode
2465 #define AndXNode     AndLNode
2466 #define OrXNode      OrLNode
2467 #define CmpXNode     CmpLNode

2468 #define SubXNode     SubLNode
2469 #define LShiftXNode  LShiftLNode
2470 // For object size computation:
2471 #define AddXNode     AddLNode
2472 #define RShiftXNode  RShiftLNode
2473 // For card marks and hashcodes
2474 #define URShiftXNode URShiftLNode
2475 // For shenandoahSupport
2476 #define LoadXNode    LoadLNode
2477 #define StoreXNode   StoreLNode
2478 // Opcodes
2479 #define Op_LShiftX   Op_LShiftL
2480 #define Op_AndX      Op_AndL
2481 #define Op_AddX      Op_AddL
2482 #define Op_SubX      Op_SubL
2483 #define Op_XorX      Op_XorL
2484 #define Op_URShiftX  Op_URShiftL
2485 #define Op_LoadX     Op_LoadL

2486 // conversions
2487 #define ConvI2X(x)   ConvI2L(x)
2488 #define ConvL2X(x)   (x)
2489 #define ConvX2I(x)   ConvL2I(x)
2490 #define ConvX2L(x)   (x)
2491 #define ConvX2UL(x)  (x)
2492 
2493 #else
2494 
2495 // For type queries and asserts
2496 #define is_intptr_t  is_int
2497 #define isa_intptr_t isa_int
2498 #define find_intptr_t_type find_int_type
2499 #define find_intptr_t_con  find_int_con
2500 #define TypeX        TypeInt
2501 #define Type_X       Type::Int
2502 #define TypeX_X      TypeInt::INT
2503 #define TypeX_ZERO   TypeInt::ZERO
2504 // For 'ideal_reg' machine registers
2505 #define Op_RegX      Op_RegI
2506 // For phase->intcon variants
2507 #define MakeConX     intcon
2508 #define ConXNode     ConINode
2509 // For array index arithmetic
2510 #define MulXNode     MulINode
2511 #define AndXNode     AndINode
2512 #define OrXNode      OrINode
2513 #define CmpXNode     CmpINode

2514 #define SubXNode     SubINode
2515 #define LShiftXNode  LShiftINode
2516 // For object size computation:
2517 #define AddXNode     AddINode
2518 #define RShiftXNode  RShiftINode
2519 // For card marks and hashcodes
2520 #define URShiftXNode URShiftINode
2521 // For shenandoahSupport
2522 #define LoadXNode    LoadINode
2523 #define StoreXNode   StoreINode
2524 // Opcodes
2525 #define Op_LShiftX   Op_LShiftI
2526 #define Op_AndX      Op_AndI
2527 #define Op_AddX      Op_AddI
2528 #define Op_SubX      Op_SubI
2529 #define Op_XorX      Op_XorI
2530 #define Op_URShiftX  Op_URShiftI
2531 #define Op_LoadX     Op_LoadI

2532 // conversions
2533 #define ConvI2X(x)   (x)
2534 #define ConvL2X(x)   ConvL2I(x)
2535 #define ConvX2I(x)   (x)
2536 #define ConvX2L(x)   ConvI2L(x)
2537 #define ConvX2UL(x)  ConvI2UL(x)
2538 
2539 #endif
2540 
2541 #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 "opto/compile.hpp"
  31 #include "opto/rangeinference.hpp"
  32 #include "runtime/handles.hpp"
  33 #include "runtime/sharedRuntime.hpp"
  34 
  35 // Portions of code courtesy of Clifford Click
  36 
  37 // Optimization - Graph Style
  38 
  39 
  40 // This class defines a Type lattice.  The lattice is used in the constant
  41 // propagation algorithms, and for some type-checking of the iloc code.
  42 // Basic types include RSD's (lower bound, upper bound, stride for integers),
  43 // float & double precision constants, sets of data-labels and code-labels.
  44 // The complete lattice is described below.  Subtypes have no relationship to
  45 // up or down in the lattice; that is entirely determined by the behavior of
  46 // the MEET/JOIN functions.
  47 
  48 class Dict;
  49 class Type;
  50 class   TypeD;
  51 class   TypeF;
  52 class   TypeH;
  53 class   TypeInteger;

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

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

 964   const Type ** const _fields;           // Array of field types
 965 
 966 public:
 967   virtual bool eq( const Type *t ) const;
 968   virtual uint hash() const;             // Type specific hashing
 969   virtual bool singleton(void) const;    // TRUE if type is a singleton
 970   virtual bool empty(void) const;        // TRUE if type is vacuous
 971 
 972   // Accessors:
 973   uint cnt() const { return _cnt; }
 974   const Type* field_at(uint i) const {
 975     assert(i < _cnt, "oob");
 976     return _fields[i];
 977   }
 978   void set_field_at(uint i, const Type* t) {
 979     assert(i < _cnt, "oob");
 980     _fields[i] = t;
 981   }
 982 
 983   static const TypeTuple *make( uint cnt, const Type **fields );
 984   static const TypeTuple *make_range(ciSignature* sig, InterfaceHandling interface_handling = ignore_interfaces, bool ret_vt_fields = false);
 985   static const TypeTuple *make_domain(ciMethod* method, InterfaceHandling interface_handling, bool vt_fields_as_args = false);
 986 
 987   // Subroutine call type with space allocated for argument types
 988   // Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly
 989   static const Type **fields( uint arg_cnt );
 990 
 991   virtual const Type *xmeet( const Type *t ) const;
 992   virtual const Type *xdual() const;    // Compute dual right now.
 993   // Convenience common pre-built types.
 994   static const TypeTuple *IFBOTH;
 995   static const TypeTuple *IFFALSE;
 996   static const TypeTuple *IFTRUE;
 997   static const TypeTuple *IFNEITHER;
 998   static const TypeTuple *LOOPBODY;
 999   static const TypeTuple *MEMBAR;
1000   static const TypeTuple *STORECONDITIONAL;
1001   static const TypeTuple *START_I2C;
1002   static const TypeTuple *INT_PAIR;
1003   static const TypeTuple *LONG_PAIR;
1004   static const TypeTuple *INT_CC_PAIR;
1005   static const TypeTuple *LONG_CC_PAIR;
1006 #ifndef PRODUCT
1007   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
1008 #endif
1009 };
1010 
1011 //------------------------------TypeAry----------------------------------------
1012 // Class of Array Types
1013 class TypeAry : public Type {
1014   TypeAry(const Type* elem, const TypeInt* size, bool stable, bool flat, bool not_flat, bool not_null_free, bool atomic) : Type(Array),
1015       _elem(elem), _size(size), _stable(stable), _flat(flat), _not_flat(not_flat), _not_null_free(not_null_free), _atomic(atomic) {}
1016 public:
1017   virtual bool eq( const Type *t ) const;
1018   virtual uint hash() const;             // Type specific hashing
1019   virtual bool singleton(void) const;    // TRUE if type is a singleton
1020   virtual bool empty(void) const;        // TRUE if type is vacuous
1021 
1022 private:
1023   const Type *_elem;            // Element type of array
1024   const TypeInt *_size;         // Elements in array
1025   const bool _stable;           // Are elements @Stable?
1026 
1027   // Inline type array properties
1028   const bool _flat;             // Array is flat
1029   const bool _not_flat;         // Array is never flat
1030   const bool _not_null_free;    // Array is never null-free
1031   const bool _atomic;           // Array is atomic
1032 
1033   friend class TypeAryPtr;
1034 
1035 public:
1036   static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false,
1037                              bool flat = false, bool not_flat = false, bool not_null_free = false, bool atomic = false);
1038 
1039   virtual const Type *xmeet( const Type *t ) const;
1040   virtual const Type *xdual() const;    // Compute dual right now.
1041   bool ary_must_be_exact() const;  // true if arrays of such are never generic
1042   virtual const TypeAry* remove_speculative() const;
1043   virtual const Type* cleanup_speculative() const;
1044 #ifndef PRODUCT
1045   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
1046 #endif
1047 };
1048 
1049 //------------------------------TypeVect---------------------------------------
1050 // Class of Vector Types
1051 class TypeVect : public Type {
1052   const BasicType _elem_bt;  // Vector's element type
1053   const uint _length;  // Elements in vector (power of 2)
1054 
1055 protected:
1056   TypeVect(TYPES t, BasicType elem_bt, uint length) : Type(t),
1057     _elem_bt(elem_bt), _length(length) {}

1164   const Type* xmeet(const Type* t) const;
1165 
1166   bool singleton(void) const;
1167   bool has_non_array_interface() const;
1168 };
1169 
1170 //------------------------------TypePtr----------------------------------------
1171 // Class of machine Pointer Types: raw data, instances or arrays.
1172 // If the _base enum is AnyPtr, then this refers to all of the above.
1173 // Otherwise the _base will indicate which subset of pointers is affected,
1174 // and the class will be inherited from.
1175 class TypePtr : public Type {
1176   friend class TypeNarrowPtr;
1177   friend class Type;
1178 protected:
1179   static const TypeInterfaces* interfaces(ciKlass*& k, bool klass, bool interface, bool array, InterfaceHandling interface_handling);
1180 
1181 public:
1182   enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
1183 protected:
1184   TypePtr(TYPES t, PTR ptr, Offset offset,
1185           const TypePtr* speculative = nullptr,
1186           int inline_depth = InlineDepthBottom) :
1187     Type(t), _speculative(speculative), _inline_depth(inline_depth), _offset(offset),
1188     _ptr(ptr) {}
1189   static const PTR ptr_meet[lastPTR][lastPTR];
1190   static const PTR ptr_dual[lastPTR];
1191   static const char * const ptr_msg[lastPTR];
1192 
1193   enum {
1194     InlineDepthBottom = INT_MAX,
1195     InlineDepthTop = -InlineDepthBottom
1196   };
1197 
1198   // Extra type information profiling gave us. We propagate it the
1199   // same way the rest of the type info is propagated. If we want to
1200   // use it, then we have to emit a guard: this part of the type is
1201   // not something we know but something we speculate about the type.
1202   const TypePtr*   _speculative;
1203   // For speculative types, we record at what inlining depth the
1204   // profiling point that provided the data is. We want to favor

1220   // utility methods to work on the inline depth of the type
1221   int dual_inline_depth() const;
1222   int meet_inline_depth(int depth) const;
1223 #ifndef PRODUCT
1224   void dump_inline_depth(outputStream *st) const;
1225 #endif
1226 
1227   // TypeInstPtr (TypeAryPtr resp.) and TypeInstKlassPtr (TypeAryKlassPtr resp.) implement very similar meet logic.
1228   // The logic for meeting 2 instances (2 arrays resp.) is shared in the 2 utility methods below. However the logic for
1229   // the oop and klass versions can be slightly different and extra logic may have to be executed depending on what
1230   // exact case the meet falls into. The MeetResult struct is used by the utility methods to communicate what case was
1231   // encountered so the right logic specific to klasses or oops can be executed.,
1232   enum MeetResult {
1233     QUICK,
1234     UNLOADED,
1235     SUBTYPE,
1236     NOT_SUBTYPE,
1237     LCA
1238   };
1239   template<class T> static TypePtr::MeetResult meet_instptr(PTR& ptr, const TypeInterfaces*& interfaces, const T* this_type,
1240                                                             const T* other_type, ciKlass*& res_klass, bool& res_xk, bool& res_flat_array);
1241  private:
1242   template<class T> static bool is_meet_subtype_of(const T* sub_type, const T* super_type);
1243  protected:
1244 
1245   template<class T> static MeetResult meet_aryptr(PTR& ptr, const Type*& elem, const T* this_ary, const T* other_ary,
1246                                                   ciKlass*& res_klass, bool& res_xk, bool &res_flat, bool &res_not_flat, bool &res_not_null_free, bool &res_atomic);
1247 
1248   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);
1249   template <class T1, class T2> static bool is_same_java_type_as_helper_for_instance(const T1* this_one, const T2* other);
1250   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);
1251   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);
1252   template <class T1, class T2> static bool is_same_java_type_as_helper_for_array(const T1* this_one, const T2* other);
1253   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);
1254   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);
1255   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);
1256 public:
1257   const Offset _offset;         // Offset into oop, with TOP & BOT
1258   const PTR _ptr;               // Pointer equivalence class
1259 
1260   int offset() const { return _offset.get(); }
1261   PTR ptr()    const { return _ptr; }
1262 
1263   static const TypePtr* make(TYPES t, PTR ptr, Offset offset,
1264                              const TypePtr* speculative = nullptr,
1265                              int inline_depth = InlineDepthBottom);
1266 
1267   // Return a 'ptr' version of this type
1268   virtual const TypePtr* cast_to_ptr_type(PTR ptr) const;
1269 
1270   virtual intptr_t get_con() const;
1271 
1272   Type::Offset xadd_offset(intptr_t offset) const;
1273   virtual const TypePtr* add_offset(intptr_t offset) const;
1274   virtual const TypePtr* with_offset(intptr_t offset) const;
1275   virtual int flat_offset() const { return offset(); }
1276   virtual bool eq(const Type *t) const;
1277   virtual uint hash() const;             // Type specific hashing
1278 
1279   virtual bool singleton(void) const;    // TRUE if type is a singleton
1280   virtual bool empty(void) const;        // TRUE if type is vacuous
1281   virtual const Type *xmeet( const Type *t ) const;
1282   virtual const Type *xmeet_helper( const Type *t ) const;
1283   Offset meet_offset(int offset) const;
1284   Offset dual_offset() const;
1285   virtual const Type *xdual() const;    // Compute dual right now.
1286 
1287   // meet, dual and join over pointer equivalence sets
1288   PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
1289   PTR dual_ptr()                   const { return ptr_dual[ptr()];      }
1290 
1291   // This is textually confusing unless one recalls that
1292   // join(t) == dual()->meet(t->dual())->dual().
1293   PTR join_ptr( const PTR in_ptr ) const {
1294     return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
1295   }
1296 
1297   // Speculative type helper methods.
1298   virtual const TypePtr* speculative() const { return _speculative; }
1299   int inline_depth() const                   { return _inline_depth; }
1300   virtual ciKlass* speculative_type() const;
1301   virtual ciKlass* speculative_type_not_null() const;
1302   virtual bool speculative_maybe_null() const;
1303   virtual bool speculative_always_null() const;
1304   virtual const TypePtr* remove_speculative() const;
1305   virtual const Type* cleanup_speculative() const;
1306   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1307   virtual bool would_improve_ptr(ProfilePtrKind maybe_null) const;
1308   virtual const TypePtr* with_inline_depth(int depth) const;
1309 
1310   virtual bool maybe_null() const { return meet_ptr(Null) == ptr(); }
1311 
1312   virtual bool can_be_inline_type() const { return false; }
1313   virtual bool flat_in_array()      const { return false; }
1314   virtual bool not_flat_in_array()  const { return true; }
1315   virtual bool is_flat()            const { return false; }
1316   virtual bool is_not_flat()        const { return false; }
1317   virtual bool is_null_free()       const { return false; }
1318   virtual bool is_not_null_free()   const { return false; }
1319   virtual bool is_atomic()          const { return false; }
1320 
1321   // Tests for relation to centerline of type lattice:
1322   static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
1323   static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
1324   // Convenience common pre-built types.
1325   static const TypePtr *NULL_PTR;
1326   static const TypePtr *NOTNULL;
1327   static const TypePtr *BOTTOM;
1328 #ifndef PRODUCT
1329   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1330 #endif
1331 };
1332 
1333 //------------------------------TypeRawPtr-------------------------------------
1334 // Class of raw pointers, pointers to things other than Oops.  Examples
1335 // include the stack pointer, top of heap, card-marking area, handles, etc.
1336 class TypeRawPtr : public TypePtr {
1337 protected:
1338   TypeRawPtr(PTR ptr, address bits) : TypePtr(RawPtr,ptr,Offset(0)), _bits(bits){}
1339 public:
1340   virtual bool eq( const Type *t ) const;
1341   virtual uint hash() const;    // Type specific hashing
1342 
1343   const address _bits;          // Constant value, if applicable
1344 
1345   static const TypeRawPtr *make( PTR ptr );
1346   static const TypeRawPtr *make( address bits );
1347 
1348   // Return a 'ptr' version of this type
1349   virtual const TypeRawPtr* cast_to_ptr_type(PTR ptr) const;
1350 
1351   virtual intptr_t get_con() const;
1352 
1353   virtual const TypePtr* add_offset(intptr_t offset) const;
1354   virtual const TypeRawPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr;}
1355 
1356   virtual const Type *xmeet( const Type *t ) const;
1357   virtual const Type *xdual() const;    // Compute dual right now.
1358   // Convenience common pre-built types.
1359   static const TypeRawPtr *BOTTOM;
1360   static const TypeRawPtr *NOTNULL;
1361 #ifndef PRODUCT
1362   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1363 #endif
1364 };
1365 
1366 //------------------------------TypeOopPtr-------------------------------------
1367 // Some kind of oop (Java pointer), either instance or array.
1368 class TypeOopPtr : public TypePtr {
1369   friend class TypeAry;
1370   friend class TypePtr;
1371   friend class TypeInstPtr;
1372   friend class TypeAryPtr;
1373 protected:
1374  TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, Offset offset, Offset field_offset, int instance_id,
1375             const TypePtr* speculative, int inline_depth);
1376 public:
1377   virtual bool eq( const Type *t ) const;
1378   virtual uint hash() const;             // Type specific hashing
1379   virtual bool singleton(void) const;    // TRUE if type is a singleton
1380   enum {
1381    InstanceTop = -1,   // undefined instance
1382    InstanceBot = 0     // any possible instance
1383   };
1384 protected:
1385 
1386   // Oop is null, unless this is a constant oop.
1387   ciObject*     _const_oop;   // Constant oop
1388   // If _klass is null, then so is _sig.  This is an unloaded klass.
1389   ciKlass*      _klass;       // Klass object
1390 
1391   const TypeInterfaces* _interfaces;
1392 
1393   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
1394   bool          _klass_is_exact;
1395   bool          _is_ptr_to_narrowoop;
1396   bool          _is_ptr_to_narrowklass;
1397   bool          _is_ptr_to_boxed_value;
1398 
1399   // If not InstanceTop or InstanceBot, indicates that this is
1400   // a particular instance of this type which is distinct.
1401   // This is the node index of the allocation node creating this instance.
1402   int           _instance_id;
1403 
1404   static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact, InterfaceHandling interface_handling);
1405 
1406   int dual_instance_id() const;
1407   int meet_instance_id(int uid) const;
1408 
1409   const TypeInterfaces* meet_interfaces(const TypeOopPtr* other) const;
1410 
1411   // Do not allow interface-vs.-noninterface joins to collapse to top.
1412   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1413 
1414   virtual ciKlass* exact_klass_helper() const { return nullptr; }
1415   virtual ciKlass* klass() const { return _klass; }
1416 
1417 public:
1418 
1419   bool is_java_subtype_of(const TypeOopPtr* other) const {
1420     return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1421   }
1422 
1423   bool is_same_java_type_as(const TypePtr* other) const {
1424     return is_same_java_type_as_helper(other->is_oopptr());
1425   }
1426 
1427   virtual bool is_same_java_type_as_helper(const TypeOopPtr* other) const {
1428     ShouldNotReachHere(); return false;
1429   }
1430 
1431   bool maybe_java_subtype_of(const TypeOopPtr* other) const {
1432     return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1433   }
1434   virtual bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1435   virtual bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }

1442     return make_from_klass_common(klass, true, false, interface_handling);
1443   }
1444   // Same as before, but will produce an exact type, even if
1445   // the klass is not final, as long as it has exactly one implementation.
1446   static const TypeOopPtr* make_from_klass_unique(ciKlass* klass, InterfaceHandling interface_handling= ignore_interfaces) {
1447     return make_from_klass_common(klass, true, true, interface_handling);
1448   }
1449   // Same as before, but does not respects UseUniqueSubclasses.
1450   // Use this only for creating array element types.
1451   static const TypeOopPtr* make_from_klass_raw(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1452     return make_from_klass_common(klass, false, false, interface_handling);
1453   }
1454   // Creates a singleton type given an object.
1455   // If the object cannot be rendered as a constant,
1456   // may return a non-singleton type.
1457   // If require_constant, produce a null if a singleton is not possible.
1458   static const TypeOopPtr* make_from_constant(ciObject* o,
1459                                               bool require_constant = false);
1460 
1461   // Make a generic (unclassed) pointer to an oop.
1462   static const TypeOopPtr* make(PTR ptr, Offset offset, int instance_id,
1463                                 const TypePtr* speculative = nullptr,
1464                                 int inline_depth = InlineDepthBottom);
1465 
1466   ciObject* const_oop()    const { return _const_oop; }
1467   // Exact klass, possibly an interface or an array of interface
1468   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k;  }
1469   ciKlass* unloaded_klass() const { assert(!is_loaded(), "only for unloaded types"); return klass(); }
1470 
1471   virtual bool  is_loaded() const { return klass()->is_loaded(); }
1472   virtual bool klass_is_exact()    const { return _klass_is_exact; }
1473 
1474   // Returns true if this pointer points at memory which contains a
1475   // compressed oop references.
1476   bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
1477   bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
1478   bool is_ptr_to_boxed_value()   const { return _is_ptr_to_boxed_value; }
1479   bool is_known_instance()       const { return _instance_id > 0; }
1480   int  instance_id()             const { return _instance_id; }
1481   bool is_known_instance_field() const { return is_known_instance() && _offset.get() >= 0; }
1482 
1483   virtual bool can_be_inline_type() const { return (_klass == nullptr || _klass->can_be_inline_klass(_klass_is_exact)); }
1484   virtual bool can_be_inline_array() const { ShouldNotReachHere(); return false; }
1485 
1486   virtual intptr_t get_con() const;
1487 
1488   virtual const TypeOopPtr* cast_to_ptr_type(PTR ptr) const;
1489 
1490   virtual const TypeOopPtr* cast_to_exactness(bool klass_is_exact) const;
1491 
1492   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1493 
1494   // corresponding pointer to klass, for a given instance
1495   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1496 
1497   virtual const TypeOopPtr* with_offset(intptr_t offset) const;
1498   virtual const TypePtr* add_offset(intptr_t offset) const;
1499 
1500   // Speculative type helper methods.
1501   virtual const TypeOopPtr* remove_speculative() const;
1502   virtual const Type* cleanup_speculative() const;
1503   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1504   virtual const TypePtr* with_inline_depth(int depth) const;

1527     return _interfaces;
1528   };
1529 
1530   const TypeOopPtr* is_reference_type(const Type* other) const {
1531     return other->isa_oopptr();
1532   }
1533 
1534   const TypeAryPtr* is_array_type(const TypeOopPtr* other) const {
1535     return other->isa_aryptr();
1536   }
1537 
1538   const TypeInstPtr* is_instance_type(const TypeOopPtr* other) const {
1539     return other->isa_instptr();
1540   }
1541 };
1542 
1543 //------------------------------TypeInstPtr------------------------------------
1544 // Class of Java object pointers, pointing either to non-array Java instances
1545 // or to a Klass* (including array klasses).
1546 class TypeInstPtr : public TypeOopPtr {
1547   TypeInstPtr(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, Offset offset,
1548               bool flat_in_array, int instance_id, const TypePtr* speculative,
1549               int inline_depth);
1550   virtual bool eq( const Type *t ) const;
1551   virtual uint hash() const;             // Type specific hashing
1552   bool _flat_in_array; // Type is flat in arrays
1553   ciKlass* exact_klass_helper() const;
1554 
1555 public:
1556 
1557   // Instance klass, ignoring any interface
1558   ciInstanceKlass* instance_klass() const {
1559     assert(!(klass()->is_loaded() && klass()->is_interface()), "");
1560     return klass()->as_instance_klass();
1561   }
1562 
1563   bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1564   bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1565   bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1566 
1567   // Make a pointer to a constant oop.
1568   static const TypeInstPtr *make(ciObject* o) {
1569     ciKlass* k = o->klass();
1570     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1571     return make(TypePtr::Constant, k, interfaces, true, o, Offset(0));
1572   }
1573   // Make a pointer to a constant oop with offset.
1574   static const TypeInstPtr *make(ciObject* o, Offset offset) {
1575     ciKlass* k = o->klass();
1576     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1577     return make(TypePtr::Constant, k, interfaces, true, o, offset);
1578   }
1579 
1580   // Make a pointer to some value of type klass.
1581   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1582     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, true, false, interface_handling);
1583     return make(ptr, klass, interfaces, false, nullptr, Offset(0));
1584   }
1585 
1586   // Make a pointer to some non-polymorphic value of exactly type klass.
1587   static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
1588     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1589     return make(ptr, klass, interfaces, true, nullptr, Offset(0));
1590   }
1591 
1592   // Make a pointer to some value of type klass with offset.
1593   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, Offset offset) {
1594     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1595     return make(ptr, klass, interfaces, false, nullptr, offset);
1596   }
1597 
1598   // Make a pointer to an oop.
1599   static const TypeInstPtr* make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, Offset offset,
1600                                  bool flat_in_array = false,
1601                                  int instance_id = InstanceBot,
1602                                  const TypePtr* speculative = nullptr,
1603                                  int inline_depth = InlineDepthBottom);
1604 
1605   static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset offset, int instance_id = InstanceBot) {
1606     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1607     return make(ptr, k, interfaces, xk, o, offset, false, instance_id);
1608   }
1609 
1610   /** Create constant type for a constant boxed value */
1611   const Type* get_const_boxed_value() const;
1612 
1613   // If this is a java.lang.Class constant, return the type for it or null.
1614   // Pass to Type::get_const_type to turn it to a type, which will usually
1615   // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
1616   ciType* java_mirror_type() const;
1617 
1618   virtual const TypeInstPtr* cast_to_ptr_type(PTR ptr) const;
1619 
1620   virtual const TypeInstPtr* cast_to_exactness(bool klass_is_exact) const;
1621 
1622   virtual const TypeInstPtr* cast_to_instance_id(int instance_id) const;
1623 
1624   virtual const TypePtr* add_offset(intptr_t offset) const;
1625   virtual const TypeInstPtr* with_offset(intptr_t offset) const;
1626 
1627   // Speculative type helper methods.
1628   virtual const TypeInstPtr* remove_speculative() const;
1629   const TypeInstPtr* with_speculative(const TypePtr* speculative) const;
1630   virtual const TypePtr* with_inline_depth(int depth) const;
1631   virtual const TypePtr* with_instance_id(int instance_id) const;
1632 
1633   virtual const TypeInstPtr* cast_to_flat_in_array() const;
1634   virtual bool flat_in_array() const { return _flat_in_array; }
1635   virtual bool not_flat_in_array() const { return !can_be_inline_type() || (_klass->is_inlinetype() && !flat_in_array()); }
1636 
1637   // the core of the computation of the meet of 2 types
1638   virtual const Type *xmeet_helper(const Type *t) const;
1639   virtual const TypeInstPtr *xmeet_unloaded(const TypeInstPtr *tinst, const TypeInterfaces* interfaces) const;
1640   virtual const Type *xdual() const;    // Compute dual right now.
1641 
1642   const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1643 
1644   virtual bool can_be_inline_array() const;
1645 
1646   // Convenience common pre-built types.
1647   static const TypeInstPtr *NOTNULL;
1648   static const TypeInstPtr *BOTTOM;
1649   static const TypeInstPtr *MIRROR;
1650   static const TypeInstPtr *MARK;
1651   static const TypeInstPtr *KLASS;
1652 #ifndef PRODUCT
1653   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1654 #endif
1655 
1656 private:
1657   virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1658 
1659   virtual bool is_meet_same_type_as(const TypePtr* other) const {
1660     return _klass->equals(other->is_instptr()->_klass) && _interfaces->eq(other->is_instptr()->_interfaces);
1661   }
1662 
1663 };
1664 
1665 //------------------------------TypeAryPtr-------------------------------------
1666 // Class of Java array pointers
1667 class TypeAryPtr : public TypeOopPtr {
1668   friend class Type;
1669   friend class TypePtr;
1670   friend class TypeInstPtr;
1671   friend class TypeInterfaces;
1672 
1673   TypeAryPtr(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1674              Offset offset, Offset field_offset, int instance_id, bool is_autobox_cache,
1675              const TypePtr* speculative, int inline_depth)
1676     : TypeOopPtr(AryPtr, ptr, k, _array_interfaces, xk, o, offset, field_offset, instance_id, speculative, inline_depth),
1677     _ary(ary),
1678     _is_autobox_cache(is_autobox_cache),
1679     _field_offset(field_offset)
1680  {
1681     int dummy;
1682     bool top_or_bottom = (base_element_type(dummy) == Type::TOP || base_element_type(dummy) == Type::BOTTOM);
1683 
1684     if (UseCompressedOops && (elem()->make_oopptr() != nullptr && !top_or_bottom) &&
1685         _offset.get() != 0 && _offset.get() != arrayOopDesc::length_offset_in_bytes() &&
1686         _offset.get() != arrayOopDesc::klass_offset_in_bytes()) {
1687       _is_ptr_to_narrowoop = true;
1688     }
1689 
1690   }
1691   virtual bool eq( const Type *t ) const;
1692   virtual uint hash() const;    // Type specific hashing
1693   const TypeAry *_ary;          // Array we point into
1694   const bool     _is_autobox_cache;
1695   // For flat inline type arrays, each field of the inline type in
1696   // the array has its own memory slice so we need to keep track of
1697   // which field is accessed
1698   const Offset _field_offset;
1699   Offset meet_field_offset(const Type::Offset offset) const;
1700   Offset dual_field_offset() const;
1701 
1702   ciKlass* compute_klass() const;
1703 
1704   // A pointer to delay allocation to Type::Initialize_shared()
1705 
1706   static const TypeInterfaces* _array_interfaces;
1707   ciKlass* exact_klass_helper() const;
1708   // Only guaranteed non null for array of basic types
1709   ciKlass* klass() const;
1710 
1711 public:
1712 
1713   bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1714   bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1715   bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1716 
1717   // returns base element type, an instance klass (and not interface) for object arrays
1718   const Type* base_element_type(int& dims) const;
1719 
1720   // Accessors
1721   bool  is_loaded() const { return (_ary->_elem->make_oopptr() ? _ary->_elem->make_oopptr()->is_loaded() : true); }
1722 
1723   const TypeAry* ary() const  { return _ary; }
1724   const Type*    elem() const { return _ary->_elem; }
1725   const TypeInt* size() const { return _ary->_size; }
1726   bool      is_stable() const { return _ary->_stable; }
1727 
1728   // Inline type array properties
1729   bool is_flat()          const { return _ary->_flat; }
1730   bool is_not_flat()      const { return _ary->_not_flat; }
1731   bool is_null_free()     const { return _ary->_elem->make_ptr() != nullptr && (_ary->_elem->make_ptr()->ptr() == NotNull || _ary->_elem->make_ptr()->ptr() == AnyNull); }
1732   bool is_not_null_free() const { return _ary->_not_null_free; }
1733   bool is_atomic()        const { return _ary->_atomic; }
1734 
1735   bool is_autobox_cache() const { return _is_autobox_cache; }
1736 
1737   static const TypeAryPtr* make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1738                                 Offset field_offset = Offset::bottom,
1739                                 int instance_id = InstanceBot,
1740                                 const TypePtr* speculative = nullptr,
1741                                 int inline_depth = InlineDepthBottom);
1742   // Constant pointer to array
1743   static const TypeAryPtr* make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1744                                 Offset field_offset = Offset::bottom,
1745                                 int instance_id = InstanceBot,
1746                                 const TypePtr* speculative = nullptr,
1747                                 int inline_depth = InlineDepthBottom,
1748                                 bool is_autobox_cache = false);
1749 
1750   // Return a 'ptr' version of this type
1751   virtual const TypeAryPtr* cast_to_ptr_type(PTR ptr) const;
1752 
1753   virtual const TypeAryPtr* cast_to_exactness(bool klass_is_exact) const;
1754 
1755   virtual const TypeAryPtr* cast_to_instance_id(int instance_id) const;
1756 
1757   virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1758   virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1759 
1760   virtual bool empty(void) const;        // TRUE if type is vacuous
1761   virtual const TypePtr *add_offset( intptr_t offset ) const;
1762   virtual const TypeAryPtr *with_offset( intptr_t offset ) const;
1763   const TypeAryPtr* with_ary(const TypeAry* ary) const;
1764 
1765   // Speculative type helper methods.
1766   virtual const TypeAryPtr* remove_speculative() const;
1767   virtual const Type* cleanup_speculative() const;
1768   virtual const TypePtr* with_inline_depth(int depth) const;
1769   virtual const TypePtr* with_instance_id(int instance_id) const;
1770 
1771   // the core of the computation of the meet of 2 types
1772   virtual const Type *xmeet_helper(const Type *t) const;
1773   virtual const Type *xdual() const;    // Compute dual right now.
1774 
1775   // Inline type array properties
1776   const TypeAryPtr* cast_to_not_flat(bool not_flat = true) const;
1777   const TypeAryPtr* cast_to_not_null_free(bool not_null_free = true) const;
1778   const TypeAryPtr* update_properties(const TypeAryPtr* new_type) const;
1779   jint flat_layout_helper() const;
1780   int flat_elem_size() const;
1781   int flat_log_elem_size() const;
1782 
1783   const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1784   int stable_dimension() const;
1785 
1786   const TypeAryPtr* cast_to_autobox_cache() const;
1787 
1788   static jint max_array_length(BasicType etype);
1789 
1790   int flat_offset() const;
1791   const Offset field_offset() const { return _field_offset; }
1792   const TypeAryPtr* with_field_offset(int offset) const;
1793   const TypePtr* add_field_offset_and_offset(intptr_t offset) const;
1794 
1795   virtual bool can_be_inline_type() const { return false; }
1796   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1797 
1798   virtual bool can_be_inline_array() const;
1799 
1800   // Convenience common pre-built types.
1801   static const TypeAryPtr* BOTTOM;
1802   static const TypeAryPtr *RANGE;
1803   static const TypeAryPtr *OOPS;
1804   static const TypeAryPtr *NARROWOOPS;
1805   static const TypeAryPtr *BYTES;
1806   static const TypeAryPtr *SHORTS;
1807   static const TypeAryPtr *CHARS;
1808   static const TypeAryPtr *INTS;
1809   static const TypeAryPtr *LONGS;
1810   static const TypeAryPtr *FLOATS;
1811   static const TypeAryPtr *DOUBLES;
1812   static const TypeAryPtr *INLINES;
1813   // selects one of the above:
1814   static const TypeAryPtr *get_array_body_type(BasicType elem) {
1815     assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != nullptr, "bad elem type");
1816     return _array_body_type[elem];
1817   }
1818   static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1819   // sharpen the type of an int which is used as an array size
1820 #ifndef PRODUCT
1821   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1822 #endif
1823 private:
1824   virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1825 };
1826 
1827 //------------------------------TypeMetadataPtr-------------------------------------
1828 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
1829 class TypeMetadataPtr : public TypePtr {
1830 protected:
1831   TypeMetadataPtr(PTR ptr, ciMetadata* metadata, Offset offset);
1832   // Do not allow interface-vs.-noninterface joins to collapse to top.
1833   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1834 public:
1835   virtual bool eq( const Type *t ) const;
1836   virtual uint hash() const;             // Type specific hashing
1837   virtual bool singleton(void) const;    // TRUE if type is a singleton
1838 
1839 private:
1840   ciMetadata*   _metadata;
1841 
1842 public:
1843   static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, Offset offset);
1844 
1845   static const TypeMetadataPtr* make(ciMethod* m);
1846   static const TypeMetadataPtr* make(ciMethodData* m);
1847 
1848   ciMetadata* metadata() const { return _metadata; }
1849 
1850   virtual const TypeMetadataPtr* cast_to_ptr_type(PTR ptr) const;
1851 
1852   virtual const TypePtr *add_offset( intptr_t offset ) const;
1853 
1854   virtual const Type *xmeet( const Type *t ) const;
1855   virtual const Type *xdual() const;    // Compute dual right now.
1856 
1857   virtual intptr_t get_con() const;
1858 
1859   // Convenience common pre-built types.
1860   static const TypeMetadataPtr *BOTTOM;
1861 
1862 #ifndef PRODUCT
1863   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1864 #endif
1865 };
1866 
1867 //------------------------------TypeKlassPtr-----------------------------------
1868 // Class of Java Klass pointers
1869 class TypeKlassPtr : public TypePtr {
1870   friend class TypeInstKlassPtr;
1871   friend class TypeAryKlassPtr;
1872   friend class TypePtr;
1873 protected:
1874   TypeKlassPtr(TYPES t, PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, Offset offset);
1875 
1876   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1877 
1878 public:
1879   virtual bool eq( const Type *t ) const;
1880   virtual uint hash() const;
1881   virtual bool singleton(void) const;    // TRUE if type is a singleton
1882 
1883 protected:
1884 
1885   ciKlass* _klass;
1886   const TypeInterfaces* _interfaces;
1887   const TypeInterfaces* meet_interfaces(const TypeKlassPtr* other) const;
1888   virtual bool must_be_exact() const { ShouldNotReachHere(); return false; }
1889   virtual ciKlass* exact_klass_helper() const;
1890   virtual ciKlass* klass() const { return  _klass; }
1891 
1892 public:
1893 
1894   bool is_java_subtype_of(const TypeKlassPtr* other) const {
1895     return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1896   }
1897   bool is_same_java_type_as(const TypePtr* other) const {
1898     return is_same_java_type_as_helper(other->is_klassptr());
1899   }
1900 
1901   bool maybe_java_subtype_of(const TypeKlassPtr* other) const {
1902     return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1903   }
1904   virtual bool is_same_java_type_as_helper(const TypeKlassPtr* other) const { ShouldNotReachHere(); return false; }
1905   virtual bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1906   virtual bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1907 
1908   // Exact klass, possibly an interface or an array of interface
1909   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k;  }
1910   virtual bool klass_is_exact()    const { return _ptr == Constant; }
1911 
1912   static const TypeKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces);
1913   static const TypeKlassPtr *make(PTR ptr, ciKlass* klass, Offset offset, InterfaceHandling interface_handling = ignore_interfaces);
1914 
1915   virtual bool  is_loaded() const { return _klass->is_loaded(); }
1916 
1917   virtual const TypeKlassPtr* cast_to_ptr_type(PTR ptr) const { ShouldNotReachHere(); return nullptr; }
1918 
1919   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const { ShouldNotReachHere(); return nullptr; }
1920 
1921   // corresponding pointer to instance, for a given class
1922   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const { ShouldNotReachHere(); return nullptr; }
1923 
1924   virtual const TypePtr *add_offset( intptr_t offset ) const { ShouldNotReachHere(); return nullptr; }
1925   virtual const Type    *xmeet( const Type *t ) const { ShouldNotReachHere(); return nullptr; }
1926   virtual const Type    *xdual() const { ShouldNotReachHere(); return nullptr; }
1927 
1928   virtual intptr_t get_con() const;
1929 
1930   virtual const TypeKlassPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr; }
1931 
1932   virtual bool can_be_inline_array() const { ShouldNotReachHere(); return false; }
1933 
1934   virtual bool not_flat_in_array_inexact() const {
1935     return true;
1936   }
1937 
1938   virtual const TypeKlassPtr* try_improve() const { return this; }
1939 
1940 #ifndef PRODUCT
1941   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1942 #endif
1943 private:
1944   virtual bool is_meet_subtype_of(const TypePtr* other) const {
1945     return is_meet_subtype_of_helper(other->is_klassptr(), klass_is_exact(), other->is_klassptr()->klass_is_exact());
1946   }
1947 
1948   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const {
1949     ShouldNotReachHere(); return false;
1950   }
1951 
1952   virtual const TypeInterfaces* interfaces() const {
1953     return _interfaces;
1954   };
1955 
1956   const TypeKlassPtr* is_reference_type(const Type* other) const {
1957     return other->isa_klassptr();
1958   }
1959 
1960   const TypeAryKlassPtr* is_array_type(const TypeKlassPtr* other) const {
1961     return other->isa_aryklassptr();
1962   }
1963 
1964   const TypeInstKlassPtr* is_instance_type(const TypeKlassPtr* other) const {
1965     return other->isa_instklassptr();
1966   }
1967 };
1968 
1969 // Instance klass pointer, mirrors TypeInstPtr
1970 class TypeInstKlassPtr : public TypeKlassPtr {
1971 
1972   TypeInstKlassPtr(PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, Offset offset, bool flat_in_array)
1973     : TypeKlassPtr(InstKlassPtr, ptr, klass, interfaces, offset), _flat_in_array(flat_in_array) {
1974     assert(klass->is_instance_klass() && (!klass->is_loaded() || !klass->is_interface()), "");
1975   }
1976 
1977   virtual bool must_be_exact() const;
1978 
1979   const bool _flat_in_array; // Type is flat in arrays
1980 
1981 public:
1982   // Instance klass ignoring any interface
1983   ciInstanceKlass* instance_klass() const {
1984     assert(!klass()->is_interface(), "");
1985     return klass()->as_instance_klass();
1986   }
1987 
1988   bool might_be_an_array() const;
1989 
1990   bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
1991   bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1992   bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1993 
1994   virtual bool can_be_inline_type() const { return (_klass == nullptr || _klass->can_be_inline_klass(klass_is_exact())); }
1995 
1996   static const TypeInstKlassPtr *make(ciKlass* k, InterfaceHandling interface_handling) {
1997     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, true, false, interface_handling);
1998     return make(TypePtr::Constant, k, interfaces, Offset(0));
1999   }
2000   static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, Offset offset, bool flat_in_array = false);
2001 
2002   static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, Offset offset) {
2003     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
2004     return make(ptr, k, interfaces, offset);
2005   }
2006 
2007   virtual const TypeInstKlassPtr* cast_to_ptr_type(PTR ptr) const;
2008 
2009   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
2010 
2011   // corresponding pointer to instance, for a given class
2012   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
2013   virtual uint hash() const;
2014   virtual bool eq(const Type *t) const;
2015 
2016   virtual const TypePtr *add_offset( intptr_t offset ) const;
2017   virtual const Type    *xmeet( const Type *t ) const;
2018   virtual const Type    *xdual() const;
2019   virtual const TypeInstKlassPtr* with_offset(intptr_t offset) const;
2020 
2021   virtual const TypeKlassPtr* try_improve() const;
2022 
2023   virtual bool flat_in_array() const { return _flat_in_array; }
2024 
2025   // Checks if this klass pointer is not flat in array by also considering exactness information.
2026   virtual bool not_flat_in_array() const {
2027     return !_klass->can_be_inline_klass(klass_is_exact()) || (_klass->is_inlinetype() && !flat_in_array());
2028   }
2029 
2030   // not_flat_in_array() version that assumes that the klass is inexact. This is used for sub type checks where the
2031   // super klass is always an exact klass constant (and thus possibly known to be not flat in array), while a sub
2032   // klass could very well be flat in array:
2033   //
2034   //           MyValue       <:       Object
2035   //        flat in array       not flat in array
2036   //
2037   // Thus, this version checks if we know that the klass is not flat in array even if it's not exact.
2038   virtual bool not_flat_in_array_inexact() const {
2039     return !_klass->can_be_inline_klass() || (_klass->is_inlinetype() && !flat_in_array());
2040   }
2041 
2042   virtual bool can_be_inline_array() const;
2043 
2044   // Convenience common pre-built types.
2045   static const TypeInstKlassPtr* OBJECT; // Not-null object klass or below
2046   static const TypeInstKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
2047 private:
2048   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
2049 };
2050 
2051 // Array klass pointer, mirrors TypeAryPtr
2052 class TypeAryKlassPtr : public TypeKlassPtr {
2053   friend class TypeInstKlassPtr;
2054   friend class Type;
2055   friend class TypePtr;
2056 
2057   const Type *_elem;
2058   const bool _not_flat;      // Array is never flat
2059   const bool _not_null_free; // Array is never null-free
2060   const bool _flat;
2061   const bool _null_free;
2062   const bool _atomic;
2063   const bool _vm_type;
2064 
2065   static const TypeInterfaces* _array_interfaces;
2066   TypeAryKlassPtr(PTR ptr, const Type *elem, ciKlass* klass, Offset offset, bool not_flat, int not_null_free, bool flat, bool null_free, bool atomic, bool vm_type)
2067     : 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), _atomic(atomic), _vm_type(vm_type) {
2068     assert(klass == nullptr || klass->is_type_array_klass() || klass->is_flat_array_klass() || !klass->as_obj_array_klass()->base_element_klass()->is_interface(), "");
2069   }
2070 
2071   virtual ciKlass* exact_klass_helper() const;
2072   // Only guaranteed non null for array of basic types
2073   virtual ciKlass* klass() const;
2074 
2075   virtual bool must_be_exact() const;
2076 
2077   bool dual_flat() const {
2078     return _flat;
2079   }
2080 
2081   bool meet_flat(bool other) const {
2082     return _flat && other;
2083   }
2084 
2085   bool dual_null_free() const {
2086     return _null_free;
2087   }
2088 
2089   bool meet_null_free(bool other) const {
2090     return _null_free && other;
2091   }
2092 
2093   bool dual_atomic() const {
2094     return _atomic;
2095   }
2096 
2097   bool meet_atomic(bool other) const {
2098     return _atomic && other;
2099   }
2100 
2101 public:
2102 
2103   // returns base element type, an instance klass (and not interface) for object arrays
2104   const Type* base_element_type(int& dims) const;
2105 
2106   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, bool atomic, bool vm_type = false);
2107 
2108   bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
2109   bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
2110   bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
2111 
2112   bool  is_loaded() const { return (_elem->isa_klassptr() ? _elem->is_klassptr()->is_loaded() : true); }
2113 
2114   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, bool atomic, bool vm_type = false);
2115   static const TypeAryKlassPtr* make(PTR ptr, ciKlass* k, Offset offset, InterfaceHandling interface_handling, bool vm_type = false);
2116   static const TypeAryKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling, bool vm_type = false);
2117 
2118   const TypeAryKlassPtr* get_vm_type(bool vm_type = true) const;
2119 
2120   const Type *elem() const { return _elem; }
2121 
2122   virtual bool eq(const Type *t) const;
2123   virtual uint hash() const;             // Type specific hashing
2124 
2125   virtual const TypeAryKlassPtr* cast_to_ptr_type(PTR ptr) const;
2126 
2127   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
2128 
2129   // corresponding pointer to instance, for a given class
2130   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
2131 
2132   virtual const TypePtr *add_offset( intptr_t offset ) const;
2133   virtual const Type    *xmeet( const Type *t ) const;
2134   virtual const Type    *xdual() const;      // Compute dual right now.
2135 
2136   virtual const TypeAryKlassPtr* with_offset(intptr_t offset) const;
2137 
2138   virtual bool empty(void) const {
2139     return TypeKlassPtr::empty() || _elem->empty();
2140   }
2141 
2142   bool is_flat()          const { return _flat; }
2143   bool is_not_flat()      const { return _not_flat; }
2144   bool is_null_free()     const { return _null_free; }
2145   bool is_not_null_free() const { return _not_null_free; }
2146   bool is_atomic()        const { return _atomic; }
2147   bool is_vm_type()       const { return _vm_type; }
2148   virtual bool can_be_inline_array() const;
2149 
2150 #ifndef PRODUCT
2151   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
2152 #endif
2153 private:
2154   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
2155 };
2156 
2157 class TypeNarrowPtr : public Type {
2158 protected:
2159   const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
2160 
2161   TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): Type(t),
2162                                                   _ptrtype(ptrtype) {
2163     assert(ptrtype->offset() == 0 ||
2164            ptrtype->offset() == OffsetBot ||
2165            ptrtype->offset() == OffsetTop, "no real offsets");
2166   }
2167 
2168   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
2169   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;

2265   }
2266 
2267   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
2268     return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
2269   }
2270 
2271 public:
2272   static const TypeNarrowKlass *make( const TypePtr* type);
2273 
2274   // static const TypeNarrowKlass *BOTTOM;
2275   static const TypeNarrowKlass *NULL_PTR;
2276 
2277 #ifndef PRODUCT
2278   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
2279 #endif
2280 };
2281 
2282 //------------------------------TypeFunc---------------------------------------
2283 // Class of Array Types
2284 class TypeFunc : public Type {
2285   TypeFunc(const TypeTuple *domain_sig, const TypeTuple *domain_cc, const TypeTuple *range_sig, const TypeTuple *range_cc)
2286     : Type(Function), _domain_sig(domain_sig), _domain_cc(domain_cc), _range_sig(range_sig), _range_cc(range_cc) {}
2287   virtual bool eq( const Type *t ) const;
2288   virtual uint hash() const;             // Type specific hashing
2289   virtual bool singleton(void) const;    // TRUE if type is a singleton
2290   virtual bool empty(void) const;        // TRUE if type is vacuous
2291 
2292   // Domains of inputs: inline type arguments are not passed by
2293   // reference, instead each field of the inline type is passed as an
2294   // argument. We maintain 2 views of the argument list here: one
2295   // based on the signature (with an inline type argument as a single
2296   // slot), one based on the actual calling convention (with a value
2297   // type argument as a list of its fields).
2298   const TypeTuple* const _domain_sig;
2299   const TypeTuple* const _domain_cc;
2300   // Range of results. Similar to domains: an inline type result can be
2301   // returned in registers in which case range_cc lists all fields and
2302   // is the actual calling convention.
2303   const TypeTuple* const _range_sig;
2304   const TypeTuple* const _range_cc;
2305 
2306 public:
2307   // Constants are shared among ADLC and VM
2308   enum { Control    = AdlcVMDeps::Control,
2309          I_O        = AdlcVMDeps::I_O,
2310          Memory     = AdlcVMDeps::Memory,
2311          FramePtr   = AdlcVMDeps::FramePtr,
2312          ReturnAdr  = AdlcVMDeps::ReturnAdr,
2313          Parms      = AdlcVMDeps::Parms
2314   };
2315 
2316 
2317   // Accessors:
2318   const TypeTuple* domain_sig() const { return _domain_sig; }
2319   const TypeTuple* domain_cc()  const { return _domain_cc; }
2320   const TypeTuple* range_sig()  const { return _range_sig; }
2321   const TypeTuple* range_cc()   const { return _range_cc; }
2322 
2323   static const TypeFunc* make(ciMethod* method, bool is_osr_compilation = false);
2324   static const TypeFunc *make(const TypeTuple* domain_sig, const TypeTuple* domain_cc,
2325                               const TypeTuple* range_sig, const TypeTuple* range_cc);
2326   static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
2327 
2328   virtual const Type *xmeet( const Type *t ) const;
2329   virtual const Type *xdual() const;    // Compute dual right now.
2330 
2331   BasicType return_type() const;
2332 
2333   bool returns_inline_type_as_fields() const { return range_sig() != range_cc(); }
2334 
2335 #ifndef PRODUCT
2336   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
2337 #endif
2338   // Convenience common pre-built types.
2339 };
2340 
2341 //------------------------------accessors--------------------------------------
2342 inline bool Type::is_ptr_to_narrowoop() const {
2343 #ifdef _LP64
2344   return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowoop_nv());
2345 #else
2346   return false;
2347 #endif
2348 }
2349 
2350 inline bool Type::is_ptr_to_narrowklass() const {
2351 #ifdef _LP64
2352   return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowklass_nv());
2353 #else
2354   return false;

2591 }
2592 
2593 inline const TypeNarrowOop* Type::make_narrowoop() const {
2594   return (_base == NarrowOop) ? is_narrowoop() :
2595                                 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : nullptr);
2596 }
2597 
2598 inline const TypeNarrowKlass* Type::make_narrowklass() const {
2599   return (_base == NarrowKlass) ? is_narrowklass() :
2600                                   (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : nullptr);
2601 }
2602 
2603 inline bool Type::is_floatingpoint() const {
2604   if( (_base == HalfFloatCon)  || (_base == HalfFloatBot) ||
2605       (_base == FloatCon)  || (_base == FloatBot) ||
2606       (_base == DoubleCon) || (_base == DoubleBot) )
2607     return true;
2608   return false;
2609 }
2610 
2611 inline bool Type::is_inlinetypeptr() const {
2612   return isa_instptr() != nullptr && is_instptr()->instance_klass()->is_inlinetype();
2613 }
2614 
2615 inline ciInlineKlass* Type::inline_klass() const {
2616   return make_ptr()->is_instptr()->instance_klass()->as_inline_klass();
2617 }
2618 
2619 template <>
2620 inline const TypeInt* Type::cast<TypeInt>() const {
2621   return is_int();
2622 }
2623 
2624 template <>
2625 inline const TypeLong* Type::cast<TypeLong>() const {
2626   return is_long();
2627 }
2628 
2629 template <>
2630 inline const TypeInt* Type::try_cast<TypeInt>() const {
2631   return isa_int();
2632 }
2633 
2634 template <>
2635 inline const TypeLong* Type::try_cast<TypeLong>() const {
2636   return isa_long();
2637 }
2638 

2644 
2645 // For type queries and asserts
2646 #define is_intptr_t  is_long
2647 #define isa_intptr_t isa_long
2648 #define find_intptr_t_type find_long_type
2649 #define find_intptr_t_con  find_long_con
2650 #define TypeX        TypeLong
2651 #define Type_X       Type::Long
2652 #define TypeX_X      TypeLong::LONG
2653 #define TypeX_ZERO   TypeLong::ZERO
2654 // For 'ideal_reg' machine registers
2655 #define Op_RegX      Op_RegL
2656 // For phase->intcon variants
2657 #define MakeConX     longcon
2658 #define ConXNode     ConLNode
2659 // For array index arithmetic
2660 #define MulXNode     MulLNode
2661 #define AndXNode     AndLNode
2662 #define OrXNode      OrLNode
2663 #define CmpXNode     CmpLNode
2664 #define CmpUXNode    CmpULNode
2665 #define SubXNode     SubLNode
2666 #define LShiftXNode  LShiftLNode
2667 // For object size computation:
2668 #define AddXNode     AddLNode
2669 #define RShiftXNode  RShiftLNode
2670 // For card marks and hashcodes
2671 #define URShiftXNode URShiftLNode
2672 // For shenandoahSupport
2673 #define LoadXNode    LoadLNode
2674 #define StoreXNode   StoreLNode
2675 // Opcodes
2676 #define Op_LShiftX   Op_LShiftL
2677 #define Op_AndX      Op_AndL
2678 #define Op_AddX      Op_AddL
2679 #define Op_SubX      Op_SubL
2680 #define Op_XorX      Op_XorL
2681 #define Op_URShiftX  Op_URShiftL
2682 #define Op_LoadX     Op_LoadL
2683 #define Op_StoreX    Op_StoreL
2684 // conversions
2685 #define ConvI2X(x)   ConvI2L(x)
2686 #define ConvL2X(x)   (x)
2687 #define ConvX2I(x)   ConvL2I(x)
2688 #define ConvX2L(x)   (x)
2689 #define ConvX2UL(x)  (x)
2690 
2691 #else
2692 
2693 // For type queries and asserts
2694 #define is_intptr_t  is_int
2695 #define isa_intptr_t isa_int
2696 #define find_intptr_t_type find_int_type
2697 #define find_intptr_t_con  find_int_con
2698 #define TypeX        TypeInt
2699 #define Type_X       Type::Int
2700 #define TypeX_X      TypeInt::INT
2701 #define TypeX_ZERO   TypeInt::ZERO
2702 // For 'ideal_reg' machine registers
2703 #define Op_RegX      Op_RegI
2704 // For phase->intcon variants
2705 #define MakeConX     intcon
2706 #define ConXNode     ConINode
2707 // For array index arithmetic
2708 #define MulXNode     MulINode
2709 #define AndXNode     AndINode
2710 #define OrXNode      OrINode
2711 #define CmpXNode     CmpINode
2712 #define CmpUXNode    CmpUNode
2713 #define SubXNode     SubINode
2714 #define LShiftXNode  LShiftINode
2715 // For object size computation:
2716 #define AddXNode     AddINode
2717 #define RShiftXNode  RShiftINode
2718 // For card marks and hashcodes
2719 #define URShiftXNode URShiftINode
2720 // For shenandoahSupport
2721 #define LoadXNode    LoadINode
2722 #define StoreXNode   StoreINode
2723 // Opcodes
2724 #define Op_LShiftX   Op_LShiftI
2725 #define Op_AndX      Op_AndI
2726 #define Op_AddX      Op_AddI
2727 #define Op_SubX      Op_SubI
2728 #define Op_XorX      Op_XorI
2729 #define Op_URShiftX  Op_URShiftI
2730 #define Op_LoadX     Op_LoadI
2731 #define Op_StoreX    Op_StoreI
2732 // conversions
2733 #define ConvI2X(x)   (x)
2734 #define ConvL2X(x)   ConvL2I(x)
2735 #define ConvX2I(x)   (x)
2736 #define ConvX2L(x)   ConvI2L(x)
2737 #define ConvX2UL(x)  ConvI2UL(x)
2738 
2739 #endif
2740 
2741 #endif // SHARE_OPTO_TYPE_HPP
< prev index next >