< prev index next >

src/share/vm/opto/type.hpp

Print this page




 965   virtual const Type *cast_to_ptr_type(PTR ptr) const;
 966 
 967   virtual intptr_t get_con() const;
 968 
 969   virtual const TypePtr *add_offset( intptr_t offset ) const;
 970 
 971   virtual const Type *xmeet( const Type *t ) const;
 972   virtual const Type *xdual() const;    // Compute dual right now.
 973   // Convenience common pre-built types.
 974   static const TypeRawPtr *BOTTOM;
 975   static const TypeRawPtr *NOTNULL;
 976 #ifndef PRODUCT
 977   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
 978 #endif
 979 };
 980 
 981 //------------------------------TypeOopPtr-------------------------------------
 982 // Some kind of oop (Java pointer), either klass or instance or array.
 983 class TypeOopPtr : public TypePtr {
 984 protected:
 985   TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset offset, int instance_id,
 986              const TypePtr* speculative, int inline_depth);
 987 public:
 988   virtual bool eq( const Type *t ) const;
 989   virtual int  hash() const;             // Type specific hashing
 990   virtual bool singleton(void) const;    // TRUE if type is a singleton
 991   enum {
 992    InstanceTop = -1,   // undefined instance
 993    InstanceBot = 0     // any possible instance
 994   };
 995 protected:
 996 
 997   // Oop is NULL, unless this is a constant oop.
 998   ciObject*     _const_oop;   // Constant oop
 999   // If _klass is NULL, then so is _sig.  This is an unloaded klass.
1000   ciKlass*      _klass;       // Klass object
1001   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
1002   bool          _klass_is_exact;
1003   bool          _is_ptr_to_narrowoop;
1004   bool          _is_ptr_to_narrowklass;
1005   bool          _is_ptr_to_boxed_value;
1006 


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




1207   Offset dual_field_offset() const;
1208 
1209   ciKlass* compute_klass(DEBUG_ONLY(bool verify = false)) const;
1210 
1211 public:
1212   // For flattened value type arrays, each field of the value type in
1213   // the array has its own memory slice so we need to keep track of
1214   // which field is accessed
1215   const Offset   _field_offset;
1216   // Accessors
1217   ciKlass* klass() const;
1218   const TypeAry* ary() const  { return _ary; }
1219   const Type*    elem() const { return _ary->_elem; }
1220   const TypeInt* size() const { return _ary->_size; }
1221   bool      is_stable() const { return _ary->_stable; }
1222 
1223   bool is_autobox_cache() const { return _is_autobox_cache; }
1224 
1225   static const TypeAryPtr* make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1226                                 Offset field_offset = Offset::bottom,
1227                                 int instance_id = InstanceBot,
1228                                 const TypePtr* speculative = NULL,
1229                                 int inline_depth = InlineDepthBottom);
1230   // Constant pointer to array
1231   static const TypeAryPtr* make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1232                                 Offset field_offset = Offset::bottom,
1233                                 int instance_id = InstanceBot,
1234                                 const TypePtr* speculative = NULL,
1235                                 int inline_depth = InlineDepthBottom,


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




 965   virtual const Type *cast_to_ptr_type(PTR ptr) const;
 966 
 967   virtual intptr_t get_con() const;
 968 
 969   virtual const TypePtr *add_offset( intptr_t offset ) const;
 970 
 971   virtual const Type *xmeet( const Type *t ) const;
 972   virtual const Type *xdual() const;    // Compute dual right now.
 973   // Convenience common pre-built types.
 974   static const TypeRawPtr *BOTTOM;
 975   static const TypeRawPtr *NOTNULL;
 976 #ifndef PRODUCT
 977   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
 978 #endif
 979 };
 980 
 981 //------------------------------TypeOopPtr-------------------------------------
 982 // Some kind of oop (Java pointer), either klass or instance or array.
 983 class TypeOopPtr : public TypePtr {
 984 protected:
 985   TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, Offset offset, Offset field_offset,
 986              int instance_id, const TypePtr* speculative, int inline_depth);
 987 public:
 988   virtual bool eq( const Type *t ) const;
 989   virtual int  hash() const;             // Type specific hashing
 990   virtual bool singleton(void) const;    // TRUE if type is a singleton
 991   enum {
 992    InstanceTop = -1,   // undefined instance
 993    InstanceBot = 0     // any possible instance
 994   };
 995 protected:
 996 
 997   // Oop is NULL, unless this is a constant oop.
 998   ciObject*     _const_oop;   // Constant oop
 999   // If _klass is NULL, then so is _sig.  This is an unloaded klass.
1000   ciKlass*      _klass;       // Klass object
1001   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
1002   bool          _klass_is_exact;
1003   bool          _is_ptr_to_narrowoop;
1004   bool          _is_ptr_to_narrowklass;
1005   bool          _is_ptr_to_boxed_value;
1006 


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




1216   // Accessors
1217   ciKlass* klass() const;
1218   const TypeAry* ary() const  { return _ary; }
1219   const Type*    elem() const { return _ary->_elem; }
1220   const TypeInt* size() const { return _ary->_size; }
1221   bool      is_stable() const { return _ary->_stable; }
1222 
1223   bool is_autobox_cache() const { return _is_autobox_cache; }
1224 
1225   static const TypeAryPtr* make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1226                                 Offset field_offset = Offset::bottom,
1227                                 int instance_id = InstanceBot,
1228                                 const TypePtr* speculative = NULL,
1229                                 int inline_depth = InlineDepthBottom);
1230   // Constant pointer to array
1231   static const TypeAryPtr* make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, Offset offset,
1232                                 Offset field_offset = Offset::bottom,
1233                                 int instance_id = InstanceBot,
1234                                 const TypePtr* speculative = NULL,
1235                                 int inline_depth = InlineDepthBottom,


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


< prev index next >