< 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   } TypeInfo;
 161 
 162   // Dictionary of types shared among compilations.
 163   static Dict* _shared_type_dict;
 164   static const TypeInfo _type_info[];
 165 
 166   static int uhash( const Type *const t );

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



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

 463   static const Type* get_typeflow_type(ciType* type);
 464 
 465   static const Type* make_from_constant(ciConstant constant,
 466                                         bool require_constant = false,
 467                                         int stable_dimension = 0,
 468                                         bool is_narrow = false,
 469                                         bool is_autobox_cache = false);
 470 
 471   static const Type* make_constant_from_field(ciInstance* holder,
 472                                               int off,
 473                                               bool is_unsigned_load,
 474                                               BasicType loadbt);
 475 
 476   static const Type* make_constant_from_field(ciField* field,
 477                                               ciInstance* holder,
 478                                               BasicType loadbt,
 479                                               bool is_unsigned_load);
 480 
 481   static const Type* make_constant_from_array_element(ciArray* array,
 482                                                       int off,

 483                                                       int stable_dimension,
 484                                                       BasicType loadbt,
 485                                                       bool is_unsigned_load);
 486 
 487   // Speculative type helper methods. See TypePtr.
 488   virtual const TypePtr* speculative() const                                  { return nullptr; }
 489   virtual ciKlass* speculative_type() const                                   { return nullptr; }
 490   virtual ciKlass* speculative_type_not_null() const                          { return nullptr; }
 491   virtual bool speculative_maybe_null() const                                 { return true; }
 492   virtual bool speculative_always_null() const                                { return true; }
 493   virtual const Type* remove_speculative() const                              { return this; }
 494   virtual const Type* cleanup_speculative() const                             { return this; }
 495   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const { return exact_kls != nullptr; }
 496   virtual bool would_improve_ptr(ProfilePtrKind ptr_kind) const { return ptr_kind == ProfileAlwaysNull || ptr_kind == ProfileNeverNull; }
 497   const Type* maybe_remove_speculative(bool include_speculative) const;
 498 
 499   virtual bool maybe_null() const { return true; }
 500   virtual bool is_known_instance() const { return false; }
 501 
 502 private:

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







1013   friend class TypeAryPtr;
1014 
1015 public:
1016   static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false);

1017 
1018   virtual const Type *xmeet( const Type *t ) const;
1019   virtual const Type *xdual() const;    // Compute dual right now.
1020   bool ary_must_be_exact() const;  // true if arrays of such are never generic
1021   virtual const TypeAry* remove_speculative() const;
1022   virtual const Type* cleanup_speculative() const;
1023 #ifndef PRODUCT
1024   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
1025 #endif
1026 };
1027 
1028 //------------------------------TypeVect---------------------------------------
1029 // Basic class of vector (mask) types.
1030 class TypeVect : public Type {
1031   const BasicType _elem_bt;  // Vector's element type
1032   const uint _length;  // Elements in vector (power of 2)
1033 
1034 protected:
1035   TypeVect(TYPES t, BasicType elem_bt, uint length) : Type(t),
1036     _elem_bt(elem_bt), _length(length) {}

1155 
1156   const Type* xmeet(const Type* t) const;
1157 
1158   bool singleton(void) const;
1159   bool has_non_array_interface() const;
1160 };
1161 
1162 //------------------------------TypePtr----------------------------------------
1163 // Class of machine Pointer Types: raw data, instances or arrays.
1164 // If the _base enum is AnyPtr, then this refers to all of the above.
1165 // Otherwise the _base will indicate which subset of pointers is affected,
1166 // and the class will be inherited from.
1167 class TypePtr : public Type {
1168   friend class TypeNarrowPtr;
1169   friend class Type;
1170 protected:
1171   static const TypeInterfaces* interfaces(ciKlass*& k, bool klass, bool interface, bool array, InterfaceHandling interface_handling);
1172 
1173 public:
1174   enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };



















1175 protected:
1176   TypePtr(TYPES t, PTR ptr, int offset,
1177           relocInfo::relocType reloc,
1178           const TypePtr* speculative = nullptr,
1179           int inline_depth = InlineDepthBottom) :
1180     Type(t), _speculative(speculative), _inline_depth(inline_depth), _offset(offset),
1181     _ptr(ptr), _reloc(reloc) {}
1182   static const PTR ptr_meet[lastPTR][lastPTR];
1183   static const PTR ptr_dual[lastPTR];
1184   static const char * const ptr_msg[lastPTR];
1185 



1186   enum {
1187     InlineDepthBottom = INT_MAX,
1188     InlineDepthTop = -InlineDepthBottom
1189   };
1190 
1191   // Extra type information profiling gave us. We propagate it the
1192   // same way the rest of the type info is propagated. If we want to
1193   // use it, then we have to emit a guard: this part of the type is
1194   // not something we know but something we speculate about the type.
1195   const TypePtr*   _speculative;
1196   // For speculative types, we record at what inlining depth the
1197   // profiling point that provided the data is. We want to favor
1198   // profile data coming from outer scopes which are likely better for
1199   // the current compilation.
1200   int _inline_depth;
1201 
1202   // utility methods to work on the speculative part of the type
1203   const TypePtr* dual_speculative() const;
1204   const TypePtr* xmeet_speculative(const TypePtr* other) const;
1205   bool eq_speculative(const TypePtr* other) const;

1214 #ifndef PRODUCT
1215   void dump_speculative(outputStream* st) const;
1216   void dump_inline_depth(outputStream* st) const;
1217   void dump_offset(outputStream* st) const;
1218 #endif
1219 
1220   // TypeInstPtr (TypeAryPtr resp.) and TypeInstKlassPtr (TypeAryKlassPtr resp.) implement very similar meet logic.
1221   // The logic for meeting 2 instances (2 arrays resp.) is shared in the 2 utility methods below. However the logic for
1222   // the oop and klass versions can be slightly different and extra logic may have to be executed depending on what
1223   // exact case the meet falls into. The MeetResult struct is used by the utility methods to communicate what case was
1224   // encountered so the right logic specific to klasses or oops can be executed.,
1225   enum MeetResult {
1226     QUICK,
1227     UNLOADED,
1228     SUBTYPE,
1229     NOT_SUBTYPE,
1230     LCA
1231   };
1232   template<class T> static TypePtr::MeetResult meet_instptr(PTR& ptr, const TypeInterfaces*& interfaces, const T* this_type,
1233                                                             const T* other_type, ciKlass*& res_klass, bool& res_xk);


1234 
1235   template<class T> static MeetResult meet_aryptr(PTR& ptr, const Type*& elem, const T* this_ary, const T* other_ary,
1236                                                   ciKlass*& res_klass, bool& res_xk);
1237 
1238   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);
1239   template <class T1, class T2> static bool is_same_java_type_as_helper_for_instance(const T1* this_one, const T2* other);
1240   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);
1241   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);
1242   template <class T1, class T2> static bool is_same_java_type_as_helper_for_array(const T1* this_one, const T2* other);
1243   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);
1244   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);
1245   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);
1246 public:
1247   const int _offset;            // Offset into oop, with TOP & BOT
1248   const PTR _ptr;               // Pointer equivalence class
1249   const relocInfo::relocType _reloc;
1250 
1251   int offset() const { return _offset; }
1252   PTR ptr()    const { return _ptr; }
1253   relocInfo::relocType reloc() const { return _reloc; }
1254 
1255   static const TypePtr *make(TYPES t, PTR ptr, int offset,
1256                              const TypePtr* speculative = nullptr,
1257                              int inline_depth = InlineDepthBottom,
1258                              relocInfo::relocType reloc = relocInfo::none);
1259 
1260   // Return a 'ptr' version of this type
1261   virtual const TypePtr* cast_to_ptr_type(PTR ptr) const;
1262 
1263   virtual intptr_t get_con() const;
1264 
1265   int xadd_offset( intptr_t offset ) const;
1266   virtual const TypePtr* add_offset(intptr_t offset) const;
1267   virtual const TypePtr* with_offset(intptr_t offset) const;

1268   virtual bool eq(const Type *t) const;
1269   virtual uint hash() const;             // Type specific hashing
1270 
1271   virtual bool singleton(void) const;    // TRUE if type is a singleton
1272   virtual bool empty(void) const;        // TRUE if type is vacuous
1273   virtual const Type *xmeet( const Type *t ) const;
1274   virtual const Type *xmeet_helper( const Type *t ) const;
1275   int meet_offset( int offset ) const;
1276   int dual_offset( ) const;
1277   virtual const Type *xdual() const;    // Compute dual right now.
1278 
1279   // meet, dual and join over pointer equivalence sets
1280   PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
1281   PTR dual_ptr()                   const { return ptr_dual[ptr()];      }
1282 
1283   // This is textually confusing unless one recalls that
1284   // join(t) == dual()->meet(t->dual())->dual().
1285   PTR join_ptr( const PTR in_ptr ) const {
1286     return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
1287   }
1288 
1289   // Speculative type helper methods.
1290   virtual const TypePtr* speculative() const { return _speculative; }
1291   int inline_depth() const                   { return _inline_depth; }
1292   virtual ciKlass* speculative_type() const;
1293   virtual ciKlass* speculative_type_not_null() const;
1294   virtual bool speculative_maybe_null() const;
1295   virtual bool speculative_always_null() const;
1296   virtual const TypePtr* remove_speculative() const;
1297   virtual const Type* cleanup_speculative() const;
1298   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1299   virtual bool would_improve_ptr(ProfilePtrKind maybe_null) const;
1300   virtual const TypePtr* with_inline_depth(int depth) const;
1301 
1302   virtual bool maybe_null() const { return meet_ptr(Null) == ptr(); }
1303 

















1304   // Tests for relation to centerline of type lattice:
1305   static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
1306   static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
1307   // Convenience common pre-built types.
1308   static const TypePtr *NULL_PTR;
1309   static const TypePtr *NOTNULL;
1310   static const TypePtr *BOTTOM;
1311 #ifndef PRODUCT
1312   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1313 #endif
1314 };
1315 
1316 //------------------------------TypeRawPtr-------------------------------------
1317 // Class of raw pointers, pointers to things other than Oops.  Examples
1318 // include the stack pointer, top of heap, card-marking area, handles, etc.
1319 class TypeRawPtr : public TypePtr {
1320 protected:
1321   TypeRawPtr(PTR ptr, address bits, relocInfo::relocType reloc) : TypePtr(RawPtr, ptr, 0, reloc), _bits(bits){}
1322 public:
1323   virtual bool eq( const Type *t ) const;
1324   virtual uint hash() const;    // Type specific hashing
1325 
1326   const address _bits;          // Constant value, if applicable
1327 
1328   static const TypeRawPtr* make(PTR ptr);
1329   static const TypeRawPtr* make(address bits, relocInfo::relocType reloc = relocInfo::external_word_type);
1330 
1331   // Return a 'ptr' version of this type
1332   virtual const TypeRawPtr* cast_to_ptr_type(PTR ptr) const;
1333 
1334   virtual intptr_t get_con() const;
1335 
1336   virtual const TypePtr* add_offset(intptr_t offset) const;
1337   virtual const TypeRawPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr;}
1338 
1339   virtual const Type *xmeet( const Type *t ) const;
1340   virtual const Type *xdual() const;    // Compute dual right now.
1341   // Convenience common pre-built types.
1342   static const TypeRawPtr *BOTTOM;
1343   static const TypeRawPtr *NOTNULL;
1344 #ifndef PRODUCT
1345   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1346 #endif
1347 };
1348 
1349 //------------------------------TypeOopPtr-------------------------------------
1350 // Some kind of oop (Java pointer), either instance or array.
1351 class TypeOopPtr : public TypePtr {
1352   friend class TypeAry;
1353   friend class TypePtr;
1354   friend class TypeInstPtr;
1355   friend class TypeAryPtr;
1356 protected:
1357  TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, int offset, int instance_id,
1358             const TypePtr* speculative, int inline_depth);
1359 public:
1360   virtual bool eq( const Type *t ) const;
1361   virtual uint hash() const;             // Type specific hashing
1362   virtual bool singleton(void) const;    // TRUE if type is a singleton
1363   enum {
1364    InstanceTop = -1,   // undefined instance
1365    InstanceBot = 0     // any possible instance
1366   };
1367 protected:
1368 
1369   // Oop is null, unless this is a constant oop.
1370   ciObject*     _const_oop;   // Constant oop
1371   // If _klass is null, then so is _sig.  This is an unloaded klass.
1372   ciKlass*      _klass;       // Klass object
1373 
1374   const TypeInterfaces* _interfaces;
1375 
1376   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
1377   bool          _klass_is_exact;
1378   bool          _is_ptr_to_narrowoop;
1379   bool          _is_ptr_to_narrowklass;
1380   bool          _is_ptr_to_boxed_value;

