161 // it is stored in the instanceklass as a NULL-terminated UTF-8 string
162 const char* _source_debug_extension;
163 // Array name derived from this class which needs unreferencing
164 // if this class is unloaded.
165 Symbol* _array_name;
166
167 // Number of heapOopSize words used by non-static fields in this klass
168 // (including inherited fields but after header_size()).
169 int _nonstatic_field_size;
170 int _static_field_size; // number words used by static fields (oop and non-oop) in this klass
171 // Constant pool index to the utf8 entry of the Generic signature,
172 // or 0 if none.
173 u2 _generic_signature_index;
174 // Constant pool index to the utf8 entry for the name of source file
175 // containing this klass, 0 if not specified.
176 u2 _source_file_name_index;
177 u2 _static_oop_field_count;// number of static oop fields in this klass
178 u2 _java_fields_count; // The number of declared Java fields
179 int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
180
181 // _is_marked_dependent can be set concurrently, thus cannot be part of the
182 // _misc_flags.
183 bool _is_marked_dependent; // used for marking during flushing and deoptimization
184
185 // The low two bits of _misc_flags contains the kind field.
186 // This can be used to quickly discriminate among the four kinds of
187 // InstanceKlass.
188
189 static const unsigned _misc_kind_field_size = 2;
190 static const unsigned _misc_kind_field_pos = 0;
191 static const unsigned _misc_kind_field_mask = (1u << _misc_kind_field_size) - 1u;
192
193 static const unsigned _misc_kind_other = 0; // concrete InstanceKlass
194 static const unsigned _misc_kind_reference = 1; // InstanceRefKlass
195 static const unsigned _misc_kind_class_loader = 2; // InstanceClassLoaderKlass
196 static const unsigned _misc_kind_mirror = 3; // InstanceMirrorKlass
197
198 // Start after _misc_kind field.
199 enum {
200 _misc_rewritten = 1 << 2, // methods rewritten.
201 _misc_has_nonstatic_fields = 1 << 3, // for sizing with UseCompressedOops
202 _misc_should_verify_class = 1 << 4, // allow caching of preverification
203 _misc_is_anonymous = 1 << 5, // has embedded _host_klass field
204 _misc_is_contended = 1 << 6, // marked with contended annotation
205 _misc_has_default_methods = 1 << 7, // class/superclass/implemented interfaces has default methods
206 _misc_declares_default_methods = 1 << 8, // directly declares default methods (any access)
207 _misc_has_been_redefined = 1 << 9, // class has been redefined
208 _misc_is_scratch_class = 1 << 10 // class is the redefined scratch class
209 };
210 u2 _misc_flags;
211 u2 _minor_version; // minor version number of class file
212 u2 _major_version; // major version number of class file
213 Thread* _init_thread; // Pointer to current thread doing initialization (to handle recusive initialization)
214 int _vtable_len; // length of Java vtable (in words)
215 int _itable_len; // length of Java itable (in words)
216 OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily)
217 MemberNameTable* _member_names; // Member names
218 JNIid* _jni_ids; // First JNI identifier for static fields in this class
219 jmethodID* _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none
220 intptr_t _dep_context; // packed DependencyContext structure
221 nmethod* _osr_nmethods_head; // Head of list of on-stack replacement nmethods for this class
222 BreakpointInfo* _breakpoints; // bpt lists, managed by Method*
223 // Linked instanceKlasses of previous versions
224 InstanceKlass* _previous_versions;
225 // JVMTI fields can be moved to their own structure - see 6315920
226 // JVMTI: cached class file, before retransformable agent modified it in CFLH
227 JvmtiCachedClassFileData* _cached_class_file;
228
229 volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change
230
231 // Class states are defined as ClassState (see above).
232 // Place the _init_state here to utilize the unused 2-byte after
233 // _idnum_allocated_count.
234 u1 _init_state; // state of class
235 u1 _reference_type; // reference type
294 return (_misc_flags & _misc_has_nonstatic_fields) != 0;
295 }
296 void set_has_nonstatic_fields(bool b) {
297 if (b) {
298 _misc_flags |= _misc_has_nonstatic_fields;
299 } else {
300 _misc_flags &= ~_misc_has_nonstatic_fields;
301 }
302 }
303
304 // field sizes
305 int nonstatic_field_size() const { return _nonstatic_field_size; }
306 void set_nonstatic_field_size(int size) { _nonstatic_field_size = size; }
307
308 int static_field_size() const { return _static_field_size; }
309 void set_static_field_size(int size) { _static_field_size = size; }
310
311 int static_oop_field_count() const { return (int)_static_oop_field_count; }
312 void set_static_oop_field_count(u2 size) { _static_oop_field_count = size; }
313
314 // Java vtable
315 int vtable_length() const { return _vtable_len; }
316 void set_vtable_length(int len) { _vtable_len = len; }
317
318 // Java itable
319 int itable_length() const { return _itable_len; }
320 void set_itable_length(int len) { _itable_len = len; }
321
322 // array klasses
323 Klass* array_klasses() const { return _array_klasses; }
324 void set_array_klasses(Klass* k) { _array_klasses = k; }
325
326 // methods
327 Array<Method*>* methods() const { return _methods; }
328 void set_methods(Array<Method*>* a) { _methods = a; }
329 Method* method_with_idnum(int idnum);
330 Method* method_with_orig_idnum(int idnum);
331 Method* method_with_orig_idnum(int idnum, int version);
332
333 // method ordering
334 Array<int>* method_ordering() const { return _method_ordering; }
335 void set_method_ordering(Array<int>* m) { _method_ordering = m; }
336 void copy_method_ordering(const intArray* m, TRAPS);
337
933 int nonstatic_oop_map_size,
934 bool is_interface, bool is_anonymous) {
935 return align_object_size(header_size() +
936 align_object_offset(vtable_length) +
937 align_object_offset(itable_length) +
938 ((is_interface || is_anonymous) ?
939 align_object_offset(nonstatic_oop_map_size) :
940 nonstatic_oop_map_size) +
941 (is_interface ? (int)sizeof(Klass*)/HeapWordSize : 0) +
942 (is_anonymous ? (int)sizeof(Klass*)/HeapWordSize : 0));
943 }
944 int size() const { return size(vtable_length(),
945 itable_length(),
946 nonstatic_oop_map_size(),
947 is_interface(),
948 is_anonymous());
949 }
950 #if INCLUDE_SERVICES
951 virtual void collect_statistics(KlassSizeStats *sz) const;
952 #endif
953
954 static ByteSize vtable_start_offset() { return in_ByteSize(header_size() * wordSize); }
955 static ByteSize vtable_length_offset() { return byte_offset_of(InstanceKlass, _vtable_len); }
956
957 intptr_t* start_of_vtable() const { return (intptr_t*) ((address)this + in_bytes(vtable_start_offset())); }
958 intptr_t* start_of_itable() const { return start_of_vtable() + align_object_offset(vtable_length()); }
959 int itable_offset_in_words() const { return start_of_itable() - (intptr_t*)this; }
960
961 intptr_t* end_of_itable() const { return start_of_itable() + itable_length(); }
962
963 address static_field_addr(int offset);
964
965 OopMapBlock* start_of_nonstatic_oop_maps() const {
966 return (OopMapBlock*)(start_of_itable() + align_object_offset(itable_length()));
967 }
968
969 Klass** end_of_nonstatic_oop_maps() const {
970 return (Klass**)(start_of_nonstatic_oop_maps() +
971 nonstatic_oop_map_count());
972 }
973
974 Klass** adr_implementor() const {
975 if (is_interface()) {
|
161 // it is stored in the instanceklass as a NULL-terminated UTF-8 string
162 const char* _source_debug_extension;
163 // Array name derived from this class which needs unreferencing
164 // if this class is unloaded.
165 Symbol* _array_name;
166
167 // Number of heapOopSize words used by non-static fields in this klass
168 // (including inherited fields but after header_size()).
169 int _nonstatic_field_size;
170 int _static_field_size; // number words used by static fields (oop and non-oop) in this klass
171 // Constant pool index to the utf8 entry of the Generic signature,
172 // or 0 if none.
173 u2 _generic_signature_index;
174 // Constant pool index to the utf8 entry for the name of source file
175 // containing this klass, 0 if not specified.
176 u2 _source_file_name_index;
177 u2 _static_oop_field_count;// number of static oop fields in this klass
178 u2 _java_fields_count; // The number of declared Java fields
179 int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
180
181 int _itable_len; // length of Java itable (in words)
182 // _is_marked_dependent can be set concurrently, thus cannot be part of the
183 // _misc_flags.
184 bool _is_marked_dependent; // used for marking during flushing and deoptimization
185
186 // The low two bits of _misc_flags contains the kind field.
187 // This can be used to quickly discriminate among the four kinds of
188 // InstanceKlass.
189
190 static const unsigned _misc_kind_field_size = 2;
191 static const unsigned _misc_kind_field_pos = 0;
192 static const unsigned _misc_kind_field_mask = (1u << _misc_kind_field_size) - 1u;
193
194 static const unsigned _misc_kind_other = 0; // concrete InstanceKlass
195 static const unsigned _misc_kind_reference = 1; // InstanceRefKlass
196 static const unsigned _misc_kind_class_loader = 2; // InstanceClassLoaderKlass
197 static const unsigned _misc_kind_mirror = 3; // InstanceMirrorKlass
198
199 // Start after _misc_kind field.
200 enum {
201 _misc_rewritten = 1 << 2, // methods rewritten.
202 _misc_has_nonstatic_fields = 1 << 3, // for sizing with UseCompressedOops
203 _misc_should_verify_class = 1 << 4, // allow caching of preverification
204 _misc_is_anonymous = 1 << 5, // has embedded _host_klass field
205 _misc_is_contended = 1 << 6, // marked with contended annotation
206 _misc_has_default_methods = 1 << 7, // class/superclass/implemented interfaces has default methods
207 _misc_declares_default_methods = 1 << 8, // directly declares default methods (any access)
208 _misc_has_been_redefined = 1 << 9, // class has been redefined
209 _misc_is_scratch_class = 1 << 10 // class is the redefined scratch class
210 };
211 u2 _misc_flags;
212 u2 _minor_version; // minor version number of class file
213 u2 _major_version; // major version number of class file
214 Thread* _init_thread; // Pointer to current thread doing initialization (to handle recusive initialization)
215 OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily)
216 MemberNameTable* _member_names; // Member names
217 JNIid* _jni_ids; // First JNI identifier for static fields in this class
218 jmethodID* _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none
219 intptr_t _dep_context; // packed DependencyContext structure
220 nmethod* _osr_nmethods_head; // Head of list of on-stack replacement nmethods for this class
221 BreakpointInfo* _breakpoints; // bpt lists, managed by Method*
222 // Linked instanceKlasses of previous versions
223 InstanceKlass* _previous_versions;
224 // JVMTI fields can be moved to their own structure - see 6315920
225 // JVMTI: cached class file, before retransformable agent modified it in CFLH
226 JvmtiCachedClassFileData* _cached_class_file;
227
228 volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change
229
230 // Class states are defined as ClassState (see above).
231 // Place the _init_state here to utilize the unused 2-byte after
232 // _idnum_allocated_count.
233 u1 _init_state; // state of class
234 u1 _reference_type; // reference type
293 return (_misc_flags & _misc_has_nonstatic_fields) != 0;
294 }
295 void set_has_nonstatic_fields(bool b) {
296 if (b) {
297 _misc_flags |= _misc_has_nonstatic_fields;
298 } else {
299 _misc_flags &= ~_misc_has_nonstatic_fields;
300 }
301 }
302
303 // field sizes
304 int nonstatic_field_size() const { return _nonstatic_field_size; }
305 void set_nonstatic_field_size(int size) { _nonstatic_field_size = size; }
306
307 int static_field_size() const { return _static_field_size; }
308 void set_static_field_size(int size) { _static_field_size = size; }
309
310 int static_oop_field_count() const { return (int)_static_oop_field_count; }
311 void set_static_oop_field_count(u2 size) { _static_oop_field_count = size; }
312
313 // Java itable
314 int itable_length() const { return _itable_len; }
315 void set_itable_length(int len) { _itable_len = len; }
316
317 // array klasses
318 Klass* array_klasses() const { return _array_klasses; }
319 void set_array_klasses(Klass* k) { _array_klasses = k; }
320
321 // methods
322 Array<Method*>* methods() const { return _methods; }
323 void set_methods(Array<Method*>* a) { _methods = a; }
324 Method* method_with_idnum(int idnum);
325 Method* method_with_orig_idnum(int idnum);
326 Method* method_with_orig_idnum(int idnum, int version);
327
328 // method ordering
329 Array<int>* method_ordering() const { return _method_ordering; }
330 void set_method_ordering(Array<int>* m) { _method_ordering = m; }
331 void copy_method_ordering(const intArray* m, TRAPS);
332
928 int nonstatic_oop_map_size,
929 bool is_interface, bool is_anonymous) {
930 return align_object_size(header_size() +
931 align_object_offset(vtable_length) +
932 align_object_offset(itable_length) +
933 ((is_interface || is_anonymous) ?
934 align_object_offset(nonstatic_oop_map_size) :
935 nonstatic_oop_map_size) +
936 (is_interface ? (int)sizeof(Klass*)/HeapWordSize : 0) +
937 (is_anonymous ? (int)sizeof(Klass*)/HeapWordSize : 0));
938 }
939 int size() const { return size(vtable_length(),
940 itable_length(),
941 nonstatic_oop_map_size(),
942 is_interface(),
943 is_anonymous());
944 }
945 #if INCLUDE_SERVICES
946 virtual void collect_statistics(KlassSizeStats *sz) const;
947 #endif
948
949 intptr_t* start_of_vtable() const { return (intptr_t*) ((address)this + in_bytes(vtable_start_offset())); }
950 intptr_t* start_of_itable() const { return start_of_vtable() + align_object_offset(vtable_length()); }
951 int itable_offset_in_words() const { return start_of_itable() - (intptr_t*)this; }
952
953 intptr_t* end_of_itable() const { return start_of_itable() + itable_length(); }
954
955 address static_field_addr(int offset);
956
957 OopMapBlock* start_of_nonstatic_oop_maps() const {
958 return (OopMapBlock*)(start_of_itable() + align_object_offset(itable_length()));
959 }
960
961 Klass** end_of_nonstatic_oop_maps() const {
962 return (Klass**)(start_of_nonstatic_oop_maps() +
963 nonstatic_oop_map_count());
964 }
965
966 Klass** adr_implementor() const {
967 if (is_interface()) {
|