< 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;
  50 class     TypeLong;
  51 class   TypeNarrowPtr;
  52 class     TypeNarrowOop;
  53 class     TypeNarrowKlass;
  54 class   TypeAry;
  55 class   TypeTuple;

  56 class   TypeVect;
  57 class     TypeVectA;
  58 class     TypeVectS;
  59 class     TypeVectD;
  60 class     TypeVectX;
  61 class     TypeVectY;
  62 class     TypeVectZ;
  63 class     TypeVectMask;
  64 class   TypePtr;
  65 class     TypeRawPtr;
  66 class     TypeOopPtr;
  67 class       TypeInstPtr;
  68 class       TypeAryPtr;
  69 class     TypeKlassPtr;
  70 class       TypeInstKlassPtr;
  71 class       TypeAryKlassPtr;
  72 class     TypeMetadataPtr;
  73 
  74 //------------------------------Type-------------------------------------------
  75 // Basic Type object, represents a set of primitive Values.

  83   enum TYPES {
  84     Bad=0,                      // Type check
  85     Control,                    // Control of code (not in lattice)
  86     Top,                        // Top of the lattice
  87     Int,                        // Integer range (lo-hi)
  88     Long,                       // Long integer range (lo-hi)
  89     Half,                       // Placeholder half of doubleword
  90     NarrowOop,                  // Compressed oop pointer
  91     NarrowKlass,                // Compressed klass pointer
  92 
  93     Tuple,                      // Method signature or object layout
  94     Array,                      // Array types
  95 
  96     VectorMask,                 // Vector predicate/mask type
  97     VectorA,                    // (Scalable) Vector types for vector length agnostic
  98     VectorS,                    //  32bit Vector types
  99     VectorD,                    //  64bit Vector types
 100     VectorX,                    // 128bit Vector types
 101     VectorY,                    // 256bit Vector types
 102     VectorZ,                    // 512bit Vector types

 103 
 104     AnyPtr,                     // Any old raw, klass, inst, or array pointer
 105     RawPtr,                     // Raw (non-oop) pointers
 106     OopPtr,                     // Any and all Java heap entities
 107     InstPtr,                    // Instance pointers (non-array objects)
 108     AryPtr,                     // Array pointers
 109     // (Ptr order matters:  See is_ptr, isa_ptr, is_oopptr, isa_oopptr.)
 110 
 111     MetadataPtr,                // Generic metadata
 112     KlassPtr,                   // Klass pointers
 113     InstKlassPtr,
 114     AryKlassPtr,
 115 
 116     Function,                   // Function signature
 117     Abio,                       // Abstract I/O
 118     Return_Address,             // Subroutine return address
 119     Memory,                     // Abstract store
 120     FloatTop,                   // No float value
 121     FloatCon,                   // Floating point constant
 122     FloatBot,                   // Any float value
 123     DoubleTop,                  // No double value
 124     DoubleCon,                  // Double precision constant
 125     DoubleBot,                  // Any double value
 126     Bottom,                     // Bottom of lattice
 127     lastype                     // Bogus ending type (not in lattice)
 128   };
 129 
 130   // Signal values for offsets from a base pointer
 131   enum OFFSET_SIGNALS {
 132     OffsetTop = -2000000000,    // undefined offset
 133     OffsetBot = -2000000001     // any possible offset
 134   };
 135 
























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

 300   const TypeAry    *is_ary() const;              // Array, NOT array pointer
 301   const TypeAry    *isa_ary() const;             // Returns NULL of not ary
 302   const TypeVect   *is_vect() const;             // Vector
 303   const TypeVect   *isa_vect() const;            // Returns NULL if not a Vector
 304   const TypeVectMask *is_vectmask() const;       // Predicate/Mask Vector
 305   const TypeVectMask *isa_vectmask() const;      // Returns NULL if not a Vector Predicate/Mask
 306   const TypePtr    *is_ptr() const;              // Asserts it is a ptr type
 307   const TypePtr    *isa_ptr() const;             // Returns NULL if not ptr type
 308   const TypeRawPtr *isa_rawptr() const;          // NOT Java oop
 309   const TypeRawPtr *is_rawptr() const;           // Asserts is rawptr
 310   const TypeNarrowOop  *is_narrowoop() const;    // Java-style GC'd pointer
 311   const TypeNarrowOop  *isa_narrowoop() const;   // Returns NULL if not oop ptr type
 312   const TypeNarrowKlass *is_narrowklass() const; // compressed klass pointer
 313   const TypeNarrowKlass *isa_narrowklass() const;// Returns NULL if not oop ptr type
 314   const TypeOopPtr   *isa_oopptr() const;        // Returns NULL if not oop ptr type
 315   const TypeOopPtr   *is_oopptr() const;         // Java-style GC'd pointer
 316   const TypeInstPtr  *isa_instptr() const;       // Returns NULL if not InstPtr
 317   const TypeInstPtr  *is_instptr() const;        // Instance
 318   const TypeAryPtr   *isa_aryptr() const;        // Returns NULL if not AryPtr
 319   const TypeAryPtr   *is_aryptr() const;         // Array oop


 320 
 321   const TypeMetadataPtr   *isa_metadataptr() const;   // Returns NULL if not oop ptr type
 322   const TypeMetadataPtr   *is_metadataptr() const;    // Java-style GC'd pointer
 323   const TypeKlassPtr      *isa_klassptr() const;      // Returns NULL if not KlassPtr
 324   const TypeKlassPtr      *is_klassptr() const;       // assert if not KlassPtr
 325   const TypeInstKlassPtr  *isa_instklassptr() const;  // Returns NULL if not IntKlassPtr
 326   const TypeInstKlassPtr  *is_instklassptr() const;   // assert if not IntKlassPtr
 327   const TypeAryKlassPtr   *isa_aryklassptr() const;   // Returns NULL if not AryKlassPtr
 328   const TypeAryKlassPtr   *is_aryklassptr() const;    // assert if not AryKlassPtr
 329 
 330   virtual bool      is_finite() const;           // Has a finite value
 331   virtual bool      is_nan()    const;           // Is not a number (NaN)
 332 



 333   // Returns this ptr type or the equivalent ptr type for this compressed pointer.
 334   const TypePtr* make_ptr() const;
 335 
 336   // Returns this oopptr type or the equivalent oopptr type for this compressed pointer.
 337   // Asserts if the underlying type is not an oopptr or narrowoop.
 338   const TypeOopPtr* make_oopptr() const;
 339 
 340   // Returns this compressed pointer or the equivalent compressed version
 341   // of this pointer type.
 342   const TypeNarrowOop* make_narrowoop() const;
 343 
 344   // Returns this compressed klass pointer or the equivalent
 345   // compressed version of this pointer type.
 346   const TypeNarrowKlass* make_narrowklass() const;
 347 
 348   // Special test for register pressure heuristic
 349   bool is_floatingpoint() const;        // True if Float or Double base type
 350 
 351   // Do you have memory, directly or through a tuple?
 352   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 int  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);
 728   static const TypeTuple *make_domain(ciInstanceKlass* recv, ciSignature *sig);
 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 int  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 #ifdef ASSERT
 780   // One type is interface, the other is oop
 781   virtual bool interface_vs_oop(const Type *t) const;
 782 #endif
 783 #ifndef PRODUCT
 784   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 785 #endif
 786 };
 787 







































 788 //------------------------------TypeVect---------------------------------------
 789 // Class of Vector Types
 790 class TypeVect : public Type {
 791   const Type*   _elem;  // Vector's element type
 792   const uint  _length;  // Elements in vector (power of 2)
 793 
 794 protected:
 795   TypeVect(TYPES t, const Type* elem, uint length) : Type(t),
 796     _elem(elem), _length(length) {}
 797 
 798 public:
 799   const Type* element_type() const { return _elem; }
 800   BasicType element_basic_type() const { return _elem->array_element_basic_type(); }
 801   uint length() const { return _length; }
 802   uint length_in_bytes() const {
 803    return _length * type2aelembytes(element_basic_type());
 804   }
 805 
 806   virtual bool eq(const Type *t) const;
 807   virtual int  hash() const;             // Type specific hashing

 871 class TypeVectMask : public TypeVect {
 872 public:
 873   friend class TypeVect;
 874   TypeVectMask(const Type* elem, uint length) : TypeVect(VectorMask, elem, length) {}
 875   virtual bool eq(const Type *t) const;
 876   virtual const Type *xdual() const;
 877   static const TypeVectMask* make(const BasicType elem_bt, uint length);
 878   static const TypeVectMask* make(const Type* elem, uint length);
 879 };
 880 
 881 //------------------------------TypePtr----------------------------------------
 882 // Class of machine Pointer Types: raw data, instances or arrays.
 883 // If the _base enum is AnyPtr, then this refers to all of the above.
 884 // Otherwise the _base will indicate which subset of pointers is affected,
 885 // and the class will be inherited from.
 886 class TypePtr : public Type {
 887   friend class TypeNarrowPtr;
 888 public:
 889   enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
 890 protected:
 891   TypePtr(TYPES t, PTR ptr, int offset,
 892           const TypePtr* speculative = NULL,
 893           int inline_depth = InlineDepthBottom) :
 894     Type(t), _speculative(speculative), _inline_depth(inline_depth), _offset(offset),
 895     _ptr(ptr) {}
 896   static const PTR ptr_meet[lastPTR][lastPTR];
 897   static const PTR ptr_dual[lastPTR];
 898   static const char * const ptr_msg[lastPTR];
 899 
 900   enum {
 901     InlineDepthBottom = INT_MAX,
 902     InlineDepthTop = -InlineDepthBottom
 903   };
 904 
 905   // Extra type information profiling gave us. We propagate it the
 906   // same way the rest of the type info is propagated. If we want to
 907   // use it, then we have to emit a guard: this part of the type is
 908   // not something we know but something we speculate about the type.
 909   const TypePtr*   _speculative;
 910   // For speculative types, we record at what inlining depth the
 911   // profiling point that provided the data is. We want to favor

 928   int dual_inline_depth() const;
 929   int meet_inline_depth(int depth) const;
 930 #ifndef PRODUCT
 931   void dump_inline_depth(outputStream *st) const;
 932 #endif
 933 
 934   // TypeInstPtr (TypeAryPtr resp.) and TypeInstKlassPtr (TypeAryKlassPtr resp.) implement very similar meet logic.
 935   // The logic for meeting 2 instances (2 arrays resp.) is shared in the 2 utility methods below. However the logic for
 936   // the oop and klass versions can be slightly different and extra logic may have to be executed depending on what
 937   // exact case the meet falls into. The MeetResult struct is used by the utility methods to communicate what case was
 938   // encountered so the right logic specific to klasses or oops can be executed.,
 939   enum MeetResult {
 940     QUICK,
 941     UNLOADED,
 942     SUBTYPE,
 943     NOT_SUBTYPE,
 944     LCA
 945   };
 946   static MeetResult
 947   meet_instptr(PTR &ptr, ciKlass* this_klass, ciKlass* tinst_klass, bool this_xk, bool tinst_xk, PTR this_ptr,
 948                PTR tinst_ptr, ciKlass*&res_klass, bool &res_xk);
 949   static MeetResult
 950   meet_aryptr(PTR& ptr, const Type*& elem, ciKlass* this_klass, ciKlass* tap_klass, bool this_xk, bool tap_xk, PTR this_ptr, PTR tap_ptr, ciKlass*& res_klass, bool& res_xk);




 951 
 952 public:
 953   const int _offset;            // Offset into oop, with TOP & BOT
 954   const PTR _ptr;               // Pointer equivalence class
 955 
 956   const int offset() const { return _offset; }
 957   const PTR ptr()    const { return _ptr; }
 958 
 959   static const TypePtr *make(TYPES t, PTR ptr, int offset,
 960                              const TypePtr* speculative = NULL,
 961                              int inline_depth = InlineDepthBottom);
 962 
 963   // Return a 'ptr' version of this type
 964   virtual const TypePtr* cast_to_ptr_type(PTR ptr) const;
 965 
 966   virtual intptr_t get_con() const;
 967 
 968   int xadd_offset( intptr_t offset ) const;
 969   virtual const TypePtr* add_offset(intptr_t offset) const;
 970   virtual const TypePtr* with_offset(intptr_t offset) const;

 971   virtual bool eq(const Type *t) const;
 972   virtual int  hash() const;             // Type specific hashing
 973 
 974   virtual bool singleton(void) const;    // TRUE if type is a singleton
 975   virtual bool empty(void) const;        // TRUE if type is vacuous
 976   virtual const Type *xmeet( const Type *t ) const;
 977   virtual const Type *xmeet_helper( const Type *t ) const;
 978   int meet_offset( int offset ) const;
 979   int dual_offset( ) const;
 980   virtual const Type *xdual() const;    // Compute dual right now.
 981 
 982   // meet, dual and join over pointer equivalence sets
 983   PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
 984   PTR dual_ptr()                   const { return ptr_dual[ptr()];      }
 985 
 986   // This is textually confusing unless one recalls that
 987   // join(t) == dual()->meet(t->dual())->dual().
 988   PTR join_ptr( const PTR in_ptr ) const {
 989     return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
 990   }
 991 
 992   // Speculative type helper methods.
 993   virtual const TypePtr* speculative() const { return _speculative; }
 994   int inline_depth() const                   { return _inline_depth; }
 995   virtual ciKlass* speculative_type() const;
 996   virtual ciKlass* speculative_type_not_null() const;
 997   virtual bool speculative_maybe_null() const;
 998   virtual bool speculative_always_null() const;
 999   virtual const TypePtr* remove_speculative() const;
1000   virtual const Type* cleanup_speculative() const;
1001   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1002   virtual bool would_improve_ptr(ProfilePtrKind maybe_null) const;
1003   virtual const TypePtr* with_inline_depth(int depth) const;
1004 
1005   virtual bool maybe_null() const { return meet_ptr(Null) == ptr(); }
1006 








1007   // Tests for relation to centerline of type lattice:
1008   static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
1009   static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
1010   // Convenience common pre-built types.
1011   static const TypePtr *NULL_PTR;
1012   static const TypePtr *NOTNULL;
1013   static const TypePtr *BOTTOM;
1014 #ifndef PRODUCT
1015   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1016 #endif
1017 };
1018 
1019 //------------------------------TypeRawPtr-------------------------------------
1020 // Class of raw pointers, pointers to things other than Oops.  Examples
1021 // include the stack pointer, top of heap, card-marking area, handles, etc.
1022 class TypeRawPtr : public TypePtr {
1023 protected:
1024   TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){}
1025 public:
1026   virtual bool eq( const Type *t ) const;
1027   virtual int  hash() const;     // Type specific hashing
1028 
1029   const address _bits;          // Constant value, if applicable
1030 
1031   static const TypeRawPtr *make( PTR ptr );
1032   static const TypeRawPtr *make( address bits );
1033 
1034   // Return a 'ptr' version of this type
1035   virtual const TypeRawPtr* cast_to_ptr_type(PTR ptr) const;
1036 
1037   virtual intptr_t get_con() const;
1038 
1039   virtual const TypePtr* add_offset(intptr_t offset) const;
1040   virtual const TypeRawPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return NULL;}
1041 
1042   virtual const Type *xmeet( const Type *t ) const;
1043   virtual const Type *xdual() const;    // Compute dual right now.
1044   // Convenience common pre-built types.
1045   static const TypeRawPtr *BOTTOM;
1046   static const TypeRawPtr *NOTNULL;
1047 #ifndef PRODUCT
1048   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1049 #endif
1050 };
1051 
1052 //------------------------------TypeOopPtr-------------------------------------
1053 // Some kind of oop (Java pointer), either instance or array.
1054 class TypeOopPtr : public TypePtr {
1055   friend class TypeAry;
1056   friend class TypePtr;
1057   friend class TypeInstPtr;
1058   friend class TypeAryPtr;
1059 protected:
1060   TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id,
1061              const TypePtr* speculative, int inline_depth);
1062 public:
1063   virtual bool eq( const Type *t ) const;
1064   virtual int  hash() const;             // Type specific hashing
1065   virtual bool singleton(void) const;    // TRUE if type is a singleton
1066   enum {
1067    InstanceTop = -1,   // undefined instance
1068    InstanceBot = 0     // any possible instance
1069   };
1070 protected:
1071 
1072   // Oop is NULL, unless this is a constant oop.
1073   ciObject*     _const_oop;   // Constant oop
1074   // If _klass is NULL, then so is _sig.  This is an unloaded klass.
1075   ciKlass*      _klass;       // Klass object
1076   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
1077   bool          _klass_is_exact;
1078   bool          _is_ptr_to_narrowoop;
1079   bool          _is_ptr_to_narrowklass;
1080   bool          _is_ptr_to_boxed_value;
1081 
1082   // If not InstanceTop or InstanceBot, indicates that this is
1083   // a particular instance of this type which is distinct.
1084   // This is the node index of the allocation node creating this instance.
1085   int           _instance_id;
1086 
1087   static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
1088 
1089   int dual_instance_id() const;
1090   int meet_instance_id(int uid) const;
1091 
1092   // Do not allow interface-vs.-noninterface joins to collapse to top.
1093   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1094 
1095   virtual ciKlass* exact_klass_helper() const { return NULL; }
1096   virtual ciKlass* klass() const { return _klass;     }
1097 
1098 public:
1099 
1100   bool is_java_subtype_of(const TypeOopPtr* other) const {
1101     return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1102   }
1103   virtual bool is_same_java_type_as(const TypeOopPtr* other) const { ShouldNotReachHere(); return false; }
1104   bool maybe_java_subtype_of(const TypeOopPtr* other) const {
1105     return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1106   }
1107   virtual bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1108   virtual bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1109 
1110 
1111   // Creates a type given a klass. Correctly handles multi-dimensional arrays
1112   // Respects UseUniqueSubclasses.
1113   // If the klass is final, the resulting type will be exact.
1114   static const TypeOopPtr* make_from_klass(ciKlass* klass) {
1115     return make_from_klass_common(klass, true, false);
1116   }
1117   // Same as before, but will produce an exact type, even if
1118   // the klass is not final, as long as it has exactly one implementation.
1119   static const TypeOopPtr* make_from_klass_unique(ciKlass* klass) {
1120     return make_from_klass_common(klass, true, true);
1121   }
1122   // Same as before, but does not respects UseUniqueSubclasses.
1123   // Use this only for creating array element types.
1124   static const TypeOopPtr* make_from_klass_raw(ciKlass* klass) {
1125     return make_from_klass_common(klass, false, false);
1126   }
1127   // Creates a singleton type given an object.
1128   // If the object cannot be rendered as a constant,
1129   // may return a non-singleton type.
1130   // If require_constant, produce a NULL if a singleton is not possible.
1131   static const TypeOopPtr* make_from_constant(ciObject* o,
1132                                               bool require_constant = false);
1133 
1134   // Make a generic (unclassed) pointer to an oop.
1135   static const TypeOopPtr* make(PTR ptr, int offset, int instance_id,
1136                                 const TypePtr* speculative = NULL,
1137                                 int inline_depth = InlineDepthBottom);
1138 
1139   ciObject* const_oop()    const { return _const_oop; }
1140   // Exact klass, possibly an interface or an array of interface
1141   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != NULL || maybe_null, ""); return k;  }
1142   ciKlass* unloaded_klass() const { assert(!is_loaded(), "only for unloaded types"); return klass(); }
1143 
1144   virtual bool  is_loaded() const { return klass()->is_loaded(); }
1145   bool klass_is_exact()    const { return _klass_is_exact; }
1146 
1147   // Returns true if this pointer points at memory which contains a
1148   // compressed oop references.
1149   bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
1150   bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
1151   bool is_ptr_to_boxed_value()   const { return _is_ptr_to_boxed_value; }
1152   bool is_known_instance()       const { return _instance_id > 0; }
1153   int  instance_id()             const { return _instance_id; }
1154   bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }



