Skip to content

Commit

Permalink
8235678: Remove unnecessary calls to Thread::current() in MutexLocker…
Browse files Browse the repository at this point in the history
… calls

Add THREAD argument when available and make Thread* the first argument to relevant MutexLocker and MonitorLocker constructors

Reviewed-by: lfoltan, coleenp, dholmes
  • Loading branch information
Harold Seigel committed Jan 16, 2020
1 parent e2240b7 commit 7fc58a1
Show file tree
Hide file tree
Showing 36 changed files with 122 additions and 121 deletions.
6 changes: 3 additions & 3 deletions src/hotspot/share/c1/c1_Runtime1.cpp
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -1040,7 +1040,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i
// Now copy code back // Now copy code back


{ {
MutexLocker ml_patch (Patching_lock, Mutex::_no_safepoint_check_flag); MutexLocker ml_patch (THREAD, Patching_lock, Mutex::_no_safepoint_check_flag);
// //
// Deoptimization may have happened while we waited for the lock. // Deoptimization may have happened while we waited for the lock.
// In that case we don't bother to do any patching we just return // In that case we don't bother to do any patching we just return
Expand Down Expand Up @@ -1259,7 +1259,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i
// If we are patching in a non-perm oop, make sure the nmethod // If we are patching in a non-perm oop, make sure the nmethod
// is on the right list. // is on the right list.
{ {
MutexLocker ml_code (CodeCache_lock, Mutex::_no_safepoint_check_flag); MutexLocker ml_code (THREAD, CodeCache_lock, Mutex::_no_safepoint_check_flag);
nmethod* nm = CodeCache::find_nmethod(caller_frame.pc()); nmethod* nm = CodeCache::find_nmethod(caller_frame.pc());
guarantee(nm != NULL, "only nmethods can contain non-perm oops"); guarantee(nm != NULL, "only nmethods can contain non-perm oops");


Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/ci/ciEnv.cpp
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -971,7 +971,7 @@ void ciEnv::register_method(ciMethod* target,
nmethod* nm = NULL; nmethod* nm = NULL;
{ {
// To prevent compile queue updates. // To prevent compile queue updates.
MutexLocker locker(MethodCompileQueue_lock, THREAD); MutexLocker locker(THREAD, MethodCompileQueue_lock);


// Prevent SystemDictionary::add_to_hierarchy from running // Prevent SystemDictionary::add_to_hierarchy from running
// and invalidating our dependencies until we install this method. // and invalidating our dependencies until we install this method.
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/ci/ciReplay.cpp
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -631,7 +631,7 @@ class CompileReplay : public StackObj {
{ {
// Grab a lock here to prevent multiple // Grab a lock here to prevent multiple
// MethodData*s from being created. // MethodData*s from being created.
MutexLocker ml(MethodData_lock, THREAD); MutexLocker ml(THREAD, MethodData_lock);
if (method->method_data() == NULL) { if (method->method_data() == NULL) {
ClassLoaderData* loader_data = method->method_holder()->class_loader_data(); ClassLoaderData* loader_data = method->method_holder()->class_loader_data();
MethodData* method_data = MethodData::allocate(loader_data, methodHandle(THREAD, method), CHECK); MethodData* method_data = MethodData::allocate(loader_data, methodHandle(THREAD, method), CHECK);
Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/share/classfile/classLoader.cpp
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -726,7 +726,7 @@ void ClassLoader::add_to_exploded_build_list(Symbol* module_sym, TRAPS) {
ModuleClassPathList* module_cpl = new ModuleClassPathList(module_sym); ModuleClassPathList* module_cpl = new ModuleClassPathList(module_sym);
module_cpl->add_to_list(new_entry); module_cpl->add_to_list(new_entry);
{ {
MutexLocker ml(Module_lock, THREAD); MutexLocker ml(THREAD, Module_lock);
_exploded_entries->push(module_cpl); _exploded_entries->push(module_cpl);
} }
log_info(class, load)("path: %s", path); log_info(class, load)("path: %s", path);
Expand Down Expand Up @@ -1090,7 +1090,7 @@ objArrayOop ClassLoader::get_system_packages(TRAPS) {
// List of pointers to PackageEntrys that have loaded classes. // List of pointers to PackageEntrys that have loaded classes.
GrowableArray<PackageEntry*>* loaded_class_pkgs = new GrowableArray<PackageEntry*>(50); GrowableArray<PackageEntry*>* loaded_class_pkgs = new GrowableArray<PackageEntry*>(50);
{ {
MutexLocker ml(Module_lock, THREAD); MutexLocker ml(THREAD, Module_lock);


PackageEntryTable* pe_table = PackageEntryTable* pe_table =
ClassLoaderData::the_null_class_loader_data()->packages(); ClassLoaderData::the_null_class_loader_data()->packages();
Expand Down Expand Up @@ -1187,7 +1187,7 @@ ClassFileStream* ClassLoader::search_module_entries(const GrowableArray<ModuleCl
// The exploded build entries can be added to at any time so a lock is // The exploded build entries can be added to at any time so a lock is
// needed when searching them. // needed when searching them.
assert(!ClassLoader::has_jrt_entry(), "Must be exploded build"); assert(!ClassLoader::has_jrt_entry(), "Must be exploded build");
MutexLocker ml(Module_lock, THREAD); MutexLocker ml(THREAD, Module_lock);
e = find_first_module_cpe(mod_entry, module_list); e = find_first_module_cpe(mod_entry, module_list);
} else { } else {
e = find_first_module_cpe(mod_entry, module_list); e = find_first_module_cpe(mod_entry, module_list);
Expand Down Expand Up @@ -1670,7 +1670,7 @@ void ClassLoader::create_javabase() {
} }


{ {
MutexLocker ml(Module_lock, THREAD); MutexLocker ml(THREAD, Module_lock);
ModuleEntry* jb_module = null_cld_modules->locked_create_entry(Handle(), ModuleEntry* jb_module = null_cld_modules->locked_create_entry(Handle(),
false, vmSymbols::java_base(), NULL, NULL, null_cld); false, vmSymbols::java_base(), NULL, NULL, null_cld);
if (jb_module == NULL) { if (jb_module == NULL) {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/classfile/javaClasses.cpp
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -882,7 +882,7 @@ void java_lang_Class::set_mirror_module_field(Klass* k, Handle mirror, Handle mo


bool javabase_was_defined = false; bool javabase_was_defined = false;
{ {
MutexLocker m1(Module_lock, THREAD); MutexLocker m1(THREAD, Module_lock);
// Keep list of classes needing java.base module fixup // Keep list of classes needing java.base module fixup
if (!ModuleEntryTable::javabase_defined()) { if (!ModuleEntryTable::javabase_defined()) {
assert(k->java_mirror() != NULL, "Class's mirror is null"); assert(k->java_mirror() != NULL, "Class's mirror is null");
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/classfile/modules.cpp
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -194,7 +194,7 @@ static void define_javabase_module(jobject module, jstring version,


bool duplicate_javabase = false; bool duplicate_javabase = false;
{ {
MutexLocker m1(Module_lock, THREAD); MutexLocker m1(THREAD, Module_lock);


if (ModuleEntryTable::javabase_defined()) { if (ModuleEntryTable::javabase_defined()) {
duplicate_javabase = true; duplicate_javabase = true;
Expand Down Expand Up @@ -379,7 +379,7 @@ void Modules::define_module(jobject module, jboolean is_open, jstring version,
PackageEntryTable* package_table = NULL; PackageEntryTable* package_table = NULL;
PackageEntry* existing_pkg = NULL; PackageEntry* existing_pkg = NULL;
{ {
MutexLocker ml(Module_lock, THREAD); MutexLocker ml(THREAD, Module_lock);


if (num_packages > 0) { if (num_packages > 0) {
package_table = get_package_entry_table(h_loader); package_table = get_package_entry_table(h_loader);
Expand Down
50 changes: 25 additions & 25 deletions src/hotspot/share/classfile/systemDictionary.cpp
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -378,7 +378,7 @@ InstanceKlass* SystemDictionary::resolve_super_or_fail(Symbol* child_name,
bool child_already_loaded = false; bool child_already_loaded = false;
bool throw_circularity_error = false; bool throw_circularity_error = false;
{ {
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(THREAD, SystemDictionary_lock);
InstanceKlass* childk = find_class(d_hash, child_name, dictionary); InstanceKlass* childk = find_class(d_hash, child_name, dictionary);
InstanceKlass* quicksuperk; InstanceKlass* quicksuperk;
// to support // loading: if child done loading, just return superclass // to support // loading: if child done loading, just return superclass
Expand Down Expand Up @@ -424,7 +424,7 @@ InstanceKlass* SystemDictionary::resolve_super_or_fail(Symbol* child_name,
// which keeps the loader_data alive, as well as all instanceKlasses in // which keeps the loader_data alive, as well as all instanceKlasses in
// the loader_data. parseClassFile adds the instanceKlass to loader_data. // the loader_data. parseClassFile adds the instanceKlass to loader_data.
{ {
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(THREAD, SystemDictionary_lock);
placeholders()->find_and_remove(p_index, p_hash, child_name, loader_data, PlaceholderTable::LOAD_SUPER, THREAD); placeholders()->find_and_remove(p_index, p_hash, child_name, loader_data, PlaceholderTable::LOAD_SUPER, THREAD);
SystemDictionary_lock->notify_all(); SystemDictionary_lock->notify_all();
} }
Expand Down Expand Up @@ -500,7 +500,7 @@ void SystemDictionary::validate_protection_domain(InstanceKlass* klass,
Symbol* kn = klass->name(); Symbol* kn = klass->name();
unsigned int d_hash = dictionary->compute_hash(kn); unsigned int d_hash = dictionary->compute_hash(kn);


MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(THREAD, SystemDictionary_lock);
int d_index = dictionary->hash_to_index(d_hash); int d_index = dictionary->hash_to_index(d_hash);
dictionary->add_protection_domain(d_index, d_hash, klass, dictionary->add_protection_domain(d_index, d_hash, klass,
protection_domain, THREAD); protection_domain, THREAD);
Expand Down Expand Up @@ -587,7 +587,7 @@ InstanceKlass* SystemDictionary::handle_parallel_super_load(
// parallelCapable class loaders do NOT wait for parallel superclass loads to complete // parallelCapable class loaders do NOT wait for parallel superclass loads to complete
// Serial class loaders and bootstrap classloader do wait for superclass loads // Serial class loaders and bootstrap classloader do wait for superclass loads
if (!class_loader.is_null() && is_parallelCapable(class_loader)) { if (!class_loader.is_null() && is_parallelCapable(class_loader)) {
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(THREAD, SystemDictionary_lock);
// Check if classloading completed while we were loading superclass or waiting // Check if classloading completed while we were loading superclass or waiting
return find_class(d_hash, name, dictionary); return find_class(d_hash, name, dictionary);
} }
Expand All @@ -597,7 +597,7 @@ InstanceKlass* SystemDictionary::handle_parallel_super_load(
bool super_load_in_progress = true; bool super_load_in_progress = true;
PlaceholderEntry* placeholder; PlaceholderEntry* placeholder;
while (super_load_in_progress) { while (super_load_in_progress) {
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(THREAD, SystemDictionary_lock);
// Check if classloading completed while we were loading superclass or waiting // Check if classloading completed while we were loading superclass or waiting
InstanceKlass* check = find_class(d_hash, name, dictionary); InstanceKlass* check = find_class(d_hash, name, dictionary);
if (check != NULL) { if (check != NULL) {
Expand Down Expand Up @@ -714,7 +714,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
name->as_C_string(), name->as_C_string(),
class_loader.is_null() ? "null" : class_loader->klass()->name()->as_C_string()); class_loader.is_null() ? "null" : class_loader->klass()->name()->as_C_string());
{ {
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(THREAD, SystemDictionary_lock);
InstanceKlass* check = find_class(d_hash, name, dictionary); InstanceKlass* check = find_class(d_hash, name, dictionary);
if (check != NULL) { if (check != NULL) {
// InstanceKlass is already loaded, so just return it // InstanceKlass is already loaded, so just return it
Expand Down Expand Up @@ -774,7 +774,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
// Allow parallel classloading of a class/classloader pair // Allow parallel classloading of a class/classloader pair


{ {
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(THREAD, SystemDictionary_lock);
if (class_loader.is_null() || !is_parallelCapable(class_loader)) { if (class_loader.is_null() || !is_parallelCapable(class_loader)) {
PlaceholderEntry* oldprobe = placeholders()->get_entry(p_index, p_hash, name, loader_data); PlaceholderEntry* oldprobe = placeholders()->get_entry(p_index, p_hash, name, loader_data);
if (oldprobe) { if (oldprobe) {
Expand Down Expand Up @@ -861,7 +861,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,


{ // Grabbing the Compile_lock prevents systemDictionary updates { // Grabbing the Compile_lock prevents systemDictionary updates
// during compilations. // during compilations.
MutexLocker mu(Compile_lock, THREAD); MutexLocker mu(THREAD, Compile_lock);
update_dictionary(d_hash, p_index, p_hash, update_dictionary(d_hash, p_index, p_hash,
k, class_loader, THREAD); k, class_loader, THREAD);
} }
Expand All @@ -879,7 +879,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
// clean up placeholder entries for LOAD_INSTANCE success or error // clean up placeholder entries for LOAD_INSTANCE success or error
// This brackets the SystemDictionary updates for both defining // This brackets the SystemDictionary updates for both defining
// and initiating loaders // and initiating loaders
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(THREAD, SystemDictionary_lock);
placeholders()->find_and_remove(p_index, p_hash, name, loader_data, PlaceholderTable::LOAD_INSTANCE, THREAD); placeholders()->find_and_remove(p_index, p_hash, name, loader_data, PlaceholderTable::LOAD_INSTANCE, THREAD);
SystemDictionary_lock->notify_all(); SystemDictionary_lock->notify_all();
} }
Expand All @@ -894,7 +894,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
#ifdef ASSERT #ifdef ASSERT
{ {
ClassLoaderData* loader_data = k->class_loader_data(); ClassLoaderData* loader_data = k->class_loader_data();
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(THREAD, SystemDictionary_lock);
InstanceKlass* kk = find_class(name, loader_data); InstanceKlass* kk = find_class(name, loader_data);
assert(kk == k, "should be present in dictionary"); assert(kk == k, "should be present in dictionary");
} }
Expand Down Expand Up @@ -1026,7 +1026,7 @@ InstanceKlass* SystemDictionary::parse_stream(Symbol* class_name,
k->class_loader_data()->initialize_holder(Handle(THREAD, k->java_mirror())); k->class_loader_data()->initialize_holder(Handle(THREAD, k->java_mirror()));


{ {
MutexLocker mu_r(Compile_lock, THREAD); MutexLocker mu_r(THREAD, Compile_lock);


// Add to class hierarchy, initialize vtables, and do possible // Add to class hierarchy, initialize vtables, and do possible
// deoptimizations. // deoptimizations.
Expand Down Expand Up @@ -1144,7 +1144,7 @@ InstanceKlass* SystemDictionary::resolve_from_stream(Symbol* class_name,


// Make sure we have an entry in the SystemDictionary on success // Make sure we have an entry in the SystemDictionary on success
debug_only( { debug_only( {
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(THREAD, SystemDictionary_lock);


Klass* check = find_class(h_name, k->class_loader_data()); Klass* check = find_class(h_name, k->class_loader_data());
assert(check == k, "should be present in the dictionary"); assert(check == k, "should be present in the dictionary");
Expand Down Expand Up @@ -1582,7 +1582,7 @@ void SystemDictionary::define_instance_class(InstanceKlass* k, TRAPS) {
unsigned int p_hash = placeholders()->compute_hash(name_h); unsigned int p_hash = placeholders()->compute_hash(name_h);
int p_index = placeholders()->hash_to_index(p_hash); int p_index = placeholders()->hash_to_index(p_hash);


MutexLocker mu_r(Compile_lock, THREAD); MutexLocker mu_r(THREAD, Compile_lock);


// Add to class hierarchy, initialize vtables, and do possible // Add to class hierarchy, initialize vtables, and do possible
// deoptimizations. // deoptimizations.
Expand Down Expand Up @@ -1639,7 +1639,7 @@ InstanceKlass* SystemDictionary::find_or_define_instance_class(Symbol* class_nam
PlaceholderEntry* probe; PlaceholderEntry* probe;


{ {
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(THREAD, SystemDictionary_lock);
// First check if class already defined // First check if class already defined
if (is_parallelDefine(class_loader)) { if (is_parallelDefine(class_loader)) {
InstanceKlass* check = find_class(d_hash, name_h, dictionary); InstanceKlass* check = find_class(d_hash, name_h, dictionary);
Expand Down Expand Up @@ -1680,7 +1680,7 @@ InstanceKlass* SystemDictionary::find_or_define_instance_class(Symbol* class_nam


// definer must notify any waiting threads // definer must notify any waiting threads
{ {
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(THREAD, SystemDictionary_lock);
PlaceholderEntry* probe = placeholders()->get_entry(p_index, p_hash, name_h, loader_data); PlaceholderEntry* probe = placeholders()->get_entry(p_index, p_hash, name_h, loader_data);
assert(probe != NULL, "DEFINE_CLASS placeholder lost?"); assert(probe != NULL, "DEFINE_CLASS placeholder lost?");
if (probe != NULL) { if (probe != NULL) {
Expand Down Expand Up @@ -2066,7 +2066,7 @@ void SystemDictionary::check_constraints(unsigned int d_hash,
Symbol *name = k->name(); Symbol *name = k->name();
ClassLoaderData *loader_data = class_loader_data(class_loader); ClassLoaderData *loader_data = class_loader_data(class_loader);


MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(THREAD, SystemDictionary_lock);


InstanceKlass* check = find_class(d_hash, name, loader_data->dictionary()); InstanceKlass* check = find_class(d_hash, name, loader_data->dictionary());
if (check != NULL) { if (check != NULL) {
Expand Down Expand Up @@ -2131,7 +2131,7 @@ void SystemDictionary::update_dictionary(unsigned int d_hash,
ClassLoaderData *loader_data = class_loader_data(class_loader); ClassLoaderData *loader_data = class_loader_data(class_loader);


{ {
MutexLocker mu1(SystemDictionary_lock, THREAD); MutexLocker mu1(THREAD, SystemDictionary_lock);


// Make a new dictionary entry. // Make a new dictionary entry.
Dictionary* dictionary = loader_data->dictionary(); Dictionary* dictionary = loader_data->dictionary();
Expand Down Expand Up @@ -2175,15 +2175,15 @@ Klass* SystemDictionary::find_constrained_instance_or_array_klass(
if (t != T_OBJECT) { if (t != T_OBJECT) {
klass = Universe::typeArrayKlassObj(t); klass = Universe::typeArrayKlassObj(t);
} else { } else {
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(THREAD, SystemDictionary_lock);
klass = constraints()->find_constrained_klass(fd.object_key(), class_loader); klass = constraints()->find_constrained_klass(fd.object_key(), class_loader);
} }
// If element class already loaded, allocate array klass // If element class already loaded, allocate array klass
if (klass != NULL) { if (klass != NULL) {
klass = klass->array_klass_or_null(fd.dimension()); klass = klass->array_klass_or_null(fd.dimension());
} }
} else { } else {
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(THREAD, SystemDictionary_lock);
// Non-array classes are easy: simply check the constraint table. // Non-array classes are easy: simply check the constraint table.
klass = constraints()->find_constrained_klass(class_name, class_loader); klass = constraints()->find_constrained_klass(class_name, class_loader);
} }
Expand Down Expand Up @@ -2224,7 +2224,7 @@ bool SystemDictionary::add_loader_constraint(Symbol* class_name,
unsigned int d_hash2 = dictionary2->compute_hash(constraint_name); unsigned int d_hash2 = dictionary2->compute_hash(constraint_name);


{ {
MutexLocker mu_s(SystemDictionary_lock, THREAD); MutexLocker mu_s(THREAD, SystemDictionary_lock);
InstanceKlass* klass1 = find_class(d_hash1, constraint_name, dictionary1); InstanceKlass* klass1 = find_class(d_hash1, constraint_name, dictionary1);
InstanceKlass* klass2 = find_class(d_hash2, constraint_name, dictionary2); InstanceKlass* klass2 = find_class(d_hash2, constraint_name, dictionary2);
return constraints()->add_entry(constraint_name, klass1, class_loader1, return constraints()->add_entry(constraint_name, klass1, class_loader1,
Expand All @@ -2239,7 +2239,7 @@ void SystemDictionary::add_resolution_error(const constantPoolHandle& pool, int
unsigned int hash = resolution_errors()->compute_hash(pool, which); unsigned int hash = resolution_errors()->compute_hash(pool, which);
int index = resolution_errors()->hash_to_index(hash); int index = resolution_errors()->hash_to_index(hash);
{ {
MutexLocker ml(SystemDictionary_lock, Thread::current()); MutexLocker ml(Thread::current(), SystemDictionary_lock);
resolution_errors()->add_entry(index, hash, pool, which, error, message); resolution_errors()->add_entry(index, hash, pool, which, error, message);
} }
} }
Expand All @@ -2255,7 +2255,7 @@ Symbol* SystemDictionary::find_resolution_error(const constantPoolHandle& pool,
unsigned int hash = resolution_errors()->compute_hash(pool, which); unsigned int hash = resolution_errors()->compute_hash(pool, which);
int index = resolution_errors()->hash_to_index(hash); int index = resolution_errors()->hash_to_index(hash);
{ {
MutexLocker ml(SystemDictionary_lock, Thread::current()); MutexLocker ml(Thread::current(), SystemDictionary_lock);
ResolutionErrorEntry* entry = resolution_errors()->find_entry(index, hash, pool, which); ResolutionErrorEntry* entry = resolution_errors()->find_entry(index, hash, pool, which);
if (entry != NULL) { if (entry != NULL) {
*message = entry->message(); *message = entry->message();
Expand Down Expand Up @@ -2368,7 +2368,7 @@ Method* SystemDictionary::find_method_handle_intrinsic(vmIntrinsics::ID iid,
// Now grab the lock. We might have to throw away the new method, // Now grab the lock. We might have to throw away the new method,
// if a racing thread has managed to install one at the same time. // if a racing thread has managed to install one at the same time.
{ {
MutexLocker ml(SystemDictionary_lock, THREAD); MutexLocker ml(THREAD, SystemDictionary_lock);
spe = invoke_method_table()->find_entry(index, hash, signature, iid); spe = invoke_method_table()->find_entry(index, hash, signature, iid);
if (spe == NULL) if (spe == NULL)
spe = invoke_method_table()->add_entry(index, hash, signature, iid); spe = invoke_method_table()->add_entry(index, hash, signature, iid);
Expand Down Expand Up @@ -2627,7 +2627,7 @@ Handle SystemDictionary::find_method_handle_type(Symbol* signature,


if (can_be_cached) { if (can_be_cached) {
// We can cache this MethodType inside the JVM. // We can cache this MethodType inside the JVM.
MutexLocker ml(SystemDictionary_lock, THREAD); MutexLocker ml(THREAD, SystemDictionary_lock);
spe = invoke_method_table()->find_entry(index, hash, signature, null_iid); spe = invoke_method_table()->find_entry(index, hash, signature, null_iid);
if (spe == NULL) if (spe == NULL)
spe = invoke_method_table()->add_entry(index, hash, signature, null_iid); spe = invoke_method_table()->add_entry(index, hash, signature, null_iid);
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/classfile/systemDictionaryShared.cpp
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -823,7 +823,7 @@ InstanceKlass* SystemDictionaryShared::find_or_load_shared_class(
ObjectLocker ol(lockObject, THREAD, DoObjectLock); ObjectLocker ol(lockObject, THREAD, DoObjectLock);


{ {
MutexLocker mu(SystemDictionary_lock, THREAD); MutexLocker mu(THREAD, SystemDictionary_lock);
InstanceKlass* check = find_class(d_hash, name, dictionary); InstanceKlass* check = find_class(d_hash, name, dictionary);
if (check != NULL) { if (check != NULL) {
return check; return check;
Expand Down Expand Up @@ -935,7 +935,7 @@ InstanceKlass* SystemDictionaryShared::acquire_class_for_current_thread(
ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader()); ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader());


{ {
MutexLocker mu(SharedDictionary_lock, THREAD); MutexLocker mu(THREAD, SharedDictionary_lock);
if (ik->class_loader_data() != NULL) { if (ik->class_loader_data() != NULL) {
// ik is already loaded (by this loader or by a different loader) // ik is already loaded (by this loader or by a different loader)
// or ik is being loaded by a different thread (by this loader or by a different loader) // or ik is being loaded by a different thread (by this loader or by a different loader)
Expand Down Expand Up @@ -978,7 +978,7 @@ bool SystemDictionaryShared::add_unregistered_class(InstanceKlass* k, TRAPS) {
} else { } else {
bool isnew = _loaded_unregistered_classes.put(name, true); bool isnew = _loaded_unregistered_classes.put(name, true);
assert(isnew, "sanity"); assert(isnew, "sanity");
MutexLocker mu_r(Compile_lock, THREAD); // add_to_hierarchy asserts this. MutexLocker mu_r(THREAD, Compile_lock); // add_to_hierarchy asserts this.
SystemDictionary::add_to_hierarchy(k, CHECK_0); SystemDictionary::add_to_hierarchy(k, CHECK_0);
return true; return true;
} }
Expand Down

0 comments on commit 7fc58a1

Please sign in to comment.