Mercurial > hg > truffle
comparison src/share/vm/opto/type.hpp @ 6725:da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author | coleenp |
---|---|
date | Sat, 01 Sep 2012 13:25:18 -0400 |
parents | 8c92982cbbc4 |
children | 8e47bac5643a |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
60 class TypeRawPtr; | 60 class TypeRawPtr; |
61 class TypeOopPtr; | 61 class TypeOopPtr; |
62 class TypeInstPtr; | 62 class TypeInstPtr; |
63 class TypeAryPtr; | 63 class TypeAryPtr; |
64 class TypeKlassPtr; | 64 class TypeKlassPtr; |
65 class TypeMetadataPtr; | |
65 | 66 |
66 //------------------------------Type------------------------------------------- | 67 //------------------------------Type------------------------------------------- |
67 // Basic Type object, represents a set of primitive Values. | 68 // Basic Type object, represents a set of primitive Values. |
68 // Types are hash-cons'd into a private class dictionary, so only one of each | 69 // Types are hash-cons'd into a private class dictionary, so only one of each |
69 // different kind of Type exists. Types are never modified after creation, so | 70 // different kind of Type exists. Types are never modified after creation, so |
91 AnyPtr, // Any old raw, klass, inst, or array pointer | 92 AnyPtr, // Any old raw, klass, inst, or array pointer |
92 RawPtr, // Raw (non-oop) pointers | 93 RawPtr, // Raw (non-oop) pointers |
93 OopPtr, // Any and all Java heap entities | 94 OopPtr, // Any and all Java heap entities |
94 InstPtr, // Instance pointers (non-array objects) | 95 InstPtr, // Instance pointers (non-array objects) |
95 AryPtr, // Array pointers | 96 AryPtr, // Array pointers |
97 // (Ptr order matters: See is_ptr, isa_ptr, is_oopptr, isa_oopptr.) | |
98 | |
99 MetadataPtr, // Generic metadata | |
96 KlassPtr, // Klass pointers | 100 KlassPtr, // Klass pointers |
97 // (Ptr order matters: See is_ptr, isa_ptr, is_oopptr, isa_oopptr.) | |
98 | 101 |
99 Function, // Function signature | 102 Function, // Function signature |
100 Abio, // Abstract I/O | 103 Abio, // Abstract I/O |
101 Return_Address, // Subroutine return address | 104 Return_Address, // Subroutine return address |
102 Memory, // Abstract store | 105 Memory, // Abstract store |
121 WidenMin = 0, | 124 WidenMin = 0, |
122 WidenMax = 3 | 125 WidenMax = 3 |
123 }; | 126 }; |
124 | 127 |
125 private: | 128 private: |
129 typedef struct { | |
130 const TYPES dual_type; | |
131 const BasicType basic_type; | |
132 const char* msg; | |
133 const bool isa_oop; | |
134 const int ideal_reg; | |
135 const relocInfo::relocType reloc; | |
136 } TypeInfo; | |
137 | |
126 // Dictionary of types shared among compilations. | 138 // Dictionary of types shared among compilations. |
127 static Dict* _shared_type_dict; | 139 static Dict* _shared_type_dict; |
140 static TypeInfo _type_info[]; | |
128 | 141 |
129 static int uhash( const Type *const t ); | 142 static int uhash( const Type *const t ); |
130 // Structural equality check. Assumes that cmp() has already compared | 143 // Structural equality check. Assumes that cmp() has already compared |
131 // the _base types and thus knows it can cast 't' appropriately. | 144 // the _base types and thus knows it can cast 't' appropriately. |
132 virtual bool eq( const Type *t ) const; | 145 virtual bool eq( const Type *t ) const; |
239 const TypeRawPtr *is_rawptr() const; // Asserts is rawptr | 252 const TypeRawPtr *is_rawptr() const; // Asserts is rawptr |
240 const TypeNarrowOop *is_narrowoop() const; // Java-style GC'd pointer | 253 const TypeNarrowOop *is_narrowoop() const; // Java-style GC'd pointer |
241 const TypeNarrowOop *isa_narrowoop() const; // Returns NULL if not oop ptr type | 254 const TypeNarrowOop *isa_narrowoop() const; // Returns NULL if not oop ptr type |
242 const TypeOopPtr *isa_oopptr() const; // Returns NULL if not oop ptr type | 255 const TypeOopPtr *isa_oopptr() const; // Returns NULL if not oop ptr type |
243 const TypeOopPtr *is_oopptr() const; // Java-style GC'd pointer | 256 const TypeOopPtr *is_oopptr() const; // Java-style GC'd pointer |
244 const TypeKlassPtr *isa_klassptr() const; // Returns NULL if not KlassPtr | |
245 const TypeKlassPtr *is_klassptr() const; // assert if not KlassPtr | |
246 const TypeInstPtr *isa_instptr() const; // Returns NULL if not InstPtr | 257 const TypeInstPtr *isa_instptr() const; // Returns NULL if not InstPtr |
247 const TypeInstPtr *is_instptr() const; // Instance | 258 const TypeInstPtr *is_instptr() const; // Instance |
248 const TypeAryPtr *isa_aryptr() const; // Returns NULL if not AryPtr | 259 const TypeAryPtr *isa_aryptr() const; // Returns NULL if not AryPtr |
249 const TypeAryPtr *is_aryptr() const; // Array oop | 260 const TypeAryPtr *is_aryptr() const; // Array oop |
261 | |
262 const TypeMetadataPtr *isa_metadataptr() const; // Returns NULL if not oop ptr type | |
263 const TypeMetadataPtr *is_metadataptr() const; // Java-style GC'd pointer | |
264 const TypeKlassPtr *isa_klassptr() const; // Returns NULL if not KlassPtr | |
265 const TypeKlassPtr *is_klassptr() const; // assert if not KlassPtr | |
266 | |
250 virtual bool is_finite() const; // Has a finite value | 267 virtual bool is_finite() const; // Has a finite value |
251 virtual bool is_nan() const; // Is not a number (NaN) | 268 virtual bool is_nan() const; // Is not a number (NaN) |
252 | 269 |
253 // Returns this ptr type or the equivalent ptr type for this compressed pointer. | 270 // Returns this ptr type or the equivalent ptr type for this compressed pointer. |
254 const TypePtr* make_ptr() const; | 271 const TypePtr* make_ptr() const; |
265 bool is_floatingpoint() const; // True if Float or Double base type | 282 bool is_floatingpoint() const; // True if Float or Double base type |
266 | 283 |
267 // Do you have memory, directly or through a tuple? | 284 // Do you have memory, directly or through a tuple? |
268 bool has_memory( ) const; | 285 bool has_memory( ) const; |
269 | 286 |
270 // Are you a pointer type or not? | |
271 bool isa_oop_ptr() const; | |
272 | |
273 // TRUE if type is a singleton | 287 // TRUE if type is a singleton |
274 virtual bool singleton(void) const; | 288 virtual bool singleton(void) const; |
275 | 289 |
276 // TRUE if type is above the lattice centerline, and is therefore vacuous | 290 // TRUE if type is above the lattice centerline, and is therefore vacuous |
277 virtual bool empty(void) const; | 291 virtual bool empty(void) const; |
282 | 296 |
283 // Map ideal registers (machine types) to ideal types | 297 // Map ideal registers (machine types) to ideal types |
284 static const Type *mreg2type[]; | 298 static const Type *mreg2type[]; |
285 | 299 |
286 // Printing, statistics | 300 // Printing, statistics |
287 static const char * const msg[lastype]; // Printable strings | |
288 #ifndef PRODUCT | 301 #ifndef PRODUCT |
289 void dump_on(outputStream *st) const; | 302 void dump_on(outputStream *st) const; |
290 void dump() const { | 303 void dump() const { |
291 dump_on(tty); | 304 dump_on(tty); |
292 } | 305 } |
293 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; | 306 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; |
294 static void dump_stats(); | 307 static void dump_stats(); |
295 static void verify_lastype(); // Check that arrays match type enum | |
296 #endif | 308 #endif |
297 void typerr(const Type *t) const; // Mixing types error | 309 void typerr(const Type *t) const; // Mixing types error |
298 | 310 |
299 // Create basic type | 311 // Create basic type |
300 static const Type* get_const_basic_type(BasicType type) { | 312 static const Type* get_const_basic_type(BasicType type) { |
334 static const Type *MULTI; | 346 static const Type *MULTI; |
335 static const Type *RETURN_ADDRESS; | 347 static const Type *RETURN_ADDRESS; |
336 static const Type *TOP; | 348 static const Type *TOP; |
337 | 349 |
338 // Mapping from compiler type to VM BasicType | 350 // Mapping from compiler type to VM BasicType |
339 BasicType basic_type() const { return _basic_type[_base]; } | 351 BasicType basic_type() const { return _type_info[_base].basic_type; } |
352 int ideal_reg() const { return _type_info[_base].ideal_reg; } | |
353 const char* msg() const { return _type_info[_base].msg; } | |
354 bool isa_oop_ptr() const { return _type_info[_base].isa_oop; } | |
355 relocInfo::relocType reloc() const { return _type_info[_base].reloc; } | |
340 | 356 |
341 // Mapping from CI type system to compiler type: | 357 // Mapping from CI type system to compiler type: |
342 static const Type* get_typeflow_type(ciType* type); | 358 static const Type* get_typeflow_type(ciType* type); |
343 | 359 |
344 private: | 360 private: |
840 #endif | 856 #endif |
841 }; | 857 }; |
842 | 858 |
843 //------------------------------TypeInstPtr------------------------------------ | 859 //------------------------------TypeInstPtr------------------------------------ |
844 // Class of Java object pointers, pointing either to non-array Java instances | 860 // Class of Java object pointers, pointing either to non-array Java instances |
845 // or to a klassOop (including array klasses). | 861 // or to a Klass* (including array klasses). |
846 class TypeInstPtr : public TypeOopPtr { | 862 class TypeInstPtr : public TypeOopPtr { |
847 TypeInstPtr( PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id ); | 863 TypeInstPtr( PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id ); |
848 virtual bool eq( const Type *t ) const; | 864 virtual bool eq( const Type *t ) const; |
849 virtual int hash() const; // Type specific hashing | 865 virtual int hash() const; // Type specific hashing |
850 | 866 |
857 | 873 |
858 // Make a pointer to a constant oop. | 874 // Make a pointer to a constant oop. |
859 static const TypeInstPtr *make(ciObject* o) { | 875 static const TypeInstPtr *make(ciObject* o) { |
860 return make(TypePtr::Constant, o->klass(), true, o, 0); | 876 return make(TypePtr::Constant, o->klass(), true, o, 0); |
861 } | 877 } |
862 | |
863 // Make a pointer to a constant oop with offset. | 878 // Make a pointer to a constant oop with offset. |
864 static const TypeInstPtr *make(ciObject* o, int offset) { | 879 static const TypeInstPtr *make(ciObject* o, int offset) { |
865 return make(TypePtr::Constant, o->klass(), true, o, offset); | 880 return make(TypePtr::Constant, o->klass(), true, o, offset); |
866 } | 881 } |
867 | 882 |
990 #ifndef PRODUCT | 1005 #ifndef PRODUCT |
991 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping | 1006 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping |
992 #endif | 1007 #endif |
993 }; | 1008 }; |
994 | 1009 |
1010 //------------------------------TypeMetadataPtr------------------------------------- | |
1011 // Some kind of metadata, either Method*, MethodData* or CPCacheOop | |
1012 class TypeMetadataPtr : public TypePtr { | |
1013 protected: | |
1014 TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset); | |
1015 public: | |
1016 virtual bool eq( const Type *t ) const; | |
1017 virtual int hash() const; // Type specific hashing | |
1018 virtual bool singleton(void) const; // TRUE if type is a singleton | |
1019 | |
1020 private: | |
1021 ciMetadata* _metadata; | |
1022 | |
1023 public: | |
1024 static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, int offset); | |
1025 | |
1026 static const TypeMetadataPtr* make(ciMethod* m); | |
1027 static const TypeMetadataPtr* make(ciMethodData* m); | |
1028 | |
1029 ciMetadata* metadata() const { return _metadata; } | |
1030 | |
1031 virtual const Type *cast_to_ptr_type(PTR ptr) const; | |
1032 | |
1033 virtual const TypePtr *add_offset( intptr_t offset ) const; | |
1034 | |
1035 virtual const Type *xmeet( const Type *t ) const; | |
1036 virtual const Type *xdual() const; // Compute dual right now. | |
1037 | |
1038 virtual intptr_t get_con() const; | |
1039 | |
1040 // Do not allow interface-vs.-noninterface joins to collapse to top. | |
1041 virtual const Type *filter( const Type *kills ) const; | |
1042 | |
1043 // Convenience common pre-built types. | |
1044 static const TypeMetadataPtr *BOTTOM; | |
1045 | |
1046 #ifndef PRODUCT | |
1047 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; | |
1048 #endif | |
1049 }; | |
1050 | |
995 //------------------------------TypeKlassPtr----------------------------------- | 1051 //------------------------------TypeKlassPtr----------------------------------- |
996 // Class of Java Klass pointers | 1052 // Class of Java Klass pointers |
997 class TypeKlassPtr : public TypeOopPtr { | 1053 class TypeKlassPtr : public TypePtr { |
998 TypeKlassPtr( PTR ptr, ciKlass* klass, int offset ); | 1054 TypeKlassPtr( PTR ptr, ciKlass* klass, int offset ); |
999 | 1055 |
1056 public: | |
1000 virtual bool eq( const Type *t ) const; | 1057 virtual bool eq( const Type *t ) const; |
1001 virtual int hash() const; // Type specific hashing | 1058 virtual int hash() const; // Type specific hashing |
1002 | 1059 virtual bool singleton(void) const; // TRUE if type is a singleton |
1003 public: | 1060 private: |
1004 ciSymbol* name() const { return _klass->name(); } | 1061 |
1005 | 1062 static const TypeKlassPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact); |
1006 bool is_loaded() const { return _klass->is_loaded(); } | 1063 |
1064 ciKlass* _klass; | |
1065 | |
1066 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.) | |
1067 bool _klass_is_exact; | |
1068 | |
1069 public: | |
1070 ciSymbol* name() const { return klass()->name(); } | |
1071 | |
1072 ciKlass* klass() const { return _klass; } | |
1073 bool klass_is_exact() const { return _klass_is_exact; } | |
1074 | |
1075 bool is_loaded() const { return klass()->is_loaded(); } | |
1076 | |
1077 // Creates a type given a klass. Correctly handles multi-dimensional arrays | |
1078 // Respects UseUniqueSubclasses. | |
1079 // If the klass is final, the resulting type will be exact. | |
1080 static const TypeKlassPtr* make_from_klass(ciKlass* klass) { | |
1081 return make_from_klass_common(klass, true, false); | |
1082 } | |
1083 // Same as before, but will produce an exact type, even if | |
1084 // the klass is not final, as long as it has exactly one implementation. | |
1085 static const TypeKlassPtr* make_from_klass_unique(ciKlass* klass) { | |
1086 return make_from_klass_common(klass, true, true); | |
1087 } | |
1088 // Same as before, but does not respects UseUniqueSubclasses. | |
1089 // Use this only for creating array element types. | |
1090 static const TypeKlassPtr* make_from_klass_raw(ciKlass* klass) { | |
1091 return make_from_klass_common(klass, false, false); | |
1092 } | |
1093 | |
1094 // Make a generic (unclassed) pointer to metadata. | |
1095 static const TypeKlassPtr* make(PTR ptr, int offset); | |
1007 | 1096 |
1008 // ptr to klass 'k' | 1097 // ptr to klass 'k' |
1009 static const TypeKlassPtr *make( ciKlass* k ) { return make( TypePtr::Constant, k, 0); } | 1098 static const TypeKlassPtr *make( ciKlass* k ) { return make( TypePtr::Constant, k, 0); } |
1010 // ptr to klass 'k' with offset | 1099 // ptr to klass 'k' with offset |
1011 static const TypeKlassPtr *make( ciKlass* k, int offset ) { return make( TypePtr::Constant, k, offset); } | 1100 static const TypeKlassPtr *make( ciKlass* k, int offset ) { return make( TypePtr::Constant, k, offset); } |
1020 const TypeOopPtr* as_instance_type() const; | 1109 const TypeOopPtr* as_instance_type() const; |
1021 | 1110 |
1022 virtual const TypePtr *add_offset( intptr_t offset ) const; | 1111 virtual const TypePtr *add_offset( intptr_t offset ) const; |
1023 virtual const Type *xmeet( const Type *t ) const; | 1112 virtual const Type *xmeet( const Type *t ) const; |
1024 virtual const Type *xdual() const; // Compute dual right now. | 1113 virtual const Type *xdual() const; // Compute dual right now. |
1114 | |
1115 virtual intptr_t get_con() const; | |
1025 | 1116 |
1026 // Convenience common pre-built types. | 1117 // Convenience common pre-built types. |
1027 static const TypeKlassPtr* OBJECT; // Not-null object klass or below | 1118 static const TypeKlassPtr* OBJECT; // Not-null object klass or below |
1028 static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same | 1119 static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same |
1029 #ifndef PRODUCT | 1120 #ifndef PRODUCT |
1115 | 1206 |
1116 BasicType return_type() const; | 1207 BasicType return_type() const; |
1117 | 1208 |
1118 #ifndef PRODUCT | 1209 #ifndef PRODUCT |
1119 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping | 1210 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping |
1120 void print_flattened() const; // Print a 'flattened' signature | |
1121 #endif | 1211 #endif |
1122 // Convenience common pre-built types. | 1212 // Convenience common pre-built types. |
1123 }; | 1213 }; |
1124 | 1214 |
1125 //------------------------------accessors-------------------------------------- | 1215 //------------------------------accessors-------------------------------------- |
1207 return (_base >= AnyPtr && _base <= KlassPtr) ? (TypePtr*)this : NULL; | 1297 return (_base >= AnyPtr && _base <= KlassPtr) ? (TypePtr*)this : NULL; |
1208 } | 1298 } |
1209 | 1299 |
1210 inline const TypeOopPtr *Type::is_oopptr() const { | 1300 inline const TypeOopPtr *Type::is_oopptr() const { |
1211 // OopPtr is the first and KlassPtr the last, with no non-oops between. | 1301 // OopPtr is the first and KlassPtr the last, with no non-oops between. |
1212 assert(_base >= OopPtr && _base <= KlassPtr, "Not a Java pointer" ) ; | 1302 assert(_base >= OopPtr && _base <= AryPtr, "Not a Java pointer" ) ; |
1213 return (TypeOopPtr*)this; | 1303 return (TypeOopPtr*)this; |
1214 } | 1304 } |
1215 | 1305 |
1216 inline const TypeOopPtr *Type::isa_oopptr() const { | 1306 inline const TypeOopPtr *Type::isa_oopptr() const { |
1217 // OopPtr is the first and KlassPtr the last, with no non-oops between. | 1307 // OopPtr is the first and KlassPtr the last, with no non-oops between. |
1218 return (_base >= OopPtr && _base <= KlassPtr) ? (TypeOopPtr*)this : NULL; | 1308 return (_base >= OopPtr && _base <= AryPtr) ? (TypeOopPtr*)this : NULL; |
1219 } | 1309 } |
1220 | 1310 |
1221 inline const TypeRawPtr *Type::isa_rawptr() const { | 1311 inline const TypeRawPtr *Type::isa_rawptr() const { |
1222 return (_base == RawPtr) ? (TypeRawPtr*)this : NULL; | 1312 return (_base == RawPtr) ? (TypeRawPtr*)this : NULL; |
1223 } | 1313 } |
1252 } | 1342 } |
1253 | 1343 |
1254 inline const TypeNarrowOop *Type::isa_narrowoop() const { | 1344 inline const TypeNarrowOop *Type::isa_narrowoop() const { |
1255 // OopPtr is the first and KlassPtr the last, with no non-oops between. | 1345 // OopPtr is the first and KlassPtr the last, with no non-oops between. |
1256 return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL; | 1346 return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL; |
1347 } | |
1348 | |
1349 inline const TypeMetadataPtr *Type::is_metadataptr() const { | |
1350 // MetadataPtr is the first and CPCachePtr the last | |
1351 assert(_base == MetadataPtr, "Not a metadata pointer" ) ; | |
1352 return (TypeMetadataPtr*)this; | |
1353 } | |
1354 | |
1355 inline const TypeMetadataPtr *Type::isa_metadataptr() const { | |
1356 return (_base == MetadataPtr) ? (TypeMetadataPtr*)this : NULL; | |
1257 } | 1357 } |
1258 | 1358 |
1259 inline const TypeKlassPtr *Type::isa_klassptr() const { | 1359 inline const TypeKlassPtr *Type::isa_klassptr() const { |
1260 return (_base == KlassPtr) ? (TypeKlassPtr*)this : NULL; | 1360 return (_base == KlassPtr) ? (TypeKlassPtr*)this : NULL; |
1261 } | 1361 } |