1155 
1156   virtual intptr_t get_con() const;
1157 
1158   virtual const TypeOopPtr* cast_to_ptr_type(PTR ptr) const;
1159 
1160   virtual const TypeOopPtr* cast_to_exactness(bool klass_is_exact) const;
1161 
1162   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1163 
1164   // corresponding pointer to klass, for a given instance
1165   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1166 
1167   virtual const TypeOopPtr* with_offset(intptr_t offset) const;
1168   virtual const TypePtr* add_offset(intptr_t offset) const;
1169 
1170   // Speculative type helper methods.
1171   virtual const TypeOopPtr* remove_speculative() const;
1172   virtual const Type* cleanup_speculative() const;
1173   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1174   virtual const TypePtr* with_inline_depth(int depth) const;
1175 
1176   virtual const TypePtr* with_instance_id(int instance_id) const;
1177 
1178   virtual const Type *xdual() const;    // Compute dual right now.
1179   // the core of the computation of the meet for TypeOopPtr and for its subclasses
1180   virtual const Type *xmeet_helper(const Type *t) const;
1181 
1182   // Convenience common pre-built type.
1183   static const TypeOopPtr *BOTTOM;
1184 #ifndef PRODUCT
1185   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1186 #endif
1187 };
1188 
1189 //------------------------------TypeInstPtr------------------------------------
1190 // Class of Java object pointers, pointing either to non-array Java instances
1191 // or to a Klass* (including array klasses).
1192 class TypeInstPtr : public TypeOopPtr {
1193   TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id,
1194               const TypePtr* speculative, int inline_depth);

1195   virtual bool eq( const Type *t ) const;
1196   virtual int  hash() const;             // Type specific hashing
1197 

1198   ciKlass* exact_klass_helper() const;
1199 
1200 public:
1201 
1202   // Instance klass, ignoring any interface
1203   ciInstanceKlass* instance_klass() const {
1204     if (klass()->is_loaded() && klass()->is_interface()) {
1205       return Compile::current()->env()->Object_klass();
1206     }
1207     return klass()->as_instance_klass();
1208   }
1209 
1210   bool is_same_java_type_as(const TypeOopPtr* other) const;
1211   bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1212   bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1213 
1214   // Make a pointer to a constant oop.
1215   static const TypeInstPtr *make(ciObject* o) {
1216     return make(TypePtr::Constant, o->klass(), true, o, 0, InstanceBot);
1217   }
1218   // Make a pointer to a constant oop with offset.
1219   static const TypeInstPtr *make(ciObject* o, int offset) {
1220     return make(TypePtr::Constant, o->klass(), true, o, offset, InstanceBot);
1221   }
1222 
1223   // Make a pointer to some value of type klass.
1224   static const TypeInstPtr *make(PTR ptr, ciKlass* klass) {
1225     return make(ptr, klass, false, NULL, 0, InstanceBot);
1226   }
1227 
1228   // Make a pointer to some non-polymorphic value of exactly type klass.
1229   static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
1230     return make(ptr, klass, true, NULL, 0, InstanceBot);
1231   }
1232 
1233   // Make a pointer to some value of type klass with offset.
1234   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
1235     return make(ptr, klass, false, NULL, offset, InstanceBot);
1236   }
1237 
1238   // Make a pointer to an oop.
1239   static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset,

1240                                  int instance_id = InstanceBot,
1241                                  const TypePtr* speculative = NULL,
1242                                  int inline_depth = InlineDepthBottom);
1243 
1244   /** Create constant type for a constant boxed value */
1245   const Type* get_const_boxed_value() const;
1246 
1247   // If this is a java.lang.Class constant, return the type for it or NULL.
1248   // Pass to Type::get_const_type to turn it to a type, which will usually
1249   // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
1250   ciType* java_mirror_type() const;
1251 
1252   virtual const TypeInstPtr* cast_to_ptr_type(PTR ptr) const;
1253 
1254   virtual const TypeInstPtr* cast_to_exactness(bool klass_is_exact) const;
1255 
1256   virtual const TypeInstPtr* cast_to_instance_id(int instance_id) const;
1257 
1258   virtual const TypePtr* add_offset(intptr_t offset) const;
1259   virtual const TypeInstPtr* with_offset(intptr_t offset) const;
1260 
1261   // Speculative type helper methods.
1262   virtual const TypeInstPtr* remove_speculative() const;
1263   virtual const TypePtr* with_inline_depth(int depth) const;
1264   virtual const TypePtr* with_instance_id(int instance_id) const;
1265 




1266   // the core of the computation of the meet of 2 types
1267   virtual const Type *xmeet_helper(const Type *t) const;
1268   virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
1269   virtual const Type *xdual() const;    // Compute dual right now.
1270 
1271   const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1272 
1273   bool is_interface() const { return is_loaded() && klass()->is_interface(); }
1274 
1275   // Convenience common pre-built types.
1276   static const TypeInstPtr *NOTNULL;
1277   static const TypeInstPtr *BOTTOM;
1278   static const TypeInstPtr *MIRROR;
1279   static const TypeInstPtr *MARK;
1280   static const TypeInstPtr *KLASS;
1281 #ifndef PRODUCT
1282   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1283 #endif
1284 };
1285 
1286 //------------------------------TypeAryPtr-------------------------------------
1287 // Class of Java array pointers
1288 class TypeAryPtr : public TypeOopPtr {
1289   TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1290               int offset, int instance_id, bool is_autobox_cache,
1291               const TypePtr* speculative, int inline_depth)
1292     : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative, inline_depth),
1293     _ary(ary),
1294     _is_autobox_cache(is_autobox_cache)

1295  {
1296 #ifdef ASSERT
1297     if (k != NULL) {
1298       // Verify that specified klass and TypeAryPtr::klass() follow the same rules.
1299       ciKlass* ck = compute_klass(true);
1300       if (k != ck) {
1301         this->dump(); tty->cr();
1302         tty->print(" k: ");
1303         k->print(); tty->cr();
1304         tty->print("ck: ");
1305         if (ck != NULL) ck->print();
1306         else tty->print("<NULL>");
1307         tty->cr();
1308         assert(false, "unexpected TypeAryPtr::_klass");
1309       }
1310     }
1311 #endif
1312   }
1313   virtual bool eq( const Type *t ) const;
1314   virtual int hash() const;     // Type specific hashing
1315   const TypeAry *_ary;          // Array we point into
1316   const bool     _is_autobox_cache;






1317 
1318   ciKlass* compute_klass(DEBUG_ONLY(bool verify = false)) const;
1319 
1320   ciKlass* exact_klass_helper() const;
1321   ciKlass* klass() const;
1322 
1323 public:
1324 
1325   bool is_same_java_type_as(const TypeOopPtr* other) const;
1326   bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1327   bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1328 
1329   // returns base element type, an instance klass (and not interface) for object arrays
1330   const Type* base_element_type(int& dims) const;
1331 
1332   // Accessors
1333   bool  is_loaded() const { return (_ary->_elem->make_oopptr() ? _ary->_elem->make_oopptr()->is_loaded() : true); }
1334 
1335   const TypeAry* ary() const  { return _ary; }
1336   const Type*    elem() const { return _ary->_elem; }
1337   const TypeInt* size() const { return _ary->_size; }
1338   bool      is_stable() const { return _ary->_stable; }
1339 






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

