8222988: Use MonitorLocker rather than MutexLocker when wait/notify used

Fixed use cases in code except CMS.

Reviewed-by: rehn, dcubed
This commit is contained in:
Coleen Phillimore 2019-04-29 16:01:52 -04:00
parent ed9eac2bb9
commit ccb2e9d925
21 changed files with 91 additions and 101 deletions

View file

@ -90,14 +90,14 @@ static inline InstanceKlass* get_ik(jclass def) {
// If any of the classes are being redefined, wait
// Parallel constant pool merging leads to indeterminate constant pools.
void VM_RedefineClasses::lock_classes() {
MutexLocker ml(RedefineClasses_lock);
MonitorLocker ml(RedefineClasses_lock);
bool has_redefined;
do {
has_redefined = false;
// Go through classes each time until none are being redefined.
for (int i = 0; i < _class_count; i++) {
if (get_ik(_class_defs[i].klass)->is_being_redefined()) {
RedefineClasses_lock->wait();
ml.wait();
has_redefined = true;
break; // for loop
}
@ -106,17 +106,17 @@ void VM_RedefineClasses::lock_classes() {
for (int i = 0; i < _class_count; i++) {
get_ik(_class_defs[i].klass)->set_is_being_redefined(true);
}
RedefineClasses_lock->notify_all();
ml.notify_all();
}
void VM_RedefineClasses::unlock_classes() {
MutexLocker ml(RedefineClasses_lock);
MonitorLocker ml(RedefineClasses_lock);
for (int i = 0; i < _class_count; i++) {
assert(get_ik(_class_defs[i].klass)->is_being_redefined(),
"should be being redefined to get here");
get_ik(_class_defs[i].klass)->set_is_being_redefined(false);
}
RedefineClasses_lock->notify_all();
ml.notify_all();
}
bool VM_RedefineClasses::doit_prologue() {