< prev index next >

src/share/vm/opto/type.hpp

Print this page




 984   virtual const Type *cast_to_ptr_type(PTR ptr) const;
 985 
 986   virtual intptr_t get_con() const;
 987 
 988   virtual const TypePtr *add_offset( intptr_t offset ) const;
 989 
 990   virtual const Type *xmeet( const Type *t ) const;
 991   virtual const Type *xdual() const;    // Compute dual right now.
 992   // Convenience common pre-built types.
 993   static const TypeRawPtr *BOTTOM;
 994   static const TypeRawPtr *NOTNULL;
 995 #ifndef PRODUCT
 996   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
 997 #endif
 998 };
 999 
1000 //------------------------------TypeOopPtr-------------------------------------
1001 // Some kind of oop (Java pointer), either instance or array.
1002 class TypeOopPtr : public TypePtr {
1003 protected:
1004   TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset offset, int instance_id,
1005              const TypePtr* speculative, int inline_depth);
1006 public:
1007   virtual bool eq( const Type *t ) const;
1008   virtual int  hash() const;             // Type specific hashing
1009   virtual bool singleton(void) const;    // TRUE if type is a singleton
1010   enum {
1011    InstanceTop = -1,   // undefined instance
1012    InstanceBot = 0     // any possible instance
1013   };
1014 protected:
1015 
1016   // Oop is NULL, unless this is a constant oop.
1017   ciObject*     _const_oop;   // Constant oop
1018   // If _klass is NULL, then so is _sig.  This is an unloaded klass.
1019   ciKlass*      _klass;       // Klass object
1020   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
1021   bool          _klass_is_exact;
1022   bool          _is_ptr_to_narrowoop;
1023   bool          _is_ptr_to_narrowklass;
1024   bool          _is_ptr_to_boxed_value;
1025 


1176 
1177   // the core of the computation of the meet of 2 types
1178   virtual const Type *xmeet_helper(const Type *t) const;
1179   virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
1180   virtual const Type *xdual() const;    // Compute dual right now.
1181 
1182   // Convenience common pre-built types.
1183   static const TypeInstPtr *NOTNULL;
1184   static const TypeInstPtr *BOTTOM;
1185   static const TypeInstPtr *MIRROR;
1186   static const TypeInstPtr *MARK;
1187   static const TypeInstPtr *KLASS;
1188 #ifndef PRODUCT
1189   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1190 #endif
1191 };
1192 
1193 //------------------------------TypeAryPtr-------------------------------------
1194 // Class of Java array pointers
1195 class TypeAryPtr : public TypeOopPtr {
1196   TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1197               Offset offset, Offset field_offset, int instance_id, bool is_autobox_cache,
1198               const TypePtr* speculative, int inline_depth)
1199     : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative, inline_depth),
1200     _ary(ary),
1201     _is_autobox_cache(is_autobox_cache),
1202     _field_offset(field_offset)
1203  {
1204 #ifdef ASSERT
1205     if (k != NULL) {
1206       // Verify that specified klass and TypeAryPtr::klass() follow the same rules.
1207       ciKlass* ck = compute_klass(true);
1208       if (k != ck) {
1209         this->dump(); tty->cr();
1210         tty->print(" k: ");
1211         k->print(); tty->cr();
1212         tty->print("ck: ");
1213         if (ck != NULL) ck->print();
1214         else tty->print("<NULL>");
1215         tty->cr();
1216         assert(false, "unexpected TypeAryPtr::_klass");
1217       }
1218     }
1219 #endif
1220   }
1221   virtual bool eq( const Type *t ) const;
1222   virtual int hash() const;     // Type specific hashing
1223   const TypeAry *_ary;          // Array we point into
1224   const bool     _is_autobox_cache;
1225   Offset meet_field_offset(int offset) const;




1226   Offset dual_field_offset() const;
1227 
1228   ciKlass* compute_klass(DEBUG_ONLY(bool verify = false)) const;
1229 
1230 public:
1231   // For flattened value type arrays, each field of the value type in
1232   // the array has its own memory slice so we need to keep track of
1233   // which field is accessed
1234   const Offset   _field_offset;
1235   // Accessors
1236   ciKlass* klass() const;
1237   const TypeAry* ary() const  { return _ary; }
1238   const Type*    elem() const { return _ary->_elem; }
1239   const TypeInt* size() const { return _ary->_size; }
1240   bool      is_stable() const { return _ary->_stable; }
1241 
1242   bool is_autobox_cache() const { return _is_autobox_cache; }
1243 
1244   static const TypeAryPtr* make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1245                                 Offset field_offset = Offset::bottom,
1246                                 int instance_id = InstanceBot,
1247                                 const TypePtr* speculative = NULL,
1248                                 int inline_depth = InlineDepthBottom);
1249   // Constant pointer to array
1250   static const TypeAryPtr* make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1251                                 Offset field_offset = Offset::bottom,
1252                                 int instance_id = InstanceBot,
1253                                 const TypePtr* speculative = NULL,
1254                                 int inline_depth = InlineDepthBottom,