1343                                 int instance_id = InstanceBot,
1344                                 const TypePtr* speculative = NULL,
1345                                 int inline_depth = InlineDepthBottom);
1346   // Constant pointer to array
1347   static const TypeAryPtr *make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset,

1348                                 int instance_id = InstanceBot,
1349                                 const TypePtr* speculative = NULL,
1350                                 int inline_depth = InlineDepthBottom, bool is_autobox_cache = false);

1351 
1352   // Return a 'ptr' version of this type
1353   virtual const TypeAryPtr* cast_to_ptr_type(PTR ptr) const;
1354 
1355   virtual const TypeAryPtr* cast_to_exactness(bool klass_is_exact) const;
1356 
1357   virtual const TypeAryPtr* cast_to_instance_id(int instance_id) const;
1358 
1359   virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1360   virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1361 
1362   virtual bool empty(void) const;        // TRUE if type is vacuous
1363   virtual const TypePtr *add_offset( intptr_t offset ) const;
1364   virtual const TypeAryPtr *with_offset( intptr_t offset ) const;
1365   const TypeAryPtr* with_ary(const TypeAry* ary) const;
1366 
1367   // Speculative type helper methods.
1368   virtual const TypeAryPtr* remove_speculative() const;

1369   virtual const TypePtr* with_inline_depth(int depth) const;
1370   virtual const TypePtr* with_instance_id(int instance_id) const;
1371 
1372   // the core of the computation of the meet of 2 types
1373   virtual const Type *xmeet_helper(const Type *t) const;
1374   virtual const Type *xdual() const;    // Compute dual right now.
1375 








1376   const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1377   int stable_dimension() const;
1378 
1379   const TypeAryPtr* cast_to_autobox_cache() const;
1380 
1381   static jint max_array_length(BasicType etype) ;







1382   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1383 
1384   // Convenience common pre-built types.
1385   static const TypeAryPtr *RANGE;
1386   static const TypeAryPtr *OOPS;
1387   static const TypeAryPtr *NARROWOOPS;
1388   static const TypeAryPtr *BYTES;
1389   static const TypeAryPtr *SHORTS;
1390   static const TypeAryPtr *CHARS;
1391   static const TypeAryPtr *INTS;
1392   static const TypeAryPtr *LONGS;
1393   static const TypeAryPtr *FLOATS;
1394   static const TypeAryPtr *DOUBLES;

1395   // selects one of the above:
1396   static const TypeAryPtr *get_array_body_type(BasicType elem) {
1397     assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != NULL, "bad elem type");
1398     return _array_body_type[elem];
1399   }
1400   static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1401   // sharpen the type of an int which is used as an array size
1402 #ifdef ASSERT
1403   // One type is interface, the other is oop
1404   virtual bool interface_vs_oop(const Type *t) const;
1405 #endif
1406 #ifndef PRODUCT
1407   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1408 #endif
1409 };
1410 
1411 //------------------------------TypeMetadataPtr-------------------------------------
1412 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
1413 class TypeMetadataPtr : public TypePtr {
1414 protected:
1415   TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset);
1416   // Do not allow interface-vs.-noninterface joins to collapse to top.
1417   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1418 public:
1419   virtual bool eq( const Type *t ) const;
1420   virtual int  hash() const;             // Type specific hashing
1421   virtual bool singleton(void) const;    // TRUE if type is a singleton
1422 
1423 private:
1424   ciMetadata*   _metadata;
1425 
1426 public:
1427   static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, int offset);
1428 
1429   static const TypeMetadataPtr* make(ciMethod* m);
1430   static const TypeMetadataPtr* make(ciMethodData* m);
1431 
1432   ciMetadata* metadata() const { return _metadata; }
1433 
1434   virtual const TypeMetadataPtr* cast_to_ptr_type(PTR ptr) const;
1435 
1436   virtual const TypePtr *add_offset( intptr_t offset ) const;
1437 
1438   virtual const Type *xmeet( const Type *t ) const;
1439   virtual const Type *xdual() const;    // Compute dual right now.
1440 
1441   virtual intptr_t get_con() const;
1442 
1443   // Convenience common pre-built types.
1444   static const TypeMetadataPtr *BOTTOM;
1445 
1446 #ifndef PRODUCT
1447   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1448 #endif
1449 };
1450 
1451 //------------------------------TypeKlassPtr-----------------------------------
1452 // Class of Java Klass pointers
1453 class TypeKlassPtr : public TypePtr {
1454   friend class TypeInstKlassPtr;
1455   friend class TypeAryKlassPtr;
1456 protected:
1457   TypeKlassPtr(TYPES t, PTR ptr, ciKlass* klass, int offset);
1458 
1459   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1460 
1461 public:
1462   virtual bool eq( const Type *t ) const;
1463   virtual int hash() const;
1464   virtual bool singleton(void) const;    // TRUE if type is a singleton
1465 
1466 protected:
1467 
1468   ciKlass* _klass;
1469 
1470   virtual bool must_be_exact() const { ShouldNotReachHere(); return false; }
1471   virtual ciKlass* exact_klass_helper() const;
1472   virtual ciKlass* klass() const { return  _klass; }
1473 
1474 public:
1475 
1476   bool is_java_subtype_of(const TypeKlassPtr* other) const {
1477     return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1478   }
1479   bool maybe_java_subtype_of(const TypeKlassPtr* other) const {
1480     return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1481   }
1482   virtual bool is_same_java_type_as(const TypeKlassPtr* other) const { ShouldNotReachHere(); return false; }
1483   virtual bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1484   virtual bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1485 
1486   // Exact klass, possibly an interface or an array of interface
1487   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != NULL || maybe_null, ""); return k;  }
1488 
1489   bool klass_is_exact()    const { return _ptr == Constant; }
1490 
1491   static const TypeKlassPtr* make(ciKlass* klass);
1492   static const TypeKlassPtr *make(PTR ptr, ciKlass* klass, int offset);
1493 
1494   virtual bool  is_loaded() const { return _klass->is_loaded(); }
1495 
1496   virtual const TypeKlassPtr* cast_to_ptr_type(PTR ptr) const { ShouldNotReachHere(); return NULL; }
1497 
1498   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const { ShouldNotReachHere(); return NULL; }
1499 
1500   // corresponding pointer to instance, for a given class
1501   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const { ShouldNotReachHere(); return NULL; }
1502 
1503   virtual const TypePtr *add_offset( intptr_t offset ) const { ShouldNotReachHere(); return NULL; }
1504   virtual const Type    *xmeet( const Type *t ) const { ShouldNotReachHere(); return NULL; }
1505   virtual const Type    *xdual() const { ShouldNotReachHere(); return NULL; }
1506 
1507   virtual intptr_t get_con() const;
1508 
1509   virtual const TypeKlassPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return NULL; }
1510 
1511 #ifndef PRODUCT
1512   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1513 #endif
1514 };
1515 
1516 // Instance klass pointer, mirrors TypeInstPtr
1517 class TypeInstKlassPtr : public TypeKlassPtr {
1518 
1519   TypeInstKlassPtr(PTR ptr, ciKlass* klass, int offset)
1520     : TypeKlassPtr(InstKlassPtr, ptr, klass, offset) {
1521   }
1522 
1523   virtual bool must_be_exact() const;
1524 


1525 public:
1526   // Instance klass ignoring any interface
1527   ciInstanceKlass* instance_klass() const {
1528     if (klass()->is_interface()) {
1529       return Compile::current()->env()->Object_klass();
1530     }
1531     return klass()->as_instance_klass();
1532   }
1533 
1534   bool is_same_java_type_as(const TypeKlassPtr* other) const;
1535   bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1536   bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1537 


1538   static const TypeInstKlassPtr *make(ciKlass* k) {
1539     return make(TypePtr::Constant, k, 0);
1540   }
1541   static const TypeInstKlassPtr *make(PTR ptr, ciKlass* k, int offset);
1542 
1543   virtual const TypeInstKlassPtr* cast_to_ptr_type(PTR ptr) const;
1544 
1545   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1546 
1547   // corresponding pointer to instance, for a given class
1548   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
1549   virtual int hash() const;
1550   virtual bool eq(const Type *t) const;
1551 
1552   virtual const TypePtr *add_offset( intptr_t offset ) const;
1553   virtual const Type    *xmeet( const Type *t ) const;
1554   virtual const Type    *xdual() const;
1555   virtual const TypeInstKlassPtr* with_offset(intptr_t offset) const;
1556 
1557   bool is_interface() const { return klass()->is_interface(); }
1558 



1559   // Convenience common pre-built types.
1560   static const TypeInstKlassPtr* OBJECT; // Not-null object klass or below
1561   static const TypeInstKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same




1562 };
1563 
1564 // Array klass pointer, mirrors TypeAryPtr
1565 class TypeAryKlassPtr : public TypeKlassPtr {
1566   friend class TypeInstKlassPtr;
1567   const Type *_elem;



1568 
1569   TypeAryKlassPtr(PTR ptr, const Type *elem, ciKlass* klass, int offset)
1570     : TypeKlassPtr(AryKlassPtr, ptr, klass, offset), _elem(elem) {
1571   }
1572 
1573   virtual ciKlass* exact_klass_helper() const;
1574   virtual ciKlass* klass() const;
1575 
1576   virtual bool must_be_exact() const;
1577 








1578 public:
1579 
1580   // returns base element type, an instance klass (and not interface) for object arrays
1581   const Type* base_element_type(int& dims) const;
1582 
1583   static const TypeAryKlassPtr *make(PTR ptr, ciKlass* k, int offset);
1584 
1585   bool is_same_java_type_as(const TypeKlassPtr* other) const;
1586   bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1587   bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1588 
1589   bool  is_loaded() const { return (_elem->isa_klassptr() ? _elem->is_klassptr()->is_loaded() : true); }
1590 
1591   static const TypeAryKlassPtr *make(PTR ptr, const Type *elem, ciKlass* k, int offset);

1592   static const TypeAryKlassPtr* make(ciKlass* klass);
1593 
1594   const Type *elem() const { return _elem; }
1595 
1596   virtual bool eq(const Type *t) const;
1597   virtual int hash() const;             // Type specific hashing
1598 
1599   virtual const TypeAryKlassPtr* cast_to_ptr_type(PTR ptr) const;
1600 
1601   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1602 
1603   // corresponding pointer to instance, for a given class
1604   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
1605 
1606   virtual const TypePtr *add_offset( intptr_t offset ) const;
1607   virtual const Type    *xmeet( const Type *t ) const;
1608   virtual const Type    *xdual() const;      // Compute dual right now.
1609 
1610   virtual const TypeAryKlassPtr* with_offset(intptr_t offset) const;
1611 
1612   virtual bool empty(void) const {
1613     return TypeKlassPtr::empty() || _elem->empty();
1614   }
1615 





1616 #ifndef PRODUCT
1617   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1618 #endif
1619 };
1620 
1621 class TypeNarrowPtr : public Type {
1622 protected:
1623   const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
1624 
1625   TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): Type(t),
1626                                                   _ptrtype(ptrtype) {
1627     assert(ptrtype->offset() == 0 ||
1628            ptrtype->offset() == OffsetBot ||
1629            ptrtype->offset() == OffsetTop, "no real offsets");
1630   }
1631 
1632   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
1633   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;
1634   virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const = 0;
1635   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const = 0;

1729   }
1730 
1731   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
1732     return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
1733   }
1734 
1735 public:
1736   static const TypeNarrowKlass *make( const TypePtr* type);
1737 
1738   // static const TypeNarrowKlass *BOTTOM;
1739   static const TypeNarrowKlass *NULL_PTR;
1740 
1741 #ifndef PRODUCT
1742   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1743 #endif
1744 };
1745 
1746 //------------------------------TypeFunc---------------------------------------
1747 // Class of Array Types
1748 class TypeFunc : public Type {
1749   TypeFunc( const TypeTuple *domain, const TypeTuple *range ) : Type(Function),  _domain(domain), _range(range) {}

1750   virtual bool eq( const Type *t ) const;
1751   virtual int  hash() const;             // Type specific hashing
1752   virtual bool singleton(void) const;    // TRUE if type is a singleton
1753   virtual bool empty(void) const;        // TRUE if type is vacuous
1754 
1755   const TypeTuple* const _domain;     // Domain of inputs
1756   const TypeTuple* const _range;      // Range of results











1757 
1758 public:
1759   // Constants are shared among ADLC and VM
1760   enum { Control    = AdlcVMDeps::Control,
1761          I_O        = AdlcVMDeps::I_O,
1762          Memory     = AdlcVMDeps::Memory,
1763          FramePtr   = AdlcVMDeps::FramePtr,
1764          ReturnAdr  = AdlcVMDeps::ReturnAdr,
1765          Parms      = AdlcVMDeps::Parms
1766   };
1767 
1768 
1769   // Accessors:
1770   const TypeTuple* domain() const { return _domain; }
1771   const TypeTuple* range()  const { return _range; }
1772 
1773   static const TypeFunc *make(ciMethod* method);
1774   static const TypeFunc *make(ciSignature signature, const Type* extra);



1775   static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
1776 
1777   virtual const Type *xmeet( const Type *t ) const;
1778   virtual const Type *xdual() const;    // Compute dual right now.
1779 
1780   BasicType return_type() const;
1781 


1782 #ifndef PRODUCT
1783   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1784 #endif
1785   // Convenience common pre-built types.
1786 };
1787 
1788 //------------------------------accessors--------------------------------------
1789 inline bool Type::is_ptr_to_narrowoop() const {
1790 #ifdef _LP64
1791   return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowoop_nv());
1792 #else
1793   return false;
1794 #endif
1795 }
1796 
1797 inline bool Type::is_ptr_to_narrowklass() const {
1798 #ifdef _LP64
1799   return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowklass_nv());
1800 #else
1801   return false;

