src/share/vm/opto/type.hpp

changeset 4159
8e47bac5643a
parent 4037
da91efe96a93
child 4313
beebba0acc11
equal deleted inserted replaced
4158:65d07d9ee446 4159:8e47bac5643a
46 class Type; 46 class Type;
47 class TypeD; 47 class TypeD;
48 class TypeF; 48 class TypeF;
49 class TypeInt; 49 class TypeInt;
50 class TypeLong; 50 class TypeLong;
51 class TypeNarrowOop; 51 class TypeNarrowPtr;
52 class TypeNarrowOop;
53 class TypeNarrowKlass;
52 class TypeAry; 54 class TypeAry;
53 class TypeTuple; 55 class TypeTuple;
54 class TypeVect; 56 class TypeVect;
55 class TypeVectS; 57 class TypeVectS;
56 class TypeVectD; 58 class TypeVectD;
79 Top, // Top of the lattice 81 Top, // Top of the lattice
80 Int, // Integer range (lo-hi) 82 Int, // Integer range (lo-hi)
81 Long, // Long integer range (lo-hi) 83 Long, // Long integer range (lo-hi)
82 Half, // Placeholder half of doubleword 84 Half, // Placeholder half of doubleword
83 NarrowOop, // Compressed oop pointer 85 NarrowOop, // Compressed oop pointer
86 NarrowKlass, // Compressed klass pointer
84 87
85 Tuple, // Method signature or object layout 88 Tuple, // Method signature or object layout
86 Array, // Array types 89 Array, // Array types
87 VectorS, // 32bit Vector types 90 VectorS, // 32bit Vector types
88 VectorD, // 64bit Vector types 91 VectorD, // 64bit Vector types
227 #endif 230 #endif
228 231
229 // Returns true if this pointer points at memory which contains a 232 // Returns true if this pointer points at memory which contains a
230 // compressed oop references. 233 // compressed oop references.
231 bool is_ptr_to_narrowoop() const; 234 bool is_ptr_to_narrowoop() const;
235 bool is_ptr_to_narrowklass() const;
232 236
233 // Convenience access 237 // Convenience access
234 float getf() const; 238 float getf() const;
235 double getd() const; 239 double getd() const;
236 240
250 const TypePtr *isa_ptr() const; // Returns NULL if not ptr type 254 const TypePtr *isa_ptr() const; // Returns NULL if not ptr type
251 const TypeRawPtr *isa_rawptr() const; // NOT Java oop 255 const TypeRawPtr *isa_rawptr() const; // NOT Java oop
252 const TypeRawPtr *is_rawptr() const; // Asserts is rawptr 256 const TypeRawPtr *is_rawptr() const; // Asserts is rawptr
253 const TypeNarrowOop *is_narrowoop() const; // Java-style GC'd pointer 257 const TypeNarrowOop *is_narrowoop() const; // Java-style GC'd pointer
254 const TypeNarrowOop *isa_narrowoop() const; // Returns NULL if not oop ptr type 258 const TypeNarrowOop *isa_narrowoop() const; // Returns NULL if not oop ptr type
259 const TypeNarrowKlass *is_narrowklass() const; // compressed klass pointer
260 const TypeNarrowKlass *isa_narrowklass() const;// Returns NULL if not oop ptr type
255 const TypeOopPtr *isa_oopptr() const; // Returns NULL if not oop ptr type 261 const TypeOopPtr *isa_oopptr() const; // Returns NULL if not oop ptr type
256 const TypeOopPtr *is_oopptr() const; // Java-style GC'd pointer 262 const TypeOopPtr *is_oopptr() const; // Java-style GC'd pointer
257 const TypeInstPtr *isa_instptr() const; // Returns NULL if not InstPtr 263 const TypeInstPtr *isa_instptr() const; // Returns NULL if not InstPtr
258 const TypeInstPtr *is_instptr() const; // Instance 264 const TypeInstPtr *is_instptr() const; // Instance
259 const TypeAryPtr *isa_aryptr() const; // Returns NULL if not AryPtr 265 const TypeAryPtr *isa_aryptr() const; // Returns NULL if not AryPtr
275 const TypeOopPtr* make_oopptr() const; 281 const TypeOopPtr* make_oopptr() const;
276 282
277 // Returns this compressed pointer or the equivalent compressed version 283 // Returns this compressed pointer or the equivalent compressed version
278 // of this pointer type. 284 // of this pointer type.
279 const TypeNarrowOop* make_narrowoop() const; 285 const TypeNarrowOop* make_narrowoop() const;
286
287 // Returns this compressed klass pointer or the equivalent
288 // compressed version of this pointer type.
289 const TypeNarrowKlass* make_narrowklass() const;
280 290
281 // Special test for register pressure heuristic 291 // Special test for register pressure heuristic
282 bool is_floatingpoint() const; // True if Float or Double base type 292 bool is_floatingpoint() const; // True if Float or Double base type
283 293
284 // Do you have memory, directly or through a tuple? 294 // Do you have memory, directly or through a tuple?
668 // Class of machine Pointer Types: raw data, instances or arrays. 678 // Class of machine Pointer Types: raw data, instances or arrays.
669 // If the _base enum is AnyPtr, then this refers to all of the above. 679 // If the _base enum is AnyPtr, then this refers to all of the above.
670 // Otherwise the _base will indicate which subset of pointers is affected, 680 // Otherwise the _base will indicate which subset of pointers is affected,
671 // and the class will be inherited from. 681 // and the class will be inherited from.
672 class TypePtr : public Type { 682 class TypePtr : public Type {
673 friend class TypeNarrowOop; 683 friend class TypeNarrowPtr;
674 public: 684 public:
675 enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR }; 685 enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
676 protected: 686 protected:
677 TypePtr( TYPES t, PTR ptr, int offset ) : Type(t), _ptr(ptr), _offset(offset) {} 687 TypePtr( TYPES t, PTR ptr, int offset ) : Type(t), _ptr(ptr), _offset(offset) {}
678 virtual bool eq( const Type *t ) const; 688 virtual bool eq( const Type *t ) const;
779 // If _klass is NULL, then so is _sig. This is an unloaded klass. 789 // If _klass is NULL, then so is _sig. This is an unloaded klass.
780 ciKlass* _klass; // Klass object 790 ciKlass* _klass; // Klass object
781 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.) 791 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.)
782 bool _klass_is_exact; 792 bool _klass_is_exact;
783 bool _is_ptr_to_narrowoop; 793 bool _is_ptr_to_narrowoop;
794 bool _is_ptr_to_narrowklass;
784 795
785 // If not InstanceTop or InstanceBot, indicates that this is 796 // If not InstanceTop or InstanceBot, indicates that this is
786 // a particular instance of this type which is distinct. 797 // a particular instance of this type which is distinct.
787 // This is the the node index of the allocation node creating this instance. 798 // This is the the node index of the allocation node creating this instance.
788 int _instance_id; 799 int _instance_id;
823 bool klass_is_exact() const { return _klass_is_exact; } 834 bool klass_is_exact() const { return _klass_is_exact; }
824 835
825 // Returns true if this pointer points at memory which contains a 836 // Returns true if this pointer points at memory which contains a
826 // compressed oop references. 837 // compressed oop references.
827 bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; } 838 bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
839 bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
828 840
829 bool is_known_instance() const { return _instance_id > 0; } 841 bool is_known_instance() const { return _instance_id > 0; }
830 int instance_id() const { return _instance_id; } 842 int instance_id() const { return _instance_id; }
831 bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; } 843 bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }
832 844
1120 #ifndef PRODUCT 1132 #ifndef PRODUCT
1121 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping 1133 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1122 #endif 1134 #endif
1123 }; 1135 };
1124 1136
1137 class TypeNarrowPtr : public Type {
1138 protected:
1139 const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
1140
1141 TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): _ptrtype(ptrtype),
1142 Type(t) {
1143 assert(ptrtype->offset() == 0 ||
1144 ptrtype->offset() == OffsetBot ||
1145 ptrtype->offset() == OffsetTop, "no real offsets");
1146 }
1147
1148 virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
1149 virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;
1150 virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const = 0;
1151 virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const = 0;
1152 public:
1153 virtual bool eq( const Type *t ) const;
1154 virtual int hash() const; // Type specific hashing
1155 virtual bool singleton(void) const; // TRUE if type is a singleton
1156
1157 virtual const Type *xmeet( const Type *t ) const;
1158 virtual const Type *xdual() const; // Compute dual right now.
1159
1160 virtual intptr_t get_con() const;
1161
1162 // Do not allow interface-vs.-noninterface joins to collapse to top.
1163 virtual const Type *filter( const Type *kills ) const;
1164
1165 virtual bool empty(void) const; // TRUE if type is vacuous
1166
1167 // returns the equivalent ptr type for this compressed pointer
1168 const TypePtr *get_ptrtype() const {
1169 return _ptrtype;
1170 }
1171
1172 #ifndef PRODUCT
1173 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1174 #endif
1175 };
1176
1125 //------------------------------TypeNarrowOop---------------------------------- 1177 //------------------------------TypeNarrowOop----------------------------------
1126 // A compressed reference to some kind of Oop. This type wraps around 1178 // A compressed reference to some kind of Oop. This type wraps around
1127 // a preexisting TypeOopPtr and forwards most of it's operations to 1179 // a preexisting TypeOopPtr and forwards most of it's operations to
1128 // the underlying type. It's only real purpose is to track the 1180 // the underlying type. It's only real purpose is to track the
1129 // oopness of the compressed oop value when we expose the conversion 1181 // oopness of the compressed oop value when we expose the conversion
1130 // between the normal and the compressed form. 1182 // between the normal and the compressed form.
1131 class TypeNarrowOop : public Type { 1183 class TypeNarrowOop : public TypeNarrowPtr {
1132 protected: 1184 protected:
1133 const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR 1185 TypeNarrowOop( const TypePtr* ptrtype): TypeNarrowPtr(NarrowOop, ptrtype) {
1134 1186 }
1135 TypeNarrowOop( const TypePtr* ptrtype): Type(NarrowOop), 1187
1136 _ptrtype(ptrtype) { 1188 virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const {
1137 assert(ptrtype->offset() == 0 || 1189 return t->isa_narrowoop();
1138 ptrtype->offset() == OffsetBot || 1190 }
1139 ptrtype->offset() == OffsetTop, "no real offsets"); 1191
1140 } 1192 virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const {
1141 public: 1193 return t->is_narrowoop();
1142 virtual bool eq( const Type *t ) const; 1194 }
1143 virtual int hash() const; // Type specific hashing 1195
1144 virtual bool singleton(void) const; // TRUE if type is a singleton 1196 virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const {
1145 1197 return new TypeNarrowOop(t);
1146 virtual const Type *xmeet( const Type *t ) const; 1198 }
1147 virtual const Type *xdual() const; // Compute dual right now. 1199
1148 1200 virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
1149 virtual intptr_t get_con() const; 1201 return (const TypeNarrowPtr*)((new TypeNarrowOop(t))->hashcons());
1150 1202 }
1151 // Do not allow interface-vs.-noninterface joins to collapse to top. 1203
1152 virtual const Type *filter( const Type *kills ) const; 1204 public:
1153
1154 virtual bool empty(void) const; // TRUE if type is vacuous
1155 1205
1156 static const TypeNarrowOop *make( const TypePtr* type); 1206 static const TypeNarrowOop *make( const TypePtr* type);
1157 1207
1158 static const TypeNarrowOop* make_from_constant(ciObject* con, bool require_constant = false) { 1208 static const TypeNarrowOop* make_from_constant(ciObject* con, bool require_constant = false) {
1159 return make(TypeOopPtr::make_from_constant(con, require_constant)); 1209 return make(TypeOopPtr::make_from_constant(con, require_constant));
1160 } 1210 }
1161 1211
1162 // returns the equivalent ptr type for this compressed pointer
1163 const TypePtr *get_ptrtype() const {
1164 return _ptrtype;
1165 }
1166
1167 static const TypeNarrowOop *BOTTOM; 1212 static const TypeNarrowOop *BOTTOM;
1168 static const TypeNarrowOop *NULL_PTR; 1213 static const TypeNarrowOop *NULL_PTR;
1214
1215 #ifndef PRODUCT
1216 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1217 #endif
1218 };
1219
1220 //------------------------------TypeNarrowKlass----------------------------------
1221 // A compressed reference to klass pointer. This type wraps around a
1222 // preexisting TypeKlassPtr and forwards most of it's operations to
1223 // the underlying type.
1224 class TypeNarrowKlass : public TypeNarrowPtr {
1225 protected:
1226 TypeNarrowKlass( const TypePtr* ptrtype): TypeNarrowPtr(NarrowKlass, ptrtype) {
1227 }
1228
1229 virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const {
1230 return t->isa_narrowklass();
1231 }
1232
1233 virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const {
1234 return t->is_narrowklass();
1235 }
1236
1237 virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const {
1238 return new TypeNarrowKlass(t);
1239 }
1240
1241 virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
1242 return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
1243 }
1244
1245 public:
1246 static const TypeNarrowKlass *make( const TypePtr* type);
1247
1248 // static const TypeNarrowKlass *BOTTOM;
1249 static const TypeNarrowKlass *NULL_PTR;
1169 1250
1170 #ifndef PRODUCT 1251 #ifndef PRODUCT
1171 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; 1252 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1172 #endif 1253 #endif
1173 }; 1254 };
1219 #else 1300 #else
1220 return false; 1301 return false;
1221 #endif 1302 #endif
1222 } 1303 }
1223 1304
1305 inline bool Type::is_ptr_to_narrowklass() const {
1306 #ifdef _LP64
1307 return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowklass_nv());
1308 #else
1309 return false;
1310 #endif
1311 }
1312
1224 inline float Type::getf() const { 1313 inline float Type::getf() const {
1225 assert( _base == FloatCon, "Not a FloatCon" ); 1314 assert( _base == FloatCon, "Not a FloatCon" );
1226 return ((TypeF*)this)->_f; 1315 return ((TypeF*)this)->_f;
1227 } 1316 }
1228 1317
1344 inline const TypeNarrowOop *Type::isa_narrowoop() const { 1433 inline const TypeNarrowOop *Type::isa_narrowoop() const {
1345 // OopPtr is the first and KlassPtr the last, with no non-oops between. 1434 // OopPtr is the first and KlassPtr the last, with no non-oops between.
1346 return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL; 1435 return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL;
1347 } 1436 }
1348 1437
1438 inline const TypeNarrowKlass *Type::is_narrowklass() const {
1439 assert(_base == NarrowKlass, "Not a narrow oop" ) ;
1440 return (TypeNarrowKlass*)this;
1441 }
1442
1443 inline const TypeNarrowKlass *Type::isa_narrowklass() const {
1444 return (_base == NarrowKlass) ? (TypeNarrowKlass*)this : NULL;
1445 }
1446
1349 inline const TypeMetadataPtr *Type::is_metadataptr() const { 1447 inline const TypeMetadataPtr *Type::is_metadataptr() const {
1350 // MetadataPtr is the first and CPCachePtr the last 1448 // MetadataPtr is the first and CPCachePtr the last
1351 assert(_base == MetadataPtr, "Not a metadata pointer" ) ; 1449 assert(_base == MetadataPtr, "Not a metadata pointer" ) ;
1352 return (TypeMetadataPtr*)this; 1450 return (TypeMetadataPtr*)this;
1353 } 1451 }
1365 return (TypeKlassPtr*)this; 1463 return (TypeKlassPtr*)this;
1366 } 1464 }
1367 1465
1368 inline const TypePtr* Type::make_ptr() const { 1466 inline const TypePtr* Type::make_ptr() const {
1369 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() : 1467 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() :
1370 (isa_ptr() ? is_ptr() : NULL); 1468 ((_base == NarrowKlass) ? is_narrowklass()->get_ptrtype() :
1469 (isa_ptr() ? is_ptr() : NULL));
1371 } 1470 }
1372 1471
1373 inline const TypeOopPtr* Type::make_oopptr() const { 1472 inline const TypeOopPtr* Type::make_oopptr() const {
1374 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->is_oopptr() : is_oopptr(); 1473 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->is_oopptr() : is_oopptr();
1375 } 1474 }
1376 1475
1377 inline const TypeNarrowOop* Type::make_narrowoop() const { 1476 inline const TypeNarrowOop* Type::make_narrowoop() const {
1378 return (_base == NarrowOop) ? is_narrowoop() : 1477 return (_base == NarrowOop) ? is_narrowoop() :
1379 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL); 1478 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL);
1479 }
1480
1481 inline const TypeNarrowKlass* Type::make_narrowklass() const {
1482 return (_base == NarrowKlass) ? is_narrowklass() :
1483 (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : NULL);
1380 } 1484 }
1381 1485
1382 inline bool Type::is_floatingpoint() const { 1486 inline bool Type::is_floatingpoint() const {
1383 if( (_base == FloatCon) || (_base == FloatBot) || 1487 if( (_base == FloatCon) || (_base == FloatBot) ||
1384 (_base == DoubleCon) || (_base == DoubleBot) ) 1488 (_base == DoubleCon) || (_base == DoubleBot) )

mercurial