< prev index next >

src/hotspot/share/opto/type.hpp

Print this page

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

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

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

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
























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

 309   const TypeNarrowKlass *isa_narrowklass() const;// Returns null if not oop ptr type
 310   const TypeOopPtr   *isa_oopptr() const;        // Returns null if not oop ptr type
 311   const TypeOopPtr   *is_oopptr() const;         // Java-style GC'd pointer
 312   const TypeInstPtr  *isa_instptr() const;       // Returns null if not InstPtr
 313   const TypeInstPtr  *is_instptr() const;        // Instance
 314   const TypeAryPtr   *isa_aryptr() const;        // Returns null if not AryPtr
 315   const TypeAryPtr   *is_aryptr() const;         // Array oop
 316 
 317   const TypeMetadataPtr   *isa_metadataptr() const;   // Returns null if not oop ptr type
 318   const TypeMetadataPtr   *is_metadataptr() const;    // Java-style GC'd pointer
 319   const TypeKlassPtr      *isa_klassptr() const;      // Returns null if not KlassPtr
 320   const TypeKlassPtr      *is_klassptr() const;       // assert if not KlassPtr
 321   const TypeInstKlassPtr  *isa_instklassptr() const;  // Returns null if not IntKlassPtr
 322   const TypeInstKlassPtr  *is_instklassptr() const;   // assert if not IntKlassPtr
 323   const TypeAryKlassPtr   *isa_aryklassptr() const;   // Returns null if not AryKlassPtr
 324   const TypeAryKlassPtr   *is_aryklassptr() const;    // assert if not AryKlassPtr
 325 
 326   virtual bool      is_finite() const;           // Has a finite value
 327   virtual bool      is_nan()    const;           // Is not a number (NaN)
 328 



 329   // Returns this ptr type or the equivalent ptr type for this compressed pointer.
 330   const TypePtr* make_ptr() const;
 331 
 332   // Returns this oopptr type or the equivalent oopptr type for this compressed pointer.
 333   // Asserts if the underlying type is not an oopptr or narrowoop.
 334   const TypeOopPtr* make_oopptr() const;
 335 
 336   // Returns this compressed pointer or the equivalent compressed version
 337   // of this pointer type.
 338   const TypeNarrowOop* make_narrowoop() const;
 339 
 340   // Returns this compressed klass pointer or the equivalent
 341   // compressed version of this pointer type.
 342   const TypeNarrowKlass* make_narrowklass() const;
 343 
 344   // Special test for register pressure heuristic
 345   bool is_floatingpoint() const;        // True if Float or Double base type
 346 
 347   // Do you have memory, directly or through a tuple?
 348   bool has_memory( ) const;

 707   const Type ** const _fields;           // Array of field types
 708 
 709 public:
 710   virtual bool eq( const Type *t ) const;
 711   virtual uint hash() const;             // Type specific hashing
 712   virtual bool singleton(void) const;    // TRUE if type is a singleton
 713   virtual bool empty(void) const;        // TRUE if type is vacuous
 714 
 715   // Accessors:
 716   uint cnt() const { return _cnt; }
 717   const Type* field_at(uint i) const {
 718     assert(i < _cnt, "oob");
 719     return _fields[i];
 720   }
 721   void set_field_at(uint i, const Type* t) {
 722     assert(i < _cnt, "oob");
 723     _fields[i] = t;
 724   }
 725 
 726   static const TypeTuple *make( uint cnt, const Type **fields );
 727   static const TypeTuple *make_range(ciSignature *sig, InterfaceHandling interface_handling = ignore_interfaces);
 728   static const TypeTuple *make_domain(ciInstanceKlass* recv, ciSignature *sig, InterfaceHandling interface_handling);
 729 
 730   // Subroutine call type with space allocated for argument types
 731   // Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly
 732   static const Type **fields( uint arg_cnt );
 733 
 734   virtual const Type *xmeet( const Type *t ) const;
 735   virtual const Type *xdual() const;    // Compute dual right now.
 736   // Convenience common pre-built types.
 737   static const TypeTuple *IFBOTH;
 738   static const TypeTuple *IFFALSE;
 739   static const TypeTuple *IFTRUE;
 740   static const TypeTuple *IFNEITHER;
 741   static const TypeTuple *LOOPBODY;
 742   static const TypeTuple *MEMBAR;
 743   static const TypeTuple *STORECONDITIONAL;
 744   static const TypeTuple *START_I2C;
 745   static const TypeTuple *INT_PAIR;
 746   static const TypeTuple *LONG_PAIR;
 747   static const TypeTuple *INT_CC_PAIR;
 748   static const TypeTuple *LONG_CC_PAIR;
 749 #ifndef PRODUCT
 750   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 751 #endif
 752 };
 753 
 754 //------------------------------TypeAry----------------------------------------
 755 // Class of Array Types
 756 class TypeAry : public Type {
 757   TypeAry(const Type* elem, const TypeInt* size, bool stable) : Type(Array),
 758       _elem(elem), _size(size), _stable(stable) {}
 759 public:
 760   virtual bool eq( const Type *t ) const;
 761   virtual uint hash() const;             // Type specific hashing
 762   virtual bool singleton(void) const;    // TRUE if type is a singleton
 763   virtual bool empty(void) const;        // TRUE if type is vacuous
 764 
 765 private:
 766   const Type *_elem;            // Element type of array
 767   const TypeInt *_size;         // Elements in array
 768   const bool _stable;           // Are elements @Stable?






 769   friend class TypeAryPtr;
 770 
 771 public:
 772   static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false);

 773 
 774   virtual const Type *xmeet( const Type *t ) const;
 775   virtual const Type *xdual() const;    // Compute dual right now.
 776   bool ary_must_be_exact() const;  // true if arrays of such are never generic
 777   virtual const TypeAry* remove_speculative() const;
 778   virtual const Type* cleanup_speculative() const;
 779 #ifndef PRODUCT
 780   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 781 #endif
 782 };
 783 
 784 //------------------------------TypeVect---------------------------------------
 785 // Class of Vector Types
 786 class TypeVect : public Type {
 787   const BasicType _elem_bt;  // Vector's element type
 788   const uint _length;  // Elements in vector (power of 2)
 789 
 790 protected:
 791   TypeVect(TYPES t, BasicType elem_bt, uint length) : Type(t),
 792     _elem_bt(elem_bt), _length(length) {}

 898 
 899   const Type* xmeet(const Type* t) const;
 900 
 901   bool singleton(void) const;
 902 };
 903 
 904 //------------------------------TypePtr----------------------------------------
 905 // Class of machine Pointer Types: raw data, instances or arrays.
 906 // If the _base enum is AnyPtr, then this refers to all of the above.
 907 // Otherwise the _base will indicate which subset of pointers is affected,
 908 // and the class will be inherited from.
 909 class TypePtr : public Type {
 910   friend class TypeNarrowPtr;
 911   friend class Type;
 912 protected:
 913   static const TypeInterfaces* interfaces(ciKlass*& k, bool klass, bool interface, bool array, InterfaceHandling interface_handling);
 914 
 915 public:
 916   enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
 917 protected:
 918   TypePtr(TYPES t, PTR ptr, int offset,
 919           const TypePtr* speculative = nullptr,
 920           int inline_depth = InlineDepthBottom) :
 921     Type(t), _speculative(speculative), _inline_depth(inline_depth), _offset(offset),
 922     _ptr(ptr) {}
 923   static const PTR ptr_meet[lastPTR][lastPTR];
 924   static const PTR ptr_dual[lastPTR];
 925   static const char * const ptr_msg[lastPTR];
 926 
 927   enum {
 928     InlineDepthBottom = INT_MAX,
 929     InlineDepthTop = -InlineDepthBottom
 930   };
 931 
 932   // Extra type information profiling gave us. We propagate it the
 933   // same way the rest of the type info is propagated. If we want to
 934   // use it, then we have to emit a guard: this part of the type is
 935   // not something we know but something we speculate about the type.
 936   const TypePtr*   _speculative;
 937   // For speculative types, we record at what inlining depth the
 938   // profiling point that provided the data is. We want to favor

 954   // utility methods to work on the inline depth of the type
 955   int dual_inline_depth() const;
 956   int meet_inline_depth(int depth) const;
 957 #ifndef PRODUCT
 958   void dump_inline_depth(outputStream *st) const;
 959 #endif
 960 
 961   // TypeInstPtr (TypeAryPtr resp.) and TypeInstKlassPtr (TypeAryKlassPtr resp.) implement very similar meet logic.
 962   // The logic for meeting 2 instances (2 arrays resp.) is shared in the 2 utility methods below. However the logic for
 963   // the oop and klass versions can be slightly different and extra logic may have to be executed depending on what
 964   // exact case the meet falls into. The MeetResult struct is used by the utility methods to communicate what case was
 965   // encountered so the right logic specific to klasses or oops can be executed.,
 966   enum MeetResult {
 967     QUICK,
 968     UNLOADED,
 969     SUBTYPE,
 970     NOT_SUBTYPE,
 971     LCA
 972   };
 973   template<class T> static TypePtr::MeetResult meet_instptr(PTR& ptr, const TypeInterfaces*& interfaces, const T* this_type,
 974                                                             const T* other_type, ciKlass*& res_klass, bool& res_xk);



 975 
 976   template<class T> static MeetResult meet_aryptr(PTR& ptr, const Type*& elem, const T* this_ary, const T* other_ary,
 977                                                   ciKlass*& res_klass, bool& res_xk);
 978 
 979   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);
 980   template <class T1, class T2> static bool is_same_java_type_as_helper_for_instance(const T1* this_one, const T2* other);
 981   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);
 982   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);
 983   template <class T1, class T2> static bool is_same_java_type_as_helper_for_array(const T1* this_one, const T2* other);
 984   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);
 985   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);
 986   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);
 987 public:
 988   const int _offset;            // Offset into oop, with TOP & BOT
 989   const PTR _ptr;               // Pointer equivalence class
 990 
 991   int offset() const { return _offset; }
 992   PTR ptr()    const { return _ptr; }
 993 
 994   static const TypePtr *make(TYPES t, PTR ptr, int offset,
 995                              const TypePtr* speculative = nullptr,
 996                              int inline_depth = InlineDepthBottom);
 997 
 998   // Return a 'ptr' version of this type
 999   virtual const TypePtr* cast_to_ptr_type(PTR ptr) const;