1381 
1382   // If not InstanceTop or InstanceBot, indicates that this is
1383   // a particular instance of this type which is distinct.
1384   // This is the node index of the allocation node creating this instance.
1385   int           _instance_id;
1386 
1387   static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact, InterfaceHandling interface_handling);
1388 
1389   int dual_instance_id() const;
1390   int meet_instance_id(int uid) const;
1391 
1392   const TypeInterfaces* meet_interfaces(const TypeOopPtr* other) const;
1393 
1394   // Do not allow interface-vs.-noninterface joins to collapse to top.
1395   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1396 
1397   virtual ciKlass* exact_klass_helper() const { return nullptr; }
1398   virtual ciKlass* klass() const { return _klass;     }
1399 
1400 #ifndef PRODUCT
1401   void dump_instance_id(outputStream* st) const;
1402 #endif // PRODUCT
1403 
1404 public:
1405 
1406   bool is_java_subtype_of(const TypeOopPtr* other) const {
1407     return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1408   }
1409 
1410   bool is_same_java_type_as(const TypePtr* other) const {
1411     return is_same_java_type_as_helper(other->is_oopptr());
1412   }
1413 
1414   virtual bool is_same_java_type_as_helper(const TypeOopPtr* other) const {
1415     ShouldNotReachHere(); return false;
1416   }
1417 
1418   bool maybe_java_subtype_of(const TypeOopPtr* other) const {

1429     return make_from_klass_common(klass, true, false, interface_handling);
1430   }
1431   // Same as before, but will produce an exact type, even if
1432   // the klass is not final, as long as it has exactly one implementation.
1433   static const TypeOopPtr* make_from_klass_unique(ciKlass* klass, InterfaceHandling interface_handling= ignore_interfaces) {
1434     return make_from_klass_common(klass, true, true, interface_handling);
1435   }
1436   // Same as before, but does not respects UseUniqueSubclasses.
1437   // Use this only for creating array element types.
1438   static const TypeOopPtr* make_from_klass_raw(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1439     return make_from_klass_common(klass, false, false, interface_handling);
1440   }
1441   // Creates a singleton type given an object.
1442   // If the object cannot be rendered as a constant,
1443   // may return a non-singleton type.
1444   // If require_constant, produce a null if a singleton is not possible.
1445   static const TypeOopPtr* make_from_constant(ciObject* o,
1446                                               bool require_constant = false);
1447 
1448   // Make a generic (unclassed) pointer to an oop.
1449   static const TypeOopPtr* make(PTR ptr, int offset, int instance_id,
1450                                 const TypePtr* speculative = nullptr,
1451                                 int inline_depth = InlineDepthBottom);
1452 
1453   ciObject* const_oop()    const { return _const_oop; }
1454   // Exact klass, possibly an interface or an array of interface
1455   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k;  }
1456   ciKlass* unloaded_klass() const { assert(!is_loaded(), "only for unloaded types"); return klass(); }
1457 
1458   virtual bool  is_loaded() const { return klass()->is_loaded(); }
1459   virtual bool klass_is_exact()    const { return _klass_is_exact; }
1460 
1461   // Returns true if this pointer points at memory which contains a
1462   // compressed oop references.
1463   bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
1464   bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
1465   bool is_ptr_to_boxed_value()   const { return _is_ptr_to_boxed_value; }

1466   bool is_known_instance()       const { return _instance_id > 0; }
1467   int  instance_id()             const { return _instance_id; }
1468   bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }



1469 
1470   virtual intptr_t get_con() const;
1471 
1472   virtual const TypeOopPtr* cast_to_ptr_type(PTR ptr) const;
1473 
1474   virtual const TypeOopPtr* cast_to_exactness(bool klass_is_exact) const;
1475 
1476   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1477 
1478   // corresponding pointer to klass, for a given instance
1479   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1480 
1481   virtual const TypeOopPtr* with_offset(intptr_t offset) const;
1482   virtual const TypePtr* add_offset(intptr_t offset) const;
1483 
1484   // Speculative type helper methods.
1485   virtual const TypeOopPtr* remove_speculative() const;
1486   virtual const Type* cleanup_speculative() const;
1487   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1488   virtual const TypePtr* with_inline_depth(int depth) const;

1511     return _interfaces;
1512   };
1513 
1514   const TypeOopPtr* is_reference_type(const Type* other) const {
1515     return other->isa_oopptr();
1516   }
1517 
1518   const TypeAryPtr* is_array_type(const TypeOopPtr* other) const {
1519     return other->isa_aryptr();
1520   }
1521 
1522   const TypeInstPtr* is_instance_type(const TypeOopPtr* other) const {
1523     return other->isa_instptr();
1524   }
1525 };
1526 
1527 //------------------------------TypeInstPtr------------------------------------
1528 // Class of Java object pointers, pointing either to non-array Java instances
1529 // or to a Klass* (including array klasses).
1530 class TypeInstPtr : public TypeOopPtr {
1531   TypeInstPtr(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, int off, int instance_id,
1532               const TypePtr* speculative, int inline_depth);




1533   virtual bool eq( const Type *t ) const;
1534   virtual uint hash() const;             // Type specific hashing
1535 
1536   ciKlass* exact_klass_helper() const;
1537 
1538 public:
1539 
1540   // Instance klass, ignoring any interface
1541   ciInstanceKlass* instance_klass() const {
1542     assert(!(klass()->is_loaded() && klass()->is_interface()), "");
1543     return klass()->as_instance_klass();
1544   }
1545 
1546   bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1547   bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1548   bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1549 
1550   // Make a pointer to a constant oop.
1551   static const TypeInstPtr *make(ciObject* o) {
1552     ciKlass* k = o->klass();
1553     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1554     return make(TypePtr::Constant, k, interfaces, true, o, 0, InstanceBot);
1555   }
1556   // Make a pointer to a constant oop with offset.
1557   static const TypeInstPtr *make(ciObject* o, int offset) {
1558     ciKlass* k = o->klass();
1559     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1560     return make(TypePtr::Constant, k, interfaces, true, o, offset, InstanceBot);
1561   }
1562 
1563   // Make a pointer to some value of type klass.
1564   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1565     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, true, false, interface_handling);
1566     return make(ptr, klass, interfaces, false, nullptr, 0, InstanceBot);
1567   }
1568 
1569   // Make a pointer to some non-polymorphic value of exactly type klass.
1570   static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
1571     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1572     return make(ptr, klass, interfaces, true, nullptr, 0, InstanceBot);
1573   }
1574 
1575   // Make a pointer to some value of type klass with offset.
1576   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
1577     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1578     return make(ptr, klass, interfaces, false, nullptr, offset, InstanceBot);
1579   }
1580 
1581   static const TypeInstPtr *make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, int offset,


1582                                  int instance_id = InstanceBot,
1583                                  const TypePtr* speculative = nullptr,
1584                                  int inline_depth = InlineDepthBottom);
1585 
1586   static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot) {

1587     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1588     return make(ptr, k, interfaces, xk, o, offset, instance_id);
1589   }
1590 
1591   // If this is a java.lang.Class constant, return the type for it or null.
1592   // Pass to Type::get_const_type to turn it to a type, which will usually
1593   // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
1594   ciType* java_mirror_type() const;
1595 
1596   virtual const TypeInstPtr* cast_to_ptr_type(PTR ptr) const;
1597 
1598   virtual const TypeInstPtr* cast_to_exactness(bool klass_is_exact) const;
1599 
1600   virtual const TypeInstPtr* cast_to_instance_id(int instance_id) const;
1601 

1602   virtual const TypePtr* add_offset(intptr_t offset) const;
1603   virtual const TypeInstPtr* with_offset(intptr_t offset) const;
1604 
1605   // Speculative type helper methods.
1606   virtual const TypeInstPtr* remove_speculative() const;
1607   const TypeInstPtr* with_speculative(const TypePtr* speculative) const;
1608   virtual const TypePtr* with_inline_depth(int depth) const;
1609   virtual const TypePtr* with_instance_id(int instance_id) const;
1610 








1611   // the core of the computation of the meet of 2 types
1612   virtual const Type *xmeet_helper(const Type *t) const;
1613   virtual const TypeInstPtr *xmeet_unloaded(const TypeInstPtr *tinst, const TypeInterfaces* interfaces) const;
1614   virtual const Type *xdual() const;    // Compute dual right now.
1615 
1616   const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1617 


1618   // Convenience common pre-built types.
1619   static const TypeInstPtr *NOTNULL;
1620   static const TypeInstPtr *BOTTOM;
1621   static const TypeInstPtr *MIRROR;
1622   static const TypeInstPtr *MARK;
1623   static const TypeInstPtr *KLASS;
1624 #ifndef PRODUCT
1625   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1626 #endif
1627 
1628 private:
1629   virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1630 
1631   virtual bool is_meet_same_type_as(const TypePtr* other) const {
1632     return _klass->equals(other->is_instptr()->_klass) && _interfaces->eq(other->is_instptr()->_interfaces);
1633   }
1634 
1635 };
1636 
1637 //------------------------------TypeAryPtr-------------------------------------
1638 // Class of Java array pointers
1639 class TypeAryPtr : public TypeOopPtr {
1640   friend class Type;
1641   friend class TypePtr;

1642   friend class TypeInterfaces;
1643 
1644   TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1645               int offset, int instance_id, bool is_autobox_cache,
1646               const TypePtr* speculative, int inline_depth)
1647     : TypeOopPtr(AryPtr,ptr,k,_array_interfaces,xk,o,offset, instance_id, speculative, inline_depth),
1648     _ary(ary),
1649     _is_autobox_cache(is_autobox_cache)

1650  {
1651     int dummy;
1652     bool top_or_bottom = (base_element_type(dummy) == Type::TOP || base_element_type(dummy) == Type::BOTTOM);
1653 
1654     if (UseCompressedOops && (elem()->make_oopptr() != nullptr && !top_or_bottom) &&
1655         _offset != 0 && _offset != arrayOopDesc::length_offset_in_bytes() &&
1656         _offset != arrayOopDesc::klass_offset_in_bytes()) {
1657       _is_ptr_to_narrowoop = true;
1658     }
1659 
1660   }
1661   virtual bool eq( const Type *t ) const;
1662   virtual uint hash() const;    // Type specific hashing
1663   const TypeAry *_ary;          // Array we point into
1664   const bool     _is_autobox_cache;






1665 
1666   ciKlass* compute_klass() const;
1667 
1668   // A pointer to delay allocation to Type::Initialize_shared()
1669 
1670   static const TypeInterfaces* _array_interfaces;
1671   ciKlass* exact_klass_helper() const;
1672   // Only guaranteed non null for array of basic types
1673   ciKlass* klass() const;
1674 
1675 public:
1676 
1677   bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1678   bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1679   bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1680 
1681   // returns base element type, an instance klass (and not interface) for object arrays
1682   const Type* base_element_type(int& dims) const;
1683 
1684   // Accessors
1685   bool  is_loaded() const { return (_ary->_elem->make_oopptr() ? _ary->_elem->make_oopptr()->is_loaded() : true); }
1686 
1687   const TypeAry* ary() const  { return _ary; }
1688   const Type*    elem() const { return _ary->_elem; }
1689   const TypeInt* size() const { return _ary->_size; }
1690   bool      is_stable() const { return _ary->_stable; }
1691 







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

1695                                 int instance_id = InstanceBot,
1696                                 const TypePtr* speculative = nullptr,
1697                                 int inline_depth = InlineDepthBottom);
1698   // Constant pointer to array
1699   static const TypeAryPtr *make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset,

1700                                 int instance_id = InstanceBot,
1701                                 const TypePtr* speculative = nullptr,
1702                                 int inline_depth = InlineDepthBottom, bool is_autobox_cache = false);

1703 
1704   // Return a 'ptr' version of this type
1705   virtual const TypeAryPtr* cast_to_ptr_type(PTR ptr) const;
1706 
1707   virtual const TypeAryPtr* cast_to_exactness(bool klass_is_exact) const;
1708 
1709   virtual const TypeAryPtr* cast_to_instance_id(int instance_id) const;
1710 
1711   virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1712   virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1713 
1714   virtual bool empty(void) const;        // TRUE if type is vacuous
1715   virtual const TypePtr *add_offset( intptr_t offset ) const;
1716   virtual const TypeAryPtr *with_offset( intptr_t offset ) const;
1717   const TypeAryPtr* with_ary(const TypeAry* ary) const;
1718 
1719   // Speculative type helper methods.
1720   virtual const TypeAryPtr* remove_speculative() const;

