8252794: Creation of JNIMethodBlock should be done with a leaf lock

Reviewed-by: coleenp, dholmes
This commit is contained in:
Robbin Ehn 2020-09-09 13:21:01 +00:00
parent 5fef8ddaff
commit d56096471b
2 changed files with 5 additions and 5 deletions

View file

@ -2185,9 +2185,9 @@ void Method::ensure_jmethod_ids(ClassLoaderData* loader_data, int capacity) {
ClassLoaderData* cld = loader_data; ClassLoaderData* cld = loader_data;
if (!SafepointSynchronize::is_at_safepoint()) { if (!SafepointSynchronize::is_at_safepoint()) {
// Have to add jmethod_ids() to class loader data thread-safely. // Have to add jmethod_ids() to class loader data thread-safely.
// Also have to add the method to the list safely, which the cld lock // Also have to add the method to the list safely, which the lock
// protects as well. // protects as well.
MutexLocker ml(cld->metaspace_lock(), Mutex::_no_safepoint_check_flag); MutexLocker ml(JmethodIdCreation_lock, Mutex::_no_safepoint_check_flag);
if (cld->jmethod_ids() == NULL) { if (cld->jmethod_ids() == NULL) {
cld->set_jmethod_ids(new JNIMethodBlock(capacity)); cld->set_jmethod_ids(new JNIMethodBlock(capacity));
} else { } else {
@ -2209,9 +2209,9 @@ jmethodID Method::make_jmethod_id(ClassLoaderData* loader_data, Method* m) {
if (!SafepointSynchronize::is_at_safepoint()) { if (!SafepointSynchronize::is_at_safepoint()) {
// Have to add jmethod_ids() to class loader data thread-safely. // Have to add jmethod_ids() to class loader data thread-safely.
// Also have to add the method to the list safely, which the cld lock // Also have to add the method to the list safely, which the lock
// protects as well. // protects as well.
MutexLocker ml(cld->metaspace_lock(), Mutex::_no_safepoint_check_flag); MutexLocker ml(JmethodIdCreation_lock, Mutex::_no_safepoint_check_flag);
if (cld->jmethod_ids() == NULL) { if (cld->jmethod_ids() == NULL) {
cld->set_jmethod_ids(new JNIMethodBlock()); cld->set_jmethod_ids(new JNIMethodBlock());
} }

View file

@ -253,7 +253,7 @@ void mutex_init() {
Notification_lock = Service_lock; Notification_lock = Service_lock;
} }
def(JmethodIdCreation_lock , PaddedMutex , leaf, true, _safepoint_check_never); // used for creating jmethodIDs. def(JmethodIdCreation_lock , PaddedMutex , special-2, true, _safepoint_check_never); // used for creating jmethodIDs.
def(SystemDictionary_lock , PaddedMonitor, leaf, true, _safepoint_check_always); def(SystemDictionary_lock , PaddedMonitor, leaf, true, _safepoint_check_always);
def(ProtectionDomainSet_lock , PaddedMutex , leaf-1, true, _safepoint_check_never); def(ProtectionDomainSet_lock , PaddedMutex , leaf-1, true, _safepoint_check_never);