diff --git a/src/hotspot/share/c1/c1_Runtime1.cpp b/src/hotspot/share/c1/c1_Runtime1.cpp index b13b1517338..7923c5b7e52 100644 --- a/src/hotspot/share/c1/c1_Runtime1.cpp +++ b/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. * * This code is free software; you can redistribute it and/or modify it @@ -1040,7 +1040,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i // 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. // In that case we don't bother to do any patching we just return @@ -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 // 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()); guarantee(nm != NULL, "only nmethods can contain non-perm oops"); diff --git a/src/hotspot/share/ci/ciEnv.cpp b/src/hotspot/share/ci/ciEnv.cpp index d7e0645abb3..b0986152346 100644 --- a/src/hotspot/share/ci/ciEnv.cpp +++ b/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. * * This code is free software; you can redistribute it and/or modify it @@ -971,7 +971,7 @@ void ciEnv::register_method(ciMethod* target, nmethod* nm = NULL; { // To prevent compile queue updates. - MutexLocker locker(MethodCompileQueue_lock, THREAD); + MutexLocker locker(THREAD, MethodCompileQueue_lock); // Prevent SystemDictionary::add_to_hierarchy from running // and invalidating our dependencies until we install this method. diff --git a/src/hotspot/share/ci/ciReplay.cpp b/src/hotspot/share/ci/ciReplay.cpp index 428c173b440..b6698694d23 100644 --- a/src/hotspot/share/ci/ciReplay.cpp +++ b/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. * * This code is free software; you can redistribute it and/or modify it @@ -631,7 +631,7 @@ class CompileReplay : public StackObj { { // Grab a lock here to prevent multiple // MethodData*s from being created. - MutexLocker ml(MethodData_lock, THREAD); + MutexLocker ml(THREAD, MethodData_lock); if (method->method_data() == NULL) { ClassLoaderData* loader_data = method->method_holder()->class_loader_data(); MethodData* method_data = MethodData::allocate(loader_data, methodHandle(THREAD, method), CHECK); diff --git a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp index 7cc49fdf281..90997ada836 100644 --- a/src/hotspot/share/classfile/classLoader.cpp +++ b/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. * * This code is free software; you can redistribute it and/or modify it @@ -726,7 +726,7 @@ void ClassLoader::add_to_exploded_build_list(Symbol* module_sym, TRAPS) { ModuleClassPathList* module_cpl = new ModuleClassPathList(module_sym); module_cpl->add_to_list(new_entry); { - MutexLocker ml(Module_lock, THREAD); + MutexLocker ml(THREAD, Module_lock); _exploded_entries->push(module_cpl); } log_info(class, load)("path: %s", path); @@ -1090,7 +1090,7 @@ objArrayOop ClassLoader::get_system_packages(TRAPS) { // List of pointers to PackageEntrys that have loaded classes. GrowableArray* loaded_class_pkgs = new GrowableArray(50); { - MutexLocker ml(Module_lock, THREAD); + MutexLocker ml(THREAD, Module_lock); PackageEntryTable* pe_table = ClassLoaderData::the_null_class_loader_data()->packages(); @@ -1187,7 +1187,7 @@ ClassFileStream* ClassLoader::search_module_entries(const GrowableArraylocked_create_entry(Handle(), false, vmSymbols::java_base(), NULL, NULL, null_cld); if (jb_module == NULL) { diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp index bf418769cdb..86ceb4f43bf 100644 --- a/src/hotspot/share/classfile/javaClasses.cpp +++ b/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. * * This code is free software; you can redistribute it and/or modify it @@ -882,7 +882,7 @@ void java_lang_Class::set_mirror_module_field(Klass* k, Handle mirror, Handle mo bool javabase_was_defined = false; { - MutexLocker m1(Module_lock, THREAD); + MutexLocker m1(THREAD, Module_lock); // Keep list of classes needing java.base module fixup if (!ModuleEntryTable::javabase_defined()) { assert(k->java_mirror() != NULL, "Class's mirror is null"); diff --git a/src/hotspot/share/classfile/modules.cpp b/src/hotspot/share/classfile/modules.cpp index c21089e7c19..c684cb9d614 100644 --- a/src/hotspot/share/classfile/modules.cpp +++ b/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. * * This code is free software; you can redistribute it and/or modify it @@ -194,7 +194,7 @@ static void define_javabase_module(jobject module, jstring version, bool duplicate_javabase = false; { - MutexLocker m1(Module_lock, THREAD); + MutexLocker m1(THREAD, Module_lock); if (ModuleEntryTable::javabase_defined()) { duplicate_javabase = true; @@ -379,7 +379,7 @@ void Modules::define_module(jobject module, jboolean is_open, jstring version, PackageEntryTable* package_table = NULL; PackageEntry* existing_pkg = NULL; { - MutexLocker ml(Module_lock, THREAD); + MutexLocker ml(THREAD, Module_lock); if (num_packages > 0) { package_table = get_package_entry_table(h_loader); diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp index 0bbe2b05bcc..205aa6fbee8 100644 --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/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. * * This code is free software; you can redistribute it and/or modify it @@ -378,7 +378,7 @@ InstanceKlass* SystemDictionary::resolve_super_or_fail(Symbol* child_name, bool child_already_loaded = 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* quicksuperk; // to support // loading: if child done loading, just return superclass @@ -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 // 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); SystemDictionary_lock->notify_all(); } @@ -500,7 +500,7 @@ void SystemDictionary::validate_protection_domain(InstanceKlass* klass, Symbol* kn = klass->name(); 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); dictionary->add_protection_domain(d_index, d_hash, klass, protection_domain, THREAD); @@ -587,7 +587,7 @@ InstanceKlass* SystemDictionary::handle_parallel_super_load( // parallelCapable class loaders do NOT wait for parallel superclass loads to complete // Serial class loaders and bootstrap classloader do wait for superclass loads 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 return find_class(d_hash, name, dictionary); } @@ -597,7 +597,7 @@ InstanceKlass* SystemDictionary::handle_parallel_super_load( bool super_load_in_progress = true; PlaceholderEntry* placeholder; 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 InstanceKlass* check = find_class(d_hash, name, dictionary); if (check != NULL) { @@ -714,7 +714,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, 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); if (check != NULL) { // InstanceKlass is already loaded, so just return it @@ -774,7 +774,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, // 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)) { PlaceholderEntry* oldprobe = placeholders()->get_entry(p_index, p_hash, name, loader_data); if (oldprobe) { @@ -861,7 +861,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, { // Grabbing the Compile_lock prevents systemDictionary updates // during compilations. - MutexLocker mu(Compile_lock, THREAD); + MutexLocker mu(THREAD, Compile_lock); update_dictionary(d_hash, p_index, p_hash, k, class_loader, THREAD); } @@ -879,7 +879,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, // clean up placeholder entries for LOAD_INSTANCE success or error // This brackets the SystemDictionary updates for both defining // 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); SystemDictionary_lock->notify_all(); } @@ -894,7 +894,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, #ifdef ASSERT { ClassLoaderData* loader_data = k->class_loader_data(); - MutexLocker mu(SystemDictionary_lock, THREAD); + MutexLocker mu(THREAD, SystemDictionary_lock); InstanceKlass* kk = find_class(name, loader_data); assert(kk == k, "should be present in dictionary"); } @@ -1026,7 +1026,7 @@ InstanceKlass* SystemDictionary::parse_stream(Symbol* class_name, 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 // deoptimizations. @@ -1144,7 +1144,7 @@ InstanceKlass* SystemDictionary::resolve_from_stream(Symbol* class_name, // Make sure we have an entry in the SystemDictionary on success debug_only( { - MutexLocker mu(SystemDictionary_lock, THREAD); + MutexLocker mu(THREAD, SystemDictionary_lock); Klass* check = find_class(h_name, k->class_loader_data()); assert(check == k, "should be present in the dictionary"); @@ -1582,7 +1582,7 @@ void SystemDictionary::define_instance_class(InstanceKlass* k, TRAPS) { unsigned int p_hash = placeholders()->compute_hash(name_h); 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 // deoptimizations. @@ -1639,7 +1639,7 @@ InstanceKlass* SystemDictionary::find_or_define_instance_class(Symbol* class_nam PlaceholderEntry* probe; { - MutexLocker mu(SystemDictionary_lock, THREAD); + MutexLocker mu(THREAD, SystemDictionary_lock); // First check if class already defined if (is_parallelDefine(class_loader)) { InstanceKlass* check = find_class(d_hash, name_h, dictionary); @@ -1680,7 +1680,7 @@ InstanceKlass* SystemDictionary::find_or_define_instance_class(Symbol* class_nam // 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); assert(probe != NULL, "DEFINE_CLASS placeholder lost?"); if (probe != NULL) { @@ -2066,7 +2066,7 @@ void SystemDictionary::check_constraints(unsigned int d_hash, Symbol *name = k->name(); 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()); if (check != NULL) { @@ -2131,7 +2131,7 @@ void SystemDictionary::update_dictionary(unsigned int d_hash, ClassLoaderData *loader_data = class_loader_data(class_loader); { - MutexLocker mu1(SystemDictionary_lock, THREAD); + MutexLocker mu1(THREAD, SystemDictionary_lock); // Make a new dictionary entry. Dictionary* dictionary = loader_data->dictionary(); @@ -2175,7 +2175,7 @@ Klass* SystemDictionary::find_constrained_instance_or_array_klass( if (t != T_OBJECT) { klass = Universe::typeArrayKlassObj(t); } else { - MutexLocker mu(SystemDictionary_lock, THREAD); + MutexLocker mu(THREAD, SystemDictionary_lock); klass = constraints()->find_constrained_klass(fd.object_key(), class_loader); } // If element class already loaded, allocate array klass @@ -2183,7 +2183,7 @@ Klass* SystemDictionary::find_constrained_instance_or_array_klass( klass = klass->array_klass_or_null(fd.dimension()); } } else { - MutexLocker mu(SystemDictionary_lock, THREAD); + MutexLocker mu(THREAD, SystemDictionary_lock); // Non-array classes are easy: simply check the constraint table. klass = constraints()->find_constrained_klass(class_name, class_loader); } @@ -2224,7 +2224,7 @@ bool SystemDictionary::add_loader_constraint(Symbol* class_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* klass2 = find_class(d_hash2, constraint_name, dictionary2); return constraints()->add_entry(constraint_name, klass1, class_loader1, @@ -2239,7 +2239,7 @@ void SystemDictionary::add_resolution_error(const constantPoolHandle& pool, int unsigned int hash = resolution_errors()->compute_hash(pool, which); 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); } } @@ -2255,7 +2255,7 @@ Symbol* SystemDictionary::find_resolution_error(const constantPoolHandle& pool, unsigned int hash = resolution_errors()->compute_hash(pool, which); 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); if (entry != NULL) { *message = entry->message(); @@ -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, // 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); if (spe == NULL) spe = invoke_method_table()->add_entry(index, hash, signature, iid); @@ -2627,7 +2627,7 @@ Handle SystemDictionary::find_method_handle_type(Symbol* signature, if (can_be_cached) { // 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); if (spe == NULL) spe = invoke_method_table()->add_entry(index, hash, signature, null_iid); diff --git a/src/hotspot/share/classfile/systemDictionaryShared.cpp b/src/hotspot/share/classfile/systemDictionaryShared.cpp index 5d7b806f25a..d7725d2ca92 100644 --- a/src/hotspot/share/classfile/systemDictionaryShared.cpp +++ b/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. * * This code is free software; you can redistribute it and/or modify it @@ -823,7 +823,7 @@ InstanceKlass* SystemDictionaryShared::find_or_load_shared_class( ObjectLocker ol(lockObject, THREAD, DoObjectLock); { - MutexLocker mu(SystemDictionary_lock, THREAD); + MutexLocker mu(THREAD, SystemDictionary_lock); InstanceKlass* check = find_class(d_hash, name, dictionary); if (check != NULL) { return check; @@ -935,7 +935,7 @@ InstanceKlass* SystemDictionaryShared::acquire_class_for_current_thread( 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) { // 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) @@ -978,7 +978,7 @@ bool SystemDictionaryShared::add_unregistered_class(InstanceKlass* k, TRAPS) { } else { bool isnew = _loaded_unregistered_classes.put(name, true); 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); return true; } diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp index ed4b36aa1ff..6580c328174 100644 --- a/src/hotspot/share/compiler/compileBroker.cpp +++ b/src/hotspot/share/compiler/compileBroker.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. * * This code is free software; you can redistribute it and/or modify it @@ -266,7 +266,7 @@ CompileTaskWrapper::~CompileTaskWrapper() { if (task->is_blocking()) { bool free_task = false; { - MutexLocker notifier(task->lock(), thread); + MutexLocker notifier(thread, task->lock()); task->mark_complete(); #if INCLUDE_JVMCI if (CompileBroker::compiler(task->comp_level())->is_jvmci()) { @@ -765,7 +765,7 @@ Handle CompileBroker::create_thread_oop(const char* name, TRAPS) { JavaThread* CompileBroker::make_thread(jobject thread_handle, CompileQueue* queue, AbstractCompiler* comp, Thread* THREAD) { JavaThread* new_thread = NULL; { - MutexLocker mu(Threads_lock, THREAD); + MutexLocker mu(THREAD, Threads_lock); if (comp != NULL) { if (!InjectCompilerCreationFailure || comp->num_compiler_threads() == 0) { CompilerCounters* counters = new CompilerCounters(); @@ -1102,7 +1102,7 @@ void CompileBroker::compile_method_base(const methodHandle& method, // Acquire our lock. { - MutexLocker locker(MethodCompileQueue_lock, thread); + MutexLocker locker(thread, MethodCompileQueue_lock); // Make sure the method has not slipped into the queues since // last we checked; note that those checks were "fast bail-outs". @@ -1507,7 +1507,7 @@ int CompileBroker::assign_compile_id(const methodHandle& method, int osr_bci) { // // Public wrapper for assign_compile_id that acquires the needed locks uint CompileBroker::assign_compile_id_unlocked(Thread* thread, const methodHandle& method, int osr_bci) { - MutexLocker locker(MethodCompileQueue_lock, thread); + MutexLocker locker(thread, MethodCompileQueue_lock); return assign_compile_id(method, osr_bci); } @@ -1552,7 +1552,7 @@ static const int JVMCI_COMPILATION_PROGRESS_WAIT_ATTEMPTS = 10; * @return true if this thread needs to free/recycle the task */ bool CompileBroker::wait_for_jvmci_completion(JVMCICompiler* jvmci, CompileTask* task, JavaThread* thread) { - MonitorLocker ml(task->lock(), thread); + MonitorLocker ml(thread, task->lock()); int progress_wait_attempts = 0; int methods_compiled = jvmci->methods_compiled(); while (!task->is_complete() && !is_compilation_disabled_forever() && @@ -1613,7 +1613,7 @@ void CompileBroker::wait_for_completion(CompileTask* task) { } else #endif { - MonitorLocker ml(task->lock(), thread); + MonitorLocker ml(thread, task->lock()); free_task = true; while (!task->is_complete() && !is_compilation_disabled_forever()) { ml.wait(); @@ -1783,7 +1783,7 @@ void CompileBroker::compiler_thread_loop() { { ASSERT_IN_VM; - MutexLocker only_one (CompileThread_lock, thread); + MutexLocker only_one (thread, CompileThread_lock); if (!ciObjectFactory::is_initialized()) { ciObjectFactory::initialize(); } diff --git a/src/hotspot/share/jfr/jni/jfrGetAllEventClasses.cpp b/src/hotspot/share/jfr/jni/jfrGetAllEventClasses.cpp index 28f7136e6ea..0b996870638 100644 --- a/src/hotspot/share/jfr/jni/jfrGetAllEventClasses.cpp +++ b/src/hotspot/share/jfr/jni/jfrGetAllEventClasses.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. * * This code is free software; you can redistribute it and/or modify it @@ -88,7 +88,7 @@ static void fill_klasses(GrowableArray& event_subklasses, const Kla DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(thread)); Stack mark_stack; - MutexLocker ml(Compile_lock, thread); + MutexLocker ml(thread, Compile_lock); mark_stack.push(event_klass->subklass()); while (!mark_stack.is_empty()) { diff --git a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp index 472e6736393..ca573bcf57b 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.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. * * This code is free software; you can redistribute it and/or modify it @@ -442,8 +442,8 @@ void JfrCheckpointManager::write_type_set() { if (LeakProfiler::is_running()) { Thread* const t = Thread::current(); // can safepoint here - MutexLocker cld_lock(ClassLoaderDataGraph_lock); - MutexLocker module_lock(Module_lock); + MutexLocker cld_lock(t, ClassLoaderDataGraph_lock); + MutexLocker module_lock(t, Module_lock); JfrCheckpointWriter leakp_writer(t); JfrCheckpointWriter writer(t); JfrTypeSet::serialize(&writer, &leakp_writer, false, false); diff --git a/src/hotspot/share/jfr/recorder/service/jfrRecorderThread.cpp b/src/hotspot/share/jfr/recorder/service/jfrRecorderThread.cpp index 34ccfa3c316..85335bc33a2 100644 --- a/src/hotspot/share/jfr/recorder/service/jfrRecorderThread.cpp +++ b/src/hotspot/share/jfr/recorder/service/jfrRecorderThread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ static Thread* start_thread(instanceHandle thread_oop, ThreadFunction proc, TRAP bool allocation_failed = false; JavaThread* new_thread = NULL; { - MutexLocker mu(Threads_lock); + MutexLocker mu(THREAD, Threads_lock); new_thread = new JavaThread(proc); // At this point it may be possible that no // osthread was created for the JavaThread due to lack of memory. diff --git a/src/hotspot/share/jvmci/jvmciRuntime.cpp b/src/hotspot/share/jvmci/jvmciRuntime.cpp index d4a29f6ee95..2c9de769dcf 100644 --- a/src/hotspot/share/jvmci/jvmciRuntime.cpp +++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1413,7 +1413,7 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV, JVMCI::CodeInstallResult result; { // To prevent compile queue updates. - MutexLocker locker(MethodCompileQueue_lock, THREAD); + MutexLocker locker(THREAD, MethodCompileQueue_lock); // Prevent SystemDictionary::add_to_hierarchy from running // and invalidating our dependencies until we install this method. diff --git a/src/hotspot/share/memory/filemap.cpp b/src/hotspot/share/memory/filemap.cpp index 7d131fe23e3..e8b10585e96 100644 --- a/src/hotspot/share/memory/filemap.cpp +++ b/src/hotspot/share/memory/filemap.cpp @@ -2107,7 +2107,7 @@ ClassPathEntry* FileMapInfo::get_classpath_entry_for_jvmti(int i, TRAPS) { } } - MutexLocker mu(CDSClassFileStream_lock, THREAD); + MutexLocker mu(THREAD, CDSClassFileStream_lock); if (_classpath_entries_for_jvmti[i] == NULL) { _classpath_entries_for_jvmti[i] = ent; } else { diff --git a/src/hotspot/share/memory/universe.cpp b/src/hotspot/share/memory/universe.cpp index bd96efa04fd..549eaa27ad0 100644 --- a/src/hotspot/share/memory/universe.cpp +++ b/src/hotspot/share/memory/universe.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. * * This code is free software; you can redistribute it and/or modify it @@ -290,11 +290,11 @@ void initialize_basic_type_klass(Klass* k, TRAPS) { } void Universe::genesis(TRAPS) { - ResourceMark rm; + ResourceMark rm(THREAD); { FlagSetting fs(_bootstrapping, true); - { MutexLocker mc(Compile_lock); + { MutexLocker mc(THREAD, Compile_lock); java_lang_Class::allocate_fixup_lists(); @@ -403,7 +403,7 @@ void Universe::genesis(TRAPS) { // Only modify the global variable inside the mutex. // If we had a race to here, the other dummy_array instances // and their elements just get dropped on the floor, which is fine. - MutexLocker ml(FullGCALot_lock); + MutexLocker ml(THREAD, FullGCALot_lock); if (_fullgc_alot_dummy_array == NULL) { _fullgc_alot_dummy_array = dummy_array(); } @@ -544,7 +544,7 @@ void initialize_itable_for_klass(InstanceKlass* k, TRAPS) { void Universe::reinitialize_itables(TRAPS) { - MutexLocker mcld(ClassLoaderDataGraph_lock); + MutexLocker mcld(THREAD, ClassLoaderDataGraph_lock); ClassLoaderDataGraph::dictionary_classes_do(initialize_itable_for_klass, CHECK); } @@ -946,7 +946,7 @@ bool universe_post_init() { // This needs to be done before the first scavenge/gc, since // it's an input to soft ref clearing policy. { - MutexLocker x(Heap_lock); + MutexLocker x(THREAD, Heap_lock); Universe::update_heap_info_at_gc(); } diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp index 1b45ac15efc..5bb0649aab7 100644 --- a/src/hotspot/share/oops/instanceKlass.cpp +++ b/src/hotspot/share/oops/instanceKlass.cpp @@ -1322,7 +1322,7 @@ Klass* InstanceKlass::array_klass_impl(bool or_null, int n, TRAPS) { JavaThread *jt = (JavaThread *)THREAD; { // Atomic creation of array_klasses - MutexLocker ma(MultiArray_lock, THREAD); + MutexLocker ma(THREAD, MultiArray_lock); // Check if update has already taken place if (array_klasses() == NULL) { diff --git a/src/hotspot/share/oops/method.cpp b/src/hotspot/share/oops/method.cpp index aa352501991..f670abc8491 100644 --- a/src/hotspot/share/oops/method.cpp +++ b/src/hotspot/share/oops/method.cpp @@ -522,7 +522,7 @@ void Method::build_interpreter_method_data(const methodHandle& method, TRAPS) { // Grab a lock here to prevent multiple // MethodData*s from being created. - MutexLocker ml(MethodData_lock, THREAD); + MutexLocker ml(THREAD, MethodData_lock); if (method->method_data() == NULL) { ClassLoaderData* loader_data = method->method_holder()->class_loader_data(); MethodData* method_data = MethodData::allocate(loader_data, method, THREAD); @@ -2455,7 +2455,7 @@ void Method::log_touched(TRAPS) { my_sig->identity_hash(); juint index = juint(hash) % table_size; - MutexLocker ml(TouchedMethodLog_lock, THREAD); + MutexLocker ml(THREAD, TouchedMethodLog_lock); if (_touched_method_table == NULL) { _touched_method_table = NEW_C_HEAP_ARRAY2(TouchedMethodRecord*, table_size, mtTracing, CURRENT_PC); diff --git a/src/hotspot/share/oops/objArrayKlass.cpp b/src/hotspot/share/oops/objArrayKlass.cpp index 29c23afcd74..11867db3374 100644 --- a/src/hotspot/share/oops/objArrayKlass.cpp +++ b/src/hotspot/share/oops/objArrayKlass.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. * * This code is free software; you can redistribute it and/or modify it @@ -334,7 +334,7 @@ Klass* ObjArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) { JavaThread *jt = (JavaThread *)THREAD; { // Ensure atomic creation of higher dimensions - MutexLocker mu(MultiArray_lock, THREAD); + MutexLocker mu(THREAD, MultiArray_lock); // Check if another thread beat us if (higher_dimension() == NULL) { diff --git a/src/hotspot/share/oops/typeArrayKlass.cpp b/src/hotspot/share/oops/typeArrayKlass.cpp index 4369289b85a..ed95f63bde3 100644 --- a/src/hotspot/share/oops/typeArrayKlass.cpp +++ b/src/hotspot/share/oops/typeArrayKlass.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. * * This code is free software; you can redistribute it and/or modify it @@ -186,7 +186,7 @@ Klass* TypeArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) { JavaThread *jt = (JavaThread *)THREAD; { // Atomic create higher dimension and link into list - MutexLocker mu(MultiArray_lock, THREAD); + MutexLocker mu(THREAD, MultiArray_lock); if (higher_dimension() == NULL) { Klass* oak = ObjArrayKlass::allocate_objArray_klass( diff --git a/src/hotspot/share/prims/jvmtiCodeBlobEvents.cpp b/src/hotspot/share/prims/jvmtiCodeBlobEvents.cpp index 6f997761b4a..1af4112c47f 100644 --- a/src/hotspot/share/prims/jvmtiCodeBlobEvents.cpp +++ b/src/hotspot/share/prims/jvmtiCodeBlobEvents.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -221,14 +221,15 @@ jvmtiError JvmtiCodeBlobEvents::generate_dynamic_code_events(JvmtiEnv* env) { // Generate a COMPILED_METHOD_LOAD event for each nnmethod jvmtiError JvmtiCodeBlobEvents::generate_compiled_method_load_events(JvmtiEnv* env) { - JvmtiThreadState* state = JvmtiThreadState::state_for(JavaThread::current()); + JavaThread* java_thread = JavaThread::current(); + JvmtiThreadState* state = JvmtiThreadState::state_for(java_thread); { NoSafepointVerifier nsv; // safepoints are not safe while collecting methods to post. { // Walk the CodeCache notifying for live nmethods, don't release the CodeCache_lock // because the sweeper may be running concurrently. // Save events to the queue for posting outside the CodeCache_lock. - MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); + MutexLocker mu(java_thread, CodeCache_lock, Mutex::_no_safepoint_check_flag); // Iterate over non-profiled and profiled nmethods NMethodIterator iter(NMethodIterator::only_alive_and_not_unloading); while(iter.next()) { diff --git a/src/hotspot/share/prims/jvmtiEnv.cpp b/src/hotspot/share/prims/jvmtiEnv.cpp index da70495cb11..f8f2f569f7d 100644 --- a/src/hotspot/share/prims/jvmtiEnv.cpp +++ b/src/hotspot/share/prims/jvmtiEnv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1330,7 +1330,7 @@ JvmtiEnv::RunAgentThread(jthread thread, jvmtiStartFunction proc, const void* ar Handle thread_hndl(current_thread, thread_oop); { - MutexLocker mu(Threads_lock); // grab Threads_lock + MutexLocker mu(current_thread, Threads_lock); // grab Threads_lock JvmtiAgentThread *new_thread = new JvmtiAgentThread(this, proc, arg); diff --git a/src/hotspot/share/prims/jvmtiExport.cpp b/src/hotspot/share/prims/jvmtiExport.cpp index 182d3b061ab..d4579dfa43d 100644 --- a/src/hotspot/share/prims/jvmtiExport.cpp +++ b/src/hotspot/share/prims/jvmtiExport.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2580,7 +2580,7 @@ void JvmtiExport::post_sampled_object_alloc(JavaThread *thread, oop object) { void JvmtiExport::cleanup_thread(JavaThread* thread) { assert(JavaThread::current() == thread, "thread is not current"); - MutexLocker mu(JvmtiThreadState_lock); + MutexLocker mu(thread, JvmtiThreadState_lock); if (thread->jvmti_thread_state() != NULL) { // This has to happen after the thread state is removed, which is diff --git a/src/hotspot/share/prims/methodHandles.cpp b/src/hotspot/share/prims/methodHandles.cpp index 82afa263737..3a1f0dc57d7 100644 --- a/src/hotspot/share/prims/methodHandles.cpp +++ b/src/hotspot/share/prims/methodHandles.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1393,7 +1393,7 @@ JVM_ENTRY(void, MHN_setCallSiteTargetNormal(JNIEnv* env, jobject igcls, jobject Handle target (THREAD, JNIHandles::resolve_non_null(target_jh)); { // Walk all nmethods depending on this call site. - MutexLocker mu(Compile_lock, thread); + MutexLocker mu(thread, Compile_lock); MethodHandles::flush_dependent_nmethods(call_site, target); java_lang_invoke_CallSite::set_target(call_site(), target()); } @@ -1405,7 +1405,7 @@ JVM_ENTRY(void, MHN_setCallSiteTargetVolatile(JNIEnv* env, jobject igcls, jobjec Handle target (THREAD, JNIHandles::resolve_non_null(target_jh)); { // Walk all nmethods depending on this call site. - MutexLocker mu(Compile_lock, thread); + MutexLocker mu(thread, Compile_lock); MethodHandles::flush_dependent_nmethods(call_site, target); java_lang_invoke_CallSite::set_target_volatile(call_site(), target()); } @@ -1499,12 +1499,12 @@ JVM_ENTRY(void, MHN_clearCallSiteContext(JNIEnv* env, jobject igcls, jobject con Handle context(THREAD, JNIHandles::resolve_non_null(context_jh)); { // Walk all nmethods depending on this call site. - MutexLocker mu1(Compile_lock, thread); + MutexLocker mu1(thread, Compile_lock); int marked = 0; { NoSafepointVerifier nsv; - MutexLocker mu2(CodeCache_lock, Mutex::_no_safepoint_check_flag); + MutexLocker mu2(THREAD, CodeCache_lock, Mutex::_no_safepoint_check_flag); DependencyContext deps = java_lang_invoke_MethodHandleNatives_CallSiteContext::vmdependencies(context()); marked = deps.remove_all_dependents(); } diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index 24723b10439..46f69dc1d73 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -1021,7 +1021,7 @@ bool WhiteBox::compile_method(Method* method, int comp_level, int bci, Thread* T // Compile method and check result nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), CompileTask::Reason_Whitebox, THREAD); - MutexLocker mu(Compile_lock); + MutexLocker mu(THREAD, Compile_lock); bool is_queued = mh->queued_for_compilation(); if ((!is_blocking && is_queued) || nm != NULL) { return true; @@ -1068,7 +1068,7 @@ WB_ENTRY(jint, WB_MatchesInline(JNIEnv* env, jobject o, jobject method, jstring methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); - ResourceMark rm; + ResourceMark rm(THREAD); const char* error_msg = NULL; char* method_str = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(pattern)); InlineMatcher* m = InlineMatcher::parse_inline_pattern(method_str, error_msg); @@ -1139,18 +1139,18 @@ WB_ENTRY(void, WB_ClearMethodState(JNIEnv* env, jobject o, jobject method)) jmethodID jmid = reflected_method_to_jmid(thread, env, method); CHECK_JNI_EXCEPTION(env); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); - MutexLocker mu(Compile_lock); + MutexLocker mu(THREAD, Compile_lock); MethodData* mdo = mh->method_data(); MethodCounters* mcs = mh->method_counters(); if (mdo != NULL) { mdo->init(); - ResourceMark rm; + ResourceMark rm(THREAD); int arg_count = mdo->method()->size_of_parameters(); for (int i = 0; i < arg_count; i++) { mdo->set_arg_modified(i, 0); } - MutexLocker mu(mdo->extra_data_lock()); + MutexLocker mu(THREAD, mdo->extra_data_lock()); mdo->clean_method_data(/*always_clean*/true); } diff --git a/src/hotspot/share/runtime/mutexLocker.hpp b/src/hotspot/share/runtime/mutexLocker.hpp index 0112c19ebf2..35e11062058 100644 --- a/src/hotspot/share/runtime/mutexLocker.hpp +++ b/src/hotspot/share/runtime/mutexLocker.hpp @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -206,7 +206,7 @@ class MutexLocker: public StackObj { } } - MutexLocker(Mutex* mutex, Thread* thread, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) : + MutexLocker(Thread* thread, Mutex* mutex, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) : _mutex(mutex) { bool no_safepoint_check = flag == Mutex::_no_safepoint_check_flag; if (_mutex != NULL) { @@ -242,8 +242,8 @@ class MonitorLocker: public MutexLocker { assert(_monitor != NULL, "NULL monitor not allowed"); } - MonitorLocker(Monitor* monitor, Thread* thread, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) : - MutexLocker(monitor, thread, flag), _flag(flag), _monitor(monitor) { + MonitorLocker(Thread* thread, Monitor* monitor, Mutex::SafepointCheckFlag flag = Mutex::_safepoint_check_flag) : + MutexLocker(thread, monitor, flag), _flag(flag), _monitor(monitor) { // Superclass constructor did locking assert(_monitor != NULL, "NULL monitor not allowed"); } diff --git a/src/hotspot/share/runtime/notificationThread.cpp b/src/hotspot/share/runtime/notificationThread.cpp index 4f92f95b55c..fb13c03292e 100644 --- a/src/hotspot/share/runtime/notificationThread.cpp +++ b/src/hotspot/share/runtime/notificationThread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,7 @@ void NotificationThread::initialize() { thread_oop, THREAD); { - MutexLocker mu(Threads_lock); + MutexLocker mu(THREAD, Threads_lock); NotificationThread* thread = new NotificationThread(¬ification_thread_entry); // At this point it may be possible that no osthread was created for the diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp index 6632615edd1..37acfee3746 100644 --- a/src/hotspot/share/runtime/os.cpp +++ b/src/hotspot/share/runtime/os.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. * * This code is free software; you can redistribute it and/or modify it @@ -492,7 +492,7 @@ void os::initialize_jdk_signal_support(TRAPS) { thread_oop, CHECK); - { MutexLocker mu(Threads_lock); + { MutexLocker mu(THREAD, Threads_lock); JavaThread* signal_thread = new JavaThread(&signal_thread_entry); // At this point it may be possible that no osthread was created for the diff --git a/src/hotspot/share/runtime/serviceThread.cpp b/src/hotspot/share/runtime/serviceThread.cpp index 0a84d2013a2..1e90b64628b 100644 --- a/src/hotspot/share/runtime/serviceThread.cpp +++ b/src/hotspot/share/runtime/serviceThread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,7 +68,7 @@ void ServiceThread::initialize() { CHECK); { - MutexLocker mu(Threads_lock); + MutexLocker mu(THREAD, Threads_lock); ServiceThread* thread = new ServiceThread(&service_thread_entry); // At this point it may be possible that no osthread was created for the diff --git a/src/hotspot/share/services/attachListener.cpp b/src/hotspot/share/services/attachListener.cpp index 8ee4dc927ea..c234b7aa734 100644 --- a/src/hotspot/share/services/attachListener.cpp +++ b/src/hotspot/share/services/attachListener.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -467,7 +467,7 @@ void AttachListener::init() { return; } - { MutexLocker mu(Threads_lock); + { MutexLocker mu(THREAD, Threads_lock); JavaThread* listener_thread = new JavaThread(&attach_listener_thread_entry); // Check that thread and osthread were created diff --git a/src/hotspot/share/services/diagnosticCommand.cpp b/src/hotspot/share/services/diagnosticCommand.cpp index e28d9727966..a8106a26801 100644 --- a/src/hotspot/share/services/diagnosticCommand.cpp +++ b/src/hotspot/share/services/diagnosticCommand.cpp @@ -449,12 +449,12 @@ void RunFinalizationDCmd::execute(DCmdSource source, TRAPS) { } void HeapInfoDCmd::execute(DCmdSource source, TRAPS) { - MutexLocker hl(Heap_lock); + MutexLocker hl(THREAD, Heap_lock); Universe::heap()->print_on(output()); } void FinalizerInfoDCmd::execute(DCmdSource source, TRAPS) { - ResourceMark rm; + ResourceMark rm(THREAD); Klass* k = SystemDictionary::resolve_or_fail( vmSymbols::finalizer_histogram_klass(), true, CHECK); diff --git a/src/hotspot/share/services/diagnosticFramework.cpp b/src/hotspot/share/services/diagnosticFramework.cpp index af4f6b78d09..34855aebeec 100644 --- a/src/hotspot/share/services/diagnosticFramework.cpp +++ b/src/hotspot/share/services/diagnosticFramework.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -455,7 +455,7 @@ void DCmdFactory::send_notification_internal(TRAPS) { HandleMark hm(THREAD); bool notif = false; { - MutexLocker ml(Notification_lock, Mutex::_no_safepoint_check_flag); + MutexLocker ml(THREAD, Notification_lock, Mutex::_no_safepoint_check_flag); notif = _has_pending_jmx_notification; _has_pending_jmx_notification = false; } diff --git a/src/hotspot/share/services/lowMemoryDetector.cpp b/src/hotspot/share/services/lowMemoryDetector.cpp index 58675b4444a..81249a09a73 100644 --- a/src/hotspot/share/services/lowMemoryDetector.cpp +++ b/src/hotspot/share/services/lowMemoryDetector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -335,7 +335,7 @@ void SensorInfo::trigger(int count, TRAPS) { { // Holds Notification_lock and update the sensor state - MutexLocker ml(Notification_lock, Mutex::_no_safepoint_check_flag); + MutexLocker ml(THREAD, Notification_lock, Mutex::_no_safepoint_check_flag); assert(_pending_trigger_count > 0, "Must have pending trigger"); _sensor_on = true; _sensor_count += count; @@ -346,7 +346,7 @@ void SensorInfo::trigger(int count, TRAPS) { void SensorInfo::clear(int count, TRAPS) { { // Holds Notification_lock and update the sensor state - MutexLocker ml(Notification_lock, Mutex::_no_safepoint_check_flag); + MutexLocker ml(THREAD, Notification_lock, Mutex::_no_safepoint_check_flag); if (_pending_clear_count == 0) { // Bail out if we lost a race to set_*_sensor_level() which may have // reactivated the sensor in the meantime because it was triggered again. diff --git a/src/hotspot/share/services/management.cpp b/src/hotspot/share/services/management.cpp index ca3bb0a61f1..29083454a34 100644 --- a/src/hotspot/share/services/management.cpp +++ b/src/hotspot/share/services/management.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1705,7 +1705,7 @@ JVM_ENTRY(jint, jmm_GetInternalThreadTimes(JNIEnv *env, ThreadTimesClosure ttc(names_ah, times_ah); { - MutexLocker ml(Threads_lock); + MutexLocker ml(THREAD, Threads_lock); Threads::threads_do(&ttc); } ttc.do_unlocked(); diff --git a/src/hotspot/share/services/memoryManager.cpp b/src/hotspot/share/services/memoryManager.cpp index 2b7b4faf797..c0e6553d983 100644 --- a/src/hotspot/share/services/memoryManager.cpp +++ b/src/hotspot/share/services/memoryManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -110,7 +110,7 @@ instanceOop MemoryManager::get_memory_manager_instance(TRAPS) { { // Get lock before setting _memory_mgr_obj // since another thread may have created the instance - MutexLocker ml(Management_lock); + MutexLocker ml(THREAD, Management_lock); // Check if another thread has created the management object. We reload // _memory_mgr_obj here because some other thread may have initialized diff --git a/src/hotspot/share/services/memoryPool.cpp b/src/hotspot/share/services/memoryPool.cpp index 3df8f630fde..1a4dc69a228 100644 --- a/src/hotspot/share/services/memoryPool.cpp +++ b/src/hotspot/share/services/memoryPool.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -110,7 +110,7 @@ instanceOop MemoryPool::get_memory_pool_instance(TRAPS) { { // Get lock since another thread may have create the instance - MutexLocker ml(Management_lock); + MutexLocker ml(THREAD, Management_lock); // Check if another thread has created the pool. We reload // _memory_pool_obj here because some other thread may have diff --git a/src/hotspot/share/services/nmtDCmd.cpp b/src/hotspot/share/services/nmtDCmd.cpp index 8e0e8a9944d..f7185801444 100644 --- a/src/hotspot/share/services/nmtDCmd.cpp +++ b/src/hotspot/share/services/nmtDCmd.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -114,7 +114,7 @@ void NMTDCmd::execute(DCmdSource source, TRAPS) { } // Serialize NMT query - MutexLocker locker(MemTracker::query_lock()); + MutexLocker locker(THREAD, MemTracker::query_lock()); if (_summary.value()) { report(true, scale_unit);