提交 afeb19bf 编写于 作者: J jiangli

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
上级 fd0689d0
...@@ -225,12 +225,16 @@ class InstanceKlass: public Klass { ...@@ -225,12 +225,16 @@ class InstanceKlass: public Klass {
u2 _java_fields_count; // The number of declared Java fields u2 _java_fields_count; // The number of declared Java fields
int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
// _is_marked_dependent can be set concurrently, thus cannot be part of the
// _misc_flags.
bool _is_marked_dependent; // used for marking during flushing and deoptimization bool _is_marked_dependent; // used for marking during flushing and deoptimization
enum { enum {
_misc_rewritten = 1 << 0, // methods rewritten. _misc_rewritten = 1 << 0, // methods rewritten.
_misc_has_nonstatic_fields = 1 << 1, // for sizing with UseCompressedOops _misc_has_nonstatic_fields = 1 << 1, // for sizing with UseCompressedOops
_misc_should_verify_class = 1 << 2, // allow caching of preverification _misc_should_verify_class = 1 << 2, // allow caching of preverification
_misc_is_anonymous = 1 << 3 // has embedded _inner_classes field _misc_is_anonymous = 1 << 3, // has embedded _inner_classes field
_misc_has_default_methods = 1 << 4 // class/superclass/implemented interfaces has default methods
}; };
u2 _misc_flags; u2 _misc_flags;
u2 _minor_version; // minor version number of class file u2 _minor_version; // minor version number of class file
...@@ -253,10 +257,6 @@ class InstanceKlass: public Klass { ...@@ -253,10 +257,6 @@ class InstanceKlass: public Klass {
jint _cached_class_file_len; // JVMTI: length of above jint _cached_class_file_len; // JVMTI: length of above
JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration
// true if class, superclass, or implemented interfaces have default methods
bool _has_default_methods;
volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change
// Method array. // Method array.
Array<Method*>* _methods; Array<Method*>* _methods;
// Interface (Klass*s) this class declares locally to implement. // Interface (Klass*s) this class declares locally to implement.
...@@ -280,6 +280,8 @@ class InstanceKlass: public Klass { ...@@ -280,6 +280,8 @@ class InstanceKlass: public Klass {
// ... // ...
Array<u2>* _fields; Array<u2>* _fields;
volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change
// Class states are defined as ClassState (see above). // Class states are defined as ClassState (see above).
// Place the _init_state here to utilize the unused 2-byte after // Place the _init_state here to utilize the unused 2-byte after
// _idnum_allocated_count. // _idnum_allocated_count.
...@@ -616,8 +618,16 @@ class InstanceKlass: public Klass { ...@@ -616,8 +618,16 @@ class InstanceKlass: public Klass {
return _jvmti_cached_class_field_map; return _jvmti_cached_class_field_map;
} }
bool has_default_methods() const { return _has_default_methods; } bool has_default_methods() const {
void set_has_default_methods(bool b) { _has_default_methods = b; } return (_misc_flags & _misc_has_default_methods) != 0;
}
void set_has_default_methods(bool b) {
if (b) {
_misc_flags |= _misc_has_default_methods;
} else {
_misc_flags &= ~_misc_has_default_methods;
}
}
// for adding methods, ConstMethod::UNSET_IDNUM means no more ids available // for adding methods, ConstMethod::UNSET_IDNUM means no more ids available
inline u2 next_method_idnum(); inline u2 next_method_idnum();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册