comparison src/share/vm/oops/instanceKlass.hpp @ 7593:337e1dd9d902

8005895: Inefficient InstanceKlass field packing wasts memory. Summary: Pack _misc_has_default_methods into the _misc_flags, move _idnum_allocated_count. Reviewed-by: coleenp, shade
author jiangli
date Fri, 11 Jan 2013 16:55:07 -0500
parents 37a3e8b7a1e9
children 212c5b9c38e7
comparison
equal deleted inserted replaced
7578:d58b7b43031b 7593:337e1dd9d902
223 int _static_field_size; // number words used by static fields (oop and non-oop) in this klass 223 int _static_field_size; // number words used by static fields (oop and non-oop) in this klass
224 u2 _static_oop_field_count;// number of static oop fields in this klass 224 u2 _static_oop_field_count;// number of static oop fields in this klass
225 u2 _java_fields_count; // The number of declared Java fields 225 u2 _java_fields_count; // The number of declared Java fields
226 int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks 226 int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
227 227
228 // _is_marked_dependent can be set concurrently, thus cannot be part of the
229 // _misc_flags.
228 bool _is_marked_dependent; // used for marking during flushing and deoptimization 230 bool _is_marked_dependent; // used for marking during flushing and deoptimization
231
229 enum { 232 enum {
230 _misc_rewritten = 1 << 0, // methods rewritten. 233 _misc_rewritten = 1 << 0, // methods rewritten.
231 _misc_has_nonstatic_fields = 1 << 1, // for sizing with UseCompressedOops 234 _misc_has_nonstatic_fields = 1 << 1, // for sizing with UseCompressedOops
232 _misc_should_verify_class = 1 << 2, // allow caching of preverification 235 _misc_should_verify_class = 1 << 2, // allow caching of preverification
233 _misc_is_anonymous = 1 << 3 // has embedded _inner_classes field 236 _misc_is_anonymous = 1 << 3, // has embedded _inner_classes field
237 _misc_has_default_methods = 1 << 4 // class/superclass/implemented interfaces has default methods
234 }; 238 };
235 u2 _misc_flags; 239 u2 _misc_flags;
236 u2 _minor_version; // minor version number of class file 240 u2 _minor_version; // minor version number of class file
237 u2 _major_version; // major version number of class file 241 u2 _major_version; // major version number of class file
238 Thread* _init_thread; // Pointer to current thread doing initialization (to handle recusive initialization) 242 Thread* _init_thread; // Pointer to current thread doing initialization (to handle recusive initialization)
251 // JVMTI fields can be moved to their own structure - see 6315920 255 // JVMTI fields can be moved to their own structure - see 6315920
252 unsigned char * _cached_class_file_bytes; // JVMTI: cached class file, before retransformable agent modified it in CFLH 256 unsigned char * _cached_class_file_bytes; // JVMTI: cached class file, before retransformable agent modified it in CFLH
253 jint _cached_class_file_len; // JVMTI: length of above 257 jint _cached_class_file_len; // JVMTI: length of above
254 JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration 258 JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration
255 259
256 // true if class, superclass, or implemented interfaces have default methods
257 bool _has_default_methods;
258
259 volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change
260 // Method array. 260 // Method array.
261 Array<Method*>* _methods; 261 Array<Method*>* _methods;
262 // Interface (Klass*s) this class declares locally to implement. 262 // Interface (Klass*s) this class declares locally to implement.
263 Array<Klass*>* _local_interfaces; 263 Array<Klass*>* _local_interfaces;
264 // Interface (Klass*s) this class implements transitively. 264 // Interface (Klass*s) this class implements transitively.
278 // [generic signature index] 278 // [generic signature index]
279 // [generic signature index] 279 // [generic signature index]
280 // ... 280 // ...
281 Array<u2>* _fields; 281 Array<u2>* _fields;
282 282
283 volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change
284
283 // Class states are defined as ClassState (see above). 285 // Class states are defined as ClassState (see above).
284 // Place the _init_state here to utilize the unused 2-byte after 286 // Place the _init_state here to utilize the unused 2-byte after
285 // _idnum_allocated_count. 287 // _idnum_allocated_count.
286 u1 _init_state; // state of class 288 u1 _init_state; // state of class
287 289
614 } 616 }
615 JvmtiCachedClassFieldMap* jvmti_cached_class_field_map() const { 617 JvmtiCachedClassFieldMap* jvmti_cached_class_field_map() const {
616 return _jvmti_cached_class_field_map; 618 return _jvmti_cached_class_field_map;
617 } 619 }
618 620
619 bool has_default_methods() const { return _has_default_methods; } 621 bool has_default_methods() const {
620 void set_has_default_methods(bool b) { _has_default_methods = b; } 622 return (_misc_flags & _misc_has_default_methods) != 0;
623 }
624 void set_has_default_methods(bool b) {
625 if (b) {
626 _misc_flags |= _misc_has_default_methods;
627 } else {
628 _misc_flags &= ~_misc_has_default_methods;
629 }
630 }
621 631
622 // for adding methods, ConstMethod::UNSET_IDNUM means no more ids available 632 // for adding methods, ConstMethod::UNSET_IDNUM means no more ids available
623 inline u2 next_method_idnum(); 633 inline u2 next_method_idnum();
624 void set_initial_method_idnum(u2 value) { _idnum_allocated_count = value; } 634 void set_initial_method_idnum(u2 value) { _idnum_allocated_count = value; }
625 635