1933 }
1934 
1935 inline const TypeInstPtr *Type::isa_instptr() const {
1936   return (_base == InstPtr) ? (TypeInstPtr*)this : NULL;
1937 }
1938 
1939 inline const TypeInstPtr *Type::is_instptr() const {
1940   assert( _base == InstPtr, "Not an object pointer" );
1941   return (TypeInstPtr*)this;
1942 }
1943 
1944 inline const TypeAryPtr *Type::isa_aryptr() const {
1945   return (_base == AryPtr) ? (TypeAryPtr*)this : NULL;
1946 }
1947 
1948 inline const TypeAryPtr *Type::is_aryptr() const {
1949   assert( _base == AryPtr, "Not an array pointer" );
1950   return (TypeAryPtr*)this;
1951 }
1952 









1953 inline const TypeNarrowOop *Type::is_narrowoop() const {
1954   // OopPtr is the first and KlassPtr the last, with no non-oops between.
1955   assert(_base == NarrowOop, "Not a narrow oop" ) ;
1956   return (TypeNarrowOop*)this;
1957 }
1958 
1959 inline const TypeNarrowOop *Type::isa_narrowoop() const {
1960   // OopPtr is the first and KlassPtr the last, with no non-oops between.
1961   return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL;
1962 }
1963 
1964 inline const TypeNarrowKlass *Type::is_narrowklass() const {
1965   assert(_base == NarrowKlass, "Not a narrow oop" ) ;
1966   return (TypeNarrowKlass*)this;
1967 }
1968 
1969 inline const TypeNarrowKlass *Type::isa_narrowklass() const {
1970   return (_base == NarrowKlass) ? (TypeNarrowKlass*)this : NULL;
1971 }
1972 

2017   return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->isa_oopptr() : isa_oopptr();
2018 }
2019 
2020 inline const TypeNarrowOop* Type::make_narrowoop() const {
2021   return (_base == NarrowOop) ? is_narrowoop() :
2022                                 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL);
2023 }
2024 
2025 inline const TypeNarrowKlass* Type::make_narrowklass() const {
2026   return (_base == NarrowKlass) ? is_narrowklass() :
2027                                   (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : NULL);
2028 }
2029 
2030 inline bool Type::is_floatingpoint() const {
2031   if( (_base == FloatCon)  || (_base == FloatBot) ||
2032       (_base == DoubleCon) || (_base == DoubleBot) )
2033     return true;
2034   return false;
2035 }
2036 









2037 
2038 // ===============================================================
2039 // Things that need to be 64-bits in the 64-bit build but
2040 // 32-bits in the 32-bit build.  Done this way to get full
2041 // optimization AND strong typing.
2042 #ifdef _LP64
2043 
2044 // For type queries and asserts
2045 #define is_intptr_t  is_long
2046 #define isa_intptr_t isa_long
2047 #define find_intptr_t_type find_long_type
2048 #define find_intptr_t_con  find_long_con
2049 #define TypeX        TypeLong
2050 #define Type_X       Type::Long
2051 #define TypeX_X      TypeLong::LONG
2052 #define TypeX_ZERO   TypeLong::ZERO
2053 // For 'ideal_reg' machine registers
2054 #define Op_RegX      Op_RegL
2055 // For phase->intcon variants
2056 #define MakeConX     longcon
2057 #define ConXNode     ConLNode
2058 // For array index arithmetic
2059 #define MulXNode     MulLNode
2060 #define AndXNode     AndLNode
2061 #define OrXNode      OrLNode
2062 #define CmpXNode     CmpLNode

2063 #define SubXNode     SubLNode
2064 #define LShiftXNode  LShiftLNode
2065 // For object size computation:
2066 #define AddXNode     AddLNode
2067 #define RShiftXNode  RShiftLNode
2068 // For card marks and hashcodes
2069 #define URShiftXNode URShiftLNode
2070 // For shenandoahSupport
2071 #define LoadXNode    LoadLNode
2072 #define StoreXNode   StoreLNode
2073 // Opcodes
2074 #define Op_LShiftX   Op_LShiftL
2075 #define Op_AndX      Op_AndL
2076 #define Op_AddX      Op_AddL
2077 #define Op_SubX      Op_SubL
2078 #define Op_XorX      Op_XorL
2079 #define Op_URShiftX  Op_URShiftL
2080 #define Op_LoadX     Op_LoadL

2081 // conversions
2082 #define ConvI2X(x)   ConvI2L(x)
2083 #define ConvL2X(x)   (x)
2084 #define ConvX2I(x)   ConvL2I(x)
2085 #define ConvX2L(x)   (x)
2086 #define ConvX2UL(x)  (x)
2087 
2088 #else
2089 
2090 // For type queries and asserts
2091 #define is_intptr_t  is_int
2092 #define isa_intptr_t isa_int
2093 #define find_intptr_t_type find_int_type
2094 #define find_intptr_t_con  find_int_con
2095 #define TypeX        TypeInt
2096 #define Type_X       Type::Int
2097 #define TypeX_X      TypeInt::INT
2098 #define TypeX_ZERO   TypeInt::ZERO
2099 // For 'ideal_reg' machine registers
2100 #define Op_RegX      Op_RegI
2101 // For phase->intcon variants
2102 #define MakeConX     intcon
2103 #define ConXNode     ConINode
2104 // For array index arithmetic
2105 #define MulXNode     MulINode
2106 #define AndXNode     AndINode
2107 #define OrXNode      OrINode
2108 #define CmpXNode     CmpINode

2109 #define SubXNode     SubINode
2110 #define LShiftXNode  LShiftINode
2111 // For object size computation:
2112 #define AddXNode     AddINode
2113 #define RShiftXNode  RShiftINode
2114 // For card marks and hashcodes
2115 #define URShiftXNode URShiftINode
2116 // For shenandoahSupport
2117 #define LoadXNode    LoadINode
2118 #define StoreXNode   StoreINode
2119 // Opcodes
2120 #define Op_LShiftX   Op_LShiftI
2121 #define Op_AndX      Op_AndI
2122 #define Op_AddX      Op_AddI
2123 #define Op_SubX      Op_SubI
2124 #define Op_XorX      Op_XorI
2125 #define Op_URShiftX  Op_URShiftI
2126 #define Op_LoadX     Op_LoadI

