Skip to content
Permalink
Browse files
8261280: Remove THREAD argument from compute_loader_lock_object
Reviewed-by: dcubed
  • Loading branch information
coleenp committed Feb 6, 2021
1 parent 74d40ab commit 2c3a86f96e3968ee1842e83eb3f85f882a0f8a19
@@ -151,14 +151,14 @@ ClassLoaderData* SystemDictionary::register_loader(Handle class_loader, bool cre
// ----------------------------------------------------------------------------
// Parallel class loading check

bool SystemDictionary::is_parallelCapable(Handle class_loader) {
bool is_parallelCapable(Handle class_loader) {
if (class_loader.is_null()) return true;
if (AlwaysLockClassLoader) return false;
return java_lang_ClassLoader::parallelCapable(class_loader());
}
// ----------------------------------------------------------------------------
// ParallelDefineClass flag does not apply to bootclass loader
bool SystemDictionary::is_parallelDefine(Handle class_loader) {
bool is_parallelDefine(Handle class_loader) {
if (class_loader.is_null()) return false;
if (AllowParallelDefineClass && java_lang_ClassLoader::parallelCapable(class_loader())) {
return true;
@@ -185,7 +185,7 @@ bool SystemDictionary::is_platform_class_loader(oop class_loader) {
return (class_loader->klass() == vmClasses::jdk_internal_loader_ClassLoaders_PlatformClassLoader_klass());
}

Handle SystemDictionary::compute_loader_lock_object(Thread* thread, Handle class_loader) {
Handle SystemDictionary::compute_loader_lock_object(Handle class_loader) {
// If class_loader is NULL or parallelCapable, the JVM doesn't acquire a lock while loading.
if (is_parallelCapable(class_loader)) {
return Handle();
@@ -703,7 +703,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
// the define.
// ParallelCapable Classloaders and the bootstrap classloader
// do not acquire lock here.
Handle lockObject = compute_loader_lock_object(THREAD, class_loader);
Handle lockObject = compute_loader_lock_object(class_loader);
ObjectLocker ol(lockObject, THREAD);

// Check again (after locking) if the class already exists in SystemDictionary
@@ -1068,7 +1068,7 @@ InstanceKlass* SystemDictionary::resolve_from_stream(Symbol* class_name,

// Classloaders that support parallelism, e.g. bootstrap classloader,
// do not acquire lock here
Handle lockObject = compute_loader_lock_object(THREAD, class_loader);
Handle lockObject = compute_loader_lock_object(class_loader);
ObjectLocker ol(lockObject, THREAD);

// Parse the stream and create a klass.
@@ -1359,7 +1359,7 @@ InstanceKlass* SystemDictionary::load_shared_class(InstanceKlass* ik,
ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader());
{
HandleMark hm(THREAD);
Handle lockObject = compute_loader_lock_object(THREAD, class_loader);
Handle lockObject = compute_loader_lock_object(class_loader);
ObjectLocker ol(lockObject, THREAD);
// prohibited package check assumes all classes loaded from archive call
// restore_unshareable_info which calls ik->set_package()
@@ -1561,7 +1561,7 @@ void SystemDictionary::define_instance_class(InstanceKlass* k, Handle class_load
// hole with systemDictionary updates and check_constraints
if (!is_parallelCapable(class_loader)) {
assert(ObjectSynchronizer::current_thread_holds_lock(THREAD->as_Java_thread(),
compute_loader_lock_object(THREAD, class_loader)),
compute_loader_lock_object(class_loader)),
"define called without lock");
}

@@ -352,9 +352,6 @@ class SystemDictionary : AllStatic {
Handle class_loader,
InstanceKlass* k, TRAPS);
static InstanceKlass* load_instance_class(Symbol* class_name, Handle class_loader, TRAPS);
static bool is_parallelDefine(Handle class_loader);
static Handle compute_loader_lock_object(Thread* thread, Handle class_loader);
static void check_loader_lock_contention(Thread* thread, Handle loader_lock);

static bool is_shared_class_visible(Symbol* class_name, InstanceKlass* ik,
PackageEntry* pkg_entry,
@@ -390,7 +387,7 @@ class SystemDictionary : AllStatic {
static InstanceKlass* load_shared_boot_class(Symbol* class_name,
PackageEntry* pkg_entry,
TRAPS);
static bool is_parallelCapable(Handle class_loader);
static Handle compute_loader_lock_object(Handle class_loader);
static InstanceKlass* find_or_define_instance_class(Symbol* class_name,
Handle class_loader,
InstanceKlass* k, TRAPS);
@@ -1036,7 +1036,7 @@ InstanceKlass* SystemDictionaryShared::find_or_load_shared_class(
// Note: currently, find_or_load_shared_class is called only from
// JVM_FindLoadedClass and used for PlatformClassLoader and AppClassLoader,
// which are parallel-capable loaders, so a lock here is NOT taken.
assert(is_parallelCapable(class_loader), "ObjectLocker not required");
assert(compute_loader_lock_object(class_loader) == NULL, "ObjectLocker not required");
{
MutexLocker mu(THREAD, SystemDictionary_lock);
InstanceKlass* check = dictionary->find_class(d_hash, name);

0 comments on commit 2c3a86f

Please sign in to comment.