1000 
1001   virtual intptr_t get_con() const;
1002 
1003   int xadd_offset( intptr_t offset ) const;
1004   virtual const TypePtr* add_offset(intptr_t offset) const;
1005   virtual const TypePtr* with_offset(intptr_t offset) const;

1006   virtual bool eq(const Type *t) const;
1007   virtual uint hash() const;             // Type specific hashing
1008 
1009   virtual bool singleton(void) const;    // TRUE if type is a singleton
1010   virtual bool empty(void) const;        // TRUE if type is vacuous
1011   virtual const Type *xmeet( const Type *t ) const;
1012   virtual const Type *xmeet_helper( const Type *t ) const;
1013   int meet_offset( int offset ) const;
1014   int dual_offset( ) const;
1015   virtual const Type *xdual() const;    // Compute dual right now.
1016 
1017   // meet, dual and join over pointer equivalence sets
1018   PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
1019   PTR dual_ptr()                   const { return ptr_dual[ptr()];      }
1020 
1021   // This is textually confusing unless one recalls that
1022   // join(t) == dual()->meet(t->dual())->dual().
1023   PTR join_ptr( const PTR in_ptr ) const {
1024     return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
1025   }
1026 
1027   // Speculative type helper methods.
1028   virtual const TypePtr* speculative() const { return _speculative; }
1029   int inline_depth() const                   { return _inline_depth; }
1030   virtual ciKlass* speculative_type() const;
1031   virtual ciKlass* speculative_type_not_null() const;
1032   virtual bool speculative_maybe_null() const;
1033   virtual bool speculative_always_null() const;
1034   virtual const TypePtr* remove_speculative() const;
1035   virtual const Type* cleanup_speculative() const;
1036   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1037   virtual bool would_improve_ptr(ProfilePtrKind maybe_null) const;
1038   virtual const TypePtr* with_inline_depth(int depth) const;
1039 
1040   virtual bool maybe_null() const { return meet_ptr(Null) == ptr(); }
1041 








1042   // Tests for relation to centerline of type lattice:
1043   static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
1044   static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
1045   // Convenience common pre-built types.
1046   static const TypePtr *NULL_PTR;
1047   static const TypePtr *NOTNULL;
1048   static const TypePtr *BOTTOM;
1049 #ifndef PRODUCT
1050   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1051 #endif
1052 };
1053 
1054 //------------------------------TypeRawPtr-------------------------------------
1055 // Class of raw pointers, pointers to things other than Oops.  Examples
1056 // include the stack pointer, top of heap, card-marking area, handles, etc.
1057 class TypeRawPtr : public TypePtr {
1058 protected:
1059   TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){}
1060 public:
1061   virtual bool eq( const Type *t ) const;
1062   virtual uint hash() const;    // Type specific hashing
1063 
1064   const address _bits;          // Constant value, if applicable
1065 
1066   static const TypeRawPtr *make( PTR ptr );
1067   static const TypeRawPtr *make( address bits );
1068 
1069   // Return a 'ptr' version of this type
1070   virtual const TypeRawPtr* cast_to_ptr_type(PTR ptr) const;
1071 
1072   virtual intptr_t get_con() const;
1073 
1074   virtual const TypePtr* add_offset(intptr_t offset) const;
1075   virtual const TypeRawPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr;}
1076 
1077   virtual const Type *xmeet( const Type *t ) const;
1078   virtual const Type *xdual() const;    // Compute dual right now.
1079   // Convenience common pre-built types.
1080   static const TypeRawPtr *BOTTOM;
1081   static const TypeRawPtr *NOTNULL;
1082 #ifndef PRODUCT
1083   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1084 #endif
1085 };
1086 
1087 //------------------------------TypeOopPtr-------------------------------------
1088 // Some kind of oop (Java pointer), either instance or array.
1089 class TypeOopPtr : public TypePtr {
1090   friend class TypeAry;
1091   friend class TypePtr;
1092   friend class TypeInstPtr;
1093   friend class TypeAryPtr;
1094 protected:
1095  TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, int offset, int instance_id,
1096             const TypePtr* speculative, int inline_depth);
1097 public:
1098   virtual bool eq( const Type *t ) const;
1099   virtual uint hash() const;             // Type specific hashing
1100   virtual bool singleton(void) const;    // TRUE if type is a singleton
1101   enum {
1102    InstanceTop = -1,   // undefined instance
1103    InstanceBot = 0     // any possible instance
1104   };
1105 protected:
1106 
1107   // Oop is null, unless this is a constant oop.
1108   ciObject*     _const_oop;   // Constant oop
1109   // If _klass is null, then so is _sig.  This is an unloaded klass.
1110   ciKlass*      _klass;       // Klass object
1111 
1112   const TypeInterfaces* _interfaces;
1113 
1114   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
1115   bool          _klass_is_exact;
1116   bool          _is_ptr_to_narrowoop;
1117   bool          _is_ptr_to_narrowklass;
1118   bool          _is_ptr_to_boxed_value;
1119 
1120   // If not InstanceTop or InstanceBot, indicates that this is
1121   // a particular instance of this type which is distinct.
1122   // This is the node index of the allocation node creating this instance.
1123   int           _instance_id;
1124 
1125   static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact, InterfaceHandling interface_handling);
1126 
1127   int dual_instance_id() const;
1128   int meet_instance_id(int uid) const;
1129 
1130   const TypeInterfaces* meet_interfaces(const TypeOopPtr* other) const;
1131 
1132   // Do not allow interface-vs.-noninterface joins to collapse to top.
1133   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1134 
1135   virtual ciKlass* exact_klass_helper() const { return nullptr; }
1136   virtual ciKlass* klass() const { return _klass;     }
1137 
1138 public:
1139 
1140   bool is_java_subtype_of(const TypeOopPtr* other) const {
1141     return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1142   }
1143 
1144   bool is_same_java_type_as(const TypePtr* other) const {
1145     return is_same_java_type_as_helper(other->is_oopptr());
1146   }
1147 
1148   virtual bool is_same_java_type_as_helper(const TypeOopPtr* other) const {
1149     ShouldNotReachHere(); return false;
1150   }
1151 
1152   bool maybe_java_subtype_of(const TypeOopPtr* other) const {
1153     return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1154   }
1155   virtual bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1156   virtual bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }

1163     return make_from_klass_common(klass, true, false, interface_handling);
1164   }
1165   // Same as before, but will produce an exact type, even if
1166   // the klass is not final, as long as it has exactly one implementation.
1167   static const TypeOopPtr* make_from_klass_unique(ciKlass* klass, InterfaceHandling interface_handling= ignore_interfaces) {
1168     return make_from_klass_common(klass, true, true, interface_handling);
1169   }
1170   // Same as before, but does not respects UseUniqueSubclasses.
1171   // Use this only for creating array element types.
1172   static const TypeOopPtr* make_from_klass_raw(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1173     return make_from_klass_common(klass, false, false, interface_handling);
1174   }
1175   // Creates a singleton type given an object.
1176   // If the object cannot be rendered as a constant,
1177   // may return a non-singleton type.
1178   // If require_constant, produce a null if a singleton is not possible.
1179   static const TypeOopPtr* make_from_constant(ciObject* o,
1180                                               bool require_constant = false);
1181 
1182   // Make a generic (unclassed) pointer to an oop.
1183   static const TypeOopPtr* make(PTR ptr, int offset, int instance_id,
1184                                 const TypePtr* speculative = nullptr,
1185                                 int inline_depth = InlineDepthBottom);
1186 
1187   ciObject* const_oop()    const { return _const_oop; }
1188   // Exact klass, possibly an interface or an array of interface
1189   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k;  }
1190   ciKlass* unloaded_klass() const { assert(!is_loaded(), "only for unloaded types"); return klass(); }
1191 
1192   virtual bool  is_loaded() const { return klass()->is_loaded(); }
1193   virtual bool klass_is_exact()    const { return _klass_is_exact; }
1194 
1195   // Returns true if this pointer points at memory which contains a
1196   // compressed oop references.
1197   bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
1198   bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
1199   bool is_ptr_to_boxed_value()   const { return _is_ptr_to_boxed_value; }
1200   bool is_known_instance()       const { return _instance_id > 0; }
1201   int  instance_id()             const { return _instance_id; }
1202   bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }



1203 
1204   virtual intptr_t get_con() const;
1205 
1206   virtual const TypeOopPtr* cast_to_ptr_type(PTR ptr) const;
1207 
1208   virtual const TypeOopPtr* cast_to_exactness(bool klass_is_exact) const;
1209 
1210   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1211 
1212   // corresponding pointer to klass, for a given instance
1213   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1214 
1215   virtual const TypeOopPtr* with_offset(intptr_t offset) const;
1216   virtual const TypePtr* add_offset(intptr_t offset) const;
1217 
1218   // Speculative type helper methods.
1219   virtual const TypeOopPtr* remove_speculative() const;
1220   virtual const Type* cleanup_speculative() const;
1221   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1222   virtual const TypePtr* with_inline_depth(int depth) const;

1245     return _interfaces;
1246   };
1247 
1248   const TypeOopPtr* is_reference_type(const Type* other) const {
1249     return other->isa_oopptr();
1250   }
1251 
1252   const TypeAryPtr* is_array_type(const TypeOopPtr* other) const {
1253     return other->isa_aryptr();
1254   }
1255 
1256   const TypeInstPtr* is_instance_type(const TypeOopPtr* other) const {
1257     return other->isa_instptr();
1258   }
1259 };
1260 
1261 //------------------------------TypeInstPtr------------------------------------
1262 // Class of Java object pointers, pointing either to non-array Java instances
1263 // or to a Klass* (including array klasses).
1264 class TypeInstPtr : public TypeOopPtr {
1265   TypeInstPtr(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, int off, int instance_id,
1266               const TypePtr* speculative, int inline_depth);

1267   virtual bool eq( const Type *t ) const;
1268   virtual uint hash() const;             // Type specific hashing
1269 
1270   ciKlass* exact_klass_helper() const;
1271 
1272 public:
1273 
1274   // Instance klass, ignoring any interface
1275   ciInstanceKlass* instance_klass() const {
1276     assert(!(klass()->is_loaded() && klass()->is_interface()), "");
1277     return klass()->as_instance_klass();
1278   }
1279 
1280   bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1281   bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1282   bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1283 
1284   // Make a pointer to a constant oop.
1285   static const TypeInstPtr *make(ciObject* o) {
1286     ciKlass* k = o->klass();
1287     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1288     return make(TypePtr::Constant, k, interfaces, true, o, 0, InstanceBot);
1289   }
1290   // Make a pointer to a constant oop with offset.
1291   static const TypeInstPtr *make(ciObject* o, int offset) {
1292     ciKlass* k = o->klass();
1293     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1294     return make(TypePtr::Constant, k, interfaces, true, o, offset, InstanceBot);
1295   }
1296 
1297   // Make a pointer to some value of type klass.
1298   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1299     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, true, false, interface_handling);
1300     return make(ptr, klass, interfaces, false, nullptr, 0, InstanceBot);
1301   }
1302 
1303   // Make a pointer to some non-polymorphic value of exactly type klass.
1304   static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
1305     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1306     return make(ptr, klass, interfaces, true, nullptr, 0, InstanceBot);
1307   }
1308 
1309   // Make a pointer to some value of type klass with offset.
1310   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
1311     const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1312     return make(ptr, klass, interfaces, false, nullptr, offset, InstanceBot);
1313   }
1314 
1315   static const TypeInstPtr *make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, int offset,


1316                                  int instance_id = InstanceBot,
1317                                  const TypePtr* speculative = nullptr,
1318                                  int inline_depth = InlineDepthBottom);
1319 
1320   static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot) {
1321     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1322     return make(ptr, k, interfaces, xk, o, offset, instance_id);
1323   }
1324 
1325   /** Create constant type for a constant boxed value */
1326   const Type* get_const_boxed_value() const;
1327 
1328   // If this is a java.lang.Class constant, return the type for it or null.
1329   // Pass to Type::get_const_type to turn it to a type, which will usually
1330   // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
1331   ciType* java_mirror_type() const;
1332 
1333   virtual const TypeInstPtr* cast_to_ptr_type(PTR ptr) const;
1334 
1335   virtual const TypeInstPtr* cast_to_exactness(bool klass_is_exact) const;
1336 
1337   virtual const TypeInstPtr* cast_to_instance_id(int instance_id) const;
1338 
1339   virtual const TypePtr* add_offset(intptr_t offset) const;
1340   virtual const TypeInstPtr* with_offset(intptr_t offset) const;
1341 
1342   // Speculative type helper methods.
1343   virtual const TypeInstPtr* remove_speculative() const;
1344   const TypeInstPtr* with_speculative(const TypePtr* speculative) const;
1345   virtual const TypePtr* with_inline_depth(int depth) const;
1346   virtual const TypePtr* with_instance_id(int instance_id) const;
1347 




1348   // the core of the computation of the meet of 2 types
1349   virtual const Type *xmeet_helper(const Type *t) const;
1350   virtual const TypeInstPtr *xmeet_unloaded(const TypeInstPtr *tinst, const TypeInterfaces* interfaces) const;
1351   virtual const Type *xdual() const;    // Compute dual right now.
1352 
1353   const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1354 