2127 // conversions
2128 #define ConvI2X(x)   (x)
2129 #define ConvL2X(x)   ConvL2I(x)
2130 #define ConvX2I(x)   (x)
2131 #define ConvX2L(x)   ConvI2L(x)
2132 #define ConvX2UL(x)  ConvI2UL(x)
2133 
2134 #endif
2135 
2136 #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;
  52 class     TypeLong;
  53 class   TypeNarrowPtr;
  54 class     TypeNarrowOop;
  55 class     TypeNarrowKlass;
  56 class   TypeAry;
  57 class   TypeTuple;
  58 class   TypeInlineType;
  59 class   TypeVect;
  60 class     TypeVectA;
  61 class     TypeVectS;
  62 class     TypeVectD;
  63 class     TypeVectX;
  64 class     TypeVectY;
  65 class     TypeVectZ;
  66 class     TypeVectMask;
  67 class   TypePtr;
  68 class     TypeRawPtr;
  69 class     TypeOopPtr;
  70 class       TypeInstPtr;
  71 class       TypeAryPtr;
  72 class     TypeKlassPtr;
  73 class       TypeInstKlassPtr;
  74 class       TypeAryKlassPtr;
  75 class     TypeMetadataPtr;
  76 
  77 //------------------------------Type-------------------------------------------
  78 // Basic Type object, represents a set of primitive Values.

  86   enum TYPES {
  87     Bad=0,                      // Type check
  88     Control,                    // Control of code (not in lattice)
  89     Top,                        // Top of the lattice
  90     Int,                        // Integer range (lo-hi)
  91     Long,                       // Long integer range (lo-hi)
  92     Half,                       // Placeholder half of doubleword
  93     NarrowOop,                  // Compressed oop pointer
  94     NarrowKlass,                // Compressed klass pointer
  95 
  96     Tuple,                      // Method signature or object layout
  97     Array,                      // Array types
  98 
  99     VectorMask,                 // Vector predicate/mask type
 100     VectorA,                    // (Scalable) Vector types for vector length agnostic
 101     VectorS,                    //  32bit Vector types
 102     VectorD,                    //  64bit Vector types
 103     VectorX,                    // 128bit Vector types
 104     VectorY,                    // 256bit Vector types
 105     VectorZ,                    // 512bit Vector types
 106     InlineType,                 // Inline type
 107 
 108     AnyPtr,                     // Any old raw, klass, inst, or array pointer
 109     RawPtr,                     // Raw (non-oop) pointers
 110     OopPtr,                     // Any and all Java heap entities
 111     InstPtr,                    // Instance pointers (non-array objects)
 112     AryPtr,                     // Array pointers
 113     // (Ptr order matters:  See is_ptr, isa_ptr, is_oopptr, isa_oopptr.)
 114 
 115     MetadataPtr,                // Generic metadata
 116     KlassPtr,                   // Klass pointers
 117     InstKlassPtr,
 118     AryKlassPtr,
 119 
 120     Function,                   // Function signature
 121     Abio,                       // Abstract I/O
 122     Return_Address,             // Subroutine return address
 123     Memory,                     // Abstract store
 124     FloatTop,                   // No float value
 125     FloatCon,                   // Floating point constant
 126     FloatBot,                   // Any float value
 127     DoubleTop,                  // No double value
 128     DoubleCon,                  // Double precision constant
 129     DoubleBot,                  // Any double value
 130     Bottom,                     // Bottom of lattice
 131     lastype                     // Bogus ending type (not in lattice)
 132   };
 133 
 134   // Signal values for offsets from a base pointer
 135   enum OFFSET_SIGNALS {
 136     OffsetTop = -2000000000,    // undefined offset
 137     OffsetBot = -2000000001     // any possible offset
 138   };
 139 
 140   class Offset {
 141   private:
 142     int _offset;
 143 
 144   public:
 145     explicit Offset(int offset) : _offset(offset) {}
 146 
 147     const Offset meet(const Offset other) const;
 148     const Offset dual() const;
 149     const Offset add(intptr_t offset) const;
 150     bool operator==(const Offset& other) const {
 151       return _offset == other._offset;
 152     }
 153     bool operator!=(const Offset& other) const {
 154       return _offset != other._offset;
 155     }
 156     int get() const { return _offset; }
 157 
 158     void dump2(outputStream *st) const;
 159 
 160     static const Offset top;
 161     static const Offset bottom;
 162   };
 163 
 164   // Min and max WIDEN values.
 165   enum WIDEN {
 166     WidenMin = 0,
 167     WidenMax = 3
 168   };
 169 
 170 private:
 171   typedef struct {
 172     TYPES                dual_type;
 173     BasicType            basic_type;
 174     const char*          msg;
 175     bool                 isa_oop;
 176     uint                 ideal_reg;
 177     relocInfo::relocType reloc;
 178   } TypeInfo;
 179 
 180   // Dictionary of types shared among compilations.
 181   static Dict* _shared_type_dict;
 182   static const TypeInfo _type_info[];
 183 

 328   const TypeAry    *is_ary() const;              // Array, NOT array pointer
 329   const TypeAry    *isa_ary() const;             // Returns NULL of not ary
 330   const TypeVect   *is_vect() const;             // Vector
 331   const TypeVect   *isa_vect() const;            // Returns NULL if not a Vector
 332   const TypeVectMask *is_vectmask() const;       // Predicate/Mask Vector
 333   const TypeVectMask *isa_vectmask() const;      // Returns NULL if not a Vector Predicate/Mask
 334   const TypePtr    *is_ptr() const;              // Asserts it is a ptr type
 335   const TypePtr    *isa_ptr() const;             // Returns NULL if not ptr type
 336   const TypeRawPtr *isa_rawptr() const;          // NOT Java oop
 337   const TypeRawPtr *is_rawptr() const;           // Asserts is rawptr
 338   const TypeNarrowOop  *is_narrowoop() const;    // Java-style GC'd pointer
 339   const TypeNarrowOop  *isa_narrowoop() const;   // Returns NULL if not oop ptr type
 340   const TypeNarrowKlass *is_narrowklass() const; // compressed klass pointer
 341   const TypeNarrowKlass *isa_narrowklass() const;// Returns NULL if not oop ptr type
 342   const TypeOopPtr   *isa_oopptr() const;        // Returns NULL if not oop ptr type
 343   const TypeOopPtr   *is_oopptr() const;         // Java-style GC'd pointer
 344   const TypeInstPtr  *isa_instptr() const;       // Returns NULL if not InstPtr
 345   const TypeInstPtr  *is_instptr() const;        // Instance
 346   const TypeAryPtr   *isa_aryptr() const;        // Returns NULL if not AryPtr
 347   const TypeAryPtr   *is_aryptr() const;         // Array oop
 348   const TypeInlineType* isa_inlinetype() const;  // Returns NULL if not Inline Type
 349   const TypeInlineType* is_inlinetype() const;   // Inline Type
 350 
 351   const TypeMetadataPtr   *isa_metadataptr() const;   // Returns NULL if not oop ptr type
 352   const TypeMetadataPtr   *is_metadataptr() const;    // Java-style GC'd pointer
 353   const TypeKlassPtr      *isa_klassptr() const;      // Returns NULL if not KlassPtr
 354   const TypeKlassPtr      *is_klassptr() const;       // assert if not KlassPtr
 355   const TypeInstKlassPtr  *isa_instklassptr() const;  // Returns NULL if not IntKlassPtr
 356   const TypeInstKlassPtr  *is_instklassptr() const;   // assert if not IntKlassPtr
 357   const TypeAryKlassPtr   *isa_aryklassptr() const;   // Returns NULL if not AryKlassPtr
 358   const TypeAryKlassPtr   *is_aryklassptr() const;    // assert if not AryKlassPtr
 359 
 360   virtual bool      is_finite() const;           // Has a finite value
 361   virtual bool      is_nan()    const;           // Is not a number (NaN)
 362 
 363   bool is_inlinetypeptr() const;
 364   virtual ciInlineKlass* inline_klass() const;
 365 
 366   // Returns this ptr type or the equivalent ptr type for this compressed pointer.
 367   const TypePtr* make_ptr() const;
 368 
 369   // Returns this oopptr type or the equivalent oopptr type for this compressed pointer.
 370   // Asserts if the underlying type is not an oopptr or narrowoop.
 371   const TypeOopPtr* make_oopptr() const;
 372 
 373   // Returns this compressed pointer or the equivalent compressed version
 374   // of this pointer type.
 375   const TypeNarrowOop* make_narrowoop() const;
 376 
 377   // Returns this compressed klass pointer or the equivalent
 378   // compressed version of this pointer type.
 379   const TypeNarrowKlass* make_narrowklass() const;
 380 
 381   // Special test for register pressure heuristic
 382   bool is_floatingpoint() const;        // True if Float or Double base type
 383 
 384   // Do you have memory, directly or through a tuple?
 385   bool has_memory( ) const;

 740   const Type ** const _fields;           // Array of field types
 741 
 742 public:
 743   virtual bool eq( const Type *t ) const;
 744   virtual int  hash() const;             // Type specific hashing
 745   virtual bool singleton(void) const;    // TRUE if type is a singleton
 746   virtual bool empty(void) const;        // TRUE if type is vacuous
 747 
 748   // Accessors:
 749   uint cnt() const { return _cnt; }
 750   const Type* field_at(uint i) const {
 751     assert(i < _cnt, "oob");
 752     return _fields[i];
 753   }
 754   void set_field_at(uint i, const Type* t) {
 755     assert(i < _cnt, "oob");
 756     _fields[i] = t;
 757   }
 758 
 759   static const TypeTuple *make( uint cnt, const Type **fields );
 760   static const TypeTuple *make_range(ciSignature* sig, bool ret_vt_fields = false);
 761   static const TypeTuple *make_domain(ciMethod* method, bool vt_fields_as_args = false);
 762 
 763   // Subroutine call type with space allocated for argument types
 764   // Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly
 765   static const Type **fields( uint arg_cnt );
 766 
 767   virtual const Type *xmeet( const Type *t ) const;
 768   virtual const Type *xdual() const;    // Compute dual right now.
 769   // Convenience common pre-built types.
 770   static const TypeTuple *IFBOTH;
 771   static const TypeTuple *IFFALSE;
 772   static const TypeTuple *IFTRUE;
 773   static const TypeTuple *IFNEITHER;
 774   static const TypeTuple *LOOPBODY;
 775   static const TypeTuple *MEMBAR;
 776   static const TypeTuple *STORECONDITIONAL;
 777   static const TypeTuple *START_I2C;
 778   static const TypeTuple *INT_PAIR;
 779   static const TypeTuple *LONG_PAIR;
 780   static const TypeTuple *INT_CC_PAIR;
 781   static const TypeTuple *LONG_CC_PAIR;
 782 #ifndef PRODUCT
 783   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 784 #endif
 785 };
 786 
 787 //------------------------------TypeAry----------------------------------------
 788 // Class of Array Types
 789 class TypeAry : public Type {
 790   TypeAry(const Type* elem, const TypeInt* size, bool stable, bool not_flat, bool not_null_free) : Type(Array),
 791       _elem(elem), _size(size), _stable(stable), _not_flat(not_flat), _not_null_free(not_null_free) {}
 792 public:
 793   virtual bool eq( const Type *t ) const;
 794   virtual int  hash() const;             // Type specific hashing
 795   virtual bool singleton(void) const;    // TRUE if type is a singleton
 796   virtual bool empty(void) const;        // TRUE if type is vacuous
 797 
 798 private:
 799   const Type *_elem;            // Element type of array
 800   const TypeInt *_size;         // Elements in array
 801   const bool _stable;           // Are elements @Stable?
 802 
 803   // Inline type array properties
 804   const bool _not_flat;         // Array is never flattened
 805   const bool _not_null_free;    // Array is never null-free
 806 
 807   friend class TypeAryPtr;
 808 
 809 public:
 810   static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false,
 811                              bool not_flat = false, bool not_null_free = false);
 812 
 813   virtual const Type *xmeet( const Type *t ) const;
 814   virtual const Type *xdual() const;    // Compute dual right now.
 815   bool ary_must_be_exact() const;  // true if arrays of such are never generic
 816   virtual const TypeAry* remove_speculative() const;
 817   virtual const Type* cleanup_speculative() const;
 818 
 819 #ifdef ASSERT
 820   // One type is interface, the other is oop
 821   virtual bool interface_vs_oop(const Type *t) const;
 822 #endif
 823 #ifndef PRODUCT
 824   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 825 #endif
 826 };
 827 
 828 
 829 //------------------------------TypeValue---------------------------------------
 830 // Class of Inline Type Types
 831 class TypeInlineType : public Type {
 832 private:
 833   ciInlineKlass* _vk;
 834   bool _larval;
 835 
 836 protected:
 837   TypeInlineType(ciInlineKlass* vk, bool larval)
 838     : Type(InlineType),
 839       _vk(vk), _larval(larval) {
 840   }
 841 
 842 public:
 843   static const TypeInlineType* make(ciInlineKlass* vk, bool larval = false);
 844   virtual ciInlineKlass* inline_klass() const { return _vk; }
 845   bool larval() const { return _larval; }
 846 
 847   virtual bool eq(const Type* t) const;
 848   virtual int  hash() const;             // Type specific hashing
 849   virtual bool singleton(void) const;    // TRUE if type is a singleton
 850   virtual bool empty(void) const;        // TRUE if type is vacuous
 851 
 852   virtual const Type* xmeet(const Type* t) const;
 853   virtual const Type* xdual() const;     // Compute dual right now.
 854 
 855   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const { return false; }
 856   virtual bool would_improve_ptr(ProfilePtrKind ptr_kind) const { return false; }
 857 
 858   virtual bool maybe_null() const { return false; }
 859 
 860   static const TypeInlineType* BOTTOM;
 861 
 862 #ifndef PRODUCT
 863   virtual void dump2(Dict &d, uint, outputStream* st) const; // Specialized per-Type dumping
 864 #endif
 865 };
 866 
 867 //------------------------------TypeVect---------------------------------------
 868 // Class of Vector Types
 869 class TypeVect : public Type {
 870   const Type*   _elem;  // Vector's element type
 871   const uint  _length;  // Elements in vector (power of 2)
 872 
 873 protected:
 874   TypeVect(TYPES t, const Type* elem, uint length) : Type(t),
 875     _elem(elem), _length(length) {}
 876 
 877 public:
 878   const Type* element_type() const { return _elem; }
 879   BasicType element_basic_type() const { return _elem->array_element_basic_type(); }
 880   uint length() const { return _length; }
 881   uint length_in_bytes() const {
 882    return _length * type2aelembytes(element_basic_type());
 883   }
 884 
 885   virtual bool eq(const Type *t) const;
 886   virtual int  hash() const;             // Type specific hashing

 950 class TypeVectMask : public TypeVect {
 951 public:
 952   friend class TypeVect;
 953   TypeVectMask(const Type* elem, uint length) : TypeVect(VectorMask, elem, length) {}
 954   virtual bool eq(const Type *t) const;
 955   virtual const Type *xdual() const;
 956   static const TypeVectMask* make(const BasicType elem_bt, uint length);
 957   static const TypeVectMask* make(const Type* elem, uint length);
 958 };
 959 
 960 //------------------------------TypePtr----------------------------------------
 961 // Class of machine Pointer Types: raw data, instances or arrays.
 962 // If the _base enum is AnyPtr, then this refers to all of the above.
 963 // Otherwise the _base will indicate which subset of pointers is affected,
 964 // and the class will be inherited from.
 965 class TypePtr : public Type {
 966   friend class TypeNarrowPtr;
 967 public:
 968   enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
 969 protected:
 970   TypePtr(TYPES t, PTR ptr, Offset offset,
 971           const TypePtr* speculative = NULL,
 972           int inline_depth = InlineDepthBottom) :
 973     Type(t), _speculative(speculative), _inline_depth(inline_depth), _offset(offset),
 974     _ptr(ptr) {}
 975   static const PTR ptr_meet[lastPTR][lastPTR];
 976   static const PTR ptr_dual[lastPTR];
 977   static const char * const ptr_msg[lastPTR];
 978 
 979   enum {
 980     InlineDepthBottom = INT_MAX,
 981     InlineDepthTop = -InlineDepthBottom
 982   };
 983 
 984   // Extra type information profiling gave us. We propagate it the
 985   // same way the rest of the type info is propagated. If we want to
 986   // use it, then we have to emit a guard: this part of the type is
 987   // not something we know but something we speculate about the type.
 988   const TypePtr*   _speculative;
 989   // For speculative types, we record at what inlining depth the
 990   // profiling point that provided the data is. We want to favor

1007   int dual_inline_depth() const;
1008   int meet_inline_depth(int depth) const;
1009 #ifndef PRODUCT
1010   void dump_inline_depth(outputStream *st) const;
1011 #endif
1012 
1013   // TypeInstPtr (TypeAryPtr resp.) and TypeInstKlassPtr (TypeAryKlassPtr resp.) implement very similar meet logic.
1014   // The logic for meeting 2 instances (2 arrays resp.) is shared in the 2 utility methods below. However the logic for
1015   // the oop and klass versions can be slightly different and extra logic may have to be executed depending on what
1016   // exact case the meet falls into. The MeetResult struct is used by the utility methods to communicate what case was
1017   // encountered so the right logic specific to klasses or oops can be executed.,
1018   enum MeetResult {
1019     QUICK,
1020     UNLOADED,
1021     SUBTYPE,
1022     NOT_SUBTYPE,
1023     LCA
1024   };
1025   static MeetResult
1026   meet_instptr(PTR &ptr, ciKlass* this_klass, ciKlass* tinst_klass, bool this_xk, bool tinst_xk, PTR this_ptr,
1027                PTR tinst_ptr, bool this_flatten_array, bool tinst_flatten_array, ciKlass*&res_klass, bool &res_xk,
1028                bool& res_flatten_array);
1029 
1030   static MeetResult meet_aryptr(PTR &ptr, const Type* this_elem, const Type* tap_elem, ciKlass* this_klass, ciKlass* tap_klass,
1031                                 bool this_xk, bool tap_xk, PTR this_ptr, PTR tap_ptr, bool this_not_flat, bool tap_not_flat,
1032                                 bool this_not_null_free, bool tap_not_null_free, const Type*& res_elem, ciKlass*&res_klass,
1033                                 bool &res_xk, bool &res_not_flat, bool &res_not_null_free);
1034 
1035 public:
1036   const Offset _offset;         // Offset into oop, with TOP & BOT
1037   const PTR _ptr;               // Pointer equivalence class
1038 
1039   const int offset() const { return _offset.get(); }
1040   const PTR ptr()    const { return _ptr; }
1041 
1042   static const TypePtr* make(TYPES t, PTR ptr, Offset offset,
1043                              const TypePtr* speculative = NULL,
1044                              int inline_depth = InlineDepthBottom);
1045 
1046   // Return a 'ptr' version of this type
1047   virtual const TypePtr* cast_to_ptr_type(PTR ptr) const;
1048 
1049   virtual intptr_t get_con() const;
1050 
1051   Type::Offset xadd_offset(intptr_t offset) const;
1052   virtual const TypePtr* add_offset(intptr_t offset) const;
1053   virtual const TypePtr* with_offset(intptr_t offset) const;
1054   virtual const int flattened_offset() const { return offset(); }
1055   virtual bool eq(const Type *t) const;
1056   virtual int  hash() const;             // Type specific hashing
1057 
1058   virtual bool singleton(void) const;    // TRUE if type is a singleton
1059   virtual bool empty(void) const;        // TRUE if type is vacuous
1060   virtual const Type *xmeet( const Type *t ) const;
1061   virtual const Type *xmeet_helper( const Type *t ) const;
1062   Offset meet_offset(int offset) const;
1063   Offset dual_offset() const;
1064   virtual const Type *xdual() const;    // Compute dual right now.
1065 
1066   // meet, dual and join over pointer equivalence sets
1067   PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
1068   PTR dual_ptr()                   const { return ptr_dual[ptr()];      }
1069 
1070   // This is textually confusing unless one recalls that
1071   // join(t) == dual()->meet(t->dual())->dual().
1072   PTR join_ptr( const PTR in_ptr ) const {
1073     return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
1074   }
1075 
1076   // Speculative type helper methods.
1077   virtual const TypePtr* speculative() const { return _speculative; }
1078   int inline_depth() const                   { return _inline_depth; }
1079   virtual ciKlass* speculative_type() const;
1080   virtual ciKlass* speculative_type_not_null() const;
1081   virtual bool speculative_maybe_null() const;
1082   virtual bool speculative_always_null() const;
1083   virtual const TypePtr* remove_speculative() const;
1084   virtual const Type* cleanup_speculative() const;
1085   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1086   virtual bool would_improve_ptr(ProfilePtrKind maybe_null) const;
1087   virtual const TypePtr* with_inline_depth(int depth) const;
1088 
1089   virtual bool maybe_null() const { return meet_ptr(Null) == ptr(); }
1090 
1091   virtual bool can_be_inline_type() const { return false; }
1092   virtual bool flatten_array()      const { return false; }
1093   virtual bool not_flatten_array()  const { return false; }
1094   virtual bool is_flat()            const { return false; }
1095   virtual bool is_not_flat()        const { return false; }
1096   virtual bool is_null_free()       const { return false; }
1097   virtual bool is_not_null_free()   const { return false; }
1098 
1099   // Tests for relation to centerline of type lattice:
1100   static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
1101   static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
1102   // Convenience common pre-built types.
1103   static const TypePtr *NULL_PTR;
1104   static const TypePtr *NOTNULL;
1105   static const TypePtr *BOTTOM;
1106 #ifndef PRODUCT
1107   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1108 #endif
1109 };
1110 
1111 //------------------------------TypeRawPtr-------------------------------------
1112 // Class of raw pointers, pointers to things other than Oops.  Examples
1113 // include the stack pointer, top of heap, card-marking area, handles, etc.
1114 class TypeRawPtr : public TypePtr {
1115 protected:
1116   TypeRawPtr(PTR ptr, address bits) : TypePtr(RawPtr,ptr,Offset(0)), _bits(bits){}
1117 public:
1118   virtual bool eq( const Type *t ) const;
1119   virtual int  hash() const;     // Type specific hashing
1120 
1121   const address _bits;          // Constant value, if applicable
1122 
1123   static const TypeRawPtr *make( PTR ptr );
1124   static const TypeRawPtr *make( address bits );
1125 
1126   // Return a 'ptr' version of this type
1127   virtual const TypeRawPtr* cast_to_ptr_type(PTR ptr) const;
1128 
1129   virtual intptr_t get_con() const;
1130 
1131   virtual const TypePtr* add_offset(intptr_t offset) const;
1132   virtual const TypeRawPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return NULL;}
1133 
1134   virtual const Type *xmeet( const Type *t ) const;
1135   virtual const Type *xdual() const;    // Compute dual right now.
1136   // Convenience common pre-built types.
1137   static const TypeRawPtr *BOTTOM;
1138   static const TypeRawPtr *NOTNULL;
1139 #ifndef PRODUCT
1140   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1141 #endif
1142 };
1143 
1144 //------------------------------TypeOopPtr-------------------------------------
1145 // Some kind of oop (Java pointer), either instance or array.
1146 class TypeOopPtr : public TypePtr {
1147   friend class TypeAry;
1148   friend class TypePtr;
1149   friend class TypeInstPtr;
1150   friend class TypeAryPtr;
1151 protected:
1152   TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset offset, Offset field_offset,
1153              int instance_id, const TypePtr* speculative, int inline_depth);
1154 public:
1155   virtual bool eq( const Type *t ) const;
1156   virtual int  hash() const;             // Type specific hashing
1157   virtual bool singleton(void) const;    // TRUE if type is a singleton
1158   enum {
1159    InstanceTop = -1,   // undefined instance
1160    InstanceBot = 0     // any possible instance
1161   };
1162 protected:
1163 
1164   // Oop is NULL, unless this is a constant oop.
1165   ciObject*     _const_oop;   // Constant oop
1166   // If _klass is NULL, then so is _sig.  This is an unloaded klass.
1167   ciKlass*      _klass;       // Klass object
1168   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
1169   bool          _klass_is_exact;
1170   bool          _is_ptr_to_narrowoop;
1171   bool          _is_ptr_to_narrowklass;
1172   bool          _is_ptr_to_boxed_value;
1173 
1174   // If not InstanceTop or InstanceBot, indicates that this is
1175   // a particular instance of this type which is distinct.
1176   // This is the node index of the allocation node creating this instance.
1177   int           _instance_id;
1178 
1179   static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
1180 
1181   int dual_instance_id() const;
1182   int meet_instance_id(int uid) const;
1183 
1184   // Do not allow interface-vs.-noninterface joins to collapse to top.
1185   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1186 
1187   virtual ciKlass* exact_klass_helper() const { return NULL; }
1188   virtual ciKlass* klass() const { return _klass; }
1189 
1190 public:
1191 
1192   bool is_java_subtype_of(const TypeOopPtr* other) const {
1193     return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1194   }
1195   virtual bool is_same_java_type_as(const TypeOopPtr* other) const { ShouldNotReachHere(); return false; }
1196   bool maybe_java_subtype_of(const TypeOopPtr* other) const {
1197     return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1198   }
1199   virtual bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1200   virtual bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1201 
1202 
1203   // Creates a type given a klass. Correctly handles multi-dimensional arrays
1204   // Respects UseUniqueSubclasses.
1205   // If the klass is final, the resulting type will be exact.
1206   static const TypeOopPtr* make_from_klass(ciKlass* klass) {
1207     return make_from_klass_common(klass, true, false);
1208   }
1209   // Same as before, but will produce an exact type, even if
1210   // the klass is not final, as long as it has exactly one implementation.
1211   static const TypeOopPtr* make_from_klass_unique(ciKlass* klass) {
1212     return make_from_klass_common(klass, true, true);
1213   }
1214   // Same as before, but does not respects UseUniqueSubclasses.
1215   // Use this only for creating array element types.
1216   static const TypeOopPtr* make_from_klass_raw(ciKlass* klass) {
1217     return make_from_klass_common(klass, false, false);
1218   }
1219   // Creates a singleton type given an object.
1220   // If the object cannot be rendered as a constant,
1221   // may return a non-singleton type.
1222   // If require_constant, produce a NULL if a singleton is not possible.
1223   static const TypeOopPtr* make_from_constant(ciObject* o,
1224                                               bool require_constant = false);
1225 
1226   // Make a generic (unclassed) pointer to an oop.
1227   static const TypeOopPtr* make(PTR ptr, Offset offset, int instance_id,
1228                                 const TypePtr* speculative = NULL,
1229                                 int inline_depth = InlineDepthBottom);
1230 
1231   ciObject* const_oop()    const { return _const_oop; }
1232   // Exact klass, possibly an interface or an array of interface
1233   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != NULL || maybe_null, ""); return k;  }
1234   ciKlass* unloaded_klass() const { assert(!is_loaded(), "only for unloaded types"); return klass(); }
1235 
1236   virtual bool  is_loaded() const { return klass()->is_loaded(); }
1237   bool klass_is_exact()    const { return _klass_is_exact; }
1238 
1239   // Returns true if this pointer points at memory which contains a
1240   // compressed oop references.
1241   bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
1242   bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
1243   bool is_ptr_to_boxed_value()   const { return _is_ptr_to_boxed_value; }
1244   bool is_known_instance()       const { return _instance_id > 0; }
1245   int  instance_id()             const { return _instance_id; }
1246   bool is_known_instance_field() const { return is_known_instance() && _offset.get() >= 0; }
1247 
1248   virtual bool can_be_inline_type() const { return (_klass == NULL || _klass->can_be_inline_klass(_klass_is_exact)); }
1249   bool can_be_inline_array() const { return (_klass == NULL || _klass->can_be_inline_array_klass()); }
1250 
1251   virtual intptr_t get_con() const;
1252 
1253   virtual const TypeOopPtr* cast_to_ptr_type(PTR ptr) const;
1254 
1255   virtual const TypeOopPtr* cast_to_exactness(bool klass_is_exact) const;
1256 
1257   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1258 
1259   // corresponding pointer to klass, for a given instance
1260   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1261 
1262   virtual const TypeOopPtr* with_offset(intptr_t offset) const;
1263   virtual const TypePtr* add_offset(intptr_t offset) const;
1264 
1265   // Speculative type helper methods.
1266   virtual const TypeOopPtr* remove_speculative() const;
1267   virtual const Type* cleanup_speculative() const;
1268   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1269   virtual const TypePtr* with_inline_depth(int depth) const;
1270 
1271   virtual const TypePtr* with_instance_id(int instance_id) const;
1272 
1273   virtual const Type *xdual() const;    // Compute dual right now.
1274   // the core of the computation of the meet for TypeOopPtr and for its subclasses
1275   virtual const Type *xmeet_helper(const Type *t) const;
1276 
1277   // Convenience common pre-built type.
1278   static const TypeOopPtr *BOTTOM;
1279 #ifndef PRODUCT
1280   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1281 #endif
1282 };
1283 
1284 //------------------------------TypeInstPtr------------------------------------
1285 // Class of Java object pointers, pointing either to non-array Java instances
1286 // or to a Klass* (including array klasses).
1287 class TypeInstPtr : public TypeOopPtr {
1288   TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset offset,
1289               bool flatten_array, int instance_id, const TypePtr* speculative,
1290               int inline_depth);
1291   virtual bool eq( const Type *t ) const;
1292   virtual int  hash() const;             // Type specific hashing
1293 
1294   bool _flatten_array;     // Type is flat in arrays
1295   ciKlass* exact_klass_helper() const;
1296 
1297 public:
1298 
1299   // Instance klass, ignoring any interface
1300   ciInstanceKlass* instance_klass() const {
1301     if (klass()->is_loaded() && klass()->is_interface()) {
1302       return Compile::current()->env()->Object_klass();
1303     }
1304     return klass()->as_instance_klass();
1305   }
1306 
1307   bool is_same_java_type_as(const TypeOopPtr* other) const;
1308   bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1309   bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1310 
1311   // Make a pointer to a constant oop.
1312   static const TypeInstPtr *make(ciObject* o) {
1313     return make(TypePtr::Constant, o->klass(), true, o, Offset(0));
1314   }
1315   // Make a pointer to a constant oop with offset.
1316   static const TypeInstPtr* make(ciObject* o, Offset offset) {
1317     return make(TypePtr::Constant, o->klass(), true, o, offset);
1318   }
1319 
1320   // Make a pointer to some value of type klass.
1321   static const TypeInstPtr *make(PTR ptr, ciKlass* klass) {
1322     return make(ptr, klass, false, NULL, Offset(0));
1323   }
1324 
1325   // Make a pointer to some non-polymorphic value of exactly type klass.
1326   static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
1327     return make(ptr, klass, true, NULL, Offset(0));
1328   }
1329 
1330   // Make a pointer to some value of type klass with offset.
1331   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, Offset offset) {
1332     return make(ptr, klass, false, NULL, offset);
1333   }
1334 
1335   // Make a pointer to an oop.
1336   static const TypeInstPtr* make(PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset offset,
1337                                  bool flatten_array = false,
1338                                  int instance_id = InstanceBot,
1339                                  const TypePtr* speculative = NULL,
1340                                  int inline_depth = InlineDepthBottom);
1341 
1342   /** Create constant type for a constant boxed value */
1343   const Type* get_const_boxed_value() const;
1344 
1345   // If this is a java.lang.Class constant, return the type for it or NULL.
1346   // Pass to Type::get_const_type to turn it to a type, which will usually
1347   // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
1348   ciType* java_mirror_type(bool* is_val_mirror = NULL) const;
1349 
1350   virtual const TypeInstPtr* cast_to_ptr_type(PTR ptr) const;
1351 
1352   virtual const TypeInstPtr* cast_to_exactness(bool klass_is_exact) const;
1353 
1354   virtual const TypeInstPtr* cast_to_instance_id(int instance_id) const;
1355 
1356   virtual const TypePtr* add_offset(intptr_t offset) const;
1357   virtual const TypeInstPtr* with_offset(intptr_t offset) const;
1358 
1359   // Speculative type helper methods.
1360   virtual const TypeInstPtr* remove_speculative() const;
1361   virtual const TypePtr* with_inline_depth(int depth) const;
1362   virtual const TypePtr* with_instance_id(int instance_id) const;
1363 
1364   virtual const TypeInstPtr* cast_to_flatten_array() const;
1365   virtual bool flatten_array() const { return _flatten_array; }
1366   virtual bool not_flatten_array() const { return !can_be_inline_type() || (_klass->is_inlinetype() && !flatten_array()); }
1367 
1368   // the core of the computation of the meet of 2 types
1369   virtual const Type *xmeet_helper(const Type *t) const;
1370   virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
1371   virtual const Type *xdual() const;    // Compute dual right now.
1372 
1373   const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1374 
1375   bool is_interface() const { return is_loaded() && klass()->is_interface(); }
1376 
1377   // Convenience common pre-built types.
1378   static const TypeInstPtr *NOTNULL;
1379   static const TypeInstPtr *BOTTOM;
1380   static const TypeInstPtr *MIRROR;
1381   static const TypeInstPtr *MARK;
1382   static const TypeInstPtr *KLASS;
1383 #ifndef PRODUCT
1384   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1385 #endif
1386 };
1387 
1388 //------------------------------TypeAryPtr-------------------------------------
1389 // Class of Java array pointers
1390 class TypeAryPtr : public TypeOopPtr {
1391   TypeAryPtr(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1392              Offset offset, Offset field_offset, int instance_id, bool is_autobox_cache,
1393              const TypePtr* speculative, int inline_depth)
1394     : TypeOopPtr(AryPtr, ptr, k, xk, o, offset, field_offset, instance_id, speculative, inline_depth),
1395     _ary(ary),
1396     _is_autobox_cache(is_autobox_cache),
1397     _field_offset(field_offset)
1398  {
1399 #ifdef ASSERT
1400     if (k != NULL) {
1401       // Verify that specified klass and TypeAryPtr::klass() follow the same rules.
1402       ciKlass* ck = compute_klass(true);
1403       if (k != ck) {
1404         this->dump(); tty->cr();
1405         tty->print(" k: ");
1406         k->print(); tty->cr();
1407         tty->print("ck: ");
1408         if (ck != NULL) ck->print();
1409         else tty->print("<NULL>");
1410         tty->cr();
1411         assert(false, "unexpected TypeAryPtr::_klass");
1412       }
1413     }
1414 #endif
1415   }
1416   virtual bool eq( const Type *t ) const;
1417   virtual int hash() const;     // Type specific hashing
1418   const TypeAry *_ary;          // Array we point into
1419   const bool     _is_autobox_cache;
1420   // For flattened inline type arrays, each field of the inline type in
1421   // the array has its own memory slice so we need to keep track of
1422   // which field is accessed
1423   const Offset _field_offset;
1424   Offset meet_field_offset(const Type::Offset offset) const;
1425   Offset dual_field_offset() const;
1426 
1427   ciKlass* compute_klass(DEBUG_ONLY(bool verify = false)) const;
1428 
1429   ciKlass* exact_klass_helper() const;
1430   ciKlass* klass() const;
1431 
1432 public:
1433 
1434   bool is_same_java_type_as(const TypeOopPtr* other) const;
1435   bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1436   bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1437 
1438   // returns base element type, an instance klass (and not interface) for object arrays
1439   const Type* base_element_type(int& dims) const;
1440 
1441   // Accessors
1442   bool  is_loaded() const { return (_ary->_elem->make_oopptr() ? _ary->_elem->make_oopptr()->is_loaded() : true); }
1443 
1444   const TypeAry* ary() const  { return _ary; }
1445   const Type*    elem() const { return _ary->_elem; }
1446   const TypeInt* size() const { return _ary->_size; }
1447   bool      is_stable() const { return _ary->_stable; }
1448 
1449   // Inline type array properties
1450   bool is_flat()          const { return _ary->_elem->isa_inlinetype() != NULL; }
1451   bool is_not_flat()      const { return _ary->_not_flat; }
1452   bool is_null_free()     const { return is_flat() || (_ary->_elem->make_ptr() != NULL && _ary->_elem->make_ptr()->is_inlinetypeptr() && !_ary->_elem->make_ptr()->maybe_null()); }
1453   bool is_not_null_free() const { return _ary->_not_null_free; }
1454 
1455   bool is_autobox_cache() const { return _is_autobox_cache; }
1456 
1457   static const TypeAryPtr* make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1458                                 Offset field_offset = Offset::bottom,
1459                                 int instance_id = InstanceBot,
1460                                 const TypePtr* speculative = NULL,
1461                                 int inline_depth = InlineDepthBottom);
1462   // Constant pointer to array
1463   static const TypeAryPtr* make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1464                                 Offset field_offset = Offset::bottom,
1465                                 int instance_id = InstanceBot,
1466                                 const TypePtr* speculative = NULL,
1467                                 int inline_depth = InlineDepthBottom,
1468                                 bool is_autobox_cache = false);
1469 
1470   // Return a 'ptr' version of this type
1471   virtual const TypeAryPtr* cast_to_ptr_type(PTR ptr) const;
1472 
1473   virtual const TypeAryPtr* cast_to_exactness(bool klass_is_exact) const;
1474 
1475   virtual const TypeAryPtr* cast_to_instance_id(int instance_id) const;
1476 
1477   virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1478   virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1479 
1480   virtual bool empty(void) const;        // TRUE if type is vacuous
1481   virtual const TypePtr *add_offset( intptr_t offset ) const;
1482   virtual const TypeAryPtr *with_offset( intptr_t offset ) const;
1483   const TypeAryPtr* with_ary(const TypeAry* ary) const;
1484 
1485   // Speculative type helper methods.
1486   virtual const TypeAryPtr* remove_speculative() const;
1487   virtual const Type* cleanup_speculative() const;
1488   virtual const TypePtr* with_inline_depth(int depth) const;
1489   virtual const TypePtr* with_instance_id(int instance_id) const;
1490 
1491   // the core of the computation of the meet of 2 types
1492   virtual const Type *xmeet_helper(const Type *t) const;
1493   virtual const Type *xdual() const;    // Compute dual right now.
1494 
1495   // Inline type array properties
1496   const TypeAryPtr* cast_to_not_flat(bool not_flat = true) const;
1497   const TypeAryPtr* cast_to_not_null_free(bool not_null_free = true) const;
1498   const TypeAryPtr* update_properties(const TypeAryPtr* new_type) const;
1499   jint flat_layout_helper() const;
1500   int flat_elem_size() const;
1501   int flat_log_elem_size() const;
1502 
1503   const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1504   int stable_dimension() const;
1505 
1506   const TypeAryPtr* cast_to_autobox_cache() const;
1507 
1508   static jint max_array_length(BasicType etype);
1509 
1510   const int flattened_offset() const;
1511   const Offset field_offset() const { return _field_offset; }
1512   const TypeAryPtr* with_field_offset(int offset) const;
1513   const TypePtr* add_field_offset_and_offset(intptr_t offset) const;
1514 
1515   virtual bool can_be_inline_type() const { return false; }
1516   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1517 
1518   // Convenience common pre-built types.
1519   static const TypeAryPtr *RANGE;
1520   static const TypeAryPtr *OOPS;
1521   static const TypeAryPtr *NARROWOOPS;
1522   static const TypeAryPtr *BYTES;
1523   static const TypeAryPtr *SHORTS;
1524   static const TypeAryPtr *CHARS;
1525   static const TypeAryPtr *INTS;
1526   static const TypeAryPtr *LONGS;
1527   static const TypeAryPtr *FLOATS;
1528   static const TypeAryPtr *DOUBLES;
1529   static const TypeAryPtr *INLINES;
1530   // selects one of the above:
1531   static const TypeAryPtr *get_array_body_type(BasicType elem) {
1532     assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != NULL, "bad elem type");
1533     return _array_body_type[elem];
1534   }
1535   static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1536   // sharpen the type of an int which is used as an array size
1537 #ifdef ASSERT
1538   // One type is interface, the other is oop
1539   virtual bool interface_vs_oop(const Type *t) const;
1540 #endif
1541 #ifndef PRODUCT
1542   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1543 #endif
1544 };
1545 
1546 //------------------------------TypeMetadataPtr-------------------------------------
1547 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
1548 class TypeMetadataPtr : public TypePtr {
1549 protected:
1550   TypeMetadataPtr(PTR ptr, ciMetadata* metadata, Offset offset);
1551   // Do not allow interface-vs.-noninterface joins to collapse to top.
1552   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1553 public:
1554   virtual bool eq( const Type *t ) const;
1555   virtual int  hash() const;             // Type specific hashing
1556   virtual bool singleton(void) const;    // TRUE if type is a singleton
1557 
1558 private:
1559   ciMetadata*   _metadata;
1560 
1561 public:
1562   static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, Offset offset);
1563 
1564   static const TypeMetadataPtr* make(ciMethod* m);
1565   static const TypeMetadataPtr* make(ciMethodData* m);
1566 
1567   ciMetadata* metadata() const { return _metadata; }
1568 
1569   virtual const TypeMetadataPtr* cast_to_ptr_type(PTR ptr) const;
1570 
1571   virtual const TypePtr *add_offset( intptr_t offset ) const;
1572 
1573   virtual const Type *xmeet( const Type *t ) const;
1574   virtual const Type *xdual() const;    // Compute dual right now.
1575 
1576   virtual intptr_t get_con() const;
1577 
1578   // Convenience common pre-built types.
1579   static const TypeMetadataPtr *BOTTOM;
1580 
1581 #ifndef PRODUCT
1582   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1583 #endif
1584 };
1585 
1586 //------------------------------TypeKlassPtr-----------------------------------
1587 // Class of Java Klass pointers
1588 class TypeKlassPtr : public TypePtr {
1589   friend class TypeInstKlassPtr;
1590   friend class TypeAryKlassPtr;
1591 protected:
1592   TypeKlassPtr(TYPES t, PTR ptr, ciKlass* klass, Offset offset);
1593 
1594   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1595 
1596 public:
1597   virtual bool eq( const Type *t ) const;
1598   virtual int hash() const;
1599   virtual bool singleton(void) const;    // TRUE if type is a singleton
1600 
1601 protected:
1602 
1603   ciKlass* _klass;
1604 
1605   virtual bool must_be_exact() const { ShouldNotReachHere(); return false; }
1606   virtual ciKlass* exact_klass_helper() const;
1607   virtual ciKlass* klass() const { return  _klass; }
1608 
1609 public:
1610 
1611   bool is_java_subtype_of(const TypeKlassPtr* other) const {
1612     return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1613   }
1614   bool maybe_java_subtype_of(const TypeKlassPtr* other) const {
1615     return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1616   }
1617   virtual bool is_same_java_type_as(const TypeKlassPtr* other) const { ShouldNotReachHere(); return false; }
1618   virtual bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1619   virtual bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1620 
1621   // Exact klass, possibly an interface or an array of interface
1622   ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != NULL || maybe_null, ""); return k;  }
1623 
1624   bool klass_is_exact()    const { return _ptr == Constant; }
1625 
1626   static const TypeKlassPtr* make(ciKlass* klass);
1627   static const TypeKlassPtr* make(PTR ptr, ciKlass* klass, Offset offset);
1628 
1629   virtual bool  is_loaded() const { return _klass->is_loaded(); }
1630 
1631   virtual const TypeKlassPtr* cast_to_ptr_type(PTR ptr) const { ShouldNotReachHere(); return NULL; }
1632 
1633   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const { ShouldNotReachHere(); return NULL; }
1634 
1635   // corresponding pointer to instance, for a given class
1636   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const { ShouldNotReachHere(); return NULL; }
1637 
1638   virtual const TypePtr *add_offset( intptr_t offset ) const { ShouldNotReachHere(); return NULL; }
1639   virtual const Type    *xmeet( const Type *t ) const { ShouldNotReachHere(); return NULL; }
1640   virtual const Type    *xdual() const { ShouldNotReachHere(); return NULL; }
1641 
1642   virtual intptr_t get_con() const;
1643 
1644   virtual const TypeKlassPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return NULL; }
1645 
1646   bool can_be_inline_array() const { return (_klass == NULL || _klass->can_be_inline_array_klass()); }