1721   virtual const TypePtr* with_inline_depth(int depth) const;
1722   virtual const TypePtr* with_instance_id(int instance_id) const;
1723 
1724   // the core of the computation of the meet of 2 types
1725   virtual const Type *xmeet_helper(const Type *t) const;
1726   virtual const Type *xdual() const;    // Compute dual right now.
1727 










1728   const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1729   int stable_dimension() const;
1730 
1731   const TypeAryPtr* cast_to_autobox_cache() const;
1732 
1733   static jint max_array_length(BasicType etype) ;







1734   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1735 


1736   // Convenience common pre-built types.
1737   static const TypeAryPtr* BOTTOM;
1738   static const TypeAryPtr* RANGE;
1739   static const TypeAryPtr* OOPS;
1740   static const TypeAryPtr* NARROWOOPS;
1741   static const TypeAryPtr* BYTES;
1742   static const TypeAryPtr* SHORTS;
1743   static const TypeAryPtr* CHARS;
1744   static const TypeAryPtr* INTS;
1745   static const TypeAryPtr* LONGS;
1746   static const TypeAryPtr* FLOATS;
1747   static const TypeAryPtr* DOUBLES;

1748   // selects one of the above:
1749   static const TypeAryPtr *get_array_body_type(BasicType elem) {
1750     assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != nullptr, "bad elem type");
1751     return _array_body_type[elem];
1752   }
1753   static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1754   // sharpen the type of an int which is used as an array size
1755 #ifndef PRODUCT
1756   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1757 #endif
1758 private:
1759   virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1760 };
1761 
1762 //------------------------------TypeMetadataPtr-------------------------------------
1763 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
1764 class TypeMetadataPtr : public TypePtr {
1765 protected:
1766   TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset);
1767   // Do not allow interface-vs.-noninterface joins to collapse to top.
1768   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1769 public:
1770   virtual bool eq( const Type *t ) const;
1771   virtual uint hash() const;             // Type specific hashing
1772   virtual bool singleton(void) const;    // TRUE if type is a singleton
1773 
1774 private:
1775   ciMetadata*   _metadata;
1776 
1777 public:
1778   static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, int offset);
1779 
1780   static const TypeMetadataPtr* make(ciMethod* m);
1781   static const TypeMetadataPtr* make(ciMethodData* m);
1782 
1783   ciMetadata* metadata() const { return _metadata; }
1784 
1785   virtual const TypeMetadataPtr* cast_to_ptr_type(PTR ptr) const;
1786 
1787   virtual const TypePtr *add_offset( intptr_t offset ) const;
1788 
1789   virtual const Type *xmeet( const Type *t ) const;
1790   virtual const Type *xdual() const;    // Compute dual right now.
1791 
1792   virtual intptr_t get_con() const;
1793 
1794   // Convenience common pre-built types.
1795   static const TypeMetadataPtr *BOTTOM;
1796 
1797 #ifndef PRODUCT
1798   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1799 #endif
1800 };
1801 
1802 //------------------------------TypeKlassPtr-----------------------------------
1803 // Class of Java Klass pointers
1804 class TypeKlassPtr : public TypePtr {
1805   friend class TypeInstKlassPtr;
1806   friend class TypeAryKlassPtr;
1807   friend class TypePtr;
1808 protected:
1809   TypeKlassPtr(TYPES t, PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, int offset);
1810 
1811   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1812 
1813 public:
1814   virtual bool eq( const Type *t ) const;
1815   virtual uint hash() const;
1816   virtual bool singleton(void) const;    // TRUE if type is a singleton
1817 
1818 protected:
1819 
1820   ciKlass* _klass;
1821   const TypeInterfaces* _interfaces;
1822   const TypeInterfaces* meet_interfaces(const TypeKlassPtr* other) const;
1823   virtual bool must_be_exact() const { ShouldNotReachHere(); return false; }
1824   virtual ciKlass* exact_klass_helper() const;
1825   virtual ciKlass* klass() const { return  _klass; }
1826 
1827 public:
1828 
1829   bool is_java_subtype_of(const TypeKlassPtr* other) const {
1830     return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1831   }
1832   bool is_same_java_type_as(const TypePtr* other) const {
1833     return is_same_java_type_as_helper(other->is_klassptr());
1834   }
1835 
1836   bool maybe_java_subtype_of(const TypeKlassPtr* other) const {
1837     return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1838   }
1839   virtual bool is_same_java_type_as_helper(const TypeKlassPtr* other) const { ShouldNotReachHere(); return false; }
1840   virtual bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1841   virtual bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1842 
1843   // Exact klass, possibly an interface or an array of interface
1844   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k;  }
1845   virtual bool klass_is_exact()    const { return _ptr == Constant; }
1846 
1847   static const TypeKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces);
1848   static const TypeKlassPtr *make(PTR ptr, ciKlass* klass, int offset, InterfaceHandling interface_handling = ignore_interfaces);
1849 
1850   virtual bool  is_loaded() const { return _klass->is_loaded(); }
1851 
1852   virtual const TypeKlassPtr* cast_to_ptr_type(PTR ptr) const { ShouldNotReachHere(); return nullptr; }
1853 
1854   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const { ShouldNotReachHere(); return nullptr; }
1855 
1856   // corresponding pointer to instance, for a given class
1857   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const { ShouldNotReachHere(); return nullptr; }
1858 
1859   virtual const TypePtr *add_offset( intptr_t offset ) const { ShouldNotReachHere(); return nullptr; }
1860   virtual const Type    *xmeet( const Type *t ) const { ShouldNotReachHere(); return nullptr; }
1861   virtual const Type    *xdual() const { ShouldNotReachHere(); return nullptr; }
1862 
1863   virtual intptr_t get_con() const;
1864 
1865   virtual const TypeKlassPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr; }
1866 


1867   virtual const TypeKlassPtr* try_improve() const { return this; }
1868 
1869 private:
1870   virtual bool is_meet_subtype_of(const TypePtr* other) const {
1871     return is_meet_subtype_of_helper(other->is_klassptr(), klass_is_exact(), other->is_klassptr()->klass_is_exact());
1872   }
1873 
1874   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const {
1875     ShouldNotReachHere(); return false;
1876   }
1877 
1878   virtual const TypeInterfaces* interfaces() const {
1879     return _interfaces;
1880   };
1881 
1882   const TypeKlassPtr* is_reference_type(const Type* other) const {
1883     return other->isa_klassptr();
1884   }
1885 
1886   const TypeAryKlassPtr* is_array_type(const TypeKlassPtr* other) const {
1887     return other->isa_aryklassptr();
1888   }
1889 
1890   const TypeInstKlassPtr* is_instance_type(const TypeKlassPtr* other) const {
1891     return other->isa_instklassptr();
1892   }
1893 };
1894 
1895 // Instance klass pointer, mirrors TypeInstPtr
1896 class TypeInstKlassPtr : public TypeKlassPtr {


1897 
1898   TypeInstKlassPtr(PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, int offset)
1899     : TypeKlassPtr(InstKlassPtr, ptr, klass, interfaces, offset) {

1900     assert(klass->is_instance_klass() && (!klass->is_loaded() || !klass->is_interface()), "");
1901   }
1902 
1903   virtual bool must_be_exact() const;
1904 
1905 public:
1906   // Instance klass ignoring any interface
1907   ciInstanceKlass* instance_klass() const {
1908     assert(!klass()->is_interface(), "");
1909     return klass()->as_instance_klass();
1910   }
1911 
1912   bool might_be_an_array() const;
1913 
1914   bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
1915   bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1916   bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1917 


1918   static const TypeInstKlassPtr *make(ciKlass* k, InterfaceHandling interface_handling) {
1919     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, true, false, interface_handling);
1920     return make(TypePtr::Constant, k, interfaces, 0);
1921   }
1922   static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, int offset);
1923 
1924   static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, int offset) {



1925     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1926     return make(ptr, k, interfaces, offset);
1927   }
1928 
1929   virtual const TypeInstKlassPtr* cast_to_ptr_type(PTR ptr) const;
1930 
1931   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1932 
1933   // corresponding pointer to instance, for a given class
1934   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
1935   virtual uint hash() const;
1936   virtual bool eq(const Type *t) const;
1937 


1938   virtual const TypePtr *add_offset( intptr_t offset ) const;
1939   virtual const Type    *xmeet( const Type *t ) const;
1940   virtual const Type    *xdual() const;
1941   virtual const TypeInstKlassPtr* with_offset(intptr_t offset) const;
1942 
1943   virtual const TypeKlassPtr* try_improve() const;
1944 








1945   // Convenience common pre-built types.
1946   static const TypeInstKlassPtr* OBJECT; // Not-null object klass or below
1947   static const TypeInstKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
1948 
1949 #ifndef PRODUCT
1950   virtual void dump2(Dict& d, uint depth, outputStream* st) const;
1951 #endif // PRODUCT
1952 
1953 private:
1954   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
1955 };
1956 
1957 // Array klass pointer, mirrors TypeAryPtr
1958 class TypeAryKlassPtr : public TypeKlassPtr {
1959   friend class TypeInstKlassPtr;
1960   friend class Type;
1961   friend class TypePtr;
1962 
1963   const Type *_elem;






1964 
1965   static const TypeInterfaces* _array_interfaces;
1966   TypeAryKlassPtr(PTR ptr, const Type *elem, ciKlass* klass, int offset)
1967     : TypeKlassPtr(AryKlassPtr, ptr, klass, _array_interfaces, offset), _elem(elem) {
1968     assert(klass == nullptr || klass->is_type_array_klass() || !klass->as_obj_array_klass()->base_element_klass()->is_interface(), "");
1969   }
1970 
1971   virtual ciKlass* exact_klass_helper() const;
1972   // Only guaranteed non null for array of basic types
1973   virtual ciKlass* klass() const;
1974 
1975   virtual bool must_be_exact() const;
1976 
























1977 public:
1978 
1979   // returns base element type, an instance klass (and not interface) for object arrays
1980   const Type* base_element_type(int& dims) const;
1981 
1982   static const TypeAryKlassPtr *make(PTR ptr, ciKlass* k, int offset, InterfaceHandling interface_handling);
1983 
1984   bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
1985   bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1986   bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1987 
1988   bool  is_loaded() const { return (_elem->isa_klassptr() ? _elem->is_klassptr()->is_loaded() : true); }
1989 
1990   static const TypeAryKlassPtr *make(PTR ptr, const Type *elem, ciKlass* k, int offset);
1991   static const TypeAryKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling);
1992 



1993   const Type *elem() const { return _elem; }
1994 
1995   virtual bool eq(const Type *t) const;
1996   virtual uint hash() const;             // Type specific hashing
1997 
1998   virtual const TypeAryKlassPtr* cast_to_ptr_type(PTR ptr) const;
1999 
2000   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
2001 
2002   // corresponding pointer to instance, for a given class
2003   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
2004 
2005   virtual const TypePtr *add_offset( intptr_t offset ) const;
2006   virtual const Type    *xmeet( const Type *t ) const;
2007   virtual const Type    *xdual() const;      // Compute dual right now.
2008 
2009   virtual const TypeAryKlassPtr* with_offset(intptr_t offset) const;
2010 
2011   virtual bool empty(void) const {
2012     return TypeKlassPtr::empty() || _elem->empty();
2013   }
2014 








2015 #ifndef PRODUCT
2016   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
2017 #endif
2018 private:
2019   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
2020 };
2021 
2022 class TypeNarrowPtr : public Type {
2023 protected:
2024   const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
2025 
2026   TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): Type(t),
2027                                                   _ptrtype(ptrtype) {
2028     assert(ptrtype->offset() == 0 ||
2029            ptrtype->offset() == OffsetBot ||
2030            ptrtype->offset() == OffsetTop, "no real offsets");
2031   }
2032 
2033   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
2034   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;

