71 // [initialization state ]
72 // [initializing thread ]
73 // [Java vtable length ]
74 // [oop map cache (stack maps) ]
75 // [EMBEDDED Java vtable ] size in words = vtable_len
76 // [EMBEDDED nonstatic oop-map blocks] size in words = nonstatic_oop_map_size
77 // The embedded nonstatic oop-map blocks are short pairs (offset, length)
78 // indicating where oops are located in instances of this klass.
79 // [EMBEDDED implementor of the interface] only exist for interface
80 // [EMBEDDED host klass ] only exist for an anonymous class (JSR 292 enabled)
81
82
83 // forward declaration for class -- see below for definition
84 class SuperTypeClosure;
85 class JNIid;
86 class jniIdMapBase;
87 class BreakpointInfo;
88 class fieldDescriptor;
89 class DepChange;
90 class nmethodBucket;
91 class PreviousVersionNode;
92 class JvmtiCachedClassFieldMap;
93 class MemberNameTable;
94
95 // This is used in iterators below.
96 class FieldClosure: public StackObj {
97 public:
98 virtual void do_field(fieldDescriptor* fd) = 0;
99 };
100
101 #ifndef PRODUCT
102 // Print fields.
103 // If "obj" argument to constructor is NULL, prints static fields, otherwise prints non-static fields.
104 class FieldPrinter: public FieldClosure {
105 oop _obj;
106 outputStream* _st;
107 public:
108 FieldPrinter(outputStream* st, oop obj = NULL) : _obj(obj), _st(st) {}
109 void do_field(fieldDescriptor* fd);
110 };
111 #endif // !PRODUCT
218 u2 _generic_signature_index;
219 // Constant pool index to the utf8 entry for the name of source file
220 // containing this klass, 0 if not specified.
221 u2 _source_file_name_index;
222 u2 _static_oop_field_count;// number of static oop fields in this klass
223 u2 _java_fields_count; // The number of declared Java fields
224 int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
225
226 // _is_marked_dependent can be set concurrently, thus cannot be part of the
227 // _misc_flags.
228 bool _is_marked_dependent; // used for marking during flushing and deoptimization
229 bool _has_unloaded_dependent;
230
231 enum {
232 _misc_rewritten = 1 << 0, // methods rewritten.
233 _misc_has_nonstatic_fields = 1 << 1, // for sizing with UseCompressedOops
234 _misc_should_verify_class = 1 << 2, // allow caching of preverification
235 _misc_is_anonymous = 1 << 3, // has embedded _host_klass field
236 _misc_is_contended = 1 << 4, // marked with contended annotation
237 _misc_has_default_methods = 1 << 5, // class/superclass/implemented interfaces has default methods
238 _misc_declares_default_methods = 1 << 6 // directly declares default methods (any access)
239 };
240 u2 _misc_flags;
241 u2 _minor_version; // minor version number of class file
242 u2 _major_version; // major version number of class file
243 Thread* _init_thread; // Pointer to current thread doing initialization (to handle recusive initialization)
244 int _vtable_len; // length of Java vtable (in words)
245 int _itable_len; // length of Java itable (in words)
246 OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily)
247 MemberNameTable* _member_names; // Member names
248 JNIid* _jni_ids; // First JNI identifier for static fields in this class
249 jmethodID* _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none
250 nmethodBucket* _dependencies; // list of dependent nmethods
251 nmethod* _osr_nmethods_head; // Head of list of on-stack replacement nmethods for this class
252 BreakpointInfo* _breakpoints; // bpt lists, managed by Method*
253 // Array of interesting part(s) of the previous version(s) of this
254 // InstanceKlass. See PreviousVersionWalker below.
255 GrowableArray<PreviousVersionNode *>* _previous_versions;
256 // JVMTI fields can be moved to their own structure - see 6315920
257 // JVMTI: cached class file, before retransformable agent modified it in CFLH
258 JvmtiCachedClassFileData* _cached_class_file;
259
260 volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change
261
262 // Class states are defined as ClassState (see above).
263 // Place the _init_state here to utilize the unused 2-byte after
264 // _idnum_allocated_count.
265 u1 _init_state; // state of class
266 u1 _reference_type; // reference type
267
268 JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration
269
270 NOT_PRODUCT(int _verify_count;) // to avoid redundant verifies
271
272 // Method array.
273 Array<Method*>* _methods;
274 // Default Method Array, concrete methods inherited from interfaces
275 Array<Method*>* _default_methods;
647 char* source_debug_extension() const { return _source_debug_extension; }
648 void set_source_debug_extension(char* array, int length);
649
650 // symbol unloading support (refcount already added)
651 Symbol* array_name() { return _array_name; }
652 void set_array_name(Symbol* name) { assert(_array_name == NULL || name == NULL, "name already created"); _array_name = name; }
653
654 // nonstatic oop-map blocks
655 static int nonstatic_oop_map_size(unsigned int oop_map_count) {
656 return oop_map_count * OopMapBlock::size_in_words();
657 }
658 unsigned int nonstatic_oop_map_count() const {
659 return _nonstatic_oop_map_size / OopMapBlock::size_in_words();
660 }
661 int nonstatic_oop_map_size() const { return _nonstatic_oop_map_size; }
662 void set_nonstatic_oop_map_size(int words) {
663 _nonstatic_oop_map_size = words;
664 }
665
666 // RedefineClasses() support for previous versions:
667 void add_previous_version(instanceKlassHandle ikh, BitMap *emcp_methods,
668 int emcp_method_count);
669 // If the _previous_versions array is non-NULL, then this klass
670 // has been redefined at least once even if we aren't currently
671 // tracking a previous version.
672 bool has_been_redefined() const { return _previous_versions != NULL; }
673 bool has_previous_version() const;
674 void init_previous_versions() {
675 _previous_versions = NULL;
676 }
677 GrowableArray<PreviousVersionNode *>* previous_versions() const {
678 return _previous_versions;
679 }
680
681 InstanceKlass* get_klass_version(int version);
682 static void purge_previous_versions(InstanceKlass* ik);
683
684 // JVMTI: Support for caching a class file before it is modified by an agent that can do retransformation
685 void set_cached_class_file(JvmtiCachedClassFileData *data) {
686 _cached_class_file = data;
687 }
688 JvmtiCachedClassFileData * get_cached_class_file() { return _cached_class_file; }
689 jint get_cached_class_file_len();
690 unsigned char * get_cached_class_file_bytes();
691
692 // JVMTI: Support for caching of field indices, types, and offsets
693 void set_jvmti_cached_class_field_map(JvmtiCachedClassFieldMap* descriptor) {
694 _jvmti_cached_class_field_map = descriptor;
695 }
696 JvmtiCachedClassFieldMap* jvmti_cached_class_field_map() const {
697 return _jvmti_cached_class_field_map;
698 }
699
700 bool has_default_methods() const {
701 return (_misc_flags & _misc_has_default_methods) != 0;
1102
1103 // Returns the array class for the n'th dimension
1104 Klass* array_klass_impl(bool or_null, int n, TRAPS);
1105
1106 // Returns the array class with this class as element type
1107 Klass* array_klass_impl(bool or_null, TRAPS);
1108
1109 // find a local method (returns NULL if not found)
1110 Method* find_method_impl(Symbol* name, Symbol* signature,
1111 OverpassLookupMode overpass_mode,
1112 StaticLookupMode static_mode,
1113 PrivateLookupMode private_mode) const;
1114 static Method* find_method_impl(Array<Method*>* methods,
1115 Symbol* name, Symbol* signature,
1116 OverpassLookupMode overpass_mode,
1117 StaticLookupMode static_mode,
1118 PrivateLookupMode private_mode);
1119
1120 // Free CHeap allocated fields.
1121 void release_C_heap_structures();
1122 public:
1123 // CDS support - remove and restore oops from metadata. Oops are not shared.
1124 virtual void remove_unshareable_info();
1125 virtual void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);
1126
1127 // jvm support
1128 jint compute_modifier_flags(TRAPS) const;
1129
1130 // JSR-292 support
1131 MemberNameTable* member_names() { return _member_names; }
1132 void set_member_names(MemberNameTable* member_names) { _member_names = member_names; }
1133 oop add_member_name(Handle member_name, bool intern);
1134
1135 public:
1136 // JVMTI support
1137 jint jvmti_class_status() const;
1138
1139 public:
1140 // Printing
1141 #ifndef PRODUCT
1197 // Accessors
1198 Klass* holder() const { return _holder; }
1199 int offset() const { return _offset; }
1200 JNIid* next() { return _next; }
1201 // Constructor
1202 JNIid(Klass* holder, int offset, JNIid* next);
1203 // Identifier lookup
1204 JNIid* find(int offset);
1205
1206 bool find_local_field(fieldDescriptor* fd) {
1207 return InstanceKlass::cast(holder())->find_local_field_from_offset(offset(), true, fd);
1208 }
1209
1210 static void deallocate(JNIid* id);
1211 // Debugging
1212 #ifdef ASSERT
1213 bool is_static_field_id() const { return _is_static_field_id; }
1214 void set_is_static_field_id() { _is_static_field_id = true; }
1215 #endif
1216 void verify(Klass* holder);
1217 };
1218
1219
1220 // If breakpoints are more numerous than just JVMTI breakpoints,
1221 // consider compressing this data structure.
1222 // It is currently a simple linked list defined in method.hpp.
1223
1224 class BreakpointInfo;
1225
1226
1227 // A collection point for interesting information about the previous
1228 // version(s) of an InstanceKlass. A GrowableArray of PreviousVersionNodes
1229 // is attached to the InstanceKlass as needed. See PreviousVersionWalker below.
1230 class PreviousVersionNode : public CHeapObj<mtClass> {
1231 private:
1232 ConstantPool* _prev_constant_pool;
1233
1234 // If the previous version of the InstanceKlass doesn't have any
1235 // EMCP methods, then _prev_EMCP_methods will be NULL. If all the
1236 // EMCP methods have been collected, then _prev_EMCP_methods can
1237 // have a length of zero.
1238 GrowableArray<Method*>* _prev_EMCP_methods;
1239
1240 public:
1241 PreviousVersionNode(ConstantPool* prev_constant_pool,
1242 GrowableArray<Method*>* prev_EMCP_methods);
1243 ~PreviousVersionNode();
1244 ConstantPool* prev_constant_pool() const {
1245 return _prev_constant_pool;
1246 }
1247 GrowableArray<Method*>* prev_EMCP_methods() const {
1248 return _prev_EMCP_methods;
1249 }
1250 };
1251
1252
1253 // Helper object for walking previous versions.
1254 class PreviousVersionWalker : public StackObj {
1255 private:
1256 Thread* _thread;
1257 GrowableArray<PreviousVersionNode *>* _previous_versions;
1258 int _current_index;
1259
1260 // A pointer to the current node object so we can handle the deletes.
1261 PreviousVersionNode* _current_p;
1262
1263 // The constant pool handle keeps all the methods in this class from being
1264 // deallocated from the metaspace during class unloading.
1265 constantPoolHandle _current_constant_pool_handle;
1266
1267 public:
1268 PreviousVersionWalker(Thread* thread, InstanceKlass *ik);
1269
1270 // Return the interesting information for the next previous version
1271 // of the klass. Returns NULL if there are no more previous versions.
1272 PreviousVersionNode* next_previous_version();
1273 };
1274
1275
1276 //
1277 // nmethodBucket is used to record dependent nmethods for
1278 // deoptimization. nmethod dependencies are actually <klass, method>
1279 // pairs but we really only care about the klass part for purposes of
1280 // finding nmethods which might need to be deoptimized. Instead of
1281 // recording the method, a count of how many times a particular nmethod
1282 // was recorded is kept. This ensures that any recording errors are
1283 // noticed since an nmethod should be removed as many times are it's
1284 // added.
1285 //
1286 class nmethodBucket: public CHeapObj<mtClass> {
1287 friend class VMStructs;
1288 private:
1289 nmethod* _nmethod;
1290 int _count;
1291 nmethodBucket* _next;
1292
|
71 // [initialization state ]
72 // [initializing thread ]
73 // [Java vtable length ]
74 // [oop map cache (stack maps) ]
75 // [EMBEDDED Java vtable ] size in words = vtable_len
76 // [EMBEDDED nonstatic oop-map blocks] size in words = nonstatic_oop_map_size
77 // The embedded nonstatic oop-map blocks are short pairs (offset, length)
78 // indicating where oops are located in instances of this klass.
79 // [EMBEDDED implementor of the interface] only exist for interface
80 // [EMBEDDED host klass ] only exist for an anonymous class (JSR 292 enabled)
81
82
83 // forward declaration for class -- see below for definition
84 class SuperTypeClosure;
85 class JNIid;
86 class jniIdMapBase;
87 class BreakpointInfo;
88 class fieldDescriptor;
89 class DepChange;
90 class nmethodBucket;
91 class JvmtiCachedClassFieldMap;
92 class MemberNameTable;
93
94 // This is used in iterators below.
95 class FieldClosure: public StackObj {
96 public:
97 virtual void do_field(fieldDescriptor* fd) = 0;
98 };
99
100 #ifndef PRODUCT
101 // Print fields.
102 // If "obj" argument to constructor is NULL, prints static fields, otherwise prints non-static fields.
103 class FieldPrinter: public FieldClosure {
104 oop _obj;
105 outputStream* _st;
106 public:
107 FieldPrinter(outputStream* st, oop obj = NULL) : _obj(obj), _st(st) {}
108 void do_field(fieldDescriptor* fd);
109 };
110 #endif // !PRODUCT
217 u2 _generic_signature_index;
218 // Constant pool index to the utf8 entry for the name of source file
219 // containing this klass, 0 if not specified.
220 u2 _source_file_name_index;
221 u2 _static_oop_field_count;// number of static oop fields in this klass
222 u2 _java_fields_count; // The number of declared Java fields
223 int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
224
225 // _is_marked_dependent can be set concurrently, thus cannot be part of the
226 // _misc_flags.
227 bool _is_marked_dependent; // used for marking during flushing and deoptimization
228 bool _has_unloaded_dependent;
229
230 enum {
231 _misc_rewritten = 1 << 0, // methods rewritten.
232 _misc_has_nonstatic_fields = 1 << 1, // for sizing with UseCompressedOops
233 _misc_should_verify_class = 1 << 2, // allow caching of preverification
234 _misc_is_anonymous = 1 << 3, // has embedded _host_klass field
235 _misc_is_contended = 1 << 4, // marked with contended annotation
236 _misc_has_default_methods = 1 << 5, // class/superclass/implemented interfaces has default methods
237 _misc_declares_default_methods = 1 << 6, // directly declares default methods (any access)
238 _misc_has_been_redefined = 1 << 7 // class has been redefined
239 };
240 u2 _misc_flags;
241 u2 _minor_version; // minor version number of class file
242 u2 _major_version; // major version number of class file
243 Thread* _init_thread; // Pointer to current thread doing initialization (to handle recusive initialization)
244 int _vtable_len; // length of Java vtable (in words)
245 int _itable_len; // length of Java itable (in words)
246 OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily)
247 MemberNameTable* _member_names; // Member names
248 JNIid* _jni_ids; // First JNI identifier for static fields in this class
249 jmethodID* _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none
250 nmethodBucket* _dependencies; // list of dependent nmethods
251 nmethod* _osr_nmethods_head; // Head of list of on-stack replacement nmethods for this class
252 BreakpointInfo* _breakpoints; // bpt lists, managed by Method*
253 // Linked instanceKlasses of previous versions
254 InstanceKlass* _previous_versions;
255 // JVMTI fields can be moved to their own structure - see 6315920
256 // JVMTI: cached class file, before retransformable agent modified it in CFLH
257 JvmtiCachedClassFileData* _cached_class_file;
258
259 volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change
260
261 // Class states are defined as ClassState (see above).
262 // Place the _init_state here to utilize the unused 2-byte after
263 // _idnum_allocated_count.
264 u1 _init_state; // state of class
265 u1 _reference_type; // reference type
266
267 JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration
268
269 NOT_PRODUCT(int _verify_count;) // to avoid redundant verifies
270
271 // Method array.
272 Array<Method*>* _methods;
273 // Default Method Array, concrete methods inherited from interfaces
274 Array<Method*>* _default_methods;
646 char* source_debug_extension() const { return _source_debug_extension; }
647 void set_source_debug_extension(char* array, int length);
648
649 // symbol unloading support (refcount already added)
650 Symbol* array_name() { return _array_name; }
651 void set_array_name(Symbol* name) { assert(_array_name == NULL || name == NULL, "name already created"); _array_name = name; }
652
653 // nonstatic oop-map blocks
654 static int nonstatic_oop_map_size(unsigned int oop_map_count) {
655 return oop_map_count * OopMapBlock::size_in_words();
656 }
657 unsigned int nonstatic_oop_map_count() const {
658 return _nonstatic_oop_map_size / OopMapBlock::size_in_words();
659 }
660 int nonstatic_oop_map_size() const { return _nonstatic_oop_map_size; }
661 void set_nonstatic_oop_map_size(int words) {
662 _nonstatic_oop_map_size = words;
663 }
664
665 // RedefineClasses() support for previous versions:
666 void add_previous_version(instanceKlassHandle ikh, int emcp_method_count);
667
668 InstanceKlass* previous_versions() const { return _previous_versions; }
669
670 bool has_been_redefined() const {
671 return (_misc_flags & _misc_has_been_redefined) != 0;
672 }
673 void set_has_been_redefined() {
674 _misc_flags |= _misc_has_been_redefined;
675 }
676
677 void init_previous_versions() {
678 _previous_versions = NULL;
679 }
680
681
682 InstanceKlass* get_klass_version(int version) {
683 for (InstanceKlass* ik = this; ik != NULL; ik = ik->previous_versions()) {
684 if (ik->constants()->version() == version) {
685 return ik;
686 }
687 }
688 return NULL;
689 }
690
691 static void purge_previous_versions(InstanceKlass* ik);
692
693 // JVMTI: Support for caching a class file before it is modified by an agent that can do retransformation
694 void set_cached_class_file(JvmtiCachedClassFileData *data) {
695 _cached_class_file = data;
696 }
697 JvmtiCachedClassFileData * get_cached_class_file() { return _cached_class_file; }
698 jint get_cached_class_file_len();
699 unsigned char * get_cached_class_file_bytes();
700
701 // JVMTI: Support for caching of field indices, types, and offsets
702 void set_jvmti_cached_class_field_map(JvmtiCachedClassFieldMap* descriptor) {
703 _jvmti_cached_class_field_map = descriptor;
704 }
705 JvmtiCachedClassFieldMap* jvmti_cached_class_field_map() const {
706 return _jvmti_cached_class_field_map;
707 }
708
709 bool has_default_methods() const {
710 return (_misc_flags & _misc_has_default_methods) != 0;
1111
1112 // Returns the array class for the n'th dimension
1113 Klass* array_klass_impl(bool or_null, int n, TRAPS);
1114
1115 // Returns the array class with this class as element type
1116 Klass* array_klass_impl(bool or_null, TRAPS);
1117
1118 // find a local method (returns NULL if not found)
1119 Method* find_method_impl(Symbol* name, Symbol* signature,
1120 OverpassLookupMode overpass_mode,
1121 StaticLookupMode static_mode,
1122 PrivateLookupMode private_mode) const;
1123 static Method* find_method_impl(Array<Method*>* methods,
1124 Symbol* name, Symbol* signature,
1125 OverpassLookupMode overpass_mode,
1126 StaticLookupMode static_mode,
1127 PrivateLookupMode private_mode);
1128
1129 // Free CHeap allocated fields.
1130 void release_C_heap_structures();
1131
1132 // RedefineClasses support
1133 void link_previous_versions(InstanceKlass* pv) { _previous_versions = pv; }
1134 void mark_newly_obsolete_methods(Array<Method*>* old_methods, int emcp_method_count);
1135 public:
1136 // CDS support - remove and restore oops from metadata. Oops are not shared.
1137 virtual void remove_unshareable_info();
1138 virtual void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);
1139
1140 // jvm support
1141 jint compute_modifier_flags(TRAPS) const;
1142
1143 // JSR-292 support
1144 MemberNameTable* member_names() { return _member_names; }
1145 void set_member_names(MemberNameTable* member_names) { _member_names = member_names; }
1146 oop add_member_name(Handle member_name, bool intern);
1147
1148 public:
1149 // JVMTI support
1150 jint jvmti_class_status() const;
1151
1152 public:
1153 // Printing
1154 #ifndef PRODUCT
1210 // Accessors
1211 Klass* holder() const { return _holder; }
1212 int offset() const { return _offset; }
1213 JNIid* next() { return _next; }
1214 // Constructor
1215 JNIid(Klass* holder, int offset, JNIid* next);
1216 // Identifier lookup
1217 JNIid* find(int offset);
1218
1219 bool find_local_field(fieldDescriptor* fd) {
1220 return InstanceKlass::cast(holder())->find_local_field_from_offset(offset(), true, fd);
1221 }
1222
1223 static void deallocate(JNIid* id);
1224 // Debugging
1225 #ifdef ASSERT
1226 bool is_static_field_id() const { return _is_static_field_id; }
1227 void set_is_static_field_id() { _is_static_field_id = true; }
1228 #endif
1229 void verify(Klass* holder);
1230 };
1231
1232
1233 //
1234 // nmethodBucket is used to record dependent nmethods for
1235 // deoptimization. nmethod dependencies are actually <klass, method>
1236 // pairs but we really only care about the klass part for purposes of
1237 // finding nmethods which might need to be deoptimized. Instead of
1238 // recording the method, a count of how many times a particular nmethod
1239 // was recorded is kept. This ensures that any recording errors are
1240 // noticed since an nmethod should be removed as many times are it's
1241 // added.
1242 //
1243 class nmethodBucket: public CHeapObj<mtClass> {
1244 friend class VMStructs;
1245 private:
1246 nmethod* _nmethod;
1247 int _count;
1248 nmethodBucket* _next;
1249
|