8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_OPTO_TYPE_HPP
26 #define SHARE_OPTO_TYPE_HPP
27
28 #include "opto/adlcVMDeps.hpp"
29 #include "runtime/handles.hpp"
30
31 // Portions of code courtesy of Clifford Click
32
33 // Optimization - Graph Style
34
35
36 // This class defines a Type lattice. The lattice is used in the constant
37 // propagation algorithms, and for some type-checking of the iloc code.
38 // Basic types include RSD's (lower bound, upper bound, stride for integers),
39 // float & double precision constants, sets of data-labels and code-labels.
40 // The complete lattice is described below. Subtypes have no relationship to
41 // up or down in the lattice; that is entirely determined by the behavior of
42 // the MEET/JOIN functions.
43
44 class Dict;
45 class Type;
46 class TypeD;
47 class TypeF;
48 class TypeH;
49 class TypeInteger;
122 Memory, // Abstract store
123 HalfFloatTop, // No float value
124 HalfFloatCon, // Floating point constant
125 HalfFloatBot, // Any float value
126 FloatTop, // No float value
127 FloatCon, // Floating point constant
128 FloatBot, // Any float value
129 DoubleTop, // No double value
130 DoubleCon, // Double precision constant
131 DoubleBot, // Any double value
132 Bottom, // Bottom of lattice
133 lastype // Bogus ending type (not in lattice)
134 };
135
136 // Signal values for offsets from a base pointer
137 enum OFFSET_SIGNALS {
138 OffsetTop = -2000000000, // undefined offset
139 OffsetBot = -2000000001 // any possible offset
140 };
141
142 // Min and max WIDEN values.
143 enum WIDEN {
144 WidenMin = 0,
145 WidenMax = 3
146 };
147
148 private:
149 typedef struct {
150 TYPES dual_type;
151 BasicType basic_type;
152 const char* msg;
153 bool isa_oop;
154 uint ideal_reg;
155 relocInfo::relocType reloc;
156 } TypeInfo;
157
158 // Dictionary of types shared among compilations.
159 static Dict* _shared_type_dict;
160 static const TypeInfo _type_info[];
161
319 const TypeInstPtr *isa_instptr() const; // Returns null if not InstPtr
320 const TypeInstPtr *is_instptr() const; // Instance
321 const TypeAryPtr *isa_aryptr() const; // Returns null if not AryPtr
322 const TypeAryPtr *is_aryptr() const; // Array oop
323
324 template <typename TypeClass>
325 const TypeClass* cast() const;
326
327 const TypeMetadataPtr *isa_metadataptr() const; // Returns null if not oop ptr type
328 const TypeMetadataPtr *is_metadataptr() const; // Java-style GC'd pointer
329 const TypeKlassPtr *isa_klassptr() const; // Returns null if not KlassPtr
330 const TypeKlassPtr *is_klassptr() const; // assert if not KlassPtr
331 const TypeInstKlassPtr *isa_instklassptr() const; // Returns null if not IntKlassPtr
332 const TypeInstKlassPtr *is_instklassptr() const; // assert if not IntKlassPtr
333 const TypeAryKlassPtr *isa_aryklassptr() const; // Returns null if not AryKlassPtr
334 const TypeAryKlassPtr *is_aryklassptr() const; // assert if not AryKlassPtr
335
336 virtual bool is_finite() const; // Has a finite value
337 virtual bool is_nan() const; // Is not a number (NaN)
338
339 // Returns this ptr type or the equivalent ptr type for this compressed pointer.
340 const TypePtr* make_ptr() const;
341
342 // Returns this oopptr type or the equivalent oopptr type for this compressed pointer.
343 // Asserts if the underlying type is not an oopptr or narrowoop.
344 const TypeOopPtr* make_oopptr() const;
345
346 // Returns this compressed pointer or the equivalent compressed version
347 // of this pointer type.
348 const TypeNarrowOop* make_narrowoop() const;
349
350 // Returns this compressed klass pointer or the equivalent
351 // compressed version of this pointer type.
352 const TypeNarrowKlass* make_narrowklass() const;
353
354 // Special test for register pressure heuristic
355 bool is_floatingpoint() const; // True if Float or Double base type
356
357 // Do you have memory, directly or through a tuple?
358 bool has_memory( ) const;
751 const Type ** const _fields; // Array of field types
752
753 public:
754 virtual bool eq( const Type *t ) const;
755 virtual uint hash() const; // Type specific hashing
756 virtual bool singleton(void) const; // TRUE if type is a singleton
757 virtual bool empty(void) const; // TRUE if type is vacuous
758
759 // Accessors:
760 uint cnt() const { return _cnt; }
761 const Type* field_at(uint i) const {
762 assert(i < _cnt, "oob");
763 return _fields[i];
764 }
765 void set_field_at(uint i, const Type* t) {
766 assert(i < _cnt, "oob");
767 _fields[i] = t;
768 }
769
770 static const TypeTuple *make( uint cnt, const Type **fields );
771 static const TypeTuple *make_range(ciSignature *sig, InterfaceHandling interface_handling = ignore_interfaces);
772 static const TypeTuple *make_domain(ciInstanceKlass* recv, ciSignature *sig, InterfaceHandling interface_handling);
773
774 // Subroutine call type with space allocated for argument types
775 // Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly
776 static const Type **fields( uint arg_cnt );
777
778 virtual const Type *xmeet( const Type *t ) const;
779 virtual const Type *xdual() const; // Compute dual right now.
780 // Convenience common pre-built types.
781 static const TypeTuple *IFBOTH;
782 static const TypeTuple *IFFALSE;
783 static const TypeTuple *IFTRUE;
784 static const TypeTuple *IFNEITHER;
785 static const TypeTuple *LOOPBODY;
786 static const TypeTuple *MEMBAR;
787 static const TypeTuple *STORECONDITIONAL;
788 static const TypeTuple *START_I2C;
789 static const TypeTuple *INT_PAIR;
790 static const TypeTuple *LONG_PAIR;
791 static const TypeTuple *INT_CC_PAIR;
792 static const TypeTuple *LONG_CC_PAIR;
793 #ifndef PRODUCT
794 virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping
795 #endif
796 };
797
798 //------------------------------TypeAry----------------------------------------
799 // Class of Array Types
800 class TypeAry : public Type {
801 TypeAry(const Type* elem, const TypeInt* size, bool stable) : Type(Array),
802 _elem(elem), _size(size), _stable(stable) {}
803 public:
804 virtual bool eq( const Type *t ) const;
805 virtual uint hash() const; // Type specific hashing
806 virtual bool singleton(void) const; // TRUE if type is a singleton
807 virtual bool empty(void) const; // TRUE if type is vacuous
808
809 private:
810 const Type *_elem; // Element type of array
811 const TypeInt *_size; // Elements in array
812 const bool _stable; // Are elements @Stable?
813 friend class TypeAryPtr;
814
815 public:
816 static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false);
817
818 virtual const Type *xmeet( const Type *t ) const;
819 virtual const Type *xdual() const; // Compute dual right now.
820 bool ary_must_be_exact() const; // true if arrays of such are never generic
821 virtual const TypeAry* remove_speculative() const;
822 virtual const Type* cleanup_speculative() const;
823 #ifndef PRODUCT
824 virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping
825 #endif
826 };
827
828 //------------------------------TypeVect---------------------------------------
829 // Class of Vector Types
830 class TypeVect : public Type {
831 const BasicType _elem_bt; // Vector's element type
832 const uint _length; // Elements in vector (power of 2)
833
834 protected:
835 TypeVect(TYPES t, BasicType elem_bt, uint length) : Type(t),
836 _elem_bt(elem_bt), _length(length) {}
942
943 const Type* xmeet(const Type* t) const;
944
945 bool singleton(void) const;
946 };
947
948 //------------------------------TypePtr----------------------------------------
949 // Class of machine Pointer Types: raw data, instances or arrays.
950 // If the _base enum is AnyPtr, then this refers to all of the above.
951 // Otherwise the _base will indicate which subset of pointers is affected,
952 // and the class will be inherited from.
953 class TypePtr : public Type {
954 friend class TypeNarrowPtr;
955 friend class Type;
956 protected:
957 static const TypeInterfaces* interfaces(ciKlass*& k, bool klass, bool interface, bool array, InterfaceHandling interface_handling);
958
959 public:
960 enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
961 protected:
962 TypePtr(TYPES t, PTR ptr, int offset,
963 const TypePtr* speculative = nullptr,
964 int inline_depth = InlineDepthBottom) :
965 Type(t), _speculative(speculative), _inline_depth(inline_depth), _offset(offset),
966 _ptr(ptr) {}
967 static const PTR ptr_meet[lastPTR][lastPTR];
968 static const PTR ptr_dual[lastPTR];
969 static const char * const ptr_msg[lastPTR];
970
971 enum {
972 InlineDepthBottom = INT_MAX,
973 InlineDepthTop = -InlineDepthBottom
974 };
975
976 // Extra type information profiling gave us. We propagate it the
977 // same way the rest of the type info is propagated. If we want to
978 // use it, then we have to emit a guard: this part of the type is
979 // not something we know but something we speculate about the type.
980 const TypePtr* _speculative;
981 // For speculative types, we record at what inlining depth the
982 // profiling point that provided the data is. We want to favor
998 // utility methods to work on the inline depth of the type
999 int dual_inline_depth() const;
1000 int meet_inline_depth(int depth) const;
1001 #ifndef PRODUCT
1002 void dump_inline_depth(outputStream *st) const;
1003 #endif
1004
1005 // TypeInstPtr (TypeAryPtr resp.) and TypeInstKlassPtr (TypeAryKlassPtr resp.) implement very similar meet logic.
1006 // The logic for meeting 2 instances (2 arrays resp.) is shared in the 2 utility methods below. However the logic for
1007 // the oop and klass versions can be slightly different and extra logic may have to be executed depending on what
1008 // exact case the meet falls into. The MeetResult struct is used by the utility methods to communicate what case was
1009 // encountered so the right logic specific to klasses or oops can be executed.,
1010 enum MeetResult {
1011 QUICK,
1012 UNLOADED,
1013 SUBTYPE,
1014 NOT_SUBTYPE,
1015 LCA
1016 };
1017 template<class T> static TypePtr::MeetResult meet_instptr(PTR& ptr, const TypeInterfaces*& interfaces, const T* this_type,
1018 const T* other_type, ciKlass*& res_klass, bool& res_xk);
1019
1020 template<class T> static MeetResult meet_aryptr(PTR& ptr, const Type*& elem, const T* this_ary, const T* other_ary,
1021 ciKlass*& res_klass, bool& res_xk);
1022
1023 template <class T1, class T2> static bool is_java_subtype_of_helper_for_instance(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1024 template <class T1, class T2> static bool is_same_java_type_as_helper_for_instance(const T1* this_one, const T2* other);
1025 template <class T1, class T2> static bool maybe_java_subtype_of_helper_for_instance(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1026 template <class T1, class T2> static bool is_java_subtype_of_helper_for_array(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1027 template <class T1, class T2> static bool is_same_java_type_as_helper_for_array(const T1* this_one, const T2* other);
1028 template <class T1, class T2> static bool maybe_java_subtype_of_helper_for_array(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1029 template <class T1, class T2> static bool is_meet_subtype_of_helper_for_instance(const T1* this_one, const T2* other, bool this_xk, bool other_xk);
1030 template <class T1, class T2> static bool is_meet_subtype_of_helper_for_array(const T1* this_one, const T2* other, bool this_xk, bool other_xk);
1031 public:
1032 const int _offset; // Offset into oop, with TOP & BOT
1033 const PTR _ptr; // Pointer equivalence class
1034
1035 int offset() const { return _offset; }
1036 PTR ptr() const { return _ptr; }
1037
1038 static const TypePtr *make(TYPES t, PTR ptr, int offset,
1039 const TypePtr* speculative = nullptr,
1040 int inline_depth = InlineDepthBottom);
1041
1042 // Return a 'ptr' version of this type
1043 virtual const TypePtr* cast_to_ptr_type(PTR ptr) const;
1044
1045 virtual intptr_t get_con() const;
1046
1047 int xadd_offset( intptr_t offset ) const;
1048 virtual const TypePtr* add_offset(intptr_t offset) const;
1049 virtual const TypePtr* with_offset(intptr_t offset) const;
1050 virtual bool eq(const Type *t) const;
1051 virtual uint hash() const; // Type specific hashing
1052
1053 virtual bool singleton(void) const; // TRUE if type is a singleton
1054 virtual bool empty(void) const; // TRUE if type is vacuous
1055 virtual const Type *xmeet( const Type *t ) const;
1056 virtual const Type *xmeet_helper( const Type *t ) const;
1057 int meet_offset( int offset ) const;
1058 int dual_offset( ) const;
1059 virtual const Type *xdual() const; // Compute dual right now.
1060
1061 // meet, dual and join over pointer equivalence sets
1062 PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
1063 PTR dual_ptr() const { return ptr_dual[ptr()]; }
1064
1065 // This is textually confusing unless one recalls that
1066 // join(t) == dual()->meet(t->dual())->dual().
1067 PTR join_ptr( const PTR in_ptr ) const {
1068 return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
1069 }
1070
1071 // Speculative type helper methods.
1072 virtual const TypePtr* speculative() const { return _speculative; }
1073 int inline_depth() const { return _inline_depth; }
1074 virtual ciKlass* speculative_type() const;
1075 virtual ciKlass* speculative_type_not_null() const;
1076 virtual bool speculative_maybe_null() const;
1077 virtual bool speculative_always_null() const;
1078 virtual const TypePtr* remove_speculative() const;
1079 virtual const Type* cleanup_speculative() const;
1080 virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1081 virtual bool would_improve_ptr(ProfilePtrKind maybe_null) const;
1082 virtual const TypePtr* with_inline_depth(int depth) const;
1083
1084 virtual bool maybe_null() const { return meet_ptr(Null) == ptr(); }
1085
1086 // Tests for relation to centerline of type lattice:
1087 static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
1088 static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
1089 // Convenience common pre-built types.
1090 static const TypePtr *NULL_PTR;
1091 static const TypePtr *NOTNULL;
1092 static const TypePtr *BOTTOM;
1093 #ifndef PRODUCT
1094 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1095 #endif
1096 };
1097
1098 //------------------------------TypeRawPtr-------------------------------------
1099 // Class of raw pointers, pointers to things other than Oops. Examples
1100 // include the stack pointer, top of heap, card-marking area, handles, etc.
1101 class TypeRawPtr : public TypePtr {
1102 protected:
1103 TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){}
1104 public:
1105 virtual bool eq( const Type *t ) const;
1106 virtual uint hash() const; // Type specific hashing
1107
1108 const address _bits; // Constant value, if applicable
1109
1110 static const TypeRawPtr *make( PTR ptr );
1111 static const TypeRawPtr *make( address bits );
1112
1113 // Return a 'ptr' version of this type
1114 virtual const TypeRawPtr* cast_to_ptr_type(PTR ptr) const;
1115
1116 virtual intptr_t get_con() const;
1117
1118 virtual const TypePtr* add_offset(intptr_t offset) const;
1119 virtual const TypeRawPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr;}
1120
1121 virtual const Type *xmeet( const Type *t ) const;
1122 virtual const Type *xdual() const; // Compute dual right now.
1123 // Convenience common pre-built types.
1124 static const TypeRawPtr *BOTTOM;
1125 static const TypeRawPtr *NOTNULL;
1126 #ifndef PRODUCT
1127 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1128 #endif
1129 };
1130
1131 //------------------------------TypeOopPtr-------------------------------------
1132 // Some kind of oop (Java pointer), either instance or array.
1133 class TypeOopPtr : public TypePtr {
1134 friend class TypeAry;
1135 friend class TypePtr;
1136 friend class TypeInstPtr;
1137 friend class TypeAryPtr;
1138 protected:
1139 TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, int offset, int instance_id,
1140 const TypePtr* speculative, int inline_depth);
1141 public:
1142 virtual bool eq( const Type *t ) const;
1143 virtual uint hash() const; // Type specific hashing
1144 virtual bool singleton(void) const; // TRUE if type is a singleton
1145 enum {
1146 InstanceTop = -1, // undefined instance
1147 InstanceBot = 0 // any possible instance
1148 };
1149 protected:
1150
1151 // Oop is null, unless this is a constant oop.
1152 ciObject* _const_oop; // Constant oop
1153 // If _klass is null, then so is _sig. This is an unloaded klass.
1154 ciKlass* _klass; // Klass object
1155
1156 const TypeInterfaces* _interfaces;
1157
1158 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.)
1159 bool _klass_is_exact;
1160 bool _is_ptr_to_narrowoop;
1161 bool _is_ptr_to_narrowklass;
1162 bool _is_ptr_to_boxed_value;
1163
1164 // If not InstanceTop or InstanceBot, indicates that this is
1165 // a particular instance of this type which is distinct.
1166 // This is the node index of the allocation node creating this instance.
1167 int _instance_id;
1168
1169 static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact, InterfaceHandling interface_handling);
1170
1171 int dual_instance_id() const;
1172 int meet_instance_id(int uid) const;
1173
1174 const TypeInterfaces* meet_interfaces(const TypeOopPtr* other) const;
1175
1176 // Do not allow interface-vs.-noninterface joins to collapse to top.
1177 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1178
1179 virtual ciKlass* exact_klass_helper() const { return nullptr; }
1180 virtual ciKlass* klass() const { return _klass; }
1181
1182 public:
1183
1184 bool is_java_subtype_of(const TypeOopPtr* other) const {
1185 return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1186 }
1187
1188 bool is_same_java_type_as(const TypePtr* other) const {
1189 return is_same_java_type_as_helper(other->is_oopptr());
1190 }
1191
1192 virtual bool is_same_java_type_as_helper(const TypeOopPtr* other) const {
1193 ShouldNotReachHere(); return false;
1194 }
1195
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; }
1207 return make_from_klass_common(klass, true, false, interface_handling);
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, InterfaceHandling interface_handling= ignore_interfaces) {
1212 return make_from_klass_common(klass, true, true, interface_handling);
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, InterfaceHandling interface_handling = ignore_interfaces) {
1217 return make_from_klass_common(klass, false, false, interface_handling);
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, int offset, int instance_id,
1228 const TypePtr* speculative = nullptr,
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 != nullptr || 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 virtual 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 >= 0; }
1247
1248 virtual intptr_t get_con() const;
1249
1250 virtual const TypeOopPtr* cast_to_ptr_type(PTR ptr) const;
1251
1252 virtual const TypeOopPtr* cast_to_exactness(bool klass_is_exact) const;
1253
1254 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1255
1256 // corresponding pointer to klass, for a given instance
1257 virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1258
1259 virtual const TypeOopPtr* with_offset(intptr_t offset) const;
1260 virtual const TypePtr* add_offset(intptr_t offset) const;
1261
1262 // Speculative type helper methods.
1263 virtual const TypeOopPtr* remove_speculative() const;
1264 virtual const Type* cleanup_speculative() const;
1265 virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1266 virtual const TypePtr* with_inline_depth(int depth) const;
1289 return _interfaces;
1290 };
1291
1292 const TypeOopPtr* is_reference_type(const Type* other) const {
1293 return other->isa_oopptr();
1294 }
1295
1296 const TypeAryPtr* is_array_type(const TypeOopPtr* other) const {
1297 return other->isa_aryptr();
1298 }
1299
1300 const TypeInstPtr* is_instance_type(const TypeOopPtr* other) const {
1301 return other->isa_instptr();
1302 }
1303 };
1304
1305 //------------------------------TypeInstPtr------------------------------------
1306 // Class of Java object pointers, pointing either to non-array Java instances
1307 // or to a Klass* (including array klasses).
1308 class TypeInstPtr : public TypeOopPtr {
1309 TypeInstPtr(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, int off, int instance_id,
1310 const TypePtr* speculative, int inline_depth);
1311 virtual bool eq( const Type *t ) const;
1312 virtual uint hash() const; // Type specific hashing
1313
1314 ciKlass* exact_klass_helper() const;
1315
1316 public:
1317
1318 // Instance klass, ignoring any interface
1319 ciInstanceKlass* instance_klass() const {
1320 assert(!(klass()->is_loaded() && klass()->is_interface()), "");
1321 return klass()->as_instance_klass();
1322 }
1323
1324 bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1325 bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1326 bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1327
1328 // Make a pointer to a constant oop.
1329 static const TypeInstPtr *make(ciObject* o) {
1330 ciKlass* k = o->klass();
1331 const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1332 return make(TypePtr::Constant, k, interfaces, true, o, 0, InstanceBot);
1333 }
1334 // Make a pointer to a constant oop with offset.
1335 static const TypeInstPtr *make(ciObject* o, int offset) {
1336 ciKlass* k = o->klass();
1337 const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1338 return make(TypePtr::Constant, k, interfaces, true, o, offset, InstanceBot);
1339 }
1340
1341 // Make a pointer to some value of type klass.
1342 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1343 const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, true, false, interface_handling);
1344 return make(ptr, klass, interfaces, false, nullptr, 0, InstanceBot);
1345 }
1346
1347 // Make a pointer to some non-polymorphic value of exactly type klass.
1348 static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
1349 const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1350 return make(ptr, klass, interfaces, true, nullptr, 0, InstanceBot);
1351 }
1352
1353 // Make a pointer to some value of type klass with offset.
1354 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
1355 const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1356 return make(ptr, klass, interfaces, false, nullptr, offset, InstanceBot);
1357 }
1358
1359 static const TypeInstPtr *make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, int offset,
1360 int instance_id = InstanceBot,
1361 const TypePtr* speculative = nullptr,
1362 int inline_depth = InlineDepthBottom);
1363
1364 static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot) {
1365 const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1366 return make(ptr, k, interfaces, xk, o, offset, instance_id);
1367 }
1368
1369 /** Create constant type for a constant boxed value */
1370 const Type* get_const_boxed_value() const;
1371
1372 // If this is a java.lang.Class constant, return the type for it or null.
1373 // Pass to Type::get_const_type to turn it to a type, which will usually
1374 // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
1375 ciType* java_mirror_type() const;
1376
1377 virtual const TypeInstPtr* cast_to_ptr_type(PTR ptr) const;
1378
1379 virtual const TypeInstPtr* cast_to_exactness(bool klass_is_exact) const;
1380
1381 virtual const TypeInstPtr* cast_to_instance_id(int instance_id) const;
1382
1383 virtual const TypePtr* add_offset(intptr_t offset) const;
1384 virtual const TypeInstPtr* with_offset(intptr_t offset) const;
1385
1386 // Speculative type helper methods.
1387 virtual const TypeInstPtr* remove_speculative() const;
1388 const TypeInstPtr* with_speculative(const TypePtr* speculative) const;
1389 virtual const TypePtr* with_inline_depth(int depth) const;
1390 virtual const TypePtr* with_instance_id(int instance_id) const;
1391
1392 // the core of the computation of the meet of 2 types
1393 virtual const Type *xmeet_helper(const Type *t) const;
1394 virtual const TypeInstPtr *xmeet_unloaded(const TypeInstPtr *tinst, const TypeInterfaces* interfaces) const;
1395 virtual const Type *xdual() const; // Compute dual right now.
1396
1397 const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1398
1399 // Convenience common pre-built types.
1400 static const TypeInstPtr *NOTNULL;
1401 static const TypeInstPtr *BOTTOM;
1402 static const TypeInstPtr *MIRROR;
1403 static const TypeInstPtr *MARK;
1404 static const TypeInstPtr *KLASS;
1405 #ifndef PRODUCT
1406 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1407 #endif
1408
1409 private:
1410 virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1411
1412 virtual bool is_meet_same_type_as(const TypePtr* other) const {
1413 return _klass->equals(other->is_instptr()->_klass) && _interfaces->eq(other->is_instptr()->_interfaces);
1414 }
1415
1416 };
1417
1418 //------------------------------TypeAryPtr-------------------------------------
1419 // Class of Java array pointers
1420 class TypeAryPtr : public TypeOopPtr {
1421 friend class Type;
1422 friend class TypePtr;
1423
1424 TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1425 int offset, int instance_id, bool is_autobox_cache,
1426 const TypePtr* speculative, int inline_depth)
1427 : TypeOopPtr(AryPtr,ptr,k,_array_interfaces,xk,o,offset, instance_id, speculative, inline_depth),
1428 _ary(ary),
1429 _is_autobox_cache(is_autobox_cache)
1430 {
1431 int dummy;
1432 bool top_or_bottom = (base_element_type(dummy) == Type::TOP || base_element_type(dummy) == Type::BOTTOM);
1433
1434 if (UseCompressedOops && (elem()->make_oopptr() != nullptr && !top_or_bottom) &&
1435 _offset != 0 && _offset != arrayOopDesc::length_offset_in_bytes() &&
1436 _offset != arrayOopDesc::klass_offset_in_bytes()) {
1437 _is_ptr_to_narrowoop = true;
1438 }
1439
1440 }
1441 virtual bool eq( const Type *t ) const;
1442 virtual uint hash() const; // Type specific hashing
1443 const TypeAry *_ary; // Array we point into
1444 const bool _is_autobox_cache;
1445
1446 ciKlass* compute_klass() const;
1447
1448 // A pointer to delay allocation to Type::Initialize_shared()
1449
1450 static const TypeInterfaces* _array_interfaces;
1451 ciKlass* exact_klass_helper() const;
1452 // Only guaranteed non null for array of basic types
1453 ciKlass* klass() const;
1454
1455 public:
1456
1457 bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1458 bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1459 bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1460
1461 // returns base element type, an instance klass (and not interface) for object arrays
1462 const Type* base_element_type(int& dims) const;
1463
1464 // Accessors
1465 bool is_loaded() const { return (_ary->_elem->make_oopptr() ? _ary->_elem->make_oopptr()->is_loaded() : true); }
1466
1467 const TypeAry* ary() const { return _ary; }
1468 const Type* elem() const { return _ary->_elem; }
1469 const TypeInt* size() const { return _ary->_size; }
1470 bool is_stable() const { return _ary->_stable; }
1471
1472 bool is_autobox_cache() const { return _is_autobox_cache; }
1473
1474 static const TypeAryPtr *make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset,
1475 int instance_id = InstanceBot,
1476 const TypePtr* speculative = nullptr,
1477 int inline_depth = InlineDepthBottom);
1478 // Constant pointer to array
1479 static const TypeAryPtr *make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset,
1480 int instance_id = InstanceBot,
1481 const TypePtr* speculative = nullptr,
1482 int inline_depth = InlineDepthBottom, bool is_autobox_cache = false);
1483
1484 // Return a 'ptr' version of this type
1485 virtual const TypeAryPtr* cast_to_ptr_type(PTR ptr) const;
1486
1487 virtual const TypeAryPtr* cast_to_exactness(bool klass_is_exact) const;
1488
1489 virtual const TypeAryPtr* cast_to_instance_id(int instance_id) const;
1490
1491 virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1492 virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1493
1494 virtual bool empty(void) const; // TRUE if type is vacuous
1495 virtual const TypePtr *add_offset( intptr_t offset ) const;
1496 virtual const TypeAryPtr *with_offset( intptr_t offset ) const;
1497 const TypeAryPtr* with_ary(const TypeAry* ary) const;
1498
1499 // Speculative type helper methods.
1500 virtual const TypeAryPtr* remove_speculative() const;
1501 virtual const TypePtr* with_inline_depth(int depth) const;
1502 virtual const TypePtr* with_instance_id(int instance_id) const;
1503
1504 // the core of the computation of the meet of 2 types
1505 virtual const Type *xmeet_helper(const Type *t) const;
1506 virtual const Type *xdual() const; // Compute dual right now.
1507
1508 const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1509 int stable_dimension() const;
1510
1511 const TypeAryPtr* cast_to_autobox_cache() const;
1512
1513 static jint max_array_length(BasicType etype) ;
1514 virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1515
1516 // Convenience common pre-built types.
1517 static const TypeAryPtr* BOTTOM;
1518 static const TypeAryPtr* RANGE;
1519 static const TypeAryPtr* OOPS;
1520 static const TypeAryPtr* NARROWOOPS;
1521 static const TypeAryPtr* BYTES;
1522 static const TypeAryPtr* SHORTS;
1523 static const TypeAryPtr* CHARS;
1524 static const TypeAryPtr* INTS;
1525 static const TypeAryPtr* LONGS;
1526 static const TypeAryPtr* FLOATS;
1527 static const TypeAryPtr* DOUBLES;
1528 // selects one of the above:
1529 static const TypeAryPtr *get_array_body_type(BasicType elem) {
1530 assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != nullptr, "bad elem type");
1531 return _array_body_type[elem];
1532 }
1533 static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1534 // sharpen the type of an int which is used as an array size
1535 #ifndef PRODUCT
1536 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1537 #endif
1538 private:
1539 virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1540 };
1541
1542 //------------------------------TypeMetadataPtr-------------------------------------
1543 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
1544 class TypeMetadataPtr : public TypePtr {
1545 protected:
1546 TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset);
1547 // Do not allow interface-vs.-noninterface joins to collapse to top.
1548 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1549 public:
1550 virtual bool eq( const Type *t ) const;
1551 virtual uint hash() const; // Type specific hashing
1552 virtual bool singleton(void) const; // TRUE if type is a singleton
1553
1554 private:
1555 ciMetadata* _metadata;
1556
1557 public:
1558 static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, int offset);
1559
1560 static const TypeMetadataPtr* make(ciMethod* m);
1561 static const TypeMetadataPtr* make(ciMethodData* m);
1562
1563 ciMetadata* metadata() const { return _metadata; }
1564
1565 virtual const TypeMetadataPtr* cast_to_ptr_type(PTR ptr) const;
1566
1567 virtual const TypePtr *add_offset( intptr_t offset ) const;
1568
1569 virtual const Type *xmeet( const Type *t ) const;
1570 virtual const Type *xdual() const; // Compute dual right now.
1571
1572 virtual intptr_t get_con() const;
1573
1574 // Convenience common pre-built types.
1575 static const TypeMetadataPtr *BOTTOM;
1576
1577 #ifndef PRODUCT
1578 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1579 #endif
1580 };
1581
1582 //------------------------------TypeKlassPtr-----------------------------------
1583 // Class of Java Klass pointers
1584 class TypeKlassPtr : public TypePtr {
1585 friend class TypeInstKlassPtr;
1586 friend class TypeAryKlassPtr;
1587 friend class TypePtr;
1588 protected:
1589 TypeKlassPtr(TYPES t, PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, int offset);
1590
1591 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1592
1593 public:
1594 virtual bool eq( const Type *t ) const;
1595 virtual uint hash() const;
1596 virtual bool singleton(void) const; // TRUE if type is a singleton
1597
1598 protected:
1599
1600 ciKlass* _klass;
1601 const TypeInterfaces* _interfaces;
1602 const TypeInterfaces* meet_interfaces(const TypeKlassPtr* other) const;
1603 virtual bool must_be_exact() const { ShouldNotReachHere(); return false; }
1604 virtual ciKlass* exact_klass_helper() const;
1605 virtual ciKlass* klass() const { return _klass; }
1606
1607 public:
1608
1609 bool is_java_subtype_of(const TypeKlassPtr* other) const {
1610 return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1611 }
1612 bool is_same_java_type_as(const TypePtr* other) const {
1613 return is_same_java_type_as_helper(other->is_klassptr());
1614 }
1615
1616 bool maybe_java_subtype_of(const TypeKlassPtr* other) const {
1617 return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1618 }
1619 virtual bool is_same_java_type_as_helper(const TypeKlassPtr* other) const { ShouldNotReachHere(); return false; }
1620 virtual bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1621 virtual bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1622
1623 // Exact klass, possibly an interface or an array of interface
1624 ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k; }
1625 virtual bool klass_is_exact() const { return _ptr == Constant; }
1626
1627 static const TypeKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces);
1628 static const TypeKlassPtr *make(PTR ptr, ciKlass* klass, int offset, InterfaceHandling interface_handling = ignore_interfaces);
1629
1630 virtual bool is_loaded() const { return _klass->is_loaded(); }
1631
1632 virtual const TypeKlassPtr* cast_to_ptr_type(PTR ptr) const { ShouldNotReachHere(); return nullptr; }
1633
1634 virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const { ShouldNotReachHere(); return nullptr; }
1635
1636 // corresponding pointer to instance, for a given class
1637 virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const { ShouldNotReachHere(); return nullptr; }
1638
1639 virtual const TypePtr *add_offset( intptr_t offset ) const { ShouldNotReachHere(); return nullptr; }
1640 virtual const Type *xmeet( const Type *t ) const { ShouldNotReachHere(); return nullptr; }
1641 virtual const Type *xdual() const { ShouldNotReachHere(); return nullptr; }
1642
1643 virtual intptr_t get_con() const;
1644
1645 virtual const TypeKlassPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr; }
1646
1647 virtual const TypeKlassPtr* try_improve() const { return this; }
1648
1649 #ifndef PRODUCT
1650 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1651 #endif
1652 private:
1653 virtual bool is_meet_subtype_of(const TypePtr* other) const {
1654 return is_meet_subtype_of_helper(other->is_klassptr(), klass_is_exact(), other->is_klassptr()->klass_is_exact());
1655 }
1656
1657 virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const {
1658 ShouldNotReachHere(); return false;
1659 }
1660
1661 virtual const TypeInterfaces* interfaces() const {
1662 return _interfaces;
1663 };
1664
1665 const TypeKlassPtr* is_reference_type(const Type* other) const {
1666 return other->isa_klassptr();
1667 }
1668
1669 const TypeAryKlassPtr* is_array_type(const TypeKlassPtr* other) const {
1670 return other->isa_aryklassptr();
1671 }
1672
1673 const TypeInstKlassPtr* is_instance_type(const TypeKlassPtr* other) const {
1674 return other->isa_instklassptr();
1675 }
1676 };
1677
1678 // Instance klass pointer, mirrors TypeInstPtr
1679 class TypeInstKlassPtr : public TypeKlassPtr {
1680
1681 TypeInstKlassPtr(PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, int offset)
1682 : TypeKlassPtr(InstKlassPtr, ptr, klass, interfaces, offset) {
1683 assert(klass->is_instance_klass() && (!klass->is_loaded() || !klass->is_interface()), "");
1684 }
1685
1686 virtual bool must_be_exact() const;
1687
1688 public:
1689 // Instance klass ignoring any interface
1690 ciInstanceKlass* instance_klass() const {
1691 assert(!klass()->is_interface(), "");
1692 return klass()->as_instance_klass();
1693 }
1694
1695 bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
1696 bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1697 bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1698
1699 static const TypeInstKlassPtr *make(ciKlass* k, InterfaceHandling interface_handling) {
1700 const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, true, false, interface_handling);
1701 return make(TypePtr::Constant, k, interfaces, 0);
1702 }
1703 static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, int offset);
1704
1705 static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, int offset) {
1706 const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1707 return make(ptr, k, interfaces, offset);
1708 }
1709
1710 virtual const TypeInstKlassPtr* cast_to_ptr_type(PTR ptr) const;
1711
1712 virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1713
1714 // corresponding pointer to instance, for a given class
1715 virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
1716 virtual uint hash() const;
1717 virtual bool eq(const Type *t) const;
1718
1719 virtual const TypePtr *add_offset( intptr_t offset ) const;
1720 virtual const Type *xmeet( const Type *t ) const;
1721 virtual const Type *xdual() const;
1722 virtual const TypeInstKlassPtr* with_offset(intptr_t offset) const;
1723
1724 virtual const TypeKlassPtr* try_improve() const;
1725
1726 // Convenience common pre-built types.
1727 static const TypeInstKlassPtr* OBJECT; // Not-null object klass or below
1728 static const TypeInstKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
1729 private:
1730 virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
1731 };
1732
1733 // Array klass pointer, mirrors TypeAryPtr
1734 class TypeAryKlassPtr : public TypeKlassPtr {
1735 friend class TypeInstKlassPtr;
1736 friend class Type;
1737 friend class TypePtr;
1738
1739 const Type *_elem;
1740
1741 static const TypeInterfaces* _array_interfaces;
1742 TypeAryKlassPtr(PTR ptr, const Type *elem, ciKlass* klass, int offset)
1743 : TypeKlassPtr(AryKlassPtr, ptr, klass, _array_interfaces, offset), _elem(elem) {
1744 assert(klass == nullptr || klass->is_type_array_klass() || !klass->as_obj_array_klass()->base_element_klass()->is_interface(), "");
1745 }
1746
1747 virtual ciKlass* exact_klass_helper() const;
1748 // Only guaranteed non null for array of basic types
1749 virtual ciKlass* klass() const;
1750
1751 virtual bool must_be_exact() const;
1752
1753 public:
1754
1755 // returns base element type, an instance klass (and not interface) for object arrays
1756 const Type* base_element_type(int& dims) const;
1757
1758 static const TypeAryKlassPtr *make(PTR ptr, ciKlass* k, int offset, InterfaceHandling interface_handling);
1759
1760 bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
1761 bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1762 bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1763
1764 bool is_loaded() const { return (_elem->isa_klassptr() ? _elem->is_klassptr()->is_loaded() : true); }
1765
1766 static const TypeAryKlassPtr *make(PTR ptr, const Type *elem, ciKlass* k, int offset);
1767 static const TypeAryKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling);
1768
1769 const Type *elem() const { return _elem; }
1770
1771 virtual bool eq(const Type *t) const;
1772 virtual uint hash() const; // Type specific hashing
1773
1774 virtual const TypeAryKlassPtr* cast_to_ptr_type(PTR ptr) const;
1775
1776 virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1777
1778 // corresponding pointer to instance, for a given class
1779 virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
1780
1781 virtual const TypePtr *add_offset( intptr_t offset ) const;
1782 virtual const Type *xmeet( const Type *t ) const;
1783 virtual const Type *xdual() const; // Compute dual right now.
1784
1785 virtual const TypeAryKlassPtr* with_offset(intptr_t offset) const;
1786
1787 virtual bool empty(void) const {
1788 return TypeKlassPtr::empty() || _elem->empty();
1789 }
1790
1791 #ifndef PRODUCT
1792 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1793 #endif
1794 private:
1795 virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
1796 };
1797
1798 class TypeNarrowPtr : public Type {
1799 protected:
1800 const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
1801
1802 TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): Type(t),
1803 _ptrtype(ptrtype) {
1804 assert(ptrtype->offset() == 0 ||
1805 ptrtype->offset() == OffsetBot ||
1806 ptrtype->offset() == OffsetTop, "no real offsets");
1807 }
1808
1809 virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
1810 virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;
1906 }
1907
1908 virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
1909 return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
1910 }
1911
1912 public:
1913 static const TypeNarrowKlass *make( const TypePtr* type);
1914
1915 // static const TypeNarrowKlass *BOTTOM;
1916 static const TypeNarrowKlass *NULL_PTR;
1917
1918 #ifndef PRODUCT
1919 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1920 #endif
1921 };
1922
1923 //------------------------------TypeFunc---------------------------------------
1924 // Class of Array Types
1925 class TypeFunc : public Type {
1926 TypeFunc( const TypeTuple *domain, const TypeTuple *range ) : Type(Function), _domain(domain), _range(range) {}
1927 virtual bool eq( const Type *t ) const;
1928 virtual uint hash() const; // Type specific hashing
1929 virtual bool singleton(void) const; // TRUE if type is a singleton
1930 virtual bool empty(void) const; // TRUE if type is vacuous
1931
1932 const TypeTuple* const _domain; // Domain of inputs
1933 const TypeTuple* const _range; // Range of results
1934
1935 public:
1936 // Constants are shared among ADLC and VM
1937 enum { Control = AdlcVMDeps::Control,
1938 I_O = AdlcVMDeps::I_O,
1939 Memory = AdlcVMDeps::Memory,
1940 FramePtr = AdlcVMDeps::FramePtr,
1941 ReturnAdr = AdlcVMDeps::ReturnAdr,
1942 Parms = AdlcVMDeps::Parms
1943 };
1944
1945
1946 // Accessors:
1947 const TypeTuple* domain() const { return _domain; }
1948 const TypeTuple* range() const { return _range; }
1949
1950 static const TypeFunc *make(ciMethod* method);
1951 static const TypeFunc *make(ciSignature signature, const Type* extra);
1952 static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
1953
1954 virtual const Type *xmeet( const Type *t ) const;
1955 virtual const Type *xdual() const; // Compute dual right now.
1956
1957 BasicType return_type() const;
1958
1959 #ifndef PRODUCT
1960 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1961 #endif
1962 // Convenience common pre-built types.
1963 };
1964
1965 //------------------------------accessors--------------------------------------
1966 inline bool Type::is_ptr_to_narrowoop() const {
1967 #ifdef _LP64
1968 return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowoop_nv());
1969 #else
1970 return false;
1971 #endif
1972 }
1973
1974 inline bool Type::is_ptr_to_narrowklass() const {
1975 #ifdef _LP64
1976 return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowklass_nv());
1977 #else
1978 return false;
2215 }
2216
2217 inline const TypeNarrowOop* Type::make_narrowoop() const {
2218 return (_base == NarrowOop) ? is_narrowoop() :
2219 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : nullptr);
2220 }
2221
2222 inline const TypeNarrowKlass* Type::make_narrowklass() const {
2223 return (_base == NarrowKlass) ? is_narrowklass() :
2224 (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : nullptr);
2225 }
2226
2227 inline bool Type::is_floatingpoint() const {
2228 if( (_base == HalfFloatCon) || (_base == HalfFloatBot) ||
2229 (_base == FloatCon) || (_base == FloatBot) ||
2230 (_base == DoubleCon) || (_base == DoubleBot) )
2231 return true;
2232 return false;
2233 }
2234
2235 template <>
2236 inline const TypeInt* Type::cast<TypeInt>() const {
2237 return is_int();
2238 }
2239
2240 template <>
2241 inline const TypeLong* Type::cast<TypeLong>() const {
2242 return is_long();
2243 }
2244
2245 // ===============================================================
2246 // Things that need to be 64-bits in the 64-bit build but
2247 // 32-bits in the 32-bit build. Done this way to get full
2248 // optimization AND strong typing.
2249 #ifdef _LP64
2250
2251 // For type queries and asserts
2252 #define is_intptr_t is_long
2253 #define isa_intptr_t isa_long
2254 #define find_intptr_t_type find_long_type
2255 #define find_intptr_t_con find_long_con
2256 #define TypeX TypeLong
2257 #define Type_X Type::Long
2258 #define TypeX_X TypeLong::LONG
2259 #define TypeX_ZERO TypeLong::ZERO
2260 // For 'ideal_reg' machine registers
2261 #define Op_RegX Op_RegL
2262 // For phase->intcon variants
2263 #define MakeConX longcon
2264 #define ConXNode ConLNode
2265 // For array index arithmetic
2266 #define MulXNode MulLNode
2267 #define AndXNode AndLNode
2268 #define OrXNode OrLNode
2269 #define CmpXNode CmpLNode
2270 #define SubXNode SubLNode
2271 #define LShiftXNode LShiftLNode
2272 // For object size computation:
2273 #define AddXNode AddLNode
2274 #define RShiftXNode RShiftLNode
2275 // For card marks and hashcodes
2276 #define URShiftXNode URShiftLNode
2277 // For shenandoahSupport
2278 #define LoadXNode LoadLNode
2279 #define StoreXNode StoreLNode
2280 // Opcodes
2281 #define Op_LShiftX Op_LShiftL
2282 #define Op_AndX Op_AndL
2283 #define Op_AddX Op_AddL
2284 #define Op_SubX Op_SubL
2285 #define Op_XorX Op_XorL
2286 #define Op_URShiftX Op_URShiftL
2287 #define Op_LoadX Op_LoadL
2288 // conversions
2289 #define ConvI2X(x) ConvI2L(x)
2290 #define ConvL2X(x) (x)
2291 #define ConvX2I(x) ConvL2I(x)
2292 #define ConvX2L(x) (x)
2293 #define ConvX2UL(x) (x)
2294
2295 #else
2296
2297 // For type queries and asserts
2298 #define is_intptr_t is_int
2299 #define isa_intptr_t isa_int
2300 #define find_intptr_t_type find_int_type
2301 #define find_intptr_t_con find_int_con
2302 #define TypeX TypeInt
2303 #define Type_X Type::Int
2304 #define TypeX_X TypeInt::INT
2305 #define TypeX_ZERO TypeInt::ZERO
2306 // For 'ideal_reg' machine registers
2307 #define Op_RegX Op_RegI
2308 // For phase->intcon variants
2309 #define MakeConX intcon
2310 #define ConXNode ConINode
2311 // For array index arithmetic
2312 #define MulXNode MulINode
2313 #define AndXNode AndINode
2314 #define OrXNode OrINode
2315 #define CmpXNode CmpINode
2316 #define SubXNode SubINode
2317 #define LShiftXNode LShiftINode
2318 // For object size computation:
2319 #define AddXNode AddINode
2320 #define RShiftXNode RShiftINode
2321 // For card marks and hashcodes
2322 #define URShiftXNode URShiftINode
2323 // For shenandoahSupport
2324 #define LoadXNode LoadINode
2325 #define StoreXNode StoreINode
2326 // Opcodes
2327 #define Op_LShiftX Op_LShiftI
2328 #define Op_AndX Op_AndI
2329 #define Op_AddX Op_AddI
2330 #define Op_SubX Op_SubI
2331 #define Op_XorX Op_XorI
2332 #define Op_URShiftX Op_URShiftI
2333 #define Op_LoadX Op_LoadI
2334 // conversions
2335 #define ConvI2X(x) (x)
2336 #define ConvL2X(x) ConvL2I(x)
2337 #define ConvX2I(x) (x)
2338 #define ConvX2L(x) ConvI2L(x)
2339 #define ConvX2UL(x) ConvI2UL(x)
2340
2341 #endif
2342
2343 #endif // SHARE_OPTO_TYPE_HPP
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_OPTO_TYPE_HPP
26 #define SHARE_OPTO_TYPE_HPP
27
28 #include "ci/ciInlineKlass.hpp"
29 #include "opto/adlcVMDeps.hpp"
30 #include "runtime/handles.hpp"
31 #include "runtime/sharedRuntime.hpp"
32
33 // Portions of code courtesy of Clifford Click
34
35 // Optimization - Graph Style
36
37
38 // This class defines a Type lattice. The lattice is used in the constant
39 // propagation algorithms, and for some type-checking of the iloc code.
40 // Basic types include RSD's (lower bound, upper bound, stride for integers),
41 // float & double precision constants, sets of data-labels and code-labels.
42 // The complete lattice is described below. Subtypes have no relationship to
43 // up or down in the lattice; that is entirely determined by the behavior of
44 // the MEET/JOIN functions.
45
46 class Dict;
47 class Type;
48 class TypeD;
49 class TypeF;
50 class TypeH;
51 class TypeInteger;
124 Memory, // Abstract store
125 HalfFloatTop, // No float value
126 HalfFloatCon, // Floating point constant
127 HalfFloatBot, // Any float value
128 FloatTop, // No float value
129 FloatCon, // Floating point constant
130 FloatBot, // Any float value
131 DoubleTop, // No double value
132 DoubleCon, // Double precision constant
133 DoubleBot, // Any double value
134 Bottom, // Bottom of lattice
135 lastype // Bogus ending type (not in lattice)
136 };
137
138 // Signal values for offsets from a base pointer
139 enum OFFSET_SIGNALS {
140 OffsetTop = -2000000000, // undefined offset
141 OffsetBot = -2000000001 // any possible offset
142 };
143
144 class Offset {
145 private:
146 int _offset;
147
148 public:
149 explicit Offset(int offset) : _offset(offset) {}
150
151 const Offset meet(const Offset other) const;
152 const Offset dual() const;
153 const Offset add(intptr_t offset) const;
154 bool operator==(const Offset& other) const {
155 return _offset == other._offset;
156 }
157 bool operator!=(const Offset& other) const {
158 return _offset != other._offset;
159 }
160 int get() const { return _offset; }
161
162 void dump2(outputStream *st) const;
163
164 static const Offset top;
165 static const Offset bottom;
166 };
167
168 // Min and max WIDEN values.
169 enum WIDEN {
170 WidenMin = 0,
171 WidenMax = 3
172 };
173
174 private:
175 typedef struct {
176 TYPES dual_type;
177 BasicType basic_type;
178 const char* msg;
179 bool isa_oop;
180 uint ideal_reg;
181 relocInfo::relocType reloc;
182 } TypeInfo;
183
184 // Dictionary of types shared among compilations.
185 static Dict* _shared_type_dict;
186 static const TypeInfo _type_info[];
187
345 const TypeInstPtr *isa_instptr() const; // Returns null if not InstPtr
346 const TypeInstPtr *is_instptr() const; // Instance
347 const TypeAryPtr *isa_aryptr() const; // Returns null if not AryPtr
348 const TypeAryPtr *is_aryptr() const; // Array oop
349
350 template <typename TypeClass>
351 const TypeClass* cast() const;
352
353 const TypeMetadataPtr *isa_metadataptr() const; // Returns null if not oop ptr type
354 const TypeMetadataPtr *is_metadataptr() const; // Java-style GC'd pointer
355 const TypeKlassPtr *isa_klassptr() const; // Returns null if not KlassPtr
356 const TypeKlassPtr *is_klassptr() const; // assert if not KlassPtr
357 const TypeInstKlassPtr *isa_instklassptr() const; // Returns null if not IntKlassPtr
358 const TypeInstKlassPtr *is_instklassptr() const; // assert if not IntKlassPtr
359 const TypeAryKlassPtr *isa_aryklassptr() const; // Returns null if not AryKlassPtr
360 const TypeAryKlassPtr *is_aryklassptr() const; // assert if not AryKlassPtr
361
362 virtual bool is_finite() const; // Has a finite value
363 virtual bool is_nan() const; // Is not a number (NaN)
364
365 bool is_inlinetypeptr() const;
366 virtual ciInlineKlass* inline_klass() const;
367
368 // Returns this ptr type or the equivalent ptr type for this compressed pointer.
369 const TypePtr* make_ptr() const;
370
371 // Returns this oopptr type or the equivalent oopptr type for this compressed pointer.
372 // Asserts if the underlying type is not an oopptr or narrowoop.
373 const TypeOopPtr* make_oopptr() const;
374
375 // Returns this compressed pointer or the equivalent compressed version
376 // of this pointer type.
377 const TypeNarrowOop* make_narrowoop() const;
378
379 // Returns this compressed klass pointer or the equivalent
380 // compressed version of this pointer type.
381 const TypeNarrowKlass* make_narrowklass() const;
382
383 // Special test for register pressure heuristic
384 bool is_floatingpoint() const; // True if Float or Double base type
385
386 // Do you have memory, directly or through a tuple?
387 bool has_memory( ) const;
780 const Type ** const _fields; // Array of field types
781
782 public:
783 virtual bool eq( const Type *t ) const;
784 virtual uint hash() const; // Type specific hashing
785 virtual bool singleton(void) const; // TRUE if type is a singleton
786 virtual bool empty(void) const; // TRUE if type is vacuous
787
788 // Accessors:
789 uint cnt() const { return _cnt; }
790 const Type* field_at(uint i) const {
791 assert(i < _cnt, "oob");
792 return _fields[i];
793 }
794 void set_field_at(uint i, const Type* t) {
795 assert(i < _cnt, "oob");
796 _fields[i] = t;
797 }
798
799 static const TypeTuple *make( uint cnt, const Type **fields );
800 static const TypeTuple *make_range(ciSignature* sig, InterfaceHandling interface_handling = ignore_interfaces, bool ret_vt_fields = false);
801 static const TypeTuple *make_domain(ciMethod* method, InterfaceHandling interface_handling, bool vt_fields_as_args = false);
802
803 // Subroutine call type with space allocated for argument types
804 // Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly
805 static const Type **fields( uint arg_cnt );
806
807 virtual const Type *xmeet( const Type *t ) const;
808 virtual const Type *xdual() const; // Compute dual right now.
809 // Convenience common pre-built types.
810 static const TypeTuple *IFBOTH;
811 static const TypeTuple *IFFALSE;
812 static const TypeTuple *IFTRUE;
813 static const TypeTuple *IFNEITHER;
814 static const TypeTuple *LOOPBODY;
815 static const TypeTuple *MEMBAR;
816 static const TypeTuple *STORECONDITIONAL;
817 static const TypeTuple *START_I2C;
818 static const TypeTuple *INT_PAIR;
819 static const TypeTuple *LONG_PAIR;
820 static const TypeTuple *INT_CC_PAIR;
821 static const TypeTuple *LONG_CC_PAIR;
822 #ifndef PRODUCT
823 virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping
824 #endif
825 };
826
827 //------------------------------TypeAry----------------------------------------
828 // Class of Array Types
829 class TypeAry : public Type {
830 TypeAry(const Type* elem, const TypeInt* size, bool stable, bool flat, bool not_flat, bool not_null_free) : Type(Array),
831 _elem(elem), _size(size), _stable(stable), _flat(flat), _not_flat(not_flat), _not_null_free(not_null_free) {}
832 public:
833 virtual bool eq( const Type *t ) const;
834 virtual uint hash() const; // Type specific hashing
835 virtual bool singleton(void) const; // TRUE if type is a singleton
836 virtual bool empty(void) const; // TRUE if type is vacuous
837
838 private:
839 const Type *_elem; // Element type of array
840 const TypeInt *_size; // Elements in array
841 const bool _stable; // Are elements @Stable?
842
843 // Inline type array properties
844 const bool _flat; // Array is flat
845 const bool _not_flat; // Array is never flat
846 const bool _not_null_free; // Array is never null-free
847
848 friend class TypeAryPtr;
849
850 public:
851 static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false,
852 bool flat = false, bool not_flat = false, bool not_null_free = false);
853
854 virtual const Type *xmeet( const Type *t ) const;
855 virtual const Type *xdual() const; // Compute dual right now.
856 bool ary_must_be_exact() const; // true if arrays of such are never generic
857 virtual const TypeAry* remove_speculative() const;
858 virtual const Type* cleanup_speculative() const;
859 #ifndef PRODUCT
860 virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping
861 #endif
862 };
863
864 //------------------------------TypeVect---------------------------------------
865 // Class of Vector Types
866 class TypeVect : public Type {
867 const BasicType _elem_bt; // Vector's element type
868 const uint _length; // Elements in vector (power of 2)
869
870 protected:
871 TypeVect(TYPES t, BasicType elem_bt, uint length) : Type(t),
872 _elem_bt(elem_bt), _length(length) {}
978
979 const Type* xmeet(const Type* t) const;
980
981 bool singleton(void) const;
982 };
983
984 //------------------------------TypePtr----------------------------------------
985 // Class of machine Pointer Types: raw data, instances or arrays.
986 // If the _base enum is AnyPtr, then this refers to all of the above.
987 // Otherwise the _base will indicate which subset of pointers is affected,
988 // and the class will be inherited from.
989 class TypePtr : public Type {
990 friend class TypeNarrowPtr;
991 friend class Type;
992 protected:
993 static const TypeInterfaces* interfaces(ciKlass*& k, bool klass, bool interface, bool array, InterfaceHandling interface_handling);
994
995 public:
996 enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
997 protected:
998 TypePtr(TYPES t, PTR ptr, Offset offset,
999 const TypePtr* speculative = nullptr,
1000 int inline_depth = InlineDepthBottom) :
1001 Type(t), _speculative(speculative), _inline_depth(inline_depth), _offset(offset),
1002 _ptr(ptr) {}
1003 static const PTR ptr_meet[lastPTR][lastPTR];
1004 static const PTR ptr_dual[lastPTR];
1005 static const char * const ptr_msg[lastPTR];
1006
1007 enum {
1008 InlineDepthBottom = INT_MAX,
1009 InlineDepthTop = -InlineDepthBottom
1010 };
1011
1012 // Extra type information profiling gave us. We propagate it the
1013 // same way the rest of the type info is propagated. If we want to
1014 // use it, then we have to emit a guard: this part of the type is
1015 // not something we know but something we speculate about the type.
1016 const TypePtr* _speculative;
1017 // For speculative types, we record at what inlining depth the
1018 // profiling point that provided the data is. We want to favor
1034 // utility methods to work on the inline depth of the type
1035 int dual_inline_depth() const;
1036 int meet_inline_depth(int depth) const;
1037 #ifndef PRODUCT
1038 void dump_inline_depth(outputStream *st) const;
1039 #endif
1040
1041 // TypeInstPtr (TypeAryPtr resp.) and TypeInstKlassPtr (TypeAryKlassPtr resp.) implement very similar meet logic.
1042 // The logic for meeting 2 instances (2 arrays resp.) is shared in the 2 utility methods below. However the logic for
1043 // the oop and klass versions can be slightly different and extra logic may have to be executed depending on what
1044 // exact case the meet falls into. The MeetResult struct is used by the utility methods to communicate what case was
1045 // encountered so the right logic specific to klasses or oops can be executed.,
1046 enum MeetResult {
1047 QUICK,
1048 UNLOADED,
1049 SUBTYPE,
1050 NOT_SUBTYPE,
1051 LCA
1052 };
1053 template<class T> static TypePtr::MeetResult meet_instptr(PTR& ptr, const TypeInterfaces*& interfaces, const T* this_type,
1054 const T* other_type, ciKlass*& res_klass, bool& res_xk, bool& res_flat_array);
1055 private:
1056 template<class T> static bool is_meet_subtype_of(const T* sub_type, const T* super_type);
1057 protected:
1058
1059 template<class T> static MeetResult meet_aryptr(PTR& ptr, const Type*& elem, const T* this_ary, const T* other_ary,
1060 ciKlass*& res_klass, bool& res_xk, bool &res_flat, bool &res_not_flat, bool &res_not_null_free);
1061
1062 template <class T1, class T2> static bool is_java_subtype_of_helper_for_instance(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1063 template <class T1, class T2> static bool is_same_java_type_as_helper_for_instance(const T1* this_one, const T2* other);
1064 template <class T1, class T2> static bool maybe_java_subtype_of_helper_for_instance(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1065 template <class T1, class T2> static bool is_java_subtype_of_helper_for_array(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1066 template <class T1, class T2> static bool is_same_java_type_as_helper_for_array(const T1* this_one, const T2* other);
1067 template <class T1, class T2> static bool maybe_java_subtype_of_helper_for_array(const T1* this_one, const T2* other, bool this_exact, bool other_exact);
1068 template <class T1, class T2> static bool is_meet_subtype_of_helper_for_instance(const T1* this_one, const T2* other, bool this_xk, bool other_xk);
1069 template <class T1, class T2> static bool is_meet_subtype_of_helper_for_array(const T1* this_one, const T2* other, bool this_xk, bool other_xk);
1070 public:
1071 const Offset _offset; // Offset into oop, with TOP & BOT
1072 const PTR _ptr; // Pointer equivalence class
1073
1074 int offset() const { return _offset.get(); }
1075 PTR ptr() const { return _ptr; }
1076
1077 static const TypePtr* make(TYPES t, PTR ptr, Offset offset,
1078 const TypePtr* speculative = nullptr,
1079 int inline_depth = InlineDepthBottom);
1080
1081 // Return a 'ptr' version of this type
1082 virtual const TypePtr* cast_to_ptr_type(PTR ptr) const;
1083
1084 virtual intptr_t get_con() const;
1085
1086 Type::Offset xadd_offset(intptr_t offset) const;
1087 virtual const TypePtr* add_offset(intptr_t offset) const;
1088 virtual const TypePtr* with_offset(intptr_t offset) const;
1089 virtual int flat_offset() const { return offset(); }
1090 virtual bool eq(const Type *t) const;
1091 virtual uint hash() const; // Type specific hashing
1092
1093 virtual bool singleton(void) const; // TRUE if type is a singleton
1094 virtual bool empty(void) const; // TRUE if type is vacuous
1095 virtual const Type *xmeet( const Type *t ) const;
1096 virtual const Type *xmeet_helper( const Type *t ) const;
1097 Offset meet_offset(int offset) const;
1098 Offset dual_offset() const;
1099 virtual const Type *xdual() const; // Compute dual right now.
1100
1101 // meet, dual and join over pointer equivalence sets
1102 PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
1103 PTR dual_ptr() const { return ptr_dual[ptr()]; }
1104
1105 // This is textually confusing unless one recalls that
1106 // join(t) == dual()->meet(t->dual())->dual().
1107 PTR join_ptr( const PTR in_ptr ) const {
1108 return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
1109 }
1110
1111 // Speculative type helper methods.
1112 virtual const TypePtr* speculative() const { return _speculative; }
1113 int inline_depth() const { return _inline_depth; }
1114 virtual ciKlass* speculative_type() const;
1115 virtual ciKlass* speculative_type_not_null() const;
1116 virtual bool speculative_maybe_null() const;
1117 virtual bool speculative_always_null() const;
1118 virtual const TypePtr* remove_speculative() const;
1119 virtual const Type* cleanup_speculative() const;
1120 virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1121 virtual bool would_improve_ptr(ProfilePtrKind maybe_null) const;
1122 virtual const TypePtr* with_inline_depth(int depth) const;
1123
1124 virtual bool maybe_null() const { return meet_ptr(Null) == ptr(); }
1125
1126 virtual bool can_be_inline_type() const { return false; }
1127 virtual bool flat_in_array() const { return false; }
1128 virtual bool not_flat_in_array() const { return true; }
1129 virtual bool is_flat() const { return false; }
1130 virtual bool is_not_flat() const { return false; }
1131 virtual bool is_null_free() const { return false; }
1132 virtual bool is_not_null_free() const { return false; }
1133
1134 // Tests for relation to centerline of type lattice:
1135 static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
1136 static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
1137 // Convenience common pre-built types.
1138 static const TypePtr *NULL_PTR;
1139 static const TypePtr *NOTNULL;
1140 static const TypePtr *BOTTOM;
1141 #ifndef PRODUCT
1142 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1143 #endif
1144 };
1145
1146 //------------------------------TypeRawPtr-------------------------------------
1147 // Class of raw pointers, pointers to things other than Oops. Examples
1148 // include the stack pointer, top of heap, card-marking area, handles, etc.
1149 class TypeRawPtr : public TypePtr {
1150 protected:
1151 TypeRawPtr(PTR ptr, address bits) : TypePtr(RawPtr,ptr,Offset(0)), _bits(bits){}
1152 public:
1153 virtual bool eq( const Type *t ) const;
1154 virtual uint hash() const; // Type specific hashing
1155
1156 const address _bits; // Constant value, if applicable
1157
1158 static const TypeRawPtr *make( PTR ptr );
1159 static const TypeRawPtr *make( address bits );
1160
1161 // Return a 'ptr' version of this type
1162 virtual const TypeRawPtr* cast_to_ptr_type(PTR ptr) const;
1163
1164 virtual intptr_t get_con() const;
1165
1166 virtual const TypePtr* add_offset(intptr_t offset) const;
1167 virtual const TypeRawPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr;}
1168
1169 virtual const Type *xmeet( const Type *t ) const;
1170 virtual const Type *xdual() const; // Compute dual right now.
1171 // Convenience common pre-built types.
1172 static const TypeRawPtr *BOTTOM;
1173 static const TypeRawPtr *NOTNULL;
1174 #ifndef PRODUCT
1175 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1176 #endif
1177 };
1178
1179 //------------------------------TypeOopPtr-------------------------------------
1180 // Some kind of oop (Java pointer), either instance or array.
1181 class TypeOopPtr : public TypePtr {
1182 friend class TypeAry;
1183 friend class TypePtr;
1184 friend class TypeInstPtr;
1185 friend class TypeAryPtr;
1186 protected:
1187 TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, Offset offset, Offset field_offset, int instance_id,
1188 const TypePtr* speculative, int inline_depth);
1189 public:
1190 virtual bool eq( const Type *t ) const;
1191 virtual uint hash() const; // Type specific hashing
1192 virtual bool singleton(void) const; // TRUE if type is a singleton
1193 enum {
1194 InstanceTop = -1, // undefined instance
1195 InstanceBot = 0 // any possible instance
1196 };
1197 protected:
1198
1199 // Oop is null, unless this is a constant oop.
1200 ciObject* _const_oop; // Constant oop
1201 // If _klass is null, then so is _sig. This is an unloaded klass.
1202 ciKlass* _klass; // Klass object
1203
1204 const TypeInterfaces* _interfaces;
1205
1206 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.)
1207 bool _klass_is_exact;
1208 bool _is_ptr_to_narrowoop;
1209 bool _is_ptr_to_narrowklass;
1210 bool _is_ptr_to_boxed_value;
1211
1212 // If not InstanceTop or InstanceBot, indicates that this is
1213 // a particular instance of this type which is distinct.
1214 // This is the node index of the allocation node creating this instance.
1215 int _instance_id;
1216
1217 static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact, InterfaceHandling interface_handling);
1218
1219 int dual_instance_id() const;
1220 int meet_instance_id(int uid) const;
1221
1222 const TypeInterfaces* meet_interfaces(const TypeOopPtr* other) const;
1223
1224 // Do not allow interface-vs.-noninterface joins to collapse to top.
1225 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1226
1227 virtual ciKlass* exact_klass_helper() const { return nullptr; }
1228 virtual ciKlass* klass() const { return _klass; }
1229
1230 public:
1231
1232 bool is_java_subtype_of(const TypeOopPtr* other) const {
1233 return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1234 }
1235
1236 bool is_same_java_type_as(const TypePtr* other) const {
1237 return is_same_java_type_as_helper(other->is_oopptr());
1238 }
1239
1240 virtual bool is_same_java_type_as_helper(const TypeOopPtr* other) const {
1241 ShouldNotReachHere(); return false;
1242 }
1243
1244 bool maybe_java_subtype_of(const TypeOopPtr* other) const {
1245 return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1246 }
1247 virtual bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1248 virtual bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1255 return make_from_klass_common(klass, true, false, interface_handling);
1256 }
1257 // Same as before, but will produce an exact type, even if
1258 // the klass is not final, as long as it has exactly one implementation.
1259 static const TypeOopPtr* make_from_klass_unique(ciKlass* klass, InterfaceHandling interface_handling= ignore_interfaces) {
1260 return make_from_klass_common(klass, true, true, interface_handling);
1261 }
1262 // Same as before, but does not respects UseUniqueSubclasses.
1263 // Use this only for creating array element types.
1264 static const TypeOopPtr* make_from_klass_raw(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1265 return make_from_klass_common(klass, false, false, interface_handling);
1266 }
1267 // Creates a singleton type given an object.
1268 // If the object cannot be rendered as a constant,
1269 // may return a non-singleton type.
1270 // If require_constant, produce a null if a singleton is not possible.
1271 static const TypeOopPtr* make_from_constant(ciObject* o,
1272 bool require_constant = false);
1273
1274 // Make a generic (unclassed) pointer to an oop.
1275 static const TypeOopPtr* make(PTR ptr, Offset offset, int instance_id,
1276 const TypePtr* speculative = nullptr,
1277 int inline_depth = InlineDepthBottom);
1278
1279 ciObject* const_oop() const { return _const_oop; }
1280 // Exact klass, possibly an interface or an array of interface
1281 ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k; }
1282 ciKlass* unloaded_klass() const { assert(!is_loaded(), "only for unloaded types"); return klass(); }
1283
1284 virtual bool is_loaded() const { return klass()->is_loaded(); }
1285 virtual bool klass_is_exact() const { return _klass_is_exact; }
1286
1287 // Returns true if this pointer points at memory which contains a
1288 // compressed oop references.
1289 bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
1290 bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
1291 bool is_ptr_to_boxed_value() const { return _is_ptr_to_boxed_value; }
1292 bool is_known_instance() const { return _instance_id > 0; }
1293 int instance_id() const { return _instance_id; }
1294 bool is_known_instance_field() const { return is_known_instance() && _offset.get() >= 0; }
1295
1296 virtual bool can_be_inline_type() const { return (_klass == nullptr || _klass->can_be_inline_klass(_klass_is_exact)); }
1297 virtual bool can_be_inline_array() const { ShouldNotReachHere(); return false; }
1298
1299 virtual intptr_t get_con() const;
1300
1301 virtual const TypeOopPtr* cast_to_ptr_type(PTR ptr) const;
1302
1303 virtual const TypeOopPtr* cast_to_exactness(bool klass_is_exact) const;
1304
1305 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1306
1307 // corresponding pointer to klass, for a given instance
1308 virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1309
1310 virtual const TypeOopPtr* with_offset(intptr_t offset) const;
1311 virtual const TypePtr* add_offset(intptr_t offset) const;
1312
1313 // Speculative type helper methods.
1314 virtual const TypeOopPtr* remove_speculative() const;
1315 virtual const Type* cleanup_speculative() const;
1316 virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1317 virtual const TypePtr* with_inline_depth(int depth) const;
1340 return _interfaces;
1341 };
1342
1343 const TypeOopPtr* is_reference_type(const Type* other) const {
1344 return other->isa_oopptr();
1345 }
1346
1347 const TypeAryPtr* is_array_type(const TypeOopPtr* other) const {
1348 return other->isa_aryptr();
1349 }
1350
1351 const TypeInstPtr* is_instance_type(const TypeOopPtr* other) const {
1352 return other->isa_instptr();
1353 }
1354 };
1355
1356 //------------------------------TypeInstPtr------------------------------------
1357 // Class of Java object pointers, pointing either to non-array Java instances
1358 // or to a Klass* (including array klasses).
1359 class TypeInstPtr : public TypeOopPtr {
1360 TypeInstPtr(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, Offset offset,
1361 bool flat_in_array, int instance_id, const TypePtr* speculative,
1362 int inline_depth);
1363 virtual bool eq( const Type *t ) const;
1364 virtual uint hash() const; // Type specific hashing
1365 bool _flat_in_array; // Type is flat in arrays
1366 ciKlass* exact_klass_helper() const;
1367
1368 public:
1369
1370 // Instance klass, ignoring any interface
1371 ciInstanceKlass* instance_klass() const {
1372 assert(!(klass()->is_loaded() && klass()->is_interface()), "");
1373 return klass()->as_instance_klass();
1374 }
1375
1376 bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1377 bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1378 bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1379
1380 // Make a pointer to a constant oop.
1381 static const TypeInstPtr *make(ciObject* o) {
1382 ciKlass* k = o->klass();
1383 const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1384 return make(TypePtr::Constant, k, interfaces, true, o, Offset(0));
1385 }
1386 // Make a pointer to a constant oop with offset.
1387 static const TypeInstPtr *make(ciObject* o, Offset offset) {
1388 ciKlass* k = o->klass();
1389 const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1390 return make(TypePtr::Constant, k, interfaces, true, o, offset);
1391 }
1392
1393 // Make a pointer to some value of type klass.
1394 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces) {
1395 const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, true, false, interface_handling);
1396 return make(ptr, klass, interfaces, false, nullptr, Offset(0));
1397 }
1398
1399 // Make a pointer to some non-polymorphic value of exactly type klass.
1400 static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
1401 const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1402 return make(ptr, klass, interfaces, true, nullptr, Offset(0));
1403 }
1404
1405 // Make a pointer to some value of type klass with offset.
1406 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, Offset offset) {
1407 const TypeInterfaces* interfaces = TypePtr::interfaces(klass, true, false, false, ignore_interfaces);
1408 return make(ptr, klass, interfaces, false, nullptr, offset);
1409 }
1410
1411 // Make a pointer to an oop.
1412 static const TypeInstPtr* make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, bool xk, ciObject* o, Offset offset,
1413 bool flat_in_array = false,
1414 int instance_id = InstanceBot,
1415 const TypePtr* speculative = nullptr,
1416 int inline_depth = InlineDepthBottom);
1417
1418 static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset offset, int instance_id = InstanceBot) {
1419 const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1420 return make(ptr, k, interfaces, xk, o, offset, false, instance_id);
1421 }
1422
1423 /** Create constant type for a constant boxed value */
1424 const Type* get_const_boxed_value() const;
1425
1426 // If this is a java.lang.Class constant, return the type for it or null.
1427 // Pass to Type::get_const_type to turn it to a type, which will usually
1428 // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
1429 ciType* java_mirror_type(bool* is_null_free_array = nullptr) const;
1430
1431 virtual const TypeInstPtr* cast_to_ptr_type(PTR ptr) const;
1432
1433 virtual const TypeInstPtr* cast_to_exactness(bool klass_is_exact) const;
1434
1435 virtual const TypeInstPtr* cast_to_instance_id(int instance_id) const;
1436
1437 virtual const TypePtr* add_offset(intptr_t offset) const;
1438 virtual const TypeInstPtr* with_offset(intptr_t offset) const;
1439
1440 // Speculative type helper methods.
1441 virtual const TypeInstPtr* remove_speculative() const;
1442 const TypeInstPtr* with_speculative(const TypePtr* speculative) const;
1443 virtual const TypePtr* with_inline_depth(int depth) const;
1444 virtual const TypePtr* with_instance_id(int instance_id) const;
1445
1446 virtual const TypeInstPtr* cast_to_flat_in_array() const;
1447 virtual bool flat_in_array() const { return _flat_in_array; }
1448 virtual bool not_flat_in_array() const { return !can_be_inline_type() || (_klass->is_inlinetype() && !flat_in_array()); }
1449
1450 // the core of the computation of the meet of 2 types
1451 virtual const Type *xmeet_helper(const Type *t) const;
1452 virtual const TypeInstPtr *xmeet_unloaded(const TypeInstPtr *tinst, const TypeInterfaces* interfaces) const;
1453 virtual const Type *xdual() const; // Compute dual right now.
1454
1455 const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1456
1457 virtual bool can_be_inline_array() const;
1458
1459 // Convenience common pre-built types.
1460 static const TypeInstPtr *NOTNULL;
1461 static const TypeInstPtr *BOTTOM;
1462 static const TypeInstPtr *MIRROR;
1463 static const TypeInstPtr *MARK;
1464 static const TypeInstPtr *KLASS;
1465 #ifndef PRODUCT
1466 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1467 #endif
1468
1469 private:
1470 virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1471
1472 virtual bool is_meet_same_type_as(const TypePtr* other) const {
1473 return _klass->equals(other->is_instptr()->_klass) && _interfaces->eq(other->is_instptr()->_interfaces);
1474 }
1475
1476 };
1477
1478 //------------------------------TypeAryPtr-------------------------------------
1479 // Class of Java array pointers
1480 class TypeAryPtr : public TypeOopPtr {
1481 friend class Type;
1482 friend class TypePtr;
1483 friend class TypeInstPtr;
1484
1485 TypeAryPtr(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1486 Offset offset, Offset field_offset, int instance_id, bool is_autobox_cache,
1487 const TypePtr* speculative, int inline_depth)
1488 : TypeOopPtr(AryPtr, ptr, k, _array_interfaces, xk, o, offset, field_offset, instance_id, speculative, inline_depth),
1489 _ary(ary),
1490 _is_autobox_cache(is_autobox_cache),
1491 _field_offset(field_offset)
1492 {
1493 int dummy;
1494 bool top_or_bottom = (base_element_type(dummy) == Type::TOP || base_element_type(dummy) == Type::BOTTOM);
1495
1496 if (UseCompressedOops && (elem()->make_oopptr() != nullptr && !top_or_bottom) &&
1497 _offset.get() != 0 && _offset.get() != arrayOopDesc::length_offset_in_bytes() &&
1498 _offset.get() != arrayOopDesc::klass_offset_in_bytes()) {
1499 _is_ptr_to_narrowoop = true;
1500 }
1501
1502 }
1503 virtual bool eq( const Type *t ) const;
1504 virtual uint hash() const; // Type specific hashing
1505 const TypeAry *_ary; // Array we point into
1506 const bool _is_autobox_cache;
1507 // For flat inline type arrays, each field of the inline type in
1508 // the array has its own memory slice so we need to keep track of
1509 // which field is accessed
1510 const Offset _field_offset;
1511 Offset meet_field_offset(const Type::Offset offset) const;
1512 Offset dual_field_offset() const;
1513
1514 ciKlass* compute_klass() const;
1515
1516 // A pointer to delay allocation to Type::Initialize_shared()
1517
1518 static const TypeInterfaces* _array_interfaces;
1519 ciKlass* exact_klass_helper() const;
1520 // Only guaranteed non null for array of basic types
1521 ciKlass* klass() const;
1522
1523 public:
1524
1525 bool is_same_java_type_as_helper(const TypeOopPtr* other) const;
1526 bool is_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1527 bool maybe_java_subtype_of_helper(const TypeOopPtr* other, bool this_exact, bool other_exact) const;
1528
1529 // returns base element type, an instance klass (and not interface) for object arrays
1530 const Type* base_element_type(int& dims) const;
1531
1532 // Accessors
1533 bool is_loaded() const { return (_ary->_elem->make_oopptr() ? _ary->_elem->make_oopptr()->is_loaded() : true); }
1534
1535 const TypeAry* ary() const { return _ary; }
1536 const Type* elem() const { return _ary->_elem; }
1537 const TypeInt* size() const { return _ary->_size; }
1538 bool is_stable() const { return _ary->_stable; }
1539
1540 // Inline type array properties
1541 bool is_flat() const { return _ary->_flat; }
1542 bool is_not_flat() const { return _ary->_not_flat; }
1543 bool is_null_free() const { return _ary->_elem->make_ptr() != nullptr && (_ary->_elem->make_ptr()->ptr() == NotNull || _ary->_elem->make_ptr()->ptr() == AnyNull); }
1544 bool is_not_null_free() const { return _ary->_not_null_free; }
1545
1546 bool is_autobox_cache() const { return _is_autobox_cache; }
1547
1548 static const TypeAryPtr* make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1549 Offset field_offset = Offset::bottom,
1550 int instance_id = InstanceBot,
1551 const TypePtr* speculative = nullptr,
1552 int inline_depth = InlineDepthBottom);
1553 // Constant pointer to array
1554 static const TypeAryPtr* make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1555 Offset field_offset = Offset::bottom,
1556 int instance_id = InstanceBot,
1557 const TypePtr* speculative = nullptr,
1558 int inline_depth = InlineDepthBottom,
1559 bool is_autobox_cache = false);
1560
1561 // Return a 'ptr' version of this type
1562 virtual const TypeAryPtr* cast_to_ptr_type(PTR ptr) const;
1563
1564 virtual const TypeAryPtr* cast_to_exactness(bool klass_is_exact) const;
1565
1566 virtual const TypeAryPtr* cast_to_instance_id(int instance_id) const;
1567
1568 virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1569 virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1570
1571 virtual bool empty(void) const; // TRUE if type is vacuous
1572 virtual const TypePtr *add_offset( intptr_t offset ) const;
1573 virtual const TypeAryPtr *with_offset( intptr_t offset ) const;
1574 const TypeAryPtr* with_ary(const TypeAry* ary) const;
1575
1576 // Speculative type helper methods.
1577 virtual const TypeAryPtr* remove_speculative() const;
1578 virtual const Type* cleanup_speculative() const;
1579 virtual const TypePtr* with_inline_depth(int depth) const;
1580 virtual const TypePtr* with_instance_id(int instance_id) const;
1581
1582 // the core of the computation of the meet of 2 types
1583 virtual const Type *xmeet_helper(const Type *t) const;
1584 virtual const Type *xdual() const; // Compute dual right now.
1585
1586 // Inline type array properties
1587 const TypeAryPtr* cast_to_not_flat(bool not_flat = true) const;
1588 const TypeAryPtr* cast_to_not_null_free(bool not_null_free = true) const;
1589 const TypeAryPtr* update_properties(const TypeAryPtr* new_type) const;
1590 jint flat_layout_helper() const;
1591 int flat_elem_size() const;
1592 int flat_log_elem_size() const;
1593
1594 const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1595 int stable_dimension() const;
1596
1597 const TypeAryPtr* cast_to_autobox_cache() const;
1598
1599 static jint max_array_length(BasicType etype);
1600
1601 int flat_offset() const;
1602 const Offset field_offset() const { return _field_offset; }
1603 const TypeAryPtr* with_field_offset(int offset) const;
1604 const TypePtr* add_field_offset_and_offset(intptr_t offset) const;
1605
1606 virtual bool can_be_inline_type() const { return false; }
1607 virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1608
1609 virtual bool can_be_inline_array() const;
1610
1611 // Convenience common pre-built types.
1612 static const TypeAryPtr* BOTTOM;
1613 static const TypeAryPtr *RANGE;
1614 static const TypeAryPtr *OOPS;
1615 static const TypeAryPtr *NARROWOOPS;
1616 static const TypeAryPtr *BYTES;
1617 static const TypeAryPtr *SHORTS;
1618 static const TypeAryPtr *CHARS;
1619 static const TypeAryPtr *INTS;
1620 static const TypeAryPtr *LONGS;
1621 static const TypeAryPtr *FLOATS;
1622 static const TypeAryPtr *DOUBLES;
1623 static const TypeAryPtr *INLINES;
1624 // selects one of the above:
1625 static const TypeAryPtr *get_array_body_type(BasicType elem) {
1626 assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != nullptr, "bad elem type");
1627 return _array_body_type[elem];
1628 }
1629 static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1630 // sharpen the type of an int which is used as an array size
1631 #ifndef PRODUCT
1632 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1633 #endif
1634 private:
1635 virtual bool is_meet_subtype_of_helper(const TypeOopPtr* other, bool this_xk, bool other_xk) const;
1636 };
1637
1638 //------------------------------TypeMetadataPtr-------------------------------------
1639 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
1640 class TypeMetadataPtr : public TypePtr {
1641 protected:
1642 TypeMetadataPtr(PTR ptr, ciMetadata* metadata, Offset offset);
1643 // Do not allow interface-vs.-noninterface joins to collapse to top.
1644 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1645 public:
1646 virtual bool eq( const Type *t ) const;
1647 virtual uint hash() const; // Type specific hashing
1648 virtual bool singleton(void) const; // TRUE if type is a singleton
1649
1650 private:
1651 ciMetadata* _metadata;
1652
1653 public:
1654 static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, Offset offset);
1655
1656 static const TypeMetadataPtr* make(ciMethod* m);
1657 static const TypeMetadataPtr* make(ciMethodData* m);
1658
1659 ciMetadata* metadata() const { return _metadata; }
1660
1661 virtual const TypeMetadataPtr* cast_to_ptr_type(PTR ptr) const;
1662
1663 virtual const TypePtr *add_offset( intptr_t offset ) const;
1664
1665 virtual const Type *xmeet( const Type *t ) const;
1666 virtual const Type *xdual() const; // Compute dual right now.
1667
1668 virtual intptr_t get_con() const;
1669
1670 // Convenience common pre-built types.
1671 static const TypeMetadataPtr *BOTTOM;
1672
1673 #ifndef PRODUCT
1674 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1675 #endif
1676 };
1677
1678 //------------------------------TypeKlassPtr-----------------------------------
1679 // Class of Java Klass pointers
1680 class TypeKlassPtr : public TypePtr {
1681 friend class TypeInstKlassPtr;
1682 friend class TypeAryKlassPtr;
1683 friend class TypePtr;
1684 protected:
1685 TypeKlassPtr(TYPES t, PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, Offset offset);
1686
1687 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1688
1689 public:
1690 virtual bool eq( const Type *t ) const;
1691 virtual uint hash() const;
1692 virtual bool singleton(void) const; // TRUE if type is a singleton
1693
1694 protected:
1695
1696 ciKlass* _klass;
1697 const TypeInterfaces* _interfaces;
1698 const TypeInterfaces* meet_interfaces(const TypeKlassPtr* other) const;
1699 virtual bool must_be_exact() const { ShouldNotReachHere(); return false; }
1700 virtual ciKlass* exact_klass_helper() const;
1701 virtual ciKlass* klass() const { return _klass; }
1702
1703 public:
1704
1705 bool is_java_subtype_of(const TypeKlassPtr* other) const {
1706 return is_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1707 }
1708 bool is_same_java_type_as(const TypePtr* other) const {
1709 return is_same_java_type_as_helper(other->is_klassptr());
1710 }
1711
1712 bool maybe_java_subtype_of(const TypeKlassPtr* other) const {
1713 return maybe_java_subtype_of_helper(other, klass_is_exact(), other->klass_is_exact());
1714 }
1715 virtual bool is_same_java_type_as_helper(const TypeKlassPtr* other) const { ShouldNotReachHere(); return false; }
1716 virtual bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1717 virtual bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const { ShouldNotReachHere(); return false; }
1718
1719 // Exact klass, possibly an interface or an array of interface
1720 ciKlass* exact_klass(bool maybe_null = false) const { assert(klass_is_exact(), ""); ciKlass* k = exact_klass_helper(); assert(k != nullptr || maybe_null, ""); return k; }
1721 virtual bool klass_is_exact() const { return _ptr == Constant; }
1722
1723 static const TypeKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling = ignore_interfaces);
1724 static const TypeKlassPtr *make(PTR ptr, ciKlass* klass, Offset offset, InterfaceHandling interface_handling = ignore_interfaces);
1725
1726 virtual bool is_loaded() const { return _klass->is_loaded(); }
1727
1728 virtual const TypeKlassPtr* cast_to_ptr_type(PTR ptr) const { ShouldNotReachHere(); return nullptr; }
1729
1730 virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const { ShouldNotReachHere(); return nullptr; }
1731
1732 // corresponding pointer to instance, for a given class
1733 virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const { ShouldNotReachHere(); return nullptr; }
1734
1735 virtual const TypePtr *add_offset( intptr_t offset ) const { ShouldNotReachHere(); return nullptr; }
1736 virtual const Type *xmeet( const Type *t ) const { ShouldNotReachHere(); return nullptr; }
1737 virtual const Type *xdual() const { ShouldNotReachHere(); return nullptr; }
1738
1739 virtual intptr_t get_con() const;
1740
1741 virtual const TypeKlassPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return nullptr; }
1742
1743 virtual bool can_be_inline_array() const { ShouldNotReachHere(); return false; }
1744
1745 virtual bool not_flat_in_array_inexact() const {
1746 return true;
1747 }
1748
1749 virtual const TypeKlassPtr* try_improve() const { return this; }
1750
1751 #ifndef PRODUCT
1752 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1753 #endif
1754 private:
1755 virtual bool is_meet_subtype_of(const TypePtr* other) const {
1756 return is_meet_subtype_of_helper(other->is_klassptr(), klass_is_exact(), other->is_klassptr()->klass_is_exact());
1757 }
1758
1759 virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const {
1760 ShouldNotReachHere(); return false;
1761 }
1762
1763 virtual const TypeInterfaces* interfaces() const {
1764 return _interfaces;
1765 };
1766
1767 const TypeKlassPtr* is_reference_type(const Type* other) const {
1768 return other->isa_klassptr();
1769 }
1770
1771 const TypeAryKlassPtr* is_array_type(const TypeKlassPtr* other) const {
1772 return other->isa_aryklassptr();
1773 }
1774
1775 const TypeInstKlassPtr* is_instance_type(const TypeKlassPtr* other) const {
1776 return other->isa_instklassptr();
1777 }
1778 };
1779
1780 // Instance klass pointer, mirrors TypeInstPtr
1781 class TypeInstKlassPtr : public TypeKlassPtr {
1782
1783 TypeInstKlassPtr(PTR ptr, ciKlass* klass, const TypeInterfaces* interfaces, Offset offset, bool flat_in_array)
1784 : TypeKlassPtr(InstKlassPtr, ptr, klass, interfaces, offset), _flat_in_array(flat_in_array) {
1785 assert(klass->is_instance_klass() && (!klass->is_loaded() || !klass->is_interface()), "");
1786 }
1787
1788 virtual bool must_be_exact() const;
1789
1790 const bool _flat_in_array; // Type is flat in arrays
1791
1792 public:
1793 // Instance klass ignoring any interface
1794 ciInstanceKlass* instance_klass() const {
1795 assert(!klass()->is_interface(), "");
1796 return klass()->as_instance_klass();
1797 }
1798
1799 bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
1800 bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1801 bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1802
1803 virtual bool can_be_inline_type() const { return (_klass == nullptr || _klass->can_be_inline_klass(klass_is_exact())); }
1804
1805 static const TypeInstKlassPtr *make(ciKlass* k, InterfaceHandling interface_handling) {
1806 const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, true, false, interface_handling);
1807 return make(TypePtr::Constant, k, interfaces, Offset(0));
1808 }
1809 static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, const TypeInterfaces* interfaces, Offset offset, bool flat_in_array = false);
1810
1811 static const TypeInstKlassPtr* make(PTR ptr, ciKlass* k, Offset offset) {
1812 const TypeInterfaces* interfaces = TypePtr::interfaces(k, true, false, false, ignore_interfaces);
1813 return make(ptr, k, interfaces, offset);
1814 }
1815
1816 virtual const TypeInstKlassPtr* cast_to_ptr_type(PTR ptr) const;
1817
1818 virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1819
1820 // corresponding pointer to instance, for a given class
1821 virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
1822 virtual uint hash() const;
1823 virtual bool eq(const Type *t) const;
1824
1825 virtual const TypePtr *add_offset( intptr_t offset ) const;
1826 virtual const Type *xmeet( const Type *t ) const;
1827 virtual const Type *xdual() const;
1828 virtual const TypeInstKlassPtr* with_offset(intptr_t offset) const;
1829
1830 virtual const TypeKlassPtr* try_improve() const;
1831
1832 virtual bool flat_in_array() const { return _flat_in_array; }
1833
1834 // Checks if this klass pointer is not flat in array by also considering exactness information.
1835 virtual bool not_flat_in_array() const {
1836 return !_klass->can_be_inline_klass(klass_is_exact()) || (_klass->is_inlinetype() && !flat_in_array());
1837 }
1838
1839 // not_flat_in_array() version that assumes that the klass is inexact. This is used for sub type checks where the
1840 // super klass is always an exact klass constant (and thus possibly known to be not flat in array), while a sub
1841 // klass could very well be flat in array:
1842 //
1843 // MyValue <: Object
1844 // flat in array not flat in array
1845 //
1846 // Thus, this version checks if we know that the klass is not flat in array even if it's not exact.
1847 virtual bool not_flat_in_array_inexact() const {
1848 return !_klass->can_be_inline_klass() || (_klass->is_inlinetype() && !flat_in_array());
1849 }
1850
1851 virtual bool can_be_inline_array() const;
1852
1853 // Convenience common pre-built types.
1854 static const TypeInstKlassPtr* OBJECT; // Not-null object klass or below
1855 static const TypeInstKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
1856 private:
1857 virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
1858 };
1859
1860 // Array klass pointer, mirrors TypeAryPtr
1861 class TypeAryKlassPtr : public TypeKlassPtr {
1862 friend class TypeInstKlassPtr;
1863 friend class Type;
1864 friend class TypePtr;
1865
1866 const Type *_elem;
1867 const bool _not_flat; // Array is never flat
1868 const bool _not_null_free; // Array is never null-free
1869 const bool _flat;
1870 const bool _null_free;
1871
1872 static const TypeInterfaces* _array_interfaces;
1873 TypeAryKlassPtr(PTR ptr, const Type *elem, ciKlass* klass, Offset offset, bool not_flat, int not_null_free, bool flat, bool null_free)
1874 : TypeKlassPtr(AryKlassPtr, ptr, klass, _array_interfaces, offset), _elem(elem), _not_flat(not_flat), _not_null_free(not_null_free), _flat(flat), _null_free(null_free) {
1875 assert(klass == nullptr || klass->is_type_array_klass() || klass->is_flat_array_klass() || !klass->as_obj_array_klass()->base_element_klass()->is_interface(), "");
1876 }
1877
1878 virtual ciKlass* exact_klass_helper() const;
1879 // Only guaranteed non null for array of basic types
1880 virtual ciKlass* klass() const;
1881
1882 virtual bool must_be_exact() const;
1883
1884 bool dual_flat() const {
1885 return _flat;
1886 }
1887
1888 bool meet_flat(bool other) const {
1889 return _flat && other;
1890 }
1891
1892 bool dual_null_free() const {
1893 return _null_free;
1894 }
1895
1896 bool meet_null_free(bool other) const {
1897 return _null_free && other;
1898 }
1899
1900 public:
1901
1902 // returns base element type, an instance klass (and not interface) for object arrays
1903 const Type* base_element_type(int& dims) const;
1904
1905 static const TypeAryKlassPtr* make(PTR ptr, ciKlass* k, Offset offset, InterfaceHandling interface_handling, bool not_flat, bool not_null_free, bool flat, bool null_free);
1906
1907 bool is_same_java_type_as_helper(const TypeKlassPtr* other) const;
1908 bool is_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1909 bool maybe_java_subtype_of_helper(const TypeKlassPtr* other, bool this_exact, bool other_exact) const;
1910
1911 bool is_loaded() const { return (_elem->isa_klassptr() ? _elem->is_klassptr()->is_loaded() : true); }
1912
1913 static const TypeAryKlassPtr* make(PTR ptr, const Type* elem, ciKlass* k, Offset offset, bool not_flat, bool not_null_free, bool flat, bool null_free);
1914 static const TypeAryKlassPtr* make(PTR ptr, ciKlass* k, Offset offset, InterfaceHandling interface_handling);
1915 static const TypeAryKlassPtr* make(ciKlass* klass, InterfaceHandling interface_handling);
1916
1917 const Type *elem() const { return _elem; }
1918
1919 virtual bool eq(const Type *t) const;
1920 virtual uint hash() const; // Type specific hashing
1921
1922 virtual const TypeAryKlassPtr* cast_to_ptr_type(PTR ptr) const;
1923
1924 virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1925
1926 const TypeAryKlassPtr* cast_to_null_free() const;
1927
1928 // corresponding pointer to instance, for a given class
1929 virtual const TypeOopPtr* as_instance_type(bool klass_change = true) const;
1930
1931 virtual const TypePtr *add_offset( intptr_t offset ) const;
1932 virtual const Type *xmeet( const Type *t ) const;
1933 virtual const Type *xdual() const; // Compute dual right now.
1934
1935 virtual const TypeAryKlassPtr* with_offset(intptr_t offset) const;
1936
1937 virtual bool empty(void) const {
1938 return TypeKlassPtr::empty() || _elem->empty();
1939 }
1940
1941 bool is_flat() const { return _flat; }
1942 bool is_not_flat() const { return _not_flat; }
1943 bool is_null_free() const { return _null_free; }
1944 bool is_not_null_free() const { return _not_null_free; }
1945 virtual bool can_be_inline_array() const;
1946
1947 #ifndef PRODUCT
1948 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1949 #endif
1950 private:
1951 virtual bool is_meet_subtype_of_helper(const TypeKlassPtr* other, bool this_xk, bool other_xk) const;
1952 };
1953
1954 class TypeNarrowPtr : public Type {
1955 protected:
1956 const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
1957
1958 TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): Type(t),
1959 _ptrtype(ptrtype) {
1960 assert(ptrtype->offset() == 0 ||
1961 ptrtype->offset() == OffsetBot ||
1962 ptrtype->offset() == OffsetTop, "no real offsets");
1963 }
1964
1965 virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
1966 virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;
2062 }
2063
2064 virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
2065 return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
2066 }
2067
2068 public:
2069 static const TypeNarrowKlass *make( const TypePtr* type);
2070
2071 // static const TypeNarrowKlass *BOTTOM;
2072 static const TypeNarrowKlass *NULL_PTR;
2073
2074 #ifndef PRODUCT
2075 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
2076 #endif
2077 };
2078
2079 //------------------------------TypeFunc---------------------------------------
2080 // Class of Array Types
2081 class TypeFunc : public Type {
2082 TypeFunc(const TypeTuple *domain_sig, const TypeTuple *domain_cc, const TypeTuple *range_sig, const TypeTuple *range_cc)
2083 : Type(Function), _domain_sig(domain_sig), _domain_cc(domain_cc), _range_sig(range_sig), _range_cc(range_cc) {}
2084 virtual bool eq( const Type *t ) const;
2085 virtual uint hash() const; // Type specific hashing
2086 virtual bool singleton(void) const; // TRUE if type is a singleton
2087 virtual bool empty(void) const; // TRUE if type is vacuous
2088
2089 // Domains of inputs: inline type arguments are not passed by
2090 // reference, instead each field of the inline type is passed as an
2091 // argument. We maintain 2 views of the argument list here: one
2092 // based on the signature (with an inline type argument as a single
2093 // slot), one based on the actual calling convention (with a value
2094 // type argument as a list of its fields).
2095 const TypeTuple* const _domain_sig;
2096 const TypeTuple* const _domain_cc;
2097 // Range of results. Similar to domains: an inline type result can be
2098 // returned in registers in which case range_cc lists all fields and
2099 // is the actual calling convention.
2100 const TypeTuple* const _range_sig;
2101 const TypeTuple* const _range_cc;
2102
2103 public:
2104 // Constants are shared among ADLC and VM
2105 enum { Control = AdlcVMDeps::Control,
2106 I_O = AdlcVMDeps::I_O,
2107 Memory = AdlcVMDeps::Memory,
2108 FramePtr = AdlcVMDeps::FramePtr,
2109 ReturnAdr = AdlcVMDeps::ReturnAdr,
2110 Parms = AdlcVMDeps::Parms
2111 };
2112
2113
2114 // Accessors:
2115 const TypeTuple* domain_sig() const { return _domain_sig; }
2116 const TypeTuple* domain_cc() const { return _domain_cc; }
2117 const TypeTuple* range_sig() const { return _range_sig; }
2118 const TypeTuple* range_cc() const { return _range_cc; }
2119
2120 static const TypeFunc* make(ciMethod* method, bool is_osr_compilation = false);
2121 static const TypeFunc *make(const TypeTuple* domain_sig, const TypeTuple* domain_cc,
2122 const TypeTuple* range_sig, const TypeTuple* range_cc);
2123 static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
2124
2125 virtual const Type *xmeet( const Type *t ) const;
2126 virtual const Type *xdual() const; // Compute dual right now.
2127
2128 BasicType return_type() const;
2129
2130 bool returns_inline_type_as_fields() const { return range_sig() != range_cc(); }
2131
2132 #ifndef PRODUCT
2133 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
2134 #endif
2135 // Convenience common pre-built types.
2136 };
2137
2138 //------------------------------accessors--------------------------------------
2139 inline bool Type::is_ptr_to_narrowoop() const {
2140 #ifdef _LP64
2141 return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowoop_nv());
2142 #else
2143 return false;
2144 #endif
2145 }
2146
2147 inline bool Type::is_ptr_to_narrowklass() const {
2148 #ifdef _LP64
2149 return (isa_oopptr() != nullptr && is_oopptr()->is_ptr_to_narrowklass_nv());
2150 #else
2151 return false;
2388 }
2389
2390 inline const TypeNarrowOop* Type::make_narrowoop() const {
2391 return (_base == NarrowOop) ? is_narrowoop() :
2392 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : nullptr);
2393 }
2394
2395 inline const TypeNarrowKlass* Type::make_narrowklass() const {
2396 return (_base == NarrowKlass) ? is_narrowklass() :
2397 (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : nullptr);
2398 }
2399
2400 inline bool Type::is_floatingpoint() const {
2401 if( (_base == HalfFloatCon) || (_base == HalfFloatBot) ||
2402 (_base == FloatCon) || (_base == FloatBot) ||
2403 (_base == DoubleCon) || (_base == DoubleBot) )
2404 return true;
2405 return false;
2406 }
2407
2408 inline bool Type::is_inlinetypeptr() const {
2409 return isa_instptr() != nullptr && is_instptr()->instance_klass()->is_inlinetype();
2410 }
2411
2412 inline ciInlineKlass* Type::inline_klass() const {
2413 return make_ptr()->is_instptr()->instance_klass()->as_inline_klass();
2414 }
2415
2416 template <>
2417 inline const TypeInt* Type::cast<TypeInt>() const {
2418 return is_int();
2419 }
2420
2421 template <>
2422 inline const TypeLong* Type::cast<TypeLong>() const {
2423 return is_long();
2424 }
2425
2426 // ===============================================================
2427 // Things that need to be 64-bits in the 64-bit build but
2428 // 32-bits in the 32-bit build. Done this way to get full
2429 // optimization AND strong typing.
2430 #ifdef _LP64
2431
2432 // For type queries and asserts
2433 #define is_intptr_t is_long
2434 #define isa_intptr_t isa_long
2435 #define find_intptr_t_type find_long_type
2436 #define find_intptr_t_con find_long_con
2437 #define TypeX TypeLong
2438 #define Type_X Type::Long
2439 #define TypeX_X TypeLong::LONG
2440 #define TypeX_ZERO TypeLong::ZERO
2441 // For 'ideal_reg' machine registers
2442 #define Op_RegX Op_RegL
2443 // For phase->intcon variants
2444 #define MakeConX longcon
2445 #define ConXNode ConLNode
2446 // For array index arithmetic
2447 #define MulXNode MulLNode
2448 #define AndXNode AndLNode
2449 #define OrXNode OrLNode
2450 #define CmpXNode CmpLNode
2451 #define CmpUXNode CmpULNode
2452 #define SubXNode SubLNode
2453 #define LShiftXNode LShiftLNode
2454 // For object size computation:
2455 #define AddXNode AddLNode
2456 #define RShiftXNode RShiftLNode
2457 // For card marks and hashcodes
2458 #define URShiftXNode URShiftLNode
2459 // For shenandoahSupport
2460 #define LoadXNode LoadLNode
2461 #define StoreXNode StoreLNode
2462 // Opcodes
2463 #define Op_LShiftX Op_LShiftL
2464 #define Op_AndX Op_AndL
2465 #define Op_AddX Op_AddL
2466 #define Op_SubX Op_SubL
2467 #define Op_XorX Op_XorL
2468 #define Op_URShiftX Op_URShiftL
2469 #define Op_LoadX Op_LoadL
2470 #define Op_StoreX Op_StoreL
2471 // conversions
2472 #define ConvI2X(x) ConvI2L(x)
2473 #define ConvL2X(x) (x)
2474 #define ConvX2I(x) ConvL2I(x)
2475 #define ConvX2L(x) (x)
2476 #define ConvX2UL(x) (x)
2477
2478 #else
2479
2480 // For type queries and asserts
2481 #define is_intptr_t is_int
2482 #define isa_intptr_t isa_int
2483 #define find_intptr_t_type find_int_type
2484 #define find_intptr_t_con find_int_con
2485 #define TypeX TypeInt
2486 #define Type_X Type::Int
2487 #define TypeX_X TypeInt::INT
2488 #define TypeX_ZERO TypeInt::ZERO
2489 // For 'ideal_reg' machine registers
2490 #define Op_RegX Op_RegI
2491 // For phase->intcon variants
2492 #define MakeConX intcon
2493 #define ConXNode ConINode
2494 // For array index arithmetic
2495 #define MulXNode MulINode
2496 #define AndXNode AndINode
2497 #define OrXNode OrINode
2498 #define CmpXNode CmpINode
2499 #define CmpUXNode CmpUNode
2500 #define SubXNode SubINode
2501 #define LShiftXNode LShiftINode
2502 // For object size computation:
2503 #define AddXNode AddINode
2504 #define RShiftXNode RShiftINode
2505 // For card marks and hashcodes
2506 #define URShiftXNode URShiftINode
2507 // For shenandoahSupport
2508 #define LoadXNode LoadINode
2509 #define StoreXNode StoreINode
2510 // Opcodes
2511 #define Op_LShiftX Op_LShiftI
2512 #define Op_AndX Op_AndI
2513 #define Op_AddX Op_AddI
2514 #define Op_SubX Op_SubI
2515 #define Op_XorX Op_XorI
2516 #define Op_URShiftX Op_URShiftI
2517 #define Op_LoadX Op_LoadI
2518 #define Op_StoreX Op_StoreI
2519 // conversions
2520 #define ConvI2X(x) (x)
2521 #define ConvL2X(x) ConvL2I(x)
2522 #define ConvX2I(x) (x)
2523 #define ConvX2L(x) ConvI2L(x)
2524 #define ConvX2UL(x) ConvI2UL(x)
2525
2526 #endif
2527
2528 #endif // SHARE_OPTO_TYPE_HPP
|