1355   // Convenience common pre-built types.
1356   static const TypeInstPtr *NOTNULL;
1357   static const TypeInstPtr *BOTTOM;
1358   static const TypeInstPtr *MIRROR;
1359   static const TypeInstPtr *MARK;
1360   static const TypeInstPtr *KLASS;
1361 #ifndef PRODUCT
1362   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1363 #endif
1364 
1365 private:
1366   virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1367 
1368   virtual bool is_meet_same_type_as(const TypePtr* other) const {
1369     return _klass->equals(other->is_instptr()->_klass) && _interfaces->eq(other->is_instptr()->_interfaces);
1370   }
1371 
1372 };
1373 
1374 //------------------------------TypeAryPtr-------------------------------------
1375 // Class of Java array pointers
1376 class TypeAryPtr : public TypeOopPtr {
1377   friend class Type;
1378   friend class TypePtr;

1379 
1380   TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1381               int offset, int instance_id, bool is_autobox_cache,
1382               const TypePtr* speculative, int inline_depth)
1383     : TypeOopPtr(AryPtr,ptr,k,_array_interfaces,xk,o,offset, instance_id, speculative, inline_depth),
1384     _ary(ary),
1385     _is_autobox_cache(is_autobox_cache)

1386  {
1387     int dummy;
1388     bool top_or_bottom = (base_element_type(dummy) == Type::TOP || base_element_type(dummy) == Type::BOTTOM);
1389 
1390     if (UseCompressedOops && (elem()->make_oopptr() != nullptr && !top_or_bottom) &&
1391         _offset != 0 && _offset != arrayOopDesc::length_offset_in_bytes() &&
1392         _offset != arrayOopDesc::klass_offset_in_bytes()) {
1393       _is_ptr_to_narrowoop = true;
1394     }
1395 
1396   }
1397   virtual bool eq( const Type *t ) const;
1398   virtual uint hash() const;    // Type specific hashing
1399   const TypeAry *_ary;          // Array we point into
1400   const bool     _is_autobox_cache;






1401 
1402   ciKlass* compute_klass() const;
1403 
1404   // A pointer to delay allocation to Type::Initialize_shared()
1405 
1406   static const TypeInterfaces* _array_interfaces;
1407   ciKlass* exact_klass_helper() const;
1408   // Only guaranteed non null for array of basic types
1409   ciKlass* klass() const;
1410 
1411 public:
1412 
1413   bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1414   bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1415   bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1416 
1417   // returns base element type, an instance klass (and not interface) for object arrays
1418   const Type* base_element_type(int& dims) const;
1419 
1420   // Accessors
1421   bool  is_loaded() const { return (_ary->_elem->make_oopptr() ? _ary->_elem->make_oopptr()->is_loaded() : true); }
1422 
1423   const TypeAry* ary() const  { return _ary; }
1424   const Type*    elem() const { return _ary->_elem; }
1425   const TypeInt* size() const { return _ary->_size; }
1426   bool      is_stable() const { return _ary->_stable; }
1427 






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

1431                                 int instance_id = InstanceBot,
1432                                 const TypePtr* speculative = nullptr,
1433                                 int inline_depth = InlineDepthBottom);
1434   // Constant pointer to array
1435   static const TypeAryPtr *make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset,

1436                                 int instance_id = InstanceBot,
1437                                 const TypePtr* speculative = nullptr,
1438                                 int inline_depth = InlineDepthBottom, bool is_autobox_cache = false);

1439 
1440   // Return a 'ptr' version of this type
1441   virtual const TypeAryPtr* cast_to_ptr_type(PTR ptr) const;
1442 
1443   virtual const TypeAryPtr* cast_to_exactness(bool klass_is_exact) const;
1444 
1445   virtual const TypeAryPtr* cast_to_instance_id(int instance_id) const;
1446 
1447   virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1448   virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1449 
1450   virtual bool empty(void) const;        // TRUE if type is vacuous
1451   virtual const TypePtr *add_offset( intptr_t offset ) const;
1452   virtual const TypeAryPtr *with_offset( intptr_t offset ) const;
1453   const TypeAryPtr* with_ary(const TypeAry* ary) const;
1454 
1455   // Speculative type helper methods.
1456   virtual const TypeAryPtr* remove_speculative() const;

1457   virtual const TypePtr* with_inline_depth(int depth) const;
1458   virtual const TypePtr* with_instance_id(int instance_id) const;
1459 
1460   // the core of the computation of the meet of 2 types
1461   virtual const Type *xmeet_helper(const Type *t) const;
1462   virtual const Type *xdual() const;    // Compute dual right now.
1463 








1464   const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1465   int stable_dimension() const;
1466 
1467   const TypeAryPtr* cast_to_autobox_cache() const;
1468 
1469   static jint max_array_length(BasicType etype) ;







1470   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1471 


1472   // Convenience common pre-built types.
1473   static const TypeAryPtr *RANGE;
1474   static const TypeAryPtr *OOPS;
1475   static const TypeAryPtr *NARROWOOPS;
1476   static const TypeAryPtr *BYTES;
1477   static const TypeAryPtr *SHORTS;
1478   static const TypeAryPtr *CHARS;
1479   static const TypeAryPtr *INTS;
1480   static const TypeAryPtr *LONGS;
1481   static const TypeAryPtr *FLOATS;
1482   static const TypeAryPtr *DOUBLES;

1483   // selects one of the above:
1484   static const TypeAryPtr *get_array_body_type(BasicType elem) {
1485     assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != nullptr, "bad elem type");
1486     return _array_body_type[elem];
1487   }
1488   static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1489   // sharpen the type of an int which is used as an array size
1490 #ifndef PRODUCT
1491   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1492 #endif
1493 private:
1494   virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1495 };
1496 
1497 //------------------------------TypeMetadataPtr-------------------------------------
1498 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
1499 class TypeMetadataPtr : public TypePtr {
1500 protected:
1501   TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset);
1502   // Do not allow interface-vs.-noninterface joins to collapse to top.
1503   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1504 public:
1505   virtual bool eq( const Type *t ) const;
1506   virtual uint hash() const;             // Type specific hashing
1507   virtual bool singleton(void) const;    // TRUE if type is a singleton
1508 
1509 private:
1510   ciMetadata*   _metadata;
1511 
1512 public:
1513   static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, int offset);
1514 
1515   static const TypeMetadataPtr* make(ciMethod* m);
1516   static const TypeMetadataPtr* make(ciMethodData* m);
1517 
1518   ciMetadata* metadata() const { return _metadata; }
1519 
1520   virtual const TypeMetadataPtr* cast_to_ptr_type(PTR ptr) const;
1521 
1522   virtual const TypePtr *add_offset( intptr_t offset ) const;
1523 
1524   virtual const Type *xmeet( const Type *t ) const;
1525   virtual const Type *xdual() const;    // Compute dual right now.
1526 
1527   virtual intptr_t get_con() const;
1528 
1529   // Convenience common pre-built types.
1530   static const TypeMetadataPtr *BOTTOM;
1531 
1532 #ifndef PRODUCT
1533   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1534 #endif
1535 };
1536 
1537 //------------------------------TypeKlassPtr-----------------------------------
1538 // Class of Java Klass pointers
1539 class TypeKlassPtr : public TypePtr {
1540   friend class TypeInstKlassPtr;
1541   friend class TypeAryKlassPtr;
1542   friend class TypePtr;
1543 protected:
1544   TypeKlassPtr(TYPES t, PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, int offset);
1545 
1546   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1547 
1548 public:
1549   virtual bool eq( const Type *t ) const;
1550   virtual uint hash() const;
1551   virtual bool singleton(void) const;    // TRUE if type is a singleton
1552 
1553 protected:
1554 
1555   ciKlass* _klass;
1556   const TypeInterfaces* _interfaces;
1557   const TypeInterfaces* meet_interfaces(const TypeKlassPtr* other) const;
1558   virtual bool must_be_exact() const { ShouldNotReachHere(); return false; }
1559   virtual ciKlass* exact_klass_helper() const;
1560   virtual ciKlass* klass() const { return  _klass; }
1561 
1562 public:
1563 
1564   bool is_java_subtype_of(const TypeKlassPtr* other) const {
1565     return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1566   }
1567   bool is_same_java_type_as(const TypePtr* other) const {
1568     return is_same_java_type_as_helper(other->is_klassptr());
1569   }
1570 
1571   bool maybe_java_subtype_of(const TypeKlassPtr* other) const {
1572     return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1573   }
1574   virtual bool is_same_java_type_as_helper(const TypeKlassPtr* other) const { ShouldNotReachHere(); return false; }
1575   virtual bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1576   virtual bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1577 
1578   // Exact klass, possibly an interface or an array of interface
1579   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k;  }
1580   virtual bool klass_is_exact()    const { return _ptr == Constant; }
1581 
1582   static const TypeKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces);
1583   static const TypeKlassPtr *make(PTR ptr, ciKlass* klass, int offset, InterfaceHandling interface_handling = ignore_interfaces);
1584 
1585   virtual bool  is_loaded() const { return _klass->is_loaded(); }
1586 
1587   virtual const TypeKlassPtr* cast_to_ptr_type(PTR ptr) const { ShouldNotReachHere(); return nullptr; }
1588 
1589   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const { ShouldNotReachHere(); return nullptr; }
1590 
1591   // corresponding pointer to instance, for a given class
1592   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const { ShouldNotReachHere(); return nullptr; }
1593 
1594   virtual const TypePtr *add_offset( intptr_t offset ) const { ShouldNotReachHere(); return nullptr; }
1595   virtual const Type    *xmeet( const Type *t ) const { ShouldNotReachHere(); return nullptr; }
1596   virtual const Type    *xdual() const { ShouldNotReachHere(); return nullptr; }
1597 
1598   virtual intptr_t get_con() const;
1599 
1600   virtual const TypeKlassPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr; }
1601 