1647 };
1648 
1649 // Instance klass pointer, mirrors TypeInstPtr
1650 class TypeInstKlassPtr : public TypeKlassPtr {
1651 
1652   TypeInstKlassPtr(PTR ptr, ciKlass* klass, Offset offset, bool flatten_array)
1653     : TypeKlassPtr(InstKlassPtr, ptr, klass, offset), _flatten_array(flatten_array) {
1654   }
1655 
1656   virtual bool must_be_exact() const;
1657 
1658   const bool _flatten_array; // Type is flat in arrays
1659 
1660 public:
1661   // Instance klass ignoring any interface
1662   ciInstanceKlass* instance_klass() const {
1663     if (klass()->is_interface()) {
1664       return Compile::current()->env()->Object_klass();
1665     }
1666     return klass()->as_instance_klass();
1667   }
1668 
1669   bool is_same_java_type_as(const TypeKlassPtr* other) const;
1670   bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1671   bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1672 
1673   virtual bool can_be_inline_type() const { return (_klass == NULL || _klass->can_be_inline_klass(klass_is_exact())); }
1674 
1675   static const TypeInstKlassPtr *make(ciKlass* k) {
1676     return make(TypePtr::Constant, k, Offset(0), false);
1677   }
1678   static const TypeInstKlassPtr *make(PTR ptr, ciKlass* k, Offset offset, bool flatten_array = false);
1679 
1680   virtual const TypeInstKlassPtr* cast_to_ptr_type(PTR ptr) const;
1681 
1682   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1683 
1684   // corresponding pointer to instance, for a given class
1685   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
1686   virtual int hash() const;
1687   virtual bool eq(const Type *t) const;
1688 
1689   virtual const TypePtr *add_offset( intptr_t offset ) const;
1690   virtual const Type    *xmeet( const Type *t ) const;
1691   virtual const Type    *xdual() const;
1692   virtual const TypeInstKlassPtr* with_offset(intptr_t offset) const;
1693 
1694   bool is_interface() const { return klass()->is_interface(); }
1695 
1696   virtual bool flatten_array() const { return _flatten_array; }
1697   virtual bool not_flatten_array() const { return !_klass->can_be_inline_klass() || (_klass->is_inlinetype() && !flatten_array()); }
1698 
1699   // Convenience common pre-built types.
1700   static const TypeInstKlassPtr* OBJECT; // Not-null object klass or below
1701   static const TypeInstKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
1702 
1703 #ifndef PRODUCT
1704   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1705 #endif
1706 };
1707 
1708 // Array klass pointer, mirrors TypeAryPtr
1709 class TypeAryKlassPtr : public TypeKlassPtr {
1710   friend class TypeInstKlassPtr;
1711   const Type *_elem;
1712   const bool _not_flat;      // Array is never flattened
1713   const bool _not_null_free; // Array is never null-free
1714   const bool _null_free;
1715 
1716   TypeAryKlassPtr(PTR ptr, const Type *elem, ciKlass* klass, Offset offset, bool not_flat, int not_null_free, bool null_free)
1717     : TypeKlassPtr(AryKlassPtr, ptr, klass, offset), _elem(elem), _not_flat(not_flat), _not_null_free(not_null_free), _null_free(null_free) {
1718   }
1719 
1720   virtual ciKlass* exact_klass_helper() const;
1721   virtual ciKlass* klass() const;
1722 
1723   virtual bool must_be_exact() const;
1724 
1725   bool dual_null_free() const {
1726     return _null_free;
1727   }
1728 
1729   bool meet_null_free(bool other) const {
1730     return _null_free && other;
1731   }
1732 
1733 public:
1734 
1735   // returns base element type, an instance klass (and not interface) for object arrays
1736   const Type* base_element_type(int& dims) const;
1737 
1738   static const TypeAryKlassPtr* make(PTR ptr, ciKlass* k, Offset offset, bool not_flat, bool not_null_free, bool null_free);
1739 
1740   bool is_same_java_type_as(const TypeKlassPtr* other) const;
1741   bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1742   bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1743 
1744   bool  is_loaded() const { return (_elem->isa_klassptr() ? _elem->is_klassptr()->is_loaded() : true); }
1745 
1746   static const TypeAryKlassPtr* make(PTR ptr, const Type* elem, ciKlass* k, Offset offset, bool not_flat, bool not_null_free, bool null_free);
1747   static const TypeAryKlassPtr* make(PTR ptr, ciKlass* k, Offset offset);
1748   static const TypeAryKlassPtr* make(ciKlass* klass);
1749 
1750   const Type *elem() const { return _elem; }
1751 
1752   virtual bool eq(const Type *t) const;
1753   virtual int hash() const;             // Type specific hashing
1754 
1755   virtual const TypeAryKlassPtr* cast_to_ptr_type(PTR ptr) const;
1756 
1757   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1758 
1759   // corresponding pointer to instance, for a given class
1760   virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
1761 
1762   virtual const TypePtr *add_offset( intptr_t offset ) const;
1763   virtual const Type    *xmeet( const Type *t ) const;
1764   virtual const Type    *xdual() const;      // Compute dual right now.
1765 
1766   virtual const TypeAryKlassPtr* with_offset(intptr_t offset) const;
1767 
1768   virtual bool empty(void) const {
1769     return TypeKlassPtr::empty() || _elem->empty();
1770   }
1771 
1772   bool is_flat()          const { return klass() != NULL && klass()->is_flat_array_klass(); }
1773   bool is_not_flat()      const { return _not_flat; }
1774   bool is_null_free()     const { return _null_free; }
1775   bool is_not_null_free() const { return _not_null_free; }
1776 
1777 #ifndef PRODUCT
1778   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1779 #endif
1780 };
1781 
1782 class TypeNarrowPtr : public Type {
1783 protected:
1784   const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
1785 
1786   TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): Type(t),
1787                                                   _ptrtype(ptrtype) {
1788     assert(ptrtype->offset() == 0 ||
1789            ptrtype->offset() == OffsetBot ||
1790            ptrtype->offset() == OffsetTop, "no real offsets");
1791   }
1792 
1793   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
1794   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;
1795   virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const = 0;
1796   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const = 0;