1263 
1264   virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1265   virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1266 
1267   virtual bool empty(void) const;        // TRUE if type is vacuous
1268   virtual const TypePtr *add_offset( intptr_t offset ) const;
1269 
1270   // Speculative type helper methods.
1271   virtual const Type* remove_speculative() const;
1272   virtual const TypePtr* with_inline_depth(int depth) const;
1273 
1274   // the core of the computation of the meet of 2 types
1275   virtual const Type *xmeet_helper(const Type *t) const;
1276   virtual const Type *xdual() const;    // Compute dual right now.
1277 
1278   const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1279   int stable_dimension() const;
1280 
1281   const TypeAryPtr* cast_to_autobox_cache(bool cache) const;
1282 
1283   const int field_offset() const { return _field_offset.get(); }
1284   const TypeAryPtr* with_field_offset(int offset) const;
1285   const TypePtr* with_field_offset_and_offset(intptr_t offset) const;
1286 
1287   // Convenience common pre-built types.
1288   static const TypeAryPtr *RANGE;
1289   static const TypeAryPtr *OOPS;
1290   static const TypeAryPtr *NARROWOOPS;
1291   static const TypeAryPtr *BYTES;
1292   static const TypeAryPtr *SHORTS;
1293   static const TypeAryPtr *CHARS;
1294   static const TypeAryPtr *INTS;
1295   static const TypeAryPtr *LONGS;
1296   static const TypeAryPtr *FLOATS;
1297   static const TypeAryPtr *DOUBLES;
1298   // selects one of the above:
1299   static const TypeAryPtr *get_array_body_type(BasicType elem) {
1300     assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != NULL, "bad elem type");
1301     return _array_body_type[elem];
1302   }
1303   static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1304   // sharpen the type of an int which is used as an array size
1305 #ifdef ASSERT
1306   // One type is interface, the other is oop
1307   virtual bool interface_vs_oop(const Type *t) const;
1308 #endif
1309 #ifndef PRODUCT
1310   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1311 #endif
1312 };
1313 
1314 //------------------------------TypeValueTypePtr-------------------------------------
1315 // Class of value type pointers
1316 class TypeValueTypePtr : public TypeOopPtr {
1317   TypeValueTypePtr(const TypeValueType* vt, PTR ptr, ciObject* o, Offset offset, int instance_id, const TypePtr* speculative, int inline_depth)
1318     : TypeOopPtr(ValueTypePtr, ptr, vt->value_klass(), true, o, offset, instance_id, speculative, inline_depth) {
1319     _vt = vt;
1320   }
1321 
1322   const TypeValueType* _vt;    // Value type we point to
1323 
1324 public:
1325   // Make a pointer to a value type
1326   static const TypeValueTypePtr* make(const TypeValueType* vt, PTR ptr = TypePtr::BotPTR, ciObject* o = NULL, Offset offset = Offset(0),
1327                                       int instance_id = InstanceBot, const TypePtr* speculative = NULL, int inline_depth = InlineDepthBottom);
1328   // Make a pointer to a value type
1329   static const TypeValueTypePtr* make(PTR ptr, ciValueKlass* vk, ciObject* o = NULL) { return make(TypeValueType::make(vk), ptr, o); }
1330   // Make a pointer to a constant value type
1331   static const TypeValueTypePtr* make(ciObject* o) { return make(TypePtr::Constant, o->klass()->as_value_klass(), o);  }
1332 
1333   const TypeValueType* value_type() const { return _vt; }
1334 
1335   virtual const TypePtr* add_offset(intptr_t offset) const;
1336 
1337   virtual const Type* cast_to_ptr_type(PTR ptr) const;
1338   virtual const TypeOopPtr* cast_to_instance_id(int instance_id) const;




 984   virtual const Type *cast_to_ptr_type(PTR ptr) const;
 985 
 986   virtual intptr_t get_con() const;
 987 
 988   virtual const TypePtr *add_offset( intptr_t offset ) const;
 989 
 990   virtual const Type *xmeet( const Type *t ) const;
 991   virtual const Type *xdual() const;    // Compute dual right now.
 992   // Convenience common pre-built types.
 993   static const TypeRawPtr *BOTTOM;
 994   static const TypeRawPtr *NOTNULL;
 995 #ifndef PRODUCT
 996   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
 997 #endif
 998 };
 999 