1602   virtual const TypeKlassPtr* try_improve() const { return this; }
1603 
1604 #ifndef PRODUCT
1605   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1606 #endif
1607 private:
1608   virtual bool is_meet_subtype_of(const TypePtr* other) const {
1609     return is_meet_subtype_of_helper(other->is_klassptr(), klass_is_exact(), other->is_klassptr()->klass_is_exact());
1610   }
1611 
1612   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const {
1613     ShouldNotReachHere(); return false;
1614   }
1615 
1616   virtual const TypeInterfaces* interfaces() const {
1617     return _interfaces;
1618   };
1619 
1620   const TypeKlassPtr* is_reference_type(const Type* other) const {
1621     return other->isa_klassptr();
1622   }
1623 
1624   const TypeAryKlassPtr* is_array_type(const TypeKlassPtr* other) const {
1625     return other->isa_aryklassptr();
1626   }
1627 
1628   const TypeInstKlassPtr* is_instance_type(const TypeKlassPtr* other) const {
1629     return other->isa_instklassptr();
1630   }
1631 };
1632 
1633 // Instance klass pointer, mirrors TypeInstPtr
1634 class TypeInstKlassPtr : public TypeKlassPtr {
1635 
1636   TypeInstKlassPtr(PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, int offset)
1637     : TypeKlassPtr(InstKlassPtr, ptr, klass, interfaces, offset) {
1638     assert(klass->is_instance_klass() && (!klass->is_loaded() || !klass->is_interface()), "");
1639   }
1640 
1641   virtual bool must_be_exact() const;
1642 


1643 public:
1644   // Instance klass ignoring any interface
1645   ciInstanceKlass* instance_klass() const {
1646     assert(!klass()->is_interface(), "");
1647     return klass()->as_instance_klass();
1648   }
1649 
1650   bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
1651   bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1652   bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1653 


1654   static const TypeInstKlassPtr *make(ciKlass* k, InterfaceHandling interface_handling) {
1655     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, true, false, interface_handling);
1656     return make(TypePtr::Constant, k, interfaces, 0);
1657   }
1658   static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, int offset);
1659 
1660   static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, int offset) {
1661     const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1662     return make(ptr, k, interfaces, offset);
1663   }
1664 
1665   virtual const TypeInstKlassPtr* cast_to_ptr_type(PTR ptr) const;
1666 
1667   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1668 
1669   // corresponding pointer to instance, for a given class
1670   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
1671   virtual uint hash() const;
1672   virtual bool eq(const Type *t) const;
1673 
1674   virtual const TypePtr *add_offset( intptr_t offset ) const;
1675   virtual const Type    *xmeet( const Type *t ) const;
1676   virtual const Type    *xdual() const;
1677   virtual const TypeInstKlassPtr* with_offset(intptr_t offset) const;
1678 
1679   virtual const TypeKlassPtr* try_improve() const;
1680 





1681   // Convenience common pre-built types.
1682   static const TypeInstKlassPtr* OBJECT; // Not-null object klass or below
1683   static const TypeInstKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
1684 private:
1685   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
1686 };
1687 
1688 // Array klass pointer, mirrors TypeAryPtr
1689 class TypeAryKlassPtr : public TypeKlassPtr {
1690   friend class TypeInstKlassPtr;
1691   friend class Type;
1692   friend class TypePtr;
1693 
1694   const Type *_elem;



1695 
1696   static const TypeInterfaces* _array_interfaces;
1697   TypeAryKlassPtr(PTR ptr, const Type *elem, ciKlass* klass, int offset)
1698     : TypeKlassPtr(AryKlassPtr, ptr, klass, _array_interfaces, offset), _elem(elem) {
1699     assert(klass == nullptr || klass->is_type_array_klass() || !klass->as_obj_array_klass()->base_element_klass()->is_interface(), "");
1700   }
1701 
1702   virtual ciKlass* exact_klass_helper() const;
1703   // Only guaranteed non null for array of basic types
1704   virtual ciKlass* klass() const;
1705 
1706   virtual bool must_be_exact() const;
1707 








1708 public:
1709 
1710   // returns base element type, an instance klass (and not interface) for object arrays
1711   const Type* base_element_type(int& dims) const;
1712 
1713   static const TypeAryKlassPtr *make(PTR ptr, ciKlass* k, int offset, InterfaceHandling interface_handling);
1714 
1715   bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
1716   bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1717   bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1718 
1719   bool  is_loaded() const { return (_elem->isa_klassptr() ? _elem->is_klassptr()->is_loaded() : true); }
1720 
1721   static const TypeAryKlassPtr *make(PTR ptr, const Type *elem, ciKlass* k, int offset);

1722   static const TypeAryKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling);
1723 
1724   const Type *elem() const { return _elem; }
1725 
1726   virtual bool eq(const Type *t) const;
1727   virtual uint hash() const;             // Type specific hashing
1728 
1729   virtual const TypeAryKlassPtr* cast_to_ptr_type(PTR ptr) const;
1730 
1731   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1732 


1733   // corresponding pointer to instance, for a given class
1734   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
1735 
1736   virtual const TypePtr *add_offset( intptr_t offset ) const;
1737   virtual const Type    *xmeet( const Type *t ) const;
1738   virtual const Type    *xdual() const;      // Compute dual right now.
1739 
1740   virtual const TypeAryKlassPtr* with_offset(intptr_t offset) const;
1741 
1742   virtual bool empty(void) const {
1743     return TypeKlassPtr::empty() || _elem->empty();
1744   }
1745 






1746 #ifndef PRODUCT
1747   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1748 #endif
1749 private:
1750   virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
1751 };
1752 
1753 class TypeNarrowPtr : public Type {
1754 protected:
1755   const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
1756 
1757   TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): Type(t),
1758                                                   _ptrtype(ptrtype) {
1759     assert(ptrtype->offset() == 0 ||
1760            ptrtype->offset() == OffsetBot ||
1761            ptrtype->offset() == OffsetTop, "no real offsets");
1762   }
1763 
1764   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
1765   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;