2130   }
2131 
2132   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
2133     return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
2134   }
2135 
2136 public:
2137   static const TypeNarrowKlass *make( const TypePtr* type);
2138 
2139   // static const TypeNarrowKlass *BOTTOM;
2140   static const TypeNarrowKlass *NULL_PTR;
2141 
2142 #ifndef PRODUCT
2143   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
2144 #endif
2145 };
2146 
2147 //------------------------------TypeFunc---------------------------------------
2148 // Class of Array Types
2149 class TypeFunc : public Type {
2150   TypeFunc( const TypeTuple *domain, const TypeTuple *range ) : Type(Function),  _domain(domain), _range(range) {}

2151   virtual bool eq( const Type *t ) const;
2152   virtual uint hash() const;             // Type specific hashing
2153   virtual bool singleton(void) const;    // TRUE if type is a singleton
2154   virtual bool empty(void) const;        // TRUE if type is vacuous
2155 
2156   const TypeTuple* const _domain;     // Domain of inputs
2157   const TypeTuple* const _range;      // Range of results












2158 
2159 public:
2160   // Constants are shared among ADLC and VM
2161   enum { Control    = AdlcVMDeps::Control,
2162          I_O        = AdlcVMDeps::I_O,
2163          Memory     = AdlcVMDeps::Memory,
2164          FramePtr   = AdlcVMDeps::FramePtr,
2165          ReturnAdr  = AdlcVMDeps::ReturnAdr,
2166          Parms      = AdlcVMDeps::Parms
2167   };
2168 
2169 
2170   // Accessors:
2171   const TypeTuple* domain() const { return _domain; }
2172   const TypeTuple* range()  const { return _range; }
2173 
2174   static const TypeFunc *make(ciMethod* method);
2175   static const TypeFunc *make(ciSignature signature, const Type* extra);





2176   static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
2177 
2178   virtual const Type *xmeet( const Type *t ) const;
2179   virtual const Type *xdual() const;    // Compute dual right now.
2180 
2181   BasicType return_type() const;
2182 






2183 #ifndef PRODUCT
2184   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
2185 #endif
2186   // Convenience common pre-built types.
2187 };
2188 
2189 //------------------------------accessors--------------------------------------
2190 inline bool Type::is_ptr_to_narrowoop() const {
2191 #ifdef _LP64
2192   return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowoop_nv());
2193 #else
2194   return false;
2195 #endif
2196 }
2197 
2198 inline bool Type::is_ptr_to_narrowklass() const {
2199 #ifdef _LP64
2200   return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowklass_nv());
2201 #else
2202   return false;

2439 }
2440 
2441 inline const TypeNarrowOop* Type::make_narrowoop() const {
2442   return (_base == NarrowOop) ? is_narrowoop() :
2443                                 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : nullptr);
2444 }
2445 
2446 inline const TypeNarrowKlass* Type::make_narrowklass() const {
2447   return (_base == NarrowKlass) ? is_narrowklass() :
2448                                   (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : nullptr);
2449 }
2450 
2451 inline bool Type::is_floatingpoint() const {
2452   if( (_base == HalfFloatCon)  || (_base == HalfFloatBot) ||
2453       (_base == FloatCon)  || (_base == FloatBot) ||
2454       (_base == DoubleCon) || (_base == DoubleBot) )
2455     return true;
2456   return false;
2457 }
2458 








2459 template <>
2460 inline const TypeInt* Type::cast<TypeInt>() const {
2461   return is_int();
2462 }
2463 
2464 template <>
2465 inline const TypeLong* Type::cast<TypeLong>() const {
2466   return is_long();
2467 }
2468 
2469 template <>
2470 inline const TypeInt* Type::try_cast<TypeInt>() const {
2471   return isa_int();
2472 }
2473 
2474 template <>
2475 inline const TypeLong* Type::try_cast<TypeLong>() const {
2476   return isa_long();
2477 }
2478 

2484 
2485 // For type queries and asserts
2486 #define is_intptr_t  is_long
2487 #define isa_intptr_t isa_long
2488 #define find_intptr_t_type find_long_type
2489 #define find_intptr_t_con  find_long_con
2490 #define TypeX        TypeLong
2491 #define Type_X       Type::Long
2492 #define TypeX_X      TypeLong::LONG
2493 #define TypeX_ZERO   TypeLong::ZERO
2494 // For 'ideal_reg' machine registers
2495 #define Op_RegX      Op_RegL
2496 // For phase->intcon variants
2497 #define MakeConX     longcon
2498 #define ConXNode     ConLNode
2499 // For array index arithmetic
2500 #define MulXNode     MulLNode
2501 #define AndXNode     AndLNode
2502 #define OrXNode      OrLNode
2503 #define CmpXNode     CmpLNode

2504 #define SubXNode     SubLNode
2505 #define LShiftXNode  LShiftLNode
2506 // For object size computation:
2507 #define AddXNode     AddLNode
2508 #define RShiftXNode  RShiftLNode
2509 // For card marks and hashcodes
2510 #define URShiftXNode URShiftLNode
2511 // For shenandoahSupport
2512 #define LoadXNode    LoadLNode
2513 #define StoreXNode   StoreLNode
2514 // Opcodes
2515 #define Op_LShiftX   Op_LShiftL
2516 #define Op_AndX      Op_AndL
2517 #define Op_AddX      Op_AddL
2518 #define Op_SubX      Op_SubL
2519 #define Op_XorX      Op_XorL
2520 #define Op_URShiftX  Op_URShiftL
2521 #define Op_LoadX     Op_LoadL

2522 // conversions
2523 #define ConvI2X(x)   ConvI2L(x)
2524 #define ConvL2X(x)   (x)
2525 #define ConvX2I(x)   ConvL2I(x)
2526 #define ConvX2L(x)   (x)
2527 #define ConvX2UL(x)  (x)
2528 
2529 #else
2530 
2531 // For type queries and asserts
2532 #define is_intptr_t  is_int
2533 #define isa_intptr_t isa_int
2534 #define find_intptr_t_type find_int_type
2535 #define find_intptr_t_con  find_int_con
2536 #define TypeX        TypeInt
2537 #define Type_X       Type::Int
2538 #define TypeX_X      TypeInt::INT
2539 #define TypeX_ZERO   TypeInt::ZERO
2540 // For 'ideal_reg' machine registers
2541 #define Op_RegX      Op_RegI
2542 // For phase->intcon variants
2543 #define MakeConX     intcon
2544 #define ConXNode     ConINode
2545 // For array index arithmetic
2546 #define MulXNode     MulINode
2547 #define AndXNode     AndINode
2548 #define OrXNode      OrINode
2549 #define CmpXNode     CmpINode

2550 #define SubXNode     SubINode
2551 #define LShiftXNode  LShiftINode
2552 // For object size computation:
2553 #define AddXNode     AddINode
2554 #define RShiftXNode  RShiftINode
2555 // For card marks and hashcodes
2556 #define URShiftXNode URShiftINode
2557 // For shenandoahSupport
2558 #define LoadXNode    LoadINode
2559 #define StoreXNode   StoreINode
2560 // Opcodes
2561 #define Op_LShiftX   Op_LShiftI
2562 #define Op_AndX      Op_AndI
2563 #define Op_AddX      Op_AddI
2564 #define Op_SubX      Op_SubI
2565 #define Op_XorX      Op_XorI
2566 #define Op_URShiftX  Op_URShiftI
2567 #define Op_LoadX     Op_LoadI

2568 // conversions
2569 #define ConvI2X(x)   (x)
2570 #define ConvL2X(x)   ConvL2I(x)
2571 #define ConvX2I(x)   (x)
2572 #define ConvX2L(x)   ConvI2L(x)
2573 #define ConvX2UL(x)  ConvI2UL(x)
2574 
2575 #endif
2576 
2577 #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 
  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   class Offset {
 148   private:
 149     int _offset;
 150 
 151   public:
 152     explicit Offset(int offset) : _offset(offset) {}
 153 
 154     const Offset meet(const Offset other) const;
 155     const Offset dual() const;
 156     const Offset add(intptr_t offset) const;
 157     bool operator==(const Offset& other) const {
 158       return _offset == other._offset;
 159     }
 160     bool operator!=(const Offset& other) const {
 161       return _offset != other._offset;
 162     }
 163     int get() const { return _offset; }
 164 
 165     void dump2(outputStream *st) const;
 166 
 167     static const Offset top;
 168     static const Offset bottom;
 169   };
 170 
 171   // Min and max WIDEN values.
 172   enum WIDEN {
 173     WidenMin = 0,
 174     WidenMax = 3
 175   };
 176 
 177 private:
 178   typedef struct {
 179     TYPES                dual_type;
 180     BasicType            basic_type;
 181     const char*          msg;
 182     bool                 isa_oop;
 183     uint                 ideal_reg;
 184   } TypeInfo;
 185 
 186   // Dictionary of types shared among compilations.
 187   static Dict* _shared_type_dict;
 188   static const TypeInfo _type_info[];
 189 
 190   static int uhash( const Type *const t );

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

 490   static const Type* get_typeflow_type(ciType* type);
 491 
 492   static const Type* make_from_constant(ciConstant constant,
 493                                         bool require_constant = false,
 494                                         int stable_dimension = 0,
 495                                         bool is_narrow = false,
 496                                         bool is_autobox_cache = false);
 497 
 498   static const Type* make_constant_from_field(ciInstance* holder,
 499                                               int off,
 500                                               bool is_unsigned_load,
 501                                               BasicType loadbt);
 502 
 503   static const Type* make_constant_from_field(ciField* field,
 504                                               ciInstance* holder,
 505                                               BasicType loadbt,
 506                                               bool is_unsigned_load);
 507 
 508   static const Type* make_constant_from_array_element(ciArray* array,
 509                                                       int off,
 510                                                       int field_offset,
 511                                                       int stable_dimension,
 512                                                       BasicType loadbt,
 513                                                       bool is_unsigned_load);
 514 
 515   // Speculative type helper methods. See TypePtr.
 516   virtual const TypePtr* speculative() const                                  { return nullptr; }
 517   virtual ciKlass* speculative_type() const                                   { return nullptr; }
 518   virtual ciKlass* speculative_type_not_null() const                          { return nullptr; }
 519   virtual bool speculative_maybe_null() const                                 { return true; }
 520   virtual bool speculative_always_null() const                                { return true; }
 521   virtual const Type* remove_speculative() const                              { return this; }
 522   virtual const Type* cleanup_speculative() const                             { return this; }
 523   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const { return exact_kls != nullptr; }
 524   virtual bool would_improve_ptr(ProfilePtrKind ptr_kind) const { return ptr_kind == ProfileAlwaysNull || ptr_kind == ProfileNeverNull; }
 525   const Type* maybe_remove_speculative(bool include_speculative) const;
 526 
 527   virtual bool maybe_null() const { return true; }
 528   virtual bool is_known_instance() const { return false; }
 529 
 530 private:

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