1890   }
1891 
1892   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
1893     return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
1894   }
1895 
1896 public:
1897   static const TypeNarrowKlass *make( const TypePtr* type);
1898 
1899   // static const TypeNarrowKlass *BOTTOM;
1900   static const TypeNarrowKlass *NULL_PTR;
1901 
1902 #ifndef PRODUCT
1903   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1904 #endif
1905 };
1906 
1907 //------------------------------TypeFunc---------------------------------------
1908 // Class of Array Types
1909 class TypeFunc : public Type {
1910   TypeFunc(const TypeTuple *domain_sig, const TypeTuple *domain_cc, const TypeTuple *range_sig, const TypeTuple *range_cc)
1911     : Type(Function), _domain_sig(domain_sig), _domain_cc(domain_cc), _range_sig(range_sig), _range_cc(range_cc) {}
1912   virtual bool eq( const Type *t ) const;
1913   virtual int  hash() const;             // Type specific hashing
1914   virtual bool singleton(void) const;    // TRUE if type is a singleton
1915   virtual bool empty(void) const;        // TRUE if type is vacuous
1916 
1917   // Domains of inputs: inline type arguments are not passed by
1918   // reference, instead each field of the inline type is passed as an
1919   // argument. We maintain 2 views of the argument list here: one
1920   // based on the signature (with an inline type argument as a single
1921   // slot), one based on the actual calling convention (with a value
1922   // type argument as a list of its fields).
1923   const TypeTuple* const _domain_sig;
1924   const TypeTuple* const _domain_cc;
1925   // Range of results. Similar to domains: an inline type result can be
1926   // returned in registers in which case range_cc lists all fields and
1927   // is the actual calling convention.
1928   const TypeTuple* const _range_sig;
1929   const TypeTuple* const _range_cc;
1930 
1931 public:
1932   // Constants are shared among ADLC and VM
1933   enum { Control    = AdlcVMDeps::Control,
1934          I_O        = AdlcVMDeps::I_O,
1935          Memory     = AdlcVMDeps::Memory,
1936          FramePtr   = AdlcVMDeps::FramePtr,
1937          ReturnAdr  = AdlcVMDeps::ReturnAdr,
1938          Parms      = AdlcVMDeps::Parms
1939   };
1940 
1941 
1942   // Accessors:
1943   const TypeTuple* domain_sig() const { return _domain_sig; }
1944   const TypeTuple* domain_cc()  const { return _domain_cc; }
1945   const TypeTuple* range_sig()  const { return _range_sig; }
1946   const TypeTuple* range_cc()   const { return _range_cc; }
1947 
1948   static const TypeFunc* make(ciMethod* method, bool is_osr_compilation = false);
1949   static const TypeFunc *make(const TypeTuple* domain_sig, const TypeTuple* domain_cc,
1950                               const TypeTuple* range_sig, const TypeTuple* range_cc);
1951   static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
1952 
1953   virtual const Type *xmeet( const Type *t ) const;
1954   virtual const Type *xdual() const;    // Compute dual right now.
1955 
1956   BasicType return_type() const;
1957 
1958   bool returns_inline_type_as_fields() const { return range_sig() != range_cc(); }
1959 
1960 #ifndef PRODUCT
1961   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1962 #endif
1963   // Convenience common pre-built types.
1964 };
1965 
1966 //------------------------------accessors--------------------------------------
1967 inline bool Type::is_ptr_to_narrowoop() const {
1968 #ifdef _LP64
1969   return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowoop_nv());
1970 #else
1971   return false;
1972 #endif
1973 }
1974 
1975 inline bool Type::is_ptr_to_narrowklass() const {
1976 #ifdef _LP64
1977   return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowklass_nv());
1978 #else
1979   return false;