1861   }
1862 
1863   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
1864     return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
1865   }
1866 
1867 public:
1868   static const TypeNarrowKlass *make( const TypePtr* type);
1869 
1870   // static const TypeNarrowKlass *BOTTOM;
1871   static const TypeNarrowKlass *NULL_PTR;
1872 
1873 #ifndef PRODUCT
1874   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1875 #endif
1876 };
1877 
1878 //------------------------------TypeFunc---------------------------------------
1879 // Class of Array Types
1880 class TypeFunc : public Type {
1881   TypeFunc( const TypeTuple *domain, const TypeTuple *range ) : Type(Function),  _domain(domain), _range(range) {}

1882   virtual bool eq( const Type *t ) const;
1883   virtual uint hash() const;             // Type specific hashing
1884   virtual bool singleton(void) const;    // TRUE if type is a singleton
1885   virtual bool empty(void) const;        // TRUE if type is vacuous
1886 
1887   const TypeTuple* const _domain;     // Domain of inputs
1888   const TypeTuple* const _range;      // Range of results











1889 
1890 public:
1891   // Constants are shared among ADLC and VM
1892   enum { Control    = AdlcVMDeps::Control,
1893          I_O        = AdlcVMDeps::I_O,
1894          Memory     = AdlcVMDeps::Memory,
1895          FramePtr   = AdlcVMDeps::FramePtr,
1896          ReturnAdr  = AdlcVMDeps::ReturnAdr,
1897          Parms      = AdlcVMDeps::Parms
1898   };
1899 
1900 
1901   // Accessors:
1902   const TypeTuple* domain() const { return _domain; }
1903   const TypeTuple* range()  const { return _range; }
1904 
1905   static const TypeFunc *make(ciMethod* method);
1906   static const TypeFunc *make(ciSignature signature, const Type* extra);



1907   static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
1908 
1909   virtual const Type *xmeet( const Type *t ) const;
1910   virtual const Type *xdual() const;    // Compute dual right now.
1911 
1912   BasicType return_type() const;
1913 


1914 #ifndef PRODUCT
1915   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1916 #endif
1917   // Convenience common pre-built types.
1918 };
1919 
1920 //------------------------------accessors--------------------------------------
1921 inline bool Type::is_ptr_to_narrowoop() const {
1922 #ifdef _LP64
1923   return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowoop_nv());
1924 #else
1925   return false;
1926 #endif
1927 }
1928 
1929 inline bool Type::is_ptr_to_narrowklass() const {
1930 #ifdef _LP64
1931   return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowklass_nv());
1932 #else
1933   return false;

2149   return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->isa_oopptr() : isa_oopptr();
2150 }
2151 
2152 inline const TypeNarrowOop* Type::make_narrowoop() const {
2153   return (_base == NarrowOop) ? is_narrowoop() :
2154                                 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : nullptr);
2155 }
2156 
2157 inline const TypeNarrowKlass* Type::make_narrowklass() const {
2158   return (_base == NarrowKlass) ? is_narrowklass() :
2159                                   (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : nullptr);
2160 }
2161 
2162 inline bool Type::is_floatingpoint() const {
2163   if( (_base == FloatCon)  || (_base == FloatBot) ||
2164       (_base == DoubleCon) || (_base == DoubleBot) )
2165     return true;
2166   return false;
2167 }
2168 








2169 
2170 // ===============================================================
2171 // Things that need to be 64-bits in the 64-bit build but
2172 // 32-bits in the 32-bit build.  Done this way to get full
2173 // optimization AND strong typing.
2174 #ifdef _LP64
2175 
2176 // For type queries and asserts
2177 #define is_intptr_t  is_long
2178 #define isa_intptr_t isa_long
2179 #define find_intptr_t_type find_long_type
2180 #define find_intptr_t_con  find_long_con
2181 #define TypeX        TypeLong
2182 #define Type_X       Type::Long
2183 #define TypeX_X      TypeLong::LONG
2184 #define TypeX_ZERO   TypeLong::ZERO
2185 // For 'ideal_reg' machine registers
2186 #define Op_RegX      Op_RegL
2187 // For phase->intcon variants
2188 #define MakeConX     longcon
2189 #define ConXNode     ConLNode
2190 // For array index arithmetic
2191 #define MulXNode     MulLNode
2192 #define AndXNode     AndLNode
2193 #define OrXNode      OrLNode
2194 #define CmpXNode     CmpLNode

2195 #define SubXNode     SubLNode
2196 #define LShiftXNode  LShiftLNode
2197 // For object size computation:
2198 #define AddXNode     AddLNode
2199 #define RShiftXNode  RShiftLNode
2200 // For card marks and hashcodes
2201 #define URShiftXNode URShiftLNode
2202 // For shenandoahSupport
2203 #define LoadXNode    LoadLNode
2204 #define StoreXNode   StoreLNode
2205 // Opcodes
2206 #define Op_LShiftX   Op_LShiftL
2207 #define Op_AndX      Op_AndL
2208 #define Op_AddX      Op_AddL
2209 #define Op_SubX      Op_SubL
2210 #define Op_XorX      Op_XorL
2211 #define Op_URShiftX  Op_URShiftL
2212 #define Op_LoadX     Op_LoadL

2213 // conversions
2214 #define ConvI2X(x)   ConvI2L(x)
2215 #define ConvL2X(x)   (x)
2216 #define ConvX2I(x)   ConvL2I(x)
2217 #define ConvX2L(x)   (x)
2218 #define ConvX2UL(x)  (x)
2219 
2220 #else
2221 
2222 // For type queries and asserts
2223 #define is_intptr_t  is_int
2224 #define isa_intptr_t isa_int
2225 #define find_intptr_t_type find_int_type
2226 #define find_intptr_t_con  find_int_con
2227 #define TypeX        TypeInt
2228 #define Type_X       Type::Int
2229 #define TypeX_X      TypeInt::INT
2230 #define TypeX_ZERO   TypeInt::ZERO
2231 // For 'ideal_reg' machine registers
2232 #define Op_RegX      Op_RegI
2233 // For phase->intcon variants
2234 #define MakeConX     intcon
2235 #define ConXNode     ConINode
2236 // For array index arithmetic
2237 #define MulXNode     MulINode
2238 #define AndXNode     AndINode
2239 #define OrXNode      OrINode
2240 #define CmpXNode     CmpINode

2241 #define SubXNode     SubINode
2242 #define LShiftXNode  LShiftINode
2243 // For object size computation:
2244 #define AddXNode     AddINode
2245 #define RShiftXNode  RShiftINode
2246 // For card marks and hashcodes
2247 #define URShiftXNode URShiftINode
2248 // For shenandoahSupport
2249 #define LoadXNode    LoadINode
2250 #define StoreXNode   StoreINode
2251 // Opcodes
2252 #define Op_LShiftX   Op_LShiftI
2253 #define Op_AndX      Op_AndI
2254 #define Op_AddX      Op_AddI
2255 #define Op_SubX      Op_SubI
2256 #define Op_XorX      Op_XorI
2257 #define Op_URShiftX  Op_URShiftI
2258 #define Op_LoadX     Op_LoadI