1000 //------------------------------TypeOopPtr-------------------------------------
1001 // Some kind of oop (Java pointer), either instance or array.
1002 class TypeOopPtr : public TypePtr {
1003 protected:
1004   TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset offset, Offset field_offset,
1005              int instance_id, const TypePtr* speculative, int inline_depth);
1006 public:
1007   virtual bool eq( const Type *t ) const;
1008   virtual int  hash() const;             // Type specific hashing
1009   virtual bool singleton(void) const;    // TRUE if type is a singleton
1010   enum {
1011    InstanceTop = -1,   // undefined instance
1012    InstanceBot = 0     // any possible instance
1013   };
1014 protected:
1015 
1016   // Oop is NULL, unless this is a constant oop.
1017   ciObject*     _const_oop;   // Constant oop
1018   // If _klass is NULL, then so is _sig.  This is an unloaded klass.
1019   ciKlass*      _klass;       // Klass object
1020   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
1021   bool          _klass_is_exact;
1022   bool          _is_ptr_to_narrowoop;
1023   bool          _is_ptr_to_narrowklass;
1024   bool          _is_ptr_to_boxed_value;
1025 


1176 
1177   // the core of the computation of the meet of 2 types
1178   virtual const Type *xmeet_helper(const Type *t) const;
1179   virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
1180   virtual const Type *xdual() const;    // Compute dual right now.
1181 
1182   // Convenience common pre-built types.
1183   static const TypeInstPtr *NOTNULL;
1184   static const TypeInstPtr *BOTTOM;
1185   static const TypeInstPtr *MIRROR;
1186   static const TypeInstPtr *MARK;
1187   static const TypeInstPtr *KLASS;
1188 #ifndef PRODUCT
1189   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1190 #endif
1191 };
1192 
1193 //------------------------------TypeAryPtr-------------------------------------
1194 // Class of Java array pointers
1195 class TypeAryPtr : public TypeOopPtr {
1196   TypeAryPtr(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1197              Offset offset, Offset field_offset, int instance_id, bool is_autobox_cache,
1198              const TypePtr* speculative, int inline_depth)
1199     : TypeOopPtr(AryPtr, ptr, k, xk, o, offset, field_offset, instance_id, speculative, inline_depth),
1200     _ary(ary),
1201     _is_autobox_cache(is_autobox_cache),
1202     _field_offset(field_offset)
1203  {
1204 #ifdef ASSERT
1205     if (k != NULL) {
1206       // Verify that specified klass and TypeAryPtr::klass() follow the same rules.
1207       ciKlass* ck = compute_klass(true);
1208       if (k != ck) {
1209         this->dump(); tty->cr();
1210         tty->print(" k: ");
1211         k->print(); tty->cr();
1212         tty->print("ck: ");
1213         if (ck != NULL) ck->print();
1214         else tty->print("<NULL>");
1215         tty->cr();
1216         assert(false, "unexpected TypeAryPtr::_klass");
1217       }
1218     }
1219 #endif
1220   }
1221   virtual bool eq( const Type *t ) const;
1222   virtual int hash() const;     // Type specific hashing
1223   const TypeAry *_ary;          // Array we point into
1224   const bool     _is_autobox_cache;
1225   // For flattened value type arrays, each field of the value type in
1226   // the array has its own memory slice so we need to keep track of
1227   // which field is accessed
1228   const Offset _field_offset;
1229   Offset meet_field_offset(const Type::Offset offset) const;
1230   Offset dual_field_offset() const;
1231 
1232   ciKlass* compute_klass(DEBUG_ONLY(bool verify = false)) const;
1233 
1234 public:




1235   // Accessors
1236   ciKlass* klass() const;
1237   const TypeAry* ary() const  { return _ary; }
1238   const Type*    elem() const { return _ary->_elem; }
1239   const TypeInt* size() const { return _ary->_size; }
1240   bool      is_stable() const { return _ary->_stable; }
1241 
1242   bool is_autobox_cache() const { return _is_autobox_cache; }
1243 
1244   static const TypeAryPtr* make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1245                                 Offset field_offset = Offset::bottom,
1246                                 int instance_id = InstanceBot,
1247                                 const TypePtr* speculative = NULL,
1248                                 int inline_depth = InlineDepthBottom);
1249   // Constant pointer to array
1250   static const TypeAryPtr* make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1251                                 Offset field_offset = Offset::bottom,
1252                                 int instance_id = InstanceBot,
1253                                 const TypePtr* speculative = NULL,
1254                                 int inline_depth = InlineDepthBottom,