1191 
1192   const Type* xmeet(const Type* t) const;
1193 
1194   bool singleton(void) const;
1195   bool has_non_array_interface() const;
1196 };
1197 
1198 //------------------------------TypePtr----------------------------------------
1199 // Class of machine Pointer Types: raw data, instances or arrays.
1200 // If the _base enum is AnyPtr, then this refers to all of the above.
1201 // Otherwise the _base will indicate which subset of pointers is affected,
1202 // and the class will be inherited from.
1203 class TypePtr : public Type {
1204   friend class TypeNarrowPtr;
1205   friend class Type;
1206 protected:
1207   static const TypeInterfaces* interfaces(ciKlass*& k, bool klass, bool interface, bool array, InterfaceHandling interface_handling);
1208 
1209 public:
1210   enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
1211 
1212   // Only applies to TypeInstPtr and TypeInstKlassPtr. Since the common super class is TypePtr, it is defined here.
1213   //
1214   // FlatInArray defines the following Boolean Lattice structure
1215   //
1216   //     TopFlat
1217   //    /      \
1218   //  Flat   NotFlat
1219   //    \      /
1220   //   MaybeFlat
1221   //
1222   // with meet (see TypePtr::meet_flat_in_array()) and join (implemented over dual, see TypePtr::flat_in_array_dual)
1223   enum FlatInArray {
1224     TopFlat,        // Dedicated top element and dual of MaybeFlat. Result when joining Flat and NotFlat.
1225     Flat,           // An instance is always flat in an array.
1226     NotFlat,        // An instance is never flat in an array.
1227     MaybeFlat,      // We don't know whether an instance is flat in an array.
1228     Uninitialized   // Used when the flat in array property was not computed, yet - should never actually end up in a type.
1229   };
1230 protected:
1231   TypePtr(TYPES t, PTR ptr, Offset offset,
1232           relocInfo::relocType reloc,
1233           const TypePtr* speculative = nullptr,
1234           int inline_depth = InlineDepthBottom) :
1235     Type(t), _speculative(speculative), _inline_depth(inline_depth), _offset(offset),
1236     _ptr(ptr), _reloc(reloc) {}
1237   static const PTR ptr_meet[lastPTR][lastPTR];
1238   static const PTR ptr_dual[lastPTR];
1239   static const char * const ptr_msg[lastPTR];
1240 
1241   static const FlatInArray flat_in_array_dual[Uninitialized];
1242   static const char* const flat_in_array_msg[Uninitialized];
1243 
1244   enum {
1245     InlineDepthBottom = INT_MAX,
1246     InlineDepthTop = -InlineDepthBottom
1247   };
1248 
1249   // Extra type information profiling gave us. We propagate it the
1250   // same way the rest of the type info is propagated. If we want to
1251   // use it, then we have to emit a guard: this part of the type is
1252   // not something we know but something we speculate about the type.
1253   const TypePtr*   _speculative;
1254   // For speculative types, we record at what inlining depth the
1255   // profiling point that provided the data is. We want to favor
1256   // profile data coming from outer scopes which are likely better for
1257   // the current compilation.
1258   int _inline_depth;
1259 
1260   // utility methods to work on the speculative part of the type
1261   const TypePtr* dual_speculative() const;
1262   const TypePtr* xmeet_speculative(const TypePtr* other) const;
1263   bool eq_speculative(const TypePtr* other) const;

1272 #ifndef PRODUCT
1273   void dump_speculative(outputStream* st) const;
1274   void dump_inline_depth(outputStream* st) const;
1275   void dump_offset(outputStream* st) const;
1276 #endif
1277 
1278   // TypeInstPtr (TypeAryPtr resp.) and TypeInstKlassPtr (TypeAryKlassPtr resp.) implement very similar meet logic.
1279   // The logic for meeting 2 instances (2 arrays resp.) is shared in the 2 utility methods below. However the logic for
1280   // the oop and klass versions can be slightly different and extra logic may have to be executed depending on what
1281   // exact case the meet falls into. The MeetResult struct is used by the utility methods to communicate what case was
1282   // encountered so the right logic specific to klasses or oops can be executed.,
1283   enum MeetResult {
1284     QUICK,
1285     UNLOADED,
1286     SUBTYPE,
1287     NOT_SUBTYPE,
1288     LCA
1289   };
1290   template<class T> static TypePtr::MeetResult meet_instptr(PTR& ptr, const TypeInterfaces*& interfaces, const T* this_type,
1291                                                             const T* other_type, ciKlass*& res_klass, bool& res_xk);
1292  protected:
1293   static FlatInArray meet_flat_in_array(FlatInArray left, FlatInArray other);
1294 
1295   template<class T> static MeetResult meet_aryptr(PTR& ptr, const Type*& elem, const T* this_ary, const T* other_ary,
1296                                                   ciKlass*& res_klass, bool& res_xk, bool &res_flat, bool &res_not_flat, bool &res_not_null_free, bool &res_atomic);
1297 
1298   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);
1299   template <class T1, class T2> static bool is_same_java_type_as_helper_for_instance(const T1* this_one, const T2* other);
1300   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);
1301   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);
1302   template <class T1, class T2> static bool is_same_java_type_as_helper_for_array(const T1* this_one, const T2* other);
1303   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);
1304   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);
1305   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);
1306 public:
1307   const Offset _offset;         // Offset into oop, with TOP & BOT
1308   const PTR _ptr;               // Pointer equivalence class
1309   const relocInfo::relocType _reloc;
1310 
1311   int offset() const { return _offset.get(); }
1312   PTR ptr()    const { return _ptr; }
1313   relocInfo::relocType reloc() const { return _reloc; }
1314 
1315   static const TypePtr* make(TYPES t, PTR ptr, Offset offset,
1316                              const TypePtr* speculative = nullptr,
1317                              int inline_depth = InlineDepthBottom,
1318                              relocInfo::relocType reloc = relocInfo::none);
1319 
1320   // Return a 'ptr' version of this type
1321   virtual const TypePtr* cast_to_ptr_type(PTR ptr) const;
1322 
1323   virtual intptr_t get_con() const;
1324 
1325   Type::Offset xadd_offset(intptr_t offset) const;
1326   virtual const TypePtr* add_offset(intptr_t offset) const;
1327   virtual const TypePtr* with_offset(intptr_t offset) const;
1328   virtual int flat_offset() const { return offset(); }
1329   virtual bool eq(const Type *t) const;
1330   virtual uint hash() const;             // Type specific hashing
1331 
1332   virtual bool singleton(void) const;    // TRUE if type is a singleton
1333   virtual bool empty(void) const;        // TRUE if type is vacuous
1334   virtual const Type *xmeet( const Type *t ) const;
1335   virtual const Type *xmeet_helper( const Type *t ) const;
1336   Offset meet_offset(int offset) const;
1337   Offset dual_offset() const;
1338   virtual const Type *xdual() const;    // Compute dual right now.
1339 
1340   // meet, dual and join over pointer equivalence sets
1341   PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
1342   PTR dual_ptr()                   const { return ptr_dual[ptr()];      }
1343 
1344   // This is textually confusing unless one recalls that
1345   // join(t) == dual()->meet(t->dual())->dual().
1346   PTR join_ptr( const PTR in_ptr ) const {
1347     return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
1348   }
1349 
1350   // Speculative type helper methods.
1351   virtual const TypePtr* speculative() const { return _speculative; }
1352   int inline_depth() const                   { return _inline_depth; }
1353   virtual ciKlass* speculative_type() const;
1354   virtual ciKlass* speculative_type_not_null() const;
1355   virtual bool speculative_maybe_null() const;
1356   virtual bool speculative_always_null() const;
1357   virtual const TypePtr* remove_speculative() const;
1358   virtual const Type* cleanup_speculative() const;
1359   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1360   virtual bool would_improve_ptr(ProfilePtrKind maybe_null) const;
1361   virtual const TypePtr* with_inline_depth(int depth) const;
1362 
1363   virtual bool maybe_null() const { return meet_ptr(Null) == ptr(); }
1364 
1365   NOT_PRODUCT(static void dump_flat_in_array(FlatInArray flat_in_array, outputStream* st);)
1366 
1367   static FlatInArray compute_flat_in_array(ciInstanceKlass* instance_klass, bool is_exact);
1368 
1369   static FlatInArray compute_flat_in_array_if_unknown(ciInstanceKlass* instance_klass, bool is_exact,
1370                                                       FlatInArray old_flat_in_array);
1371 
1372   virtual bool can_be_inline_type() const { return false; }
1373   virtual bool is_flat_in_array()     const { return flat_in_array() == Flat; }
1374   virtual bool is_not_flat_in_array() const { return flat_in_array() == NotFlat; }
1375   virtual FlatInArray flat_in_array() const { return NotFlat; }
1376   virtual bool is_flat()            const { return false; }
1377   virtual bool is_not_flat()        const { return false; }
1378   virtual bool is_null_free()       const { return false; }
1379   virtual bool is_not_null_free()   const { return false; }
1380   virtual bool is_atomic()          const { return false; }
1381 
1382   // Tests for relation to centerline of type lattice:
1383   static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
1384   static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
1385   // Convenience common pre-built types.
1386   static const TypePtr *NULL_PTR;
1387   static const TypePtr *NOTNULL;
1388   static const TypePtr *BOTTOM;
1389 #ifndef PRODUCT
1390   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1391 #endif
1392 };
1393 
1394 //------------------------------TypeRawPtr-------------------------------------
1395 // Class of raw pointers, pointers to things other than Oops.  Examples
1396 // include the stack pointer, top of heap, card-marking area, handles, etc.
1397 class TypeRawPtr : public TypePtr {
1398 protected:
1399   TypeRawPtr(PTR ptr, address bits, relocInfo::relocType reloc) : TypePtr(RawPtr, ptr, Offset(0), reloc), _bits(bits){}
1400 public:
1401   virtual bool eq( const Type *t ) const;
1402   virtual uint hash() const;    // Type specific hashing
1403 
1404   const address _bits;          // Constant value, if applicable
1405 
1406   static const TypeRawPtr* make(PTR ptr);
1407   static const TypeRawPtr* make(address bits, relocInfo::relocType reloc = relocInfo::external_word_type);
1408 
1409   // Return a 'ptr' version of this type
1410   virtual const TypeRawPtr* cast_to_ptr_type(PTR ptr) const;
1411 
1412   virtual intptr_t get_con() const;
1413 
1414   virtual const TypePtr* add_offset(intptr_t offset) const;
1415   virtual const TypeRawPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr;}
1416 
1417   virtual const Type *xmeet( const Type *t ) const;
1418   virtual const Type *xdual() const;    // Compute dual right now.
1419   // Convenience common pre-built types.
1420   static const TypeRawPtr *BOTTOM;
1421   static const TypeRawPtr *NOTNULL;
1422 #ifndef PRODUCT
1423   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1424 #endif
1425 };
1426 
1427 //------------------------------TypeOopPtr-------------------------------------
1428 // Some kind of oop (Java pointer), either instance or array.
1429 class TypeOopPtr : public TypePtr {
1430   friend class TypeAry;
1431   friend class TypePtr;
1432   friend class TypeInstPtr;
1433   friend class TypeAryPtr;
1434 protected:
1435  TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, Offset offset, Offset field_offset, int instance_id,
1436             const TypePtr* speculative, int inline_depth);
1437 public:
1438   virtual bool eq( const Type *t ) const;
1439   virtual uint hash() const;             // Type specific hashing
1440   virtual bool singleton(void) const;    // TRUE if type is a singleton
1441   enum {
1442    InstanceTop = -1,   // undefined instance
1443    InstanceBot = 0     // any possible instance
1444   };
1445 protected:
1446 
1447   // Oop is null, unless this is a constant oop.
1448   ciObject*     _const_oop;   // Constant oop
1449   // If _klass is null, then so is _sig.  This is an unloaded klass.
1450   ciKlass*      _klass;       // Klass object
1451 
1452   const TypeInterfaces* _interfaces;
1453 
1454   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
1455   bool          _klass_is_exact;
1456   bool          _is_ptr_to_narrowoop;
1457   bool          _is_ptr_to_narrowklass;
1458   bool          _is_ptr_to_boxed_value;
1459   bool          _is_ptr_to_strict_final_field;
1460 
1461   // If not InstanceTop or InstanceBot, indicates that this is
1462   // a particular instance of this type which is distinct.
1463   // This is the node index of the allocation node creating this instance.
1464   int           _instance_id;
1465 
1466   static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact, InterfaceHandling interface_handling);
1467 
1468   int dual_instance_id() const;
1469   int meet_instance_id(int uid) const;
1470 
1471   const TypeInterfaces* meet_interfaces(const TypeOopPtr* other) const;
1472 
1473   // Do not allow interface-vs.-noninterface joins to collapse to top.
1474   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1475 
1476   virtual ciKlass* exact_klass_helper() const { return nullptr; }
1477   virtual ciKlass* klass() const { return _klass; }
1478 
1479 #ifndef PRODUCT
1480   void dump_instance_id(outputStream* st) const;
1481 #endif // PRODUCT
1482 
1483 public:
1484 
1485   bool is_java_subtype_of(const TypeOopPtr* other) const {
1486     return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1487   }
1488 
1489   bool is_same_java_type_as(const TypePtr* other) const {
1490     return is_same_java_type_as_helper(other->is_oopptr());
1491   }
1492 
1493   virtual bool is_same_java_type_as_helper(const TypeOopPtr* other) const {
1494     ShouldNotReachHere(); return false;
1495   }
1496 
1497   bool maybe_java_subtype_of(const TypeOopPtr* other) const {

1508     return make_from_klass_common(klass, true, false, interface_handling);
1509   }
1510   // Same as before, but will produce an exact type, even if
1511   // the klass is not final, as long as it has exactly one implementation.
1512   static const TypeOopPtr* make_from_klass_unique(ciKlass* klass, InterfaceHandling interface_handling= ignore_interfaces) {
1513     return make_from_klass_common(klass, true, true, interface_handling);
1514   }
1515   // Same as before, but does not respects UseUniqueSubclasses.
1516   // Use this only for creating array element types.
1517   static const TypeOopPtr* make_from_klass_raw(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1518     return make_from_klass_common(klass, false, false, interface_handling);
1519   }
1520   // Creates a singleton type given an object.
1521   // If the object cannot be rendered as a constant,
1522   // may return a non-singleton type.
1523   // If require_constant, produce a null if a singleton is not possible.
1524   static const TypeOopPtr* make_from_constant(ciObject* o,
1525                                               bool require_constant = false);
1526 
1527   // Make a generic (unclassed) pointer to an oop.
1528   static const TypeOopPtr* make(PTR ptr, Offset offset, int instance_id,
1529                                 const TypePtr* speculative = nullptr,
1530                                 int inline_depth = InlineDepthBottom);
1531 
1532   ciObject* const_oop()    const { return _const_oop; }
1533   // Exact klass, possibly an interface or an array of interface
1534   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k;  }
1535   ciKlass* unloaded_klass() const { assert(!is_loaded(), "only for unloaded types"); return klass(); }
1536 
1537   virtual bool  is_loaded() const { return klass()->is_loaded(); }
1538   virtual bool klass_is_exact()    const { return _klass_is_exact; }
1539 
1540   // Returns true if this pointer points at memory which contains a
1541   // compressed oop references.
1542   bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
1543   bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
1544   bool is_ptr_to_boxed_value()   const { return _is_ptr_to_boxed_value; }
1545   bool is_ptr_to_strict_final_field() const { return _is_ptr_to_strict_final_field; }
1546   bool is_known_instance()       const { return _instance_id > 0; }
1547   int  instance_id()             const { return _instance_id; }
1548   bool is_known_instance_field() const { return is_known_instance() && _offset.get() >= 0; }
1549 
1550   virtual bool can_be_inline_type() const { return (_klass == nullptr || _klass->can_be_inline_klass(_klass_is_exact)); }
1551   virtual bool can_be_inline_array() const { ShouldNotReachHere(); return false; }
1552 
1553   virtual intptr_t get_con() const;
1554 
1555   virtual const TypeOopPtr* cast_to_ptr_type(PTR ptr) const;
1556 
1557   virtual const TypeOopPtr* cast_to_exactness(bool klass_is_exact) const;
1558 
1559   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1560 
1561   // corresponding pointer to klass, for a given instance
1562   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1563 
1564   virtual const TypeOopPtr* with_offset(intptr_t offset) const;
1565   virtual const TypePtr* add_offset(intptr_t offset) const;
1566 
1567   // Speculative type helper methods.
1568   virtual const TypeOopPtr* remove_speculative() const;
1569   virtual const Type* cleanup_speculative() const;
1570   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1571   virtual const TypePtr* with_inline_depth(int depth) const;

