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