1263 
1264   virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1265   virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1266 
1267   virtual bool empty(void) const;        // TRUE if type is vacuous
1268   virtual const TypePtr *add_offset( intptr_t offset ) const;
1269 
1270   // Speculative type helper methods.
1271   virtual const Type* remove_speculative() const;
1272   virtual const TypePtr* with_inline_depth(int depth) const;
1273 
1274   // the core of the computation of the meet of 2 types
1275   virtual const Type *xmeet_helper(const Type *t) const;
1276   virtual const Type *xdual() const;    // Compute dual right now.
1277 
1278   const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1279   int stable_dimension() const;
1280 
1281   const TypeAryPtr* cast_to_autobox_cache(bool cache) const;
1282 
1283   const Offset field_offset() const { return _field_offset; }
1284   const TypeAryPtr* with_field_offset(int offset) const;
1285   const TypePtr* with_field_offset_and_offset(intptr_t offset) const;
1286 
1287   // Convenience common pre-built types.
1288   static const TypeAryPtr *RANGE;
1289   static const TypeAryPtr *OOPS;
1290   static const TypeAryPtr *NARROWOOPS;
1291   static const TypeAryPtr *BYTES;
1292   static const TypeAryPtr *SHORTS;
1293   static const TypeAryPtr *CHARS;
1294   static const TypeAryPtr *INTS;
1295   static const TypeAryPtr *LONGS;
1296   static const TypeAryPtr *FLOATS;
1297   static const TypeAryPtr *DOUBLES;
1298   // selects one of the above:
1299   static const TypeAryPtr *get_array_body_type(BasicType elem) {
1300     assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != NULL, "bad elem type");
1301     return _array_body_type[elem];
1302   }
1303   static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1304   // sharpen the type of an int which is used as an array size
1305 #ifdef ASSERT
1306   // One type is interface, the other is oop
1307   virtual bool interface_vs_oop(const Type *t) const;
1308 #endif
1309 #ifndef PRODUCT
1310   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1311 #endif
1312 };
1313 
1314 //------------------------------TypeValueTypePtr-------------------------------------
1315 // Class of value type pointers
1316 class TypeValueTypePtr : public TypeOopPtr {
1317   TypeValueTypePtr(const TypeValueType* vt, PTR ptr, ciObject* o, Offset offset, int instance_id, const TypePtr* speculative, int inline_depth)
1318     : TypeOopPtr(ValueTypePtr, ptr, vt->value_klass(), true, o, offset, Offset::bottom, instance_id, speculative, inline_depth) {
1319     _vt = vt;
1320   }
1321 
1322   const TypeValueType* _vt;    // Value type we point to
1323 
1324 public:
1325   // Make a pointer to a value type
1326   static const TypeValueTypePtr* make(const TypeValueType* vt, PTR ptr = TypePtr::BotPTR, ciObject* o = NULL, Offset offset = Offset(0),
1327                                       int instance_id = InstanceBot, const TypePtr* speculative = NULL, int inline_depth = InlineDepthBottom);
1328   // Make a pointer to a value type
1329   static const TypeValueTypePtr* make(PTR ptr, ciValueKlass* vk, ciObject* o = NULL) { return make(TypeValueType::make(vk), ptr, o); }
1330   // Make a pointer to a constant value type
1331   static const TypeValueTypePtr* make(ciObject* o) { return make(TypePtr::Constant, o->klass()->as_value_klass(), o);  }
1332 
1333   const TypeValueType* value_type() const { return _vt; }
1334 
1335   virtual const TypePtr* add_offset(intptr_t offset) const;
1336 
1337   virtual const Type* cast_to_ptr_type(PTR ptr) const;
1338   virtual const TypeOopPtr* cast_to_instance_id(int instance_id) const;


< prev index next >