2259 // conversions
2260 #define ConvI2X(x)   (x)
2261 #define ConvL2X(x)   ConvL2I(x)
2262 #define ConvX2I(x)   (x)
2263 #define ConvX2L(x)   ConvI2L(x)
2264 #define ConvX2UL(x)  ConvI2UL(x)
2265 
2266 #endif
2267 
2268 #endif // SHARE_OPTO_TYPE_HPP

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

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

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

 736   const Type ** const _fields;           // Array of field types
 737 
 738 public:
 739   virtual bool eq( const Type *t ) const;
 740   virtual uint hash() const;             // Type specific hashing
 741   virtual bool singleton(void) const;    // TRUE if type is a singleton
 742   virtual bool empty(void) const;        // TRUE if type is vacuous
 743 
 744   // Accessors:
 745   uint cnt() const { return _cnt; }
 746   const Type* field_at(uint i) const {
 747     assert(i < _cnt, "oob");
 748     return _fields[i];
 749   }
 750   void set_field_at(uint i, const Type* t) {
 751     assert(i < _cnt, "oob");
 752     _fields[i] = t;
 753   }
 754 
 755   static const TypeTuple *make( uint cnt, const Type **fields );
 756   static const TypeTuple *make_range(ciSignature* sig, InterfaceHandling interface_handling = ignore_interfaces, bool ret_vt_fields = false);
 757   static const TypeTuple *make_domain(ciMethod* method, InterfaceHandling interface_handling, bool vt_fields_as_args = false);
 758 
 759   // Subroutine call type with space allocated for argument types
 760   // Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly
 761   static const Type **fields( uint arg_cnt );
 762 
 763   virtual const Type *xmeet( const Type *t ) const;
 764   virtual const Type *xdual() const;    // Compute dual right now.
 765   // Convenience common pre-built types.
 766   static const TypeTuple *IFBOTH;
 767   static const TypeTuple *IFFALSE;
 768   static const TypeTuple *IFTRUE;
 769   static const TypeTuple *IFNEITHER;
 770   static const TypeTuple *LOOPBODY;
 771   static const TypeTuple *MEMBAR;
 772   static const TypeTuple *STORECONDITIONAL;
 773   static const TypeTuple *START_I2C;
 774   static const TypeTuple *INT_PAIR;
 775   static const TypeTuple *LONG_PAIR;
 776   static const TypeTuple *INT_CC_PAIR;
 777   static const TypeTuple *LONG_CC_PAIR;
 778 #ifndef PRODUCT
 779   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 780 #endif
 781 };
 782 
 783 //------------------------------TypeAry----------------------------------------
 784 // Class of Array Types
 785 class TypeAry : public Type {
 786   TypeAry(const Type* elem, const TypeInt* size, bool stable, bool flat, bool not_flat, bool not_null_free) : Type(Array),
 787       _elem(elem), _size(size), _stable(stable), _flat(flat), _not_flat(not_flat), _not_null_free(not_null_free) {}
 788 public:
 789   virtual bool eq( const Type *t ) const;
 790   virtual uint hash() const;             // Type specific hashing
 791   virtual bool singleton(void) const;    // TRUE if type is a singleton
 792   virtual bool empty(void) const;        // TRUE if type is vacuous
 793 
 794 private:
 795   const Type *_elem;            // Element type of array
 796   const TypeInt *_size;         // Elements in array
 797   const bool _stable;           // Are elements @Stable?
 798 
 799   // Inline type array properties
 800   const bool _flat;             // Array is flat
 801   const bool _not_flat;         // Array is never flat
 802   const bool _not_null_free;    // Array is never null-free
 803 
 804   friend class TypeAryPtr;
 805 
 806 public:
 807   static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false,
 808                              bool flat = false, bool not_flat = false, bool not_null_free = false);
 809 
 810   virtual const Type *xmeet( const Type *t ) const;
 811   virtual const Type *xdual() const;    // Compute dual right now.
 812   bool ary_must_be_exact() const;  // true if arrays of such are never generic
 813   virtual const TypeAry* remove_speculative() const;
 814   virtual const Type* cleanup_speculative() const;
 815 #ifndef PRODUCT
 816   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 817 #endif
 818 };
 819 
 820 //------------------------------TypeVect---------------------------------------
 821 // Class of Vector Types
 822 class TypeVect : public Type {
 823   const BasicType _elem_bt;  // Vector's element type
 824   const uint _length;  // Elements in vector (power of 2)
 825 
 826 protected:
 827   TypeVect(TYPES t, BasicType elem_bt, uint length) : Type(t),
 828     _elem_bt(elem_bt), _length(length) {}

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

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

1211     return make_from_klass_common(klass, true, false, interface_handling);
1212   }
1213   // Same as before, but will produce an exact type, even if
1214   // the klass is not final, as long as it has exactly one implementation.
1215   static const TypeOopPtr* make_from_klass_unique(ciKlass* klass, InterfaceHandling interface_handling= ignore_interfaces) {
1216     return make_from_klass_common(klass, true, true, interface_handling);
1217   }
1218   // Same as before, but does not respects UseUniqueSubclasses.
1219   // Use this only for creating array element types.
1220   static const TypeOopPtr* make_from_klass_raw(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1221     return make_from_klass_common(klass, false, false, interface_handling);
1222   }
1223   // Creates a singleton type given an object.
1224   // If the object cannot be rendered as a constant,
1225   // may return a non-singleton type.
1226   // If require_constant, produce a null if a singleton is not possible.
1227   static const TypeOopPtr* make_from_constant(ciObject* o,
1228                                               bool require_constant = false);
1229 
1230   // Make a generic (unclassed) pointer to an oop.
1231   static const TypeOopPtr* make(PTR ptr, Offset offset, int instance_id,
1232                                 const TypePtr* speculative = nullptr,
1233                                 int inline_depth = InlineDepthBottom);
1234 
1235   ciObject* const_oop()    const { return _const_oop; }
1236   // Exact klass, possibly an interface or an array of interface
1237   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k;  }
1238   ciKlass* unloaded_klass() const { assert(!is_loaded(), "only for unloaded types"); return klass(); }
1239 
1240   virtual bool  is_loaded() const { return klass()->is_loaded(); }
1241   virtual bool klass_is_exact()    const { return _klass_is_exact; }
1242 
1243   // Returns true if this pointer points at memory which contains a
1244   // compressed oop references.
1245   bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
1246   bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
1247   bool is_ptr_to_boxed_value()   const { return _is_ptr_to_boxed_value; }
1248   bool is_known_instance()       const { return _instance_id > 0; }
1249   int  instance_id()             const { return _instance_id; }
1250   bool is_known_instance_field() const { return is_known_instance() && _offset.get() >= 0; }
1251 
1252   virtual bool can_be_inline_type() const { return (_klass == nullptr || _klass->can_be_inline_klass(_klass_is_exact)); }
1253   virtual bool can_be_inline_array() const { ShouldNotReachHere(); return false; }
1254 
1255   virtual intptr_t get_con() const;
1256 
1257   virtual const TypeOopPtr* cast_to_ptr_type(PTR ptr) const;
1258 
1259   virtual const TypeOopPtr* cast_to_exactness(bool klass_is_exact) const;
1260 
1261   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1262 
1263   // corresponding pointer to klass, for a given instance
1264   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1265 
1266   virtual const TypeOopPtr* with_offset(intptr_t offset) const;
1267   virtual const TypePtr* add_offset(intptr_t offset) const;
1268 
1269   // Speculative type helper methods.
1270   virtual const TypeOopPtr* remove_speculative() const;
1271   virtual const Type* cleanup_speculative() const;
1272   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1273   virtual const TypePtr* with_inline_depth(int depth) const;

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