1594     return _interfaces;
1595   };
1596 
1597   const TypeOopPtr* is_reference_type(const Type* other) const {
1598     return other->isa_oopptr();
1599   }
1600 
1601   const TypeAryPtr* is_array_type(const TypeOopPtr* other) const {
1602     return other->isa_aryptr();
1603   }
1604 
1605   const TypeInstPtr* is_instance_type(const TypeOopPtr* other) const {
1606     return other->isa_instptr();
1607   }
1608 };
1609 
1610 //------------------------------TypeInstPtr------------------------------------
1611 // Class of Java object pointers, pointing either to non-array Java instances
1612 // or to a Klass* (including array klasses).
1613 class TypeInstPtr : public TypeOopPtr {
1614   // Can this instance be in a flat array?
1615   FlatInArray _flat_in_array;
1616 
1617   TypeInstPtr(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, Offset offset,
1618               FlatInArray flat_in_array, int instance_id, const TypePtr* speculative,
1619               int inline_depth);
1620   virtual bool eq( const Type *t ) const;
1621   virtual uint hash() const;             // Type specific hashing

1622   ciKlass* exact_klass_helper() const;
1623 
1624 public:
1625 
1626   // Instance klass, ignoring any interface
1627   ciInstanceKlass* instance_klass() const {
1628     assert(!(klass()->is_loaded() && klass()->is_interface()), "");
1629     return klass()->as_instance_klass();
1630   }
1631 
1632   bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1633   bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1634   bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1635 
1636   // Make a pointer to a constant oop.
1637   static const TypeInstPtr *make(ciObject* o) {
1638     ciKlass* k = o->klass();
1639     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1640     return make(TypePtr::Constant, k, interfaces, true, o, Offset(0));
1641   }
1642   // Make a pointer to a constant oop with offset.
1643   static const TypeInstPtr *make(ciObject* o, Offset offset) {
1644     ciKlass* k = o->klass();
1645     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1646     return make(TypePtr::Constant, k, interfaces, true, o, offset);
1647   }
1648 
1649   // Make a pointer to some value of type klass.
1650   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1651     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, true, false, interface_handling);
1652     return make(ptr, klass, interfaces, false, nullptr, Offset(0));
1653   }
1654 
1655   // Make a pointer to some non-polymorphic value of exactly type klass.
1656   static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
1657     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1658     return make(ptr, klass, interfaces, true, nullptr, Offset(0));
1659   }
1660 
1661   // Make a pointer to some value of type klass with offset.
1662   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, Offset offset) {
1663     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1664     return make(ptr, klass, interfaces, false, nullptr, offset);
1665   }
1666 
1667   // Make a pointer to an oop.
1668   static const TypeInstPtr* make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, Offset offset,
1669                                  FlatInArray flat_in_array = Uninitialized,
1670                                  int instance_id = InstanceBot,
1671                                  const TypePtr* speculative = nullptr,
1672                                  int inline_depth = InlineDepthBottom);
1673 
1674   static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset offset, int instance_id = InstanceBot,
1675                                  FlatInArray flat_in_array = Uninitialized) {
1676     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1677     return make(ptr, k, interfaces, xk, o, offset, flat_in_array, instance_id);
1678   }
1679 
1680   // If this is a java.lang.Class constant, return the type for it or null.
1681   // Pass to Type::get_const_type to turn it to a type, which will usually
1682   // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
1683   ciType* java_mirror_type() const;
1684 
1685   virtual const TypeInstPtr* cast_to_ptr_type(PTR ptr) const;
1686 
1687   virtual const TypeInstPtr* cast_to_exactness(bool klass_is_exact) const;
1688 
1689   virtual const TypeInstPtr* cast_to_instance_id(int instance_id) const;
1690 
1691   virtual bool empty() const;
1692   virtual const TypePtr* add_offset(intptr_t offset) const;
1693   virtual const TypeInstPtr* with_offset(intptr_t offset) const;
1694 
1695   // Speculative type helper methods.
1696   virtual const TypeInstPtr* remove_speculative() const;
1697   const TypeInstPtr* with_speculative(const TypePtr* speculative) const;
1698   virtual const TypePtr* with_inline_depth(int depth) const;
1699   virtual const TypePtr* with_instance_id(int instance_id) const;
1700 
1701   virtual const TypeInstPtr* cast_to_flat_in_array() const;
1702   virtual const TypeInstPtr* cast_to_maybe_flat_in_array() const;
1703   virtual FlatInArray flat_in_array() const { return _flat_in_array; }
1704 
1705   FlatInArray dual_flat_in_array() const {
1706     return flat_in_array_dual[_flat_in_array];
1707   }
1708 
1709   // the core of the computation of the meet of 2 types
1710   virtual const Type *xmeet_helper(const Type *t) const;
1711   virtual const TypeInstPtr *xmeet_unloaded(const TypeInstPtr *tinst, const TypeInterfaces* interfaces) const;
1712   virtual const Type *xdual() const;    // Compute dual right now.
1713 
1714   const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1715 
1716   virtual bool can_be_inline_array() const;
1717 
1718   // Convenience common pre-built types.
1719   static const TypeInstPtr *NOTNULL;
1720   static const TypeInstPtr *BOTTOM;
1721   static const TypeInstPtr *MIRROR;
1722   static const TypeInstPtr *MARK;
1723   static const TypeInstPtr *KLASS;
1724 #ifndef PRODUCT
1725   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1726 #endif
1727 
1728 private:
1729   virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1730 
1731   virtual bool is_meet_same_type_as(const TypePtr* other) const {
1732     return _klass->equals(other->is_instptr()->_klass) && _interfaces->eq(other->is_instptr()->_interfaces);
1733   }
1734 
1735 };
1736 
1737 //------------------------------TypeAryPtr-------------------------------------
1738 // Class of Java array pointers
1739 class TypeAryPtr : public TypeOopPtr {
1740   friend class Type;
1741   friend class TypePtr;
1742   friend class TypeInstPtr;
1743   friend class TypeInterfaces;
1744 
1745   TypeAryPtr(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1746              Offset offset, Offset field_offset, int instance_id, bool is_autobox_cache,
1747              const TypePtr* speculative, int inline_depth)
1748     : TypeOopPtr(AryPtr, ptr, k, _array_interfaces, xk, o, offset, field_offset, instance_id, speculative, inline_depth),
1749     _ary(ary),
1750     _is_autobox_cache(is_autobox_cache),
1751     _field_offset(field_offset)
1752  {
1753     int dummy;
1754     bool top_or_bottom = (base_element_type(dummy) == Type::TOP || base_element_type(dummy) == Type::BOTTOM);
1755 
1756     if (UseCompressedOops && (elem()->make_oopptr() != nullptr && !top_or_bottom) &&
1757         _offset.get() != 0 && _offset.get() != arrayOopDesc::length_offset_in_bytes() &&
1758         _offset.get() != arrayOopDesc::klass_offset_in_bytes()) {
1759       _is_ptr_to_narrowoop = true;
1760     }
1761 
1762   }
1763   virtual bool eq( const Type *t ) const;
1764   virtual uint hash() const;    // Type specific hashing
1765   const TypeAry *_ary;          // Array we point into
1766   const bool     _is_autobox_cache;
1767   // For flat inline type arrays, each field of the inline type in
1768   // the array has its own memory slice so we need to keep track of
1769   // which field is accessed
1770   const Offset _field_offset;
1771   Offset meet_field_offset(const Type::Offset offset) const;
1772   Offset dual_field_offset() const;
1773 
1774   ciKlass* compute_klass() const;
1775 
1776   // A pointer to delay allocation to Type::Initialize_shared()
1777 
1778   static const TypeInterfaces* _array_interfaces;
1779   ciKlass* exact_klass_helper() const;
1780   // Only guaranteed non null for array of basic types
1781   ciKlass* klass() const;
1782 
1783 public:
1784 
1785   bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1786   bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1787   bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1788 
1789   // returns base element type, an instance klass (and not interface) for object arrays
1790   const Type* base_element_type(int& dims) const;
1791 
1792   // Accessors
1793   bool  is_loaded() const { return (_ary->_elem->make_oopptr() ? _ary->_elem->make_oopptr()->is_loaded() : true); }
1794 
1795   const TypeAry* ary() const  { return _ary; }
1796   const Type*    elem() const { return _ary->_elem; }
1797   const TypeInt* size() const { return _ary->_size; }
1798   bool      is_stable() const { return _ary->_stable; }
1799 
1800   // Inline type array properties
1801   bool is_flat()          const { return _ary->_flat; }
1802   bool is_not_flat()      const { return _ary->_not_flat; }
1803   bool is_null_free()     const { return _ary->_elem->make_ptr() != nullptr && (_ary->_elem->make_ptr()->ptr() == NotNull || _ary->_elem->make_ptr()->ptr() == AnyNull); }
1804   bool is_not_null_free() const { return _ary->_not_null_free; }
1805   bool is_atomic()        const { return _ary->_atomic; }
1806 
1807   bool is_autobox_cache() const { return _is_autobox_cache; }
1808 
1809   static const TypeAryPtr* make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1810                                 Offset field_offset = Offset::bottom,
1811                                 int instance_id = InstanceBot,
1812                                 const TypePtr* speculative = nullptr,
1813                                 int inline_depth = InlineDepthBottom);
1814   // Constant pointer to array
1815   static const TypeAryPtr* make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1816                                 Offset field_offset = Offset::bottom,
1817                                 int instance_id = InstanceBot,
1818                                 const TypePtr* speculative = nullptr,
1819                                 int inline_depth = InlineDepthBottom,
1820                                 bool is_autobox_cache = false);
1821 
1822   // Return a 'ptr' version of this type
1823   virtual const TypeAryPtr* cast_to_ptr_type(PTR ptr) const;
1824 
1825   virtual const TypeAryPtr* cast_to_exactness(bool klass_is_exact) const;
1826 
1827   virtual const TypeAryPtr* cast_to_instance_id(int instance_id) const;
1828 
1829   virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1830   virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1831 
1832   virtual bool empty(void) const;        // TRUE if type is vacuous
1833   virtual const TypePtr *add_offset( intptr_t offset ) const;
1834   virtual const TypeAryPtr *with_offset( intptr_t offset ) const;
1835   const TypeAryPtr* with_ary(const TypeAry* ary) const;
1836 
1837   // Speculative type helper methods.
1838   virtual const TypeAryPtr* remove_speculative() const;
1839   virtual const Type* cleanup_speculative() const;
1840   virtual const TypePtr* with_inline_depth(int depth) const;
1841   virtual const TypePtr* with_instance_id(int instance_id) const;
1842 
1843   // the core of the computation of the meet of 2 types
1844   virtual const Type *xmeet_helper(const Type *t) const;
1845   virtual const Type *xdual() const;    // Compute dual right now.
1846 
1847   // Inline type array properties
1848   const TypeAryPtr* cast_to_flat(bool flat) const;
1849   const TypeAryPtr* cast_to_not_flat(bool not_flat = true) const;
1850   const TypeAryPtr* cast_to_null_free(bool null_free) const;
1851   const TypeAryPtr* cast_to_not_null_free(bool not_null_free = true) const;
1852   const TypeAryPtr* update_properties(const TypeAryPtr* new_type) const;
1853   jint flat_layout_helper() const;
1854   int flat_elem_size() const;
1855   int flat_log_elem_size() const;
1856 
1857   const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1858   int stable_dimension() const;
1859 
1860   const TypeAryPtr* cast_to_autobox_cache() const;
1861 
1862   static jint max_array_length(BasicType etype);
1863 
1864   int flat_offset() const;
1865   const Offset field_offset() const { return _field_offset; }
1866   const TypeAryPtr* with_field_offset(int offset) const;
1867   const TypePtr* add_field_offset_and_offset(intptr_t offset) const;
1868 
1869   virtual bool can_be_inline_type() const { return false; }
1870   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1871 
1872   virtual bool can_be_inline_array() const;
1873 
1874   // Convenience common pre-built types.
1875   static const TypeAryPtr* BOTTOM;
1876   static const TypeAryPtr *RANGE;
1877   static const TypeAryPtr *OOPS;
1878   static const TypeAryPtr *NARROWOOPS;
1879   static const TypeAryPtr *BYTES;
1880   static const TypeAryPtr *SHORTS;
1881   static const TypeAryPtr *CHARS;
1882   static const TypeAryPtr *INTS;
1883   static const TypeAryPtr *LONGS;
1884   static const TypeAryPtr *FLOATS;
1885   static const TypeAryPtr *DOUBLES;
1886   static const TypeAryPtr *INLINES;
1887   // selects one of the above:
1888   static const TypeAryPtr *get_array_body_type(BasicType elem) {
1889     assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != nullptr, "bad elem type");
1890     return _array_body_type[elem];
1891   }
1892   static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1893   // sharpen the type of an int which is used as an array size
1894 #ifndef PRODUCT
1895   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1896 #endif
1897 private:
1898   virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1899 };
1900 
1901 //------------------------------TypeMetadataPtr-------------------------------------
1902 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
1903 class TypeMetadataPtr : public TypePtr {
1904 protected:
1905   TypeMetadataPtr(PTR ptr, ciMetadata* metadata, Offset offset);
1906   // Do not allow interface-vs.-noninterface joins to collapse to top.
1907   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1908 public:
1909   virtual bool eq( const Type *t ) const;
1910   virtual uint hash() const;             // Type specific hashing
1911   virtual bool singleton(void) const;    // TRUE if type is a singleton
1912 
1913 private:
1914   ciMetadata*   _metadata;
1915 
1916 public:
1917   static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, Offset offset);
1918 
1919   static const TypeMetadataPtr* make(ciMethod* m);
1920   static const TypeMetadataPtr* make(ciMethodData* m);
1921 
1922   ciMetadata* metadata() const { return _metadata; }
1923 
1924   virtual const TypeMetadataPtr* cast_to_ptr_type(PTR ptr) const;
1925 
1926   virtual const TypePtr *add_offset( intptr_t offset ) const;
1927 
1928   virtual const Type *xmeet( const Type *t ) const;
1929   virtual const Type *xdual() const;    // Compute dual right now.
1930 
1931   virtual intptr_t get_con() const;
1932 
1933   // Convenience common pre-built types.
1934   static const TypeMetadataPtr *BOTTOM;
1935 
1936 #ifndef PRODUCT
1937   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1938 #endif
1939 };
1940 
1941 //------------------------------TypeKlassPtr-----------------------------------
1942 // Class of Java Klass pointers
1943 class TypeKlassPtr : public TypePtr {
1944   friend class TypeInstKlassPtr;
1945   friend class TypeAryKlassPtr;
1946   friend class TypePtr;
1947 protected:
1948   TypeKlassPtr(TYPES t, PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, Offset offset);
1949 
1950   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1951 
1952 public:
1953   virtual bool eq( const Type *t ) const;
1954   virtual uint hash() const;
1955   virtual bool singleton(void) const;    // TRUE if type is a singleton
1956 
1957 protected:
1958 
1959   ciKlass* _klass;
1960   const TypeInterfaces* _interfaces;
1961   const TypeInterfaces* meet_interfaces(const TypeKlassPtr* other) const;
1962   virtual bool must_be_exact() const { ShouldNotReachHere(); return false; }
1963   virtual ciKlass* exact_klass_helper() const;
1964   virtual ciKlass* klass() const { return  _klass; }
1965 
1966 public:
1967 
1968   bool is_java_subtype_of(const TypeKlassPtr* other) const {
1969     return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1970   }
1971   bool is_same_java_type_as(const TypePtr* other) const {
1972     return is_same_java_type_as_helper(other->is_klassptr());
1973   }
1974 
1975   bool maybe_java_subtype_of(const TypeKlassPtr* other) const {
1976     return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1977   }
1978   virtual bool is_same_java_type_as_helper(const TypeKlassPtr* other) const { ShouldNotReachHere(); return false; }
1979   virtual bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1980   virtual bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1981 
1982   // Exact klass, possibly an interface or an array of interface
1983   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k;  }
1984   virtual bool klass_is_exact()    const { return _ptr == Constant; }
1985 
1986   static const TypeKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces);

1987 
1988   virtual bool  is_loaded() const { return _klass->is_loaded(); }
1989 
1990   virtual const TypeKlassPtr* cast_to_ptr_type(PTR ptr) const { ShouldNotReachHere(); return nullptr; }
1991 
1992   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const { ShouldNotReachHere(); return nullptr; }
1993 
1994   // corresponding pointer to instance, for a given class
1995   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const { ShouldNotReachHere(); return nullptr; }
1996 
1997   virtual const TypePtr *add_offset( intptr_t offset ) const { ShouldNotReachHere(); return nullptr; }
1998   virtual const Type    *xmeet( const Type *t ) const { ShouldNotReachHere(); return nullptr; }
1999   virtual const Type    *xdual() const { ShouldNotReachHere(); return nullptr; }
2000 
2001   virtual intptr_t get_con() const;
2002 
2003   virtual const TypeKlassPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr; }
2004 
2005   virtual bool can_be_inline_array() const { ShouldNotReachHere(); return false; }
2006 
2007   virtual const TypeKlassPtr* try_improve() const { return this; }
2008 
2009 private:
2010   virtual bool is_meet_subtype_of(const TypePtr* other) const {
2011     return is_meet_subtype_of_helper(other->is_klassptr(), klass_is_exact(), other->is_klassptr()->klass_is_exact());
2012   }
2013 
2014   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const {
2015     ShouldNotReachHere(); return false;
2016   }
2017 
2018   virtual const TypeInterfaces* interfaces() const {
2019     return _interfaces;
2020   };
2021 
2022   const TypeKlassPtr* is_reference_type(const Type* other) const {
2023     return other->isa_klassptr();
2024   }
2025 
2026   const TypeAryKlassPtr* is_array_type(const TypeKlassPtr* other) const {
2027     return other->isa_aryklassptr();
2028   }
2029 
2030   const TypeInstKlassPtr* is_instance_type(const TypeKlassPtr* other) const {
2031     return other->isa_instklassptr();
2032   }
2033 };
2034 
2035 // Instance klass pointer, mirrors TypeInstPtr
2036 class TypeInstKlassPtr : public TypeKlassPtr {
2037   // Can an instance of this class be in a flat array?
2038   const FlatInArray _flat_in_array;
2039 
2040   TypeInstKlassPtr(PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, Offset offset, FlatInArray flat_in_array)
2041     : TypeKlassPtr(InstKlassPtr, ptr, klass, interfaces, offset), _flat_in_array(flat_in_array) {
2042     assert(flat_in_array != Uninitialized, "must be set now");
2043     assert(klass->is_instance_klass() && (!klass->is_loaded() || !klass->is_interface()), "");
2044   }
2045 
2046   virtual bool must_be_exact() const;
2047 
2048 public:
2049   // Instance klass ignoring any interface
2050   ciInstanceKlass* instance_klass() const {
2051     assert(!klass()->is_interface(), "");
2052     return klass()->as_instance_klass();
2053   }
2054 
2055   bool might_be_an_array() const;
2056 
2057   bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
2058   bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
2059   bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
2060 
2061   virtual bool can_be_inline_type() const { return (_klass == nullptr || _klass->can_be_inline_klass(klass_is_exact())); }
2062 
2063   static const TypeInstKlassPtr *make(ciKlass* k, InterfaceHandling interface_handling) {
2064     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, true, false, interface_handling);
2065     return make(TypePtr::Constant, k, interfaces, Offset(0));
2066   }

2067 
2068   static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, Offset offset,
2069                                       FlatInArray flat_in_array = Uninitialized);
2070 
2071   static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, Offset offset, FlatInArray flat_in_array = Uninitialized) {
2072     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
2073     return make(ptr, k, interfaces, offset, flat_in_array);
2074   }
2075 
2076   virtual const TypeInstKlassPtr* cast_to_ptr_type(PTR ptr) const;
2077 
2078   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
2079 
2080   // corresponding pointer to instance, for a given class
2081   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
2082   virtual uint hash() const;
2083   virtual bool eq(const Type *t) const;
2084 
2085 
2086   virtual bool empty() const;
2087   virtual const TypePtr *add_offset( intptr_t offset ) const;
2088   virtual const Type    *xmeet( const Type *t ) const;
2089   virtual const Type    *xdual() const;
2090   virtual const TypeInstKlassPtr* with_offset(intptr_t offset) const;
2091 
2092   virtual const TypeKlassPtr* try_improve() const;
2093 
2094   virtual FlatInArray flat_in_array() const { return _flat_in_array; }
2095 
2096   FlatInArray dual_flat_in_array() const {
2097     return flat_in_array_dual[_flat_in_array];
2098   }
2099 
2100   virtual bool can_be_inline_array() const;
2101 
2102   // Convenience common pre-built types.
2103   static const TypeInstKlassPtr* OBJECT; // Not-null object klass or below
2104   static const TypeInstKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
2105 
2106 #ifndef PRODUCT
2107   virtual void dump2(Dict& d, uint depth, outputStream* st) const;
2108 #endif // PRODUCT
2109 
2110 private:
2111   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
2112 };
2113 
2114 // Array klass pointer, mirrors TypeAryPtr
2115 class TypeAryKlassPtr : public TypeKlassPtr {
2116   friend class TypeInstKlassPtr;
2117   friend class Type;
2118   friend class TypePtr;
2119 
2120   const Type *_elem;
2121   const bool _not_flat;      // Array is never flat
2122   const bool _not_null_free; // Array is never null-free
2123   const bool _flat;
2124   const bool _null_free;
2125   const bool _atomic;
2126   const bool _refined_type;
2127 
2128   static const TypeInterfaces* _array_interfaces;
2129   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 refined_type)
2130     : 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), _refined_type(refined_type) {
2131     assert(klass == nullptr || klass->is_type_array_klass() || klass->is_flat_array_klass() || !klass->as_obj_array_klass()->base_element_klass()->is_interface(), "");
2132   }
2133 
2134   virtual ciKlass* exact_klass_helper() const;
2135   // Only guaranteed non null for array of basic types
2136   virtual ciKlass* klass() const;
2137 
2138   virtual bool must_be_exact() const;
2139 
2140   bool dual_flat() const {
2141     return _flat;
2142   }
2143 
2144   bool meet_flat(bool other) const {
2145     return _flat && other;
2146   }
2147 
2148   bool dual_null_free() const {
2149     return _null_free;
2150   }
2151 
2152   bool meet_null_free(bool other) const {
2153     return _null_free && other;
2154   }
2155 
2156   bool dual_atomic() const {
2157     return _atomic;
2158   }
2159 
2160   bool meet_atomic(bool other) const {
2161     return _atomic && other;
2162   }
2163 
2164 public:
2165 
2166   // returns base element type, an instance klass (and not interface) for object arrays
2167   const Type* base_element_type(int& dims) const;
2168 
2169   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 refined_type);
2170 
2171   bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
2172   bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
2173   bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
2174 
2175   bool  is_loaded() const { return (_elem->isa_klassptr() ? _elem->is_klassptr()->is_loaded() : true); }
2176 
2177   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 refined_type);
2178   static const TypeAryKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling);
2179 
2180   const TypeAryKlassPtr* cast_to_non_refined() const;
2181   const TypeAryKlassPtr* cast_to_refined_array_klass_ptr(bool refined = true) const;
2182 
2183   const Type *elem() const { return _elem; }
2184 
2185   virtual bool eq(const Type *t) const;
2186   virtual uint hash() const;             // Type specific hashing
2187 
2188   virtual const TypeAryKlassPtr* cast_to_ptr_type(PTR ptr) const;
2189 
2190   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
2191 
2192   // corresponding pointer to instance, for a given class
2193   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
2194 
2195   virtual const TypePtr *add_offset( intptr_t offset ) const;
2196   virtual const Type    *xmeet( const Type *t ) const;
2197   virtual const Type    *xdual() const;      // Compute dual right now.
2198 
2199   virtual const TypeAryKlassPtr* with_offset(intptr_t offset) const;
2200 
2201   virtual bool empty(void) const {
2202     return TypeKlassPtr::empty() || _elem->empty();
2203   }
2204 
2205   bool is_flat()          const { return _flat; }
2206   bool is_not_flat()      const { return _not_flat; }
2207   bool is_null_free()     const { return _null_free; }
2208   bool is_not_null_free() const { return _not_null_free; }
2209   bool is_atomic()        const { return _atomic; }
2210   bool is_refined_type()  const { return _refined_type; }
2211   virtual bool can_be_inline_array() const;
2212 
2213 #ifndef PRODUCT
2214   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
2215 #endif
2216 private:
2217   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
2218 };
2219 
2220 class TypeNarrowPtr : public Type {
2221 protected:
2222   const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
2223 
2224   TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): Type(t),
2225                                                   _ptrtype(ptrtype) {
2226     assert(ptrtype->offset() == 0 ||
2227            ptrtype->offset() == OffsetBot ||
2228            ptrtype->offset() == OffsetTop, "no real offsets");
2229   }
2230 
2231   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
2232   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;

2328   }
2329 
2330   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
2331     return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
2332   }
2333 
2334 public:
2335   static const TypeNarrowKlass *make( const TypePtr* type);
2336 
2337   // static const TypeNarrowKlass *BOTTOM;
2338   static const TypeNarrowKlass *NULL_PTR;
2339 
2340 #ifndef PRODUCT
2341   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
2342 #endif
2343 };
2344 
2345 //------------------------------TypeFunc---------------------------------------
2346 // Class of Array Types
2347 class TypeFunc : public Type {
2348   TypeFunc(const TypeTuple *domain_sig, const TypeTuple* domain_cc, const TypeTuple* range_sig, const TypeTuple* range_cc, bool scalarized_return)
2349     : Type(Function), _domain_sig(domain_sig), _domain_cc(domain_cc), _range_sig(range_sig), _range_cc(range_cc), _scalarized_return(scalarized_return) {}
2350   virtual bool eq( const Type *t ) const;
2351   virtual uint hash() const;             // Type specific hashing
2352   virtual bool singleton(void) const;    // TRUE if type is a singleton
2353   virtual bool empty(void) const;        // TRUE if type is vacuous
2354 
2355   // Domains of inputs: inline type arguments are not passed by
2356   // reference, instead each field of the inline type is passed as an
2357   // argument. We maintain 2 views of the argument list here: one
2358   // based on the signature (with an inline type argument as a single
2359   // slot), one based on the actual calling convention (with a value
2360   // type argument as a list of its fields).
2361   const TypeTuple* const _domain_sig;
2362   const TypeTuple* const _domain_cc;
2363   // Range of results. Similar to domains: an inline type result can be
2364   // returned in registers in which case range_cc lists all fields and
2365   // is the actual calling convention.
2366   const TypeTuple* const _range_sig;
2367   const TypeTuple* const _range_cc;
2368   const bool _scalarized_return;
2369 
2370 public:
2371   // Constants are shared among ADLC and VM
2372   enum { Control    = AdlcVMDeps::Control,
2373          I_O        = AdlcVMDeps::I_O,
2374          Memory     = AdlcVMDeps::Memory,
2375          FramePtr   = AdlcVMDeps::FramePtr,
2376          ReturnAdr  = AdlcVMDeps::ReturnAdr,
2377          Parms      = AdlcVMDeps::Parms
2378   };
2379 
2380 
2381   // Accessors:
2382   const TypeTuple* domain_sig() const { return _domain_sig; }
2383   const TypeTuple* domain_cc()  const { return _domain_cc; }
2384   const TypeTuple* range_sig()  const { return _range_sig; }
2385   const TypeTuple* range_cc()   const { return _range_cc; }
2386   bool scalarized_return()      const { return _scalarized_return; }
2387 
2388   static const TypeFunc* make(ciMethod* method, bool is_call = true, bool is_osr_compilation = false);
2389   static const TypeFunc *make(const TypeTuple* domain_sig, const TypeTuple* domain_cc,
2390                               const TypeTuple* range_sig, const TypeTuple* range_cc,
2391                               bool scalarized_return = false);
2392   static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
2393 
2394   virtual const Type *xmeet( const Type *t ) const;
2395   virtual const Type *xdual() const;    // Compute dual right now.
2396 
2397   BasicType return_type() const;
2398 
2399   bool returns_inline_type_as_fields() const {
2400     // First condition is not sufficient because returned value class can be empty
2401     assert(_range_sig == _range_cc || _scalarized_return, "Only possible with scalarized return");
2402     return _scalarized_return;
2403   }
2404 
2405 #ifndef PRODUCT
2406   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
2407 #endif
2408   // Convenience common pre-built types.
2409 };
2410 
2411 //------------------------------accessors--------------------------------------
2412 inline bool Type::is_ptr_to_narrowoop() const {
2413 #ifdef _LP64
2414   return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowoop_nv());
2415 #else
2416   return false;
2417 #endif
2418 }
2419 
2420 inline bool Type::is_ptr_to_narrowklass() const {
2421 #ifdef _LP64
2422   return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowklass_nv());
2423 #else
2424   return false;

2661 }
2662 
2663 inline const TypeNarrowOop* Type::make_narrowoop() const {
2664   return (_base == NarrowOop) ? is_narrowoop() :
2665                                 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : nullptr);
2666 }
2667 
2668 inline const TypeNarrowKlass* Type::make_narrowklass() const {
2669   return (_base == NarrowKlass) ? is_narrowklass() :
2670                                   (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : nullptr);
2671 }
2672 
2673 inline bool Type::is_floatingpoint() const {
2674   if( (_base == HalfFloatCon)  || (_base == HalfFloatBot) ||
2675       (_base == FloatCon)  || (_base == FloatBot) ||
2676       (_base == DoubleCon) || (_base == DoubleBot) )
2677     return true;
2678   return false;
2679 }
2680 
2681 inline bool Type::is_inlinetypeptr() const {
2682   return isa_instptr() != nullptr && is_instptr()->instance_klass()->is_inlinetype();
2683 }
2684 
2685 inline ciInlineKlass* Type::inline_klass() const {
2686   return make_ptr()->is_instptr()->instance_klass()->as_inline_klass();
2687 }
2688 
2689 template <>
2690 inline const TypeInt* Type::cast<TypeInt>() const {
2691   return is_int();
2692 }
2693 
2694 template <>
2695 inline const TypeLong* Type::cast<TypeLong>() const {
2696   return is_long();
2697 }
2698 
2699 template <>
2700 inline const TypeInt* Type::try_cast<TypeInt>() const {
2701   return isa_int();
2702 }
2703 
2704 template <>
2705 inline const TypeLong* Type::try_cast<TypeLong>() const {
2706   return isa_long();
2707 }
2708 

2714 
2715 // For type queries and asserts
2716 #define is_intptr_t  is_long
2717 #define isa_intptr_t isa_long
2718 #define find_intptr_t_type find_long_type
2719 #define find_intptr_t_con  find_long_con
2720 #define TypeX        TypeLong
2721 #define Type_X       Type::Long
2722 #define TypeX_X      TypeLong::LONG
2723 #define TypeX_ZERO   TypeLong::ZERO
2724 // For 'ideal_reg' machine registers
2725 #define Op_RegX      Op_RegL
2726 // For phase->intcon variants
2727 #define MakeConX     longcon
2728 #define ConXNode     ConLNode
2729 // For array index arithmetic
2730 #define MulXNode     MulLNode
2731 #define AndXNode     AndLNode
2732 #define OrXNode      OrLNode
2733 #define CmpXNode     CmpLNode
2734 #define CmpUXNode    CmpULNode
2735 #define SubXNode     SubLNode
2736 #define LShiftXNode  LShiftLNode
2737 // For object size computation:
2738 #define AddXNode     AddLNode
2739 #define RShiftXNode  RShiftLNode
2740 // For card marks and hashcodes
2741 #define URShiftXNode URShiftLNode
2742 // For shenandoahSupport
2743 #define LoadXNode    LoadLNode
2744 #define StoreXNode   StoreLNode
2745 // Opcodes
2746 #define Op_LShiftX   Op_LShiftL
2747 #define Op_AndX      Op_AndL
2748 #define Op_AddX      Op_AddL
2749 #define Op_SubX      Op_SubL
2750 #define Op_XorX      Op_XorL
2751 #define Op_URShiftX  Op_URShiftL
2752 #define Op_LoadX     Op_LoadL
2753 #define Op_StoreX    Op_StoreL
2754 // conversions
2755 #define ConvI2X(x)   ConvI2L(x)
2756 #define ConvL2X(x)   (x)
2757 #define ConvX2I(x)   ConvL2I(x)
2758 #define ConvX2L(x)   (x)
2759 #define ConvX2UL(x)  (x)
2760 
2761 #else
2762 
2763 // For type queries and asserts
2764 #define is_intptr_t  is_int
2765 #define isa_intptr_t isa_int
2766 #define find_intptr_t_type find_int_type
2767 #define find_intptr_t_con  find_int_con
2768 #define TypeX        TypeInt
2769 #define Type_X       Type::Int
2770 #define TypeX_X      TypeInt::INT
2771 #define TypeX_ZERO   TypeInt::ZERO
2772 // For 'ideal_reg' machine registers
2773 #define Op_RegX      Op_RegI
2774 // For phase->intcon variants
2775 #define MakeConX     intcon
2776 #define ConXNode     ConINode
2777 // For array index arithmetic
2778 #define MulXNode     MulINode
2779 #define AndXNode     AndINode
2780 #define OrXNode      OrINode
2781 #define CmpXNode     CmpINode
2782 #define CmpUXNode    CmpUNode
2783 #define SubXNode     SubINode
2784 #define LShiftXNode  LShiftINode
2785 // For object size computation:
2786 #define AddXNode     AddINode
2787 #define RShiftXNode  RShiftINode
2788 // For card marks and hashcodes
2789 #define URShiftXNode URShiftINode
2790 // For shenandoahSupport
2791 #define LoadXNode    LoadINode
2792 #define StoreXNode   StoreINode
2793 // Opcodes
2794 #define Op_LShiftX   Op_LShiftI
2795 #define Op_AndX      Op_AndI
2796 #define Op_AddX      Op_AddI
2797 #define Op_SubX      Op_SubI
2798 #define Op_XorX      Op_XorI
2799 #define Op_URShiftX  Op_URShiftI
2800 #define Op_LoadX     Op_LoadI
2801 #define Op_StoreX    Op_StoreI
2802 // conversions
2803 #define ConvI2X(x)   (x)
2804 #define ConvL2X(x)   ConvL2I(x)
2805 #define ConvX2I(x)   (x)
2806 #define ConvX2L(x)   ConvI2L(x)
2807 #define ConvX2UL(x)  ConvI2UL(x)
2808 
2809 #endif
2810 
2811 #endif // SHARE_OPTO_TYPE_HPP
< prev index next >