Skip to content

Commit 3607a5c

Browse files
committedDec 17, 2021
8277216: Examine InstanceKlass::_misc_flags for concurrency issues
Reviewed-by: hseigel, dholmes
1 parent abab173 commit 3607a5c

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed
 

‎src/hotspot/share/oops/instanceKlass.hpp

+9-20
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,7 @@ class InstanceKlass: public Klass {
253253
_misc_is_shared_boot_class = 1 << 10, // defining class loader is boot class loader
254254
_misc_is_shared_platform_class = 1 << 11, // defining class loader is platform class loader
255255
_misc_is_shared_app_class = 1 << 12, // defining class loader is app class loader
256-
_misc_has_resolved_methods = 1 << 13, // resolved methods table entries added for this class
257-
_misc_has_contended_annotations = 1 << 14 // has @Contended annotation
256+
_misc_has_contended_annotations = 1 << 13 // has @Contended annotation
258257
};
259258
u2 shared_loader_type_bits() const {
260259
return _misc_is_shared_boot_class|_misc_is_shared_platform_class|_misc_is_shared_app_class;
@@ -366,10 +365,6 @@ class InstanceKlass: public Klass {
366365
_misc_flags |= _misc_shared_loading_failed;
367366
}
368367

369-
void clear_shared_loading_failed() {
370-
_misc_flags &= ~_misc_shared_loading_failed;
371-
}
372-
373368
void set_shared_class_loader_type(s2 loader_type);
374369

375370
void assign_class_loader_type();
@@ -378,10 +373,9 @@ class InstanceKlass: public Klass {
378373
return (_misc_flags & _misc_has_nonstatic_fields) != 0;
379374
}
380375
void set_has_nonstatic_fields(bool b) {
376+
assert(!has_nonstatic_fields(), "set once");
381377
if (b) {
382378
_misc_flags |= _misc_has_nonstatic_fields;
383-
} else {
384-
_misc_flags &= ~_misc_has_nonstatic_fields;
385379
}
386380
}
387381

@@ -563,10 +557,9 @@ class InstanceKlass: public Klass {
563557
return (_misc_flags & _misc_should_verify_class) != 0;
564558
}
565559
void set_should_verify_class(bool value) {
560+
assert(!should_verify_class(), "set once");
566561
if (value) {
567562
_misc_flags |= _misc_should_verify_class;
568-
} else {
569-
_misc_flags &= ~_misc_should_verify_class;
570563
}
571564
}
572565

@@ -695,10 +688,9 @@ class InstanceKlass: public Klass {
695688
return (_misc_flags & _misc_is_contended) != 0;
696689
}
697690
void set_is_contended(bool value) {
691+
assert(!is_contended(), "set once");
698692
if (value) {
699693
_misc_flags |= _misc_is_contended;
700-
} else {
701-
_misc_flags &= ~_misc_is_contended;
702694
}
703695
}
704696

@@ -733,10 +725,9 @@ class InstanceKlass: public Klass {
733725
return ((_misc_flags & _misc_has_contended_annotations) != 0);
734726
}
735727
void set_has_contended_annotations(bool value) {
728+
assert(!has_contended_annotations(), "set once");
736729
if (value) {
737730
_misc_flags |= _misc_has_contended_annotations;
738-
} else {
739-
_misc_flags &= ~_misc_has_contended_annotations;
740731
}
741732
}
742733

@@ -789,11 +780,11 @@ class InstanceKlass: public Klass {
789780
}
790781

791782
bool has_resolved_methods() const {
792-
return (_misc_flags & _misc_has_resolved_methods) != 0;
783+
return _access_flags.has_resolved_methods();
793784
}
794785

795786
void set_has_resolved_methods() {
796-
_misc_flags |= _misc_has_resolved_methods;
787+
_access_flags.set_has_resolved_methods();
797788
}
798789
private:
799790

@@ -862,21 +853,19 @@ class InstanceKlass: public Klass {
862853
return (_misc_flags & _misc_has_nonstatic_concrete_methods) != 0;
863854
}
864855
void set_has_nonstatic_concrete_methods(bool b) {
856+
assert(!has_nonstatic_concrete_methods(), "set once");
865857
if (b) {
866858
_misc_flags |= _misc_has_nonstatic_concrete_methods;
867-
} else {
868-
_misc_flags &= ~_misc_has_nonstatic_concrete_methods;
869859
}
870860
}
871861

872862
bool declares_nonstatic_concrete_methods() const {
873863
return (_misc_flags & _misc_declares_nonstatic_concrete_methods) != 0;
874864
}
875865
void set_declares_nonstatic_concrete_methods(bool b) {
866+
assert(!declares_nonstatic_concrete_methods(), "set once");
876867
if (b) {
877868
_misc_flags |= _misc_declares_nonstatic_concrete_methods;
878-
} else {
879-
_misc_flags &= ~_misc_declares_nonstatic_concrete_methods;
880869
}
881870
}
882871

‎src/hotspot/share/utilities/accessFlags.hpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ enum {
7070
JVM_ACC_IS_HIDDEN_CLASS = 0x04000000, // True if klass is hidden
7171
JVM_ACC_IS_VALUE_BASED_CLASS = 0x08000000, // True if klass is marked as a ValueBased class
7272
JVM_ACC_IS_BEING_REDEFINED = 0x00100000, // True if the klass is being redefined.
73+
JVM_ACC_HAS_RESOLVED_METHODS = 0x00200000, // True if the klass has resolved methods
7374

7475
// Klass* and Method* flags
75-
JVM_ACC_HAS_LOCAL_VARIABLE_TABLE= 0x00200000,
76+
JVM_ACC_HAS_LOCAL_VARIABLE_TABLE= 0x00400000,
7677

77-
JVM_ACC_PROMOTED_FLAGS = 0x00200000, // flags promoted from methods to the holding klass
78+
JVM_ACC_PROMOTED_FLAGS = 0x00400000, // flags promoted from methods to the holding klass
7879

7980
// field flags
8081
// Note: these flags must be defined in the low order 16 bits because
@@ -164,6 +165,9 @@ class AccessFlags {
164165
void set_is_being_redefined() { atomic_set_bits(JVM_ACC_IS_BEING_REDEFINED); }
165166
void clear_is_being_redefined() { atomic_clear_bits(JVM_ACC_IS_BEING_REDEFINED); }
166167

168+
bool has_resolved_methods() const { return (_flags & JVM_ACC_HAS_RESOLVED_METHODS) != 0; }
169+
void set_has_resolved_methods() { atomic_set_bits(JVM_ACC_HAS_RESOLVED_METHODS); }
170+
167171
// field flags
168172
bool is_field_access_watched() const { return (_flags & JVM_ACC_FIELD_ACCESS_WATCHED) != 0; }
169173
bool is_field_modification_watched() const

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Dec 17, 2021

@openjdk-notifier[bot]
Please sign in to comment.