1987   }
1988 
1989   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
1990     return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
1991   }
1992 
1993 public:
1994   static const TypeNarrowKlass *make( const TypePtr* type);
1995 
1996   // static const TypeNarrowKlass *BOTTOM;
1997   static const TypeNarrowKlass *NULL_PTR;
1998 
1999 #ifndef PRODUCT
2000   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
2001 #endif
2002 };
2003 
2004 //------------------------------TypeFunc---------------------------------------
2005 // Class of Array Types
2006 class TypeFunc : public Type {
2007   TypeFunc(const TypeTuple *domain_sig, const TypeTuple *domain_cc, const TypeTuple *range_sig, const TypeTuple *range_cc)
2008     : Type(Function), _domain_sig(domain_sig), _domain_cc(domain_cc), _range_sig(range_sig), _range_cc(range_cc) {}
2009   virtual bool eq( const Type *t ) const;
2010   virtual uint hash() const;             // Type specific hashing
2011   virtual bool singleton(void) const;    // TRUE if type is a singleton
2012   virtual bool empty(void) const;        // TRUE if type is vacuous
2013 
2014   // Domains of inputs: inline type arguments are not passed by
2015   // reference, instead each field of the inline type is passed as an
2016   // argument. We maintain 2 views of the argument list here: one
2017   // based on the signature (with an inline type argument as a single
2018   // slot), one based on the actual calling convention (with a value
2019   // type argument as a list of its fields).
2020   const TypeTuple* const _domain_sig;
2021   const TypeTuple* const _domain_cc;
2022   // Range of results. Similar to domains: an inline type result can be
2023   // returned in registers in which case range_cc lists all fields and
2024   // is the actual calling convention.
2025   const TypeTuple* const _range_sig;
2026   const TypeTuple* const _range_cc;
2027 
2028 public:
2029   // Constants are shared among ADLC and VM
2030   enum { Control    = AdlcVMDeps::Control,
2031          I_O        = AdlcVMDeps::I_O,
2032          Memory     = AdlcVMDeps::Memory,
2033          FramePtr   = AdlcVMDeps::FramePtr,
2034          ReturnAdr  = AdlcVMDeps::ReturnAdr,
2035          Parms      = AdlcVMDeps::Parms
2036   };
2037 
2038 
2039   // Accessors:
2040   const TypeTuple* domain_sig() const { return _domain_sig; }
2041   const TypeTuple* domain_cc()  const { return _domain_cc; }
2042   const TypeTuple* range_sig()  const { return _range_sig; }
2043   const TypeTuple* range_cc()   const { return _range_cc; }
2044 
2045   static const TypeFunc* make(ciMethod* method, bool is_osr_compilation = false);
2046   static const TypeFunc *make(const TypeTuple* domain_sig, const TypeTuple* domain_cc,
2047                               const TypeTuple* range_sig, const TypeTuple* range_cc);
2048   static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
2049 
2050   virtual const Type *xmeet( const Type *t ) const;
2051   virtual const Type *xdual() const;    // Compute dual right now.
2052 
2053   BasicType return_type() const;
2054 
2055   bool returns_inline_type_as_fields() const { return range_sig() != range_cc(); }
2056 
2057 #ifndef PRODUCT
2058   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
2059 #endif
2060   // Convenience common pre-built types.
2061 };
2062 
2063 //------------------------------accessors--------------------------------------
2064 inline bool Type::is_ptr_to_narrowoop() const {
2065 #ifdef _LP64
2066   return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowoop_nv());
2067 #else
2068   return false;
2069 #endif
2070 }
2071 
2072 inline bool Type::is_ptr_to_narrowklass() const {
2073 #ifdef _LP64
2074   return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowklass_nv());
2075 #else
2076   return false;

2292   return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->isa_oopptr() : isa_oopptr();
2293 }
2294 
2295 inline const TypeNarrowOop* Type::make_narrowoop() const {
2296   return (_base == NarrowOop) ? is_narrowoop() :
2297                                 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : nullptr);
2298 }
2299 
2300 inline const TypeNarrowKlass* Type::make_narrowklass() const {
2301   return (_base == NarrowKlass) ? is_narrowklass() :
2302                                   (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : nullptr);
2303 }
2304 
2305 inline bool Type::is_floatingpoint() const {
2306   if( (_base == FloatCon)  || (_base == FloatBot) ||
2307       (_base == DoubleCon) || (_base == DoubleBot) )
2308     return true;
2309   return false;
2310 }
2311 
2312 inline bool Type::is_inlinetypeptr() const {
2313   return isa_instptr() != nullptr && is_instptr()->instance_klass()->is_inlinetype();
2314 }
2315 
2316 inline ciInlineKlass* Type::inline_klass() const {
2317   return make_ptr()->is_instptr()->instance_klass()->as_inline_klass();
2318 }
2319 
2320 
2321 // ===============================================================
2322 // Things that need to be 64-bits in the 64-bit build but
2323 // 32-bits in the 32-bit build.  Done this way to get full
2324 // optimization AND strong typing.
2325 #ifdef _LP64
2326 
2327 // For type queries and asserts
2328 #define is_intptr_t  is_long
2329 #define isa_intptr_t isa_long
2330 #define find_intptr_t_type find_long_type
2331 #define find_intptr_t_con  find_long_con
2332 #define TypeX        TypeLong
2333 #define Type_X       Type::Long
2334 #define TypeX_X      TypeLong::LONG
2335 #define TypeX_ZERO   TypeLong::ZERO
2336 // For 'ideal_reg' machine registers
2337 #define Op_RegX      Op_RegL
2338 // For phase->intcon variants
2339 #define MakeConX     longcon
2340 #define ConXNode     ConLNode
2341 // For array index arithmetic
2342 #define MulXNode     MulLNode
2343 #define AndXNode     AndLNode
2344 #define OrXNode      OrLNode
2345 #define CmpXNode     CmpLNode
2346 #define CmpUXNode    CmpULNode
2347 #define SubXNode     SubLNode
2348 #define LShiftXNode  LShiftLNode
2349 // For object size computation:
2350 #define AddXNode     AddLNode
2351 #define RShiftXNode  RShiftLNode
2352 // For card marks and hashcodes
2353 #define URShiftXNode URShiftLNode
2354 // For shenandoahSupport
2355 #define LoadXNode    LoadLNode
2356 #define StoreXNode   StoreLNode
2357 // Opcodes
2358 #define Op_LShiftX   Op_LShiftL
2359 #define Op_AndX      Op_AndL
2360 #define Op_AddX      Op_AddL
2361 #define Op_SubX      Op_SubL
2362 #define Op_XorX      Op_XorL
2363 #define Op_URShiftX  Op_URShiftL
2364 #define Op_LoadX     Op_LoadL
2365 #define Op_StoreX    Op_StoreL
2366 // conversions
2367 #define ConvI2X(x)   ConvI2L(x)
2368 #define ConvL2X(x)   (x)
2369 #define ConvX2I(x)   ConvL2I(x)
2370 #define ConvX2L(x)   (x)
2371 #define ConvX2UL(x)  (x)
2372 
2373 #else
2374 
2375 // For type queries and asserts
2376 #define is_intptr_t  is_int
2377 #define isa_intptr_t isa_int
2378 #define find_intptr_t_type find_int_type
2379 #define find_intptr_t_con  find_int_con
2380 #define TypeX        TypeInt
2381 #define Type_X       Type::Int
2382 #define TypeX_X      TypeInt::INT
2383 #define TypeX_ZERO   TypeInt::ZERO
2384 // For 'ideal_reg' machine registers
2385 #define Op_RegX      Op_RegI
2386 // For phase->intcon variants
2387 #define MakeConX     intcon
2388 #define ConXNode     ConINode
2389 // For array index arithmetic
2390 #define MulXNode     MulINode
2391 #define AndXNode     AndINode
2392 #define OrXNode      OrINode
2393 #define CmpXNode     CmpINode
2394 #define CmpUXNode    CmpUNode
2395 #define SubXNode     SubINode
2396 #define LShiftXNode  LShiftINode
2397 // For object size computation:
2398 #define AddXNode     AddINode
2399 #define RShiftXNode  RShiftINode
2400 // For card marks and hashcodes
2401 #define URShiftXNode URShiftINode
2402 // For shenandoahSupport
2403 #define LoadXNode    LoadINode
2404 #define StoreXNode   StoreINode
2405 // Opcodes
2406 #define Op_LShiftX   Op_LShiftI
2407 #define Op_AndX      Op_AndI
2408 #define Op_AddX      Op_AddI
2409 #define Op_SubX      Op_SubI
2410 #define Op_XorX      Op_XorI
2411 #define Op_URShiftX  Op_URShiftI
2412 #define Op_LoadX     Op_LoadI
2413 #define Op_StoreX    Op_StoreI
2414 // conversions
2415 #define ConvI2X(x)   (x)
2416 #define ConvL2X(x)   ConvL2I(x)
2417 #define ConvX2I(x)   (x)
2418 #define ConvX2L(x)   ConvI2L(x)
2419 #define ConvX2UL(x)  ConvI2UL(x)
2420 
2421 #endif
2422 
2423 #endif // SHARE_OPTO_TYPE_HPP
< prev index next >