2111 }
2112 
2113 inline const TypeInstPtr *Type::isa_instptr() const {
2114   return (_base == InstPtr) ? (TypeInstPtr*)this : NULL;
2115 }
2116 
2117 inline const TypeInstPtr *Type::is_instptr() const {
2118   assert( _base == InstPtr, "Not an object pointer" );
2119   return (TypeInstPtr*)this;
2120 }
2121 
2122 inline const TypeAryPtr *Type::isa_aryptr() const {
2123   return (_base == AryPtr) ? (TypeAryPtr*)this : NULL;
2124 }
2125 
2126 inline const TypeAryPtr *Type::is_aryptr() const {
2127   assert( _base == AryPtr, "Not an array pointer" );
2128   return (TypeAryPtr*)this;
2129 }
2130 
2131 inline const TypeInlineType* Type::isa_inlinetype() const {
2132   return (_base == InlineType) ? (TypeInlineType*)this : NULL;
2133 }
2134 
2135 inline const TypeInlineType* Type::is_inlinetype() const {
2136   assert(_base == InlineType, "Not an inline type");
2137   return (TypeInlineType*)this;
2138 }
2139 
2140 inline const TypeNarrowOop *Type::is_narrowoop() const {
2141   // OopPtr is the first and KlassPtr the last, with no non-oops between.
2142   assert(_base == NarrowOop, "Not a narrow oop" ) ;
2143   return (TypeNarrowOop*)this;
2144 }
2145 
2146 inline const TypeNarrowOop *Type::isa_narrowoop() const {
2147   // OopPtr is the first and KlassPtr the last, with no non-oops between.
2148   return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL;
2149 }
2150 
2151 inline const TypeNarrowKlass *Type::is_narrowklass() const {
2152   assert(_base == NarrowKlass, "Not a narrow oop" ) ;
2153   return (TypeNarrowKlass*)this;
2154 }
2155 
2156 inline const TypeNarrowKlass *Type::isa_narrowklass() const {
2157   return (_base == NarrowKlass) ? (TypeNarrowKlass*)this : NULL;
2158 }
2159 

2204   return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->isa_oopptr() : isa_oopptr();
2205 }
2206 
2207 inline const TypeNarrowOop* Type::make_narrowoop() const {
2208   return (_base == NarrowOop) ? is_narrowoop() :
2209                                 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL);
2210 }
2211 
2212 inline const TypeNarrowKlass* Type::make_narrowklass() const {
2213   return (_base == NarrowKlass) ? is_narrowklass() :
2214                                   (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : NULL);
2215 }
2216 
2217 inline bool Type::is_floatingpoint() const {
2218   if( (_base == FloatCon)  || (_base == FloatBot) ||
2219       (_base == DoubleCon) || (_base == DoubleBot) )
2220     return true;
2221   return false;
2222 }
2223 
2224 inline bool Type::is_inlinetypeptr() const {
2225   return isa_instptr() != NULL && is_instptr()->instance_klass()->is_inlinetype();
2226 }
2227 
2228 inline ciInlineKlass* Type::inline_klass() const {
2229   assert(is_inlinetypeptr(), "must be an inline type ptr");
2230   return is_instptr()->instance_klass()->as_inline_klass();
2231 }
2232 
2233 
2234 // ===============================================================
2235 // Things that need to be 64-bits in the 64-bit build but
2236 // 32-bits in the 32-bit build.  Done this way to get full
2237 // optimization AND strong typing.
2238 #ifdef _LP64
2239 
2240 // For type queries and asserts
2241 #define is_intptr_t  is_long
2242 #define isa_intptr_t isa_long
2243 #define find_intptr_t_type find_long_type
2244 #define find_intptr_t_con  find_long_con
2245 #define TypeX        TypeLong
2246 #define Type_X       Type::Long
2247 #define TypeX_X      TypeLong::LONG
2248 #define TypeX_ZERO   TypeLong::ZERO
2249 // For 'ideal_reg' machine registers
2250 #define Op_RegX      Op_RegL
2251 // For phase->intcon variants
2252 #define MakeConX     longcon
2253 #define ConXNode     ConLNode
2254 // For array index arithmetic
2255 #define MulXNode     MulLNode
2256 #define AndXNode     AndLNode
2257 #define OrXNode      OrLNode
2258 #define CmpXNode     CmpLNode
2259 #define CmpUXNode    CmpULNode
2260 #define SubXNode     SubLNode
2261 #define LShiftXNode  LShiftLNode
2262 // For object size computation:
2263 #define AddXNode     AddLNode
2264 #define RShiftXNode  RShiftLNode
2265 // For card marks and hashcodes
2266 #define URShiftXNode URShiftLNode
2267 // For shenandoahSupport
2268 #define LoadXNode    LoadLNode
2269 #define StoreXNode   StoreLNode
2270 // Opcodes
2271 #define Op_LShiftX   Op_LShiftL
2272 #define Op_AndX      Op_AndL
2273 #define Op_AddX      Op_AddL
2274 #define Op_SubX      Op_SubL
2275 #define Op_XorX      Op_XorL
2276 #define Op_URShiftX  Op_URShiftL
2277 #define Op_LoadX     Op_LoadL
2278 #define Op_StoreX    Op_StoreL
2279 // conversions
2280 #define ConvI2X(x)   ConvI2L(x)
2281 #define ConvL2X(x)   (x)
2282 #define ConvX2I(x)   ConvL2I(x)
2283 #define ConvX2L(x)   (x)
2284 #define ConvX2UL(x)  (x)
2285 
2286 #else
2287 
2288 // For type queries and asserts
2289 #define is_intptr_t  is_int
2290 #define isa_intptr_t isa_int
2291 #define find_intptr_t_type find_int_type
2292 #define find_intptr_t_con  find_int_con
2293 #define TypeX        TypeInt
2294 #define Type_X       Type::Int
2295 #define TypeX_X      TypeInt::INT
2296 #define TypeX_ZERO   TypeInt::ZERO
2297 // For 'ideal_reg' machine registers
2298 #define Op_RegX      Op_RegI
2299 // For phase->intcon variants
2300 #define MakeConX     intcon
2301 #define ConXNode     ConINode
2302 // For array index arithmetic
2303 #define MulXNode     MulINode
2304 #define AndXNode     AndINode
2305 #define OrXNode      OrINode
2306 #define CmpXNode     CmpINode
2307 #define CmpUXNode    CmpUNode
2308 #define SubXNode     SubINode
2309 #define LShiftXNode  LShiftINode
2310 // For object size computation:
2311 #define AddXNode     AddINode
2312 #define RShiftXNode  RShiftINode
2313 // For card marks and hashcodes
2314 #define URShiftXNode URShiftINode
2315 // For shenandoahSupport
2316 #define LoadXNode    LoadINode
2317 #define StoreXNode   StoreINode
2318 // Opcodes
2319 #define Op_LShiftX   Op_LShiftI
2320 #define Op_AndX      Op_AndI
2321 #define Op_AddX      Op_AddI
2322 #define Op_SubX      Op_SubI
2323 #define Op_XorX      Op_XorI
2324 #define Op_URShiftX  Op_URShiftI
2325 #define Op_LoadX     Op_LoadI
2326 #define Op_StoreX    Op_StoreI
2327 // conversions
2328 #define ConvI2X(x)   (x)
2329 #define ConvL2X(x)   ConvL2I(x)
2330 #define ConvX2I(x)   (x)
2331 #define ConvX2L(x)   ConvI2L(x)
2332 #define ConvX2UL(x)  ConvI2UL(x)
2333 
2334 #endif
2335 
2336 #endif // SHARE_OPTO_TYPE_HPP
< prev index next >