8277216: Examine InstanceKlass::_misc_flags for concurrency issues

Reviewed-by: hseigel, dholmes
This commit is contained in:
Coleen Phillimore 2021-12-17 13:42:54 +00:00
parent abab1738a7
commit 3607a5cdd9
2 changed files with 15 additions and 22 deletions
src/hotspot/share

@ -253,8 +253,7 @@ class InstanceKlass: public Klass {
_misc_is_shared_boot_class = 1 << 10, // defining class loader is boot class loader
_misc_is_shared_platform_class = 1 << 11, // defining class loader is platform class loader
_misc_is_shared_app_class = 1 << 12, // defining class loader is app class loader
_misc_has_resolved_methods = 1 << 13, // resolved methods table entries added for this class
_misc_has_contended_annotations = 1 << 14 // has @Contended annotation
_misc_has_contended_annotations = 1 << 13 // has @Contended annotation
};
u2 shared_loader_type_bits() const {
return _misc_is_shared_boot_class|_misc_is_shared_platform_class|_misc_is_shared_app_class;
@ -366,10 +365,6 @@ class InstanceKlass: public Klass {
_misc_flags |= _misc_shared_loading_failed;
}
void clear_shared_loading_failed() {
_misc_flags &= ~_misc_shared_loading_failed;
}
void set_shared_class_loader_type(s2 loader_type);
void assign_class_loader_type();
@ -378,10 +373,9 @@ class InstanceKlass: public Klass {
return (_misc_flags & _misc_has_nonstatic_fields) != 0;
}
void set_has_nonstatic_fields(bool b) {
assert(!has_nonstatic_fields(), "set once");
if (b) {
_misc_flags |= _misc_has_nonstatic_fields;
} else {
_misc_flags &= ~_misc_has_nonstatic_fields;
}
}
@ -563,10 +557,9 @@ public:
return (_misc_flags & _misc_should_verify_class) != 0;
}
void set_should_verify_class(bool value) {
assert(!should_verify_class(), "set once");
if (value) {
_misc_flags |= _misc_should_verify_class;
} else {
_misc_flags &= ~_misc_should_verify_class;
}
}
@ -695,10 +688,9 @@ public:
return (_misc_flags & _misc_is_contended) != 0;
}
void set_is_contended(bool value) {
assert(!is_contended(), "set once");
if (value) {
_misc_flags |= _misc_is_contended;
} else {
_misc_flags &= ~_misc_is_contended;
}
}
@ -733,10 +725,9 @@ public:
return ((_misc_flags & _misc_has_contended_annotations) != 0);
}
void set_has_contended_annotations(bool value) {
assert(!has_contended_annotations(), "set once");
if (value) {
_misc_flags |= _misc_has_contended_annotations;
} else {
_misc_flags &= ~_misc_has_contended_annotations;
}
}
@ -789,11 +780,11 @@ public:
}
bool has_resolved_methods() const {
return (_misc_flags & _misc_has_resolved_methods) != 0;
return _access_flags.has_resolved_methods();
}
void set_has_resolved_methods() {
_misc_flags |= _misc_has_resolved_methods;
_access_flags.set_has_resolved_methods();
}
private:
@ -862,10 +853,9 @@ public:
return (_misc_flags & _misc_has_nonstatic_concrete_methods) != 0;
}
void set_has_nonstatic_concrete_methods(bool b) {
assert(!has_nonstatic_concrete_methods(), "set once");
if (b) {
_misc_flags |= _misc_has_nonstatic_concrete_methods;
} else {
_misc_flags &= ~_misc_has_nonstatic_concrete_methods;
}
}
@ -873,10 +863,9 @@ public:
return (_misc_flags & _misc_declares_nonstatic_concrete_methods) != 0;
}
void set_declares_nonstatic_concrete_methods(bool b) {
assert(!declares_nonstatic_concrete_methods(), "set once");
if (b) {
_misc_flags |= _misc_declares_nonstatic_concrete_methods;
} else {
_misc_flags &= ~_misc_declares_nonstatic_concrete_methods;
}
}

@ -70,11 +70,12 @@ enum {
JVM_ACC_IS_HIDDEN_CLASS = 0x04000000, // True if klass is hidden
JVM_ACC_IS_VALUE_BASED_CLASS = 0x08000000, // True if klass is marked as a ValueBased class
JVM_ACC_IS_BEING_REDEFINED = 0x00100000, // True if the klass is being redefined.
JVM_ACC_HAS_RESOLVED_METHODS = 0x00200000, // True if the klass has resolved methods
// Klass* and Method* flags
JVM_ACC_HAS_LOCAL_VARIABLE_TABLE= 0x00200000,
JVM_ACC_HAS_LOCAL_VARIABLE_TABLE= 0x00400000,
JVM_ACC_PROMOTED_FLAGS = 0x00200000, // flags promoted from methods to the holding klass
JVM_ACC_PROMOTED_FLAGS = 0x00400000, // flags promoted from methods to the holding klass
// field flags
// Note: these flags must be defined in the low order 16 bits because
@ -164,6 +165,9 @@ class AccessFlags {
void set_is_being_redefined() { atomic_set_bits(JVM_ACC_IS_BEING_REDEFINED); }
void clear_is_being_redefined() { atomic_clear_bits(JVM_ACC_IS_BEING_REDEFINED); }
bool has_resolved_methods() const { return (_flags & JVM_ACC_HAS_RESOLVED_METHODS) != 0; }
void set_has_resolved_methods() { atomic_set_bits(JVM_ACC_HAS_RESOLVED_METHODS); }
// field flags
bool is_field_access_watched() const { return (_flags & JVM_ACC_FIELD_ACCESS_WATCHED) != 0; }
bool is_field_modification_watched() const