8213137: Remove static initialization of monitor/mutex instances

Moved to the global mutex list in mutexLocker

Reviewed-by: tschatzl, dcubed, rehn, eosterlund
This commit is contained in:
David Holmes 2018-11-08 07:42:08 -05:00
parent fdfbfb2f8b
commit eac28d7fae
13 changed files with 37 additions and 44 deletions

View File

@ -89,8 +89,6 @@ CodeCacheUnloadingTask::~CodeCacheUnloadingTask() {
CodeCache::verify_icholder_relocations();
}
Monitor* CodeCacheUnloadingTask::_lock = new Monitor(Mutex::leaf, "Code Cache Unload lock", false, Monitor::_safepoint_check_never);
void CodeCacheUnloadingTask::claim_nmethods(CompiledMethod** claimed_nmethods, int *num_claimed_nmethods) {
CompiledMethod* first;
CompiledMethodIterator last;

View File

@ -56,7 +56,6 @@ public:
};
class CodeCacheUnloadingTask {
static Monitor* _lock;
CodeCache::UnloadingScope _unloading_scope;
const bool _unloading_occurred;

View File

@ -321,7 +321,6 @@ class JfrThreadSampler : public NonJavaThread {
int _cur_index;
const u4 _max_frames;
volatile bool _disenrolled;
static Monitor* _transition_block_lock;
JavaThread* next_thread(ThreadsList* t_list, JavaThread* first_sampled, JavaThread* current);
void task_stacktrace(JfrSampleType type, JavaThread** last_thread);
@ -339,12 +338,10 @@ class JfrThreadSampler : public NonJavaThread {
public:
void run();
static Monitor* transition_block() { return _transition_block_lock; }
static Monitor* transition_block() { return JfrThreadSampler_lock; }
static void on_javathread_suspend(JavaThread* thread);
};
Monitor* JfrThreadSampler::_transition_block_lock = new Monitor(Mutex::leaf, "Trace block", true, Monitor::_safepoint_check_never);
static void clear_transition_block(JavaThread* jt) {
jt->clear_trace_flag();
JfrThreadLocal* const tl = jt->jfr_thread_local();

View File

@ -106,7 +106,7 @@ Monitor* Notify_lock = NULL;
Mutex* ProfilePrint_lock = NULL;
Mutex* ExceptionCache_lock = NULL;
Mutex* OsrList_lock = NULL;
Mutex* NMethodSweeperStats_lock = NULL;
#ifndef PRODUCT
Mutex* FullGCALot_lock = NULL;
#endif
@ -138,6 +138,7 @@ Mutex* JfrStacktrace_lock = NULL;
Monitor* JfrMsg_lock = NULL;
Mutex* JfrBuffer_lock = NULL;
Mutex* JfrStream_lock = NULL;
Monitor* JfrThreadSampler_lock = NULL;
#endif
#ifndef SUPPORTS_NATIVE_CX8
@ -147,6 +148,9 @@ Monitor* CodeHeapStateAnalytics_lock = NULL;
Mutex* MetaspaceExpand_lock = NULL;
Mutex* ClassLoaderDataGraph_lock = NULL;
Monitor* ThreadsSMRDelete_lock = NULL;
Mutex* SharedDecoder_lock = NULL;
Mutex* DCmdFactory_lock = NULL;
#define MAX_NUM_MUTEX 128
static Monitor * _mutex_array[MAX_NUM_MUTEX];
@ -243,7 +247,7 @@ void mutex_init() {
def(JmethodIdCreation_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always); // used for creating jmethodIDs.
def(SystemDictionary_lock , PaddedMonitor, leaf, true, Monitor::_safepoint_check_always); // lookups done by VM thread
def(SharedDictionary_lock , PaddedMutex, leaf, true, Monitor::_safepoint_check_always); // lookups done by VM thread
def(SharedDictionary_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always); // lookups done by VM thread
def(Module_lock , PaddedMutex , leaf+2, true, Monitor::_safepoint_check_always);
def(InlineCacheBuffer_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_always);
def(VMStatistic_lock , PaddedMutex , leaf, false, Monitor::_safepoint_check_always);
@ -318,6 +322,7 @@ void mutex_init() {
def(JfrBuffer_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_never);
def(JfrStream_lock , PaddedMutex , leaf+1, true, Monitor::_safepoint_check_never); // ensure to rank lower than 'safepoint'
def(JfrStacktrace_lock , PaddedMutex , special, true, Monitor::_safepoint_check_sometimes);
def(JfrThreadSampler_lock , PaddedMonitor, leaf, true, Monitor::_safepoint_check_never);
#endif
#ifndef SUPPORTS_NATIVE_CX8
@ -325,6 +330,11 @@ void mutex_init() {
#endif
def(CodeHeapStateAnalytics_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_never);
def(NMethodSweeperStats_lock , PaddedMutex , special, true, Monitor::_safepoint_check_sometimes);
def(ThreadsSMRDelete_lock , PaddedMonitor, special, false, Monitor::_safepoint_check_never);
def(SharedDecoder_lock , PaddedMutex , native, false, Monitor::_safepoint_check_never);
def(DCmdFactory_lock , PaddedMutex , leaf, true, Monitor::_safepoint_check_never);
}
GCMutexLocker::GCMutexLocker(Monitor * mutex) {

View File

@ -110,6 +110,7 @@ extern Monitor* Notify_lock; // a lock used to synchronize t
extern Mutex* ProfilePrint_lock; // a lock used to serialize the printing of profiles
extern Mutex* ExceptionCache_lock; // a lock used to synchronize exception cache updates
extern Mutex* OsrList_lock; // a lock used to serialize access to OSR queues
extern Mutex* NMethodSweeperStats_lock; // a lock used to serialize access to sweeper statistics
#ifndef PRODUCT
extern Mutex* FullGCALot_lock; // a lock to make FullGCALot MT safe
@ -132,12 +133,15 @@ extern Mutex* Management_lock; // a lock used to serialize JVM
extern Monitor* Service_lock; // a lock used for service thread operation
extern Monitor* PeriodicTask_lock; // protects the periodic task structure
extern Monitor* RedefineClasses_lock; // locks classes from parallel redefinition
extern Monitor* ThreadsSMRDelete_lock; // Used by ThreadsSMRSupport to take pressure off the Threads_lock
extern Mutex* SharedDecoder_lock; // serializes access to the decoder during normal (not error reporting) use
extern Mutex* DCmdFactory_lock; // serialize access to DCmdFactory information
#if INCLUDE_JFR
extern Mutex* JfrStacktrace_lock; // used to guard access to the JFR stacktrace table
extern Monitor* JfrMsg_lock; // protects JFR messaging
extern Mutex* JfrBuffer_lock; // protects JFR buffer operations
extern Mutex* JfrStream_lock; // protects JFR stream access
extern Monitor* JfrThreadSampler_lock; // used to suspend/resume JFR thread sampler
#endif
#ifndef SUPPORTS_NATIVE_CX8

View File

@ -164,8 +164,6 @@ Tickspan NMethodSweeper::_total_time_this_sweep; // Total time thi
Tickspan NMethodSweeper::_peak_sweep_time; // Peak time for a full sweep
Tickspan NMethodSweeper::_peak_sweep_fraction_time; // Peak time sweeping one fraction
Monitor* NMethodSweeper::_stat_lock = new Monitor(Mutex::special, "Sweeper::Statistics", true, Monitor::_safepoint_check_sometimes);
class MarkActivationClosure: public CodeBlobClosure {
public:
virtual void do_code_blob(CodeBlob* cb) {
@ -578,7 +576,7 @@ void NMethodSweeper::sweep_code_cache() {
const Ticks sweep_end_counter = Ticks::now();
const Tickspan sweep_time = sweep_end_counter - sweep_start_counter;
{
MutexLockerEx mu(_stat_lock, Mutex::_no_safepoint_check_flag);
MutexLockerEx mu(NMethodSweeperStats_lock, Mutex::_no_safepoint_check_flag);
_total_time_sweeping += sweep_time;
_total_time_this_sweep += sweep_time;
_peak_sweep_fraction_time = MAX2(sweep_time, _peak_sweep_fraction_time);

View File

@ -88,8 +88,6 @@ class NMethodSweeper : public AllStatic {
static Tickspan _peak_sweep_time; // Peak time for a full sweep
static Tickspan _peak_sweep_fraction_time; // Peak time sweeping one fraction
static Monitor* _stat_lock;
static MethodStateChange process_compiled_method(CompiledMethod *nm);
static void release_compiled_method(CompiledMethod* nm);

View File

@ -36,10 +36,6 @@
#include "utilities/resourceHash.hpp"
#include "utilities/vmError.hpp"
Monitor* ThreadsSMRSupport::_delete_lock =
new Monitor(Monitor::special, "Thread_SMR_delete_lock",
false /* allow_vm_block */,
Monitor::_safepoint_check_never);
// The '_cnt', '_max' and '_times" fields are enabled via
// -XX:+EnableThreadSMRStatistics:

View File

@ -91,7 +91,8 @@ class ThreadsSMRSupport : AllStatic {
// The coordination between ThreadsSMRSupport::release_stable_list() and
// ThreadsSMRSupport::smr_delete() uses the delete_lock in order to
// reduce the traffic on the Threads_lock.
static Monitor* _delete_lock;
static Monitor* delete_lock() { return ThreadsSMRDelete_lock; }
// The '_cnt', '_max' and '_times" fields are enabled via
// -XX:+EnableThreadSMRStatistics (see thread.cpp for a
// description about each field):
@ -121,7 +122,6 @@ class ThreadsSMRSupport : AllStatic {
static void add_deleted_thread_times(uint add_value);
static void add_tlh_times(uint add_value);
static void clear_delete_notify();
static Monitor* delete_lock() { return _delete_lock; }
static bool delete_notify();
static void free_list(ThreadsList* threads);
static void inc_deleted_thread_cnt();

View File

@ -491,11 +491,10 @@ void DCmdFactory::send_notification_internal(TRAPS) {
}
}
Mutex* DCmdFactory::_dcmdFactory_lock = new Mutex(Mutex::leaf, "DCmdFactory", true, Monitor::_safepoint_check_never);
bool DCmdFactory::_send_jmx_notification = false;
DCmdFactory* DCmdFactory::factory(DCmdSource source, const char* name, size_t len) {
MutexLockerEx ml(_dcmdFactory_lock, Mutex::_no_safepoint_check_flag);
MutexLockerEx ml(DCmdFactory_lock, Mutex::_no_safepoint_check_flag);
DCmdFactory* factory = _DCmdFactoryList;
while (factory != NULL) {
if (strlen(factory->name()) == len &&
@ -512,7 +511,7 @@ DCmdFactory* DCmdFactory::factory(DCmdSource source, const char* name, size_t le
}
int DCmdFactory::register_DCmdFactory(DCmdFactory* factory) {
MutexLockerEx ml(_dcmdFactory_lock, Mutex::_no_safepoint_check_flag);
MutexLockerEx ml(DCmdFactory_lock, Mutex::_no_safepoint_check_flag);
factory->_next = _DCmdFactoryList;
_DCmdFactoryList = factory;
if (_send_jmx_notification && !factory->_hidden
@ -537,7 +536,7 @@ DCmd* DCmdFactory::create_local_DCmd(DCmdSource source, CmdLine &line,
}
GrowableArray<const char*>* DCmdFactory::DCmd_list(DCmdSource source) {
MutexLockerEx ml(_dcmdFactory_lock, Mutex::_no_safepoint_check_flag);
MutexLockerEx ml(DCmdFactory_lock, Mutex::_no_safepoint_check_flag);
GrowableArray<const char*>* array = new GrowableArray<const char*>();
DCmdFactory* factory = _DCmdFactoryList;
while (factory != NULL) {
@ -550,7 +549,7 @@ GrowableArray<const char*>* DCmdFactory::DCmd_list(DCmdSource source) {
}
GrowableArray<DCmdInfo*>* DCmdFactory::DCmdInfo_list(DCmdSource source ) {
MutexLockerEx ml(_dcmdFactory_lock, Mutex::_no_safepoint_check_flag);
MutexLockerEx ml(DCmdFactory_lock, Mutex::_no_safepoint_check_flag);
GrowableArray<DCmdInfo*>* array = new GrowableArray<DCmdInfo*>();
DCmdFactory* factory = _DCmdFactoryList;
while (factory != NULL) {

View File

@ -344,7 +344,6 @@ public:
// management.cpp)
class DCmdFactory: public CHeapObj<mtInternal> {
private:
static Mutex* _dcmdFactory_lock;
static bool _send_jmx_notification;
static bool _has_pending_jmx_notification;
static DCmdFactory* _DCmdFactoryList;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2018, 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
@ -41,14 +41,9 @@
AbstractDecoder* Decoder::_shared_decoder = NULL;
AbstractDecoder* Decoder::_error_handler_decoder = NULL;
NullDecoder Decoder::_do_nothing_decoder;
Mutex* Decoder::_shared_decoder_lock = new Mutex(Mutex::native,
"SharedDecoderLock",
false,
Monitor::_safepoint_check_never);
AbstractDecoder* Decoder::get_shared_instance() {
assert(_shared_decoder_lock != NULL && _shared_decoder_lock->owned_by_self(),
"Require DecoderLock to enter");
assert(shared_decoder_lock()->owned_by_self(), "Require DecoderLock to enter");
if (_shared_decoder == NULL) {
_shared_decoder = create_decoder();
@ -89,21 +84,22 @@ inline bool DecoderLocker::is_first_error_thread() {
DecoderLocker::DecoderLocker() :
MutexLockerEx(DecoderLocker::is_first_error_thread() ?
NULL : Decoder::shared_decoder_lock(), true) {
NULL : Decoder::shared_decoder_lock(),
Mutex::_no_safepoint_check_flag) {
_decoder = is_first_error_thread() ?
Decoder::get_error_handler_instance() : Decoder::get_shared_instance();
assert(_decoder != NULL, "null decoder");
}
Mutex* Decoder::shared_decoder_lock() {
assert(_shared_decoder_lock != NULL, "Just check");
return _shared_decoder_lock;
assert(SharedDecoder_lock != NULL, "Just check");
return SharedDecoder_lock;
}
bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const char* modulepath, bool demangle) {
assert(_shared_decoder_lock != NULL, "Just check");
bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid;
MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true);
MutexLockerEx locker(error_handling_thread ? NULL : shared_decoder_lock(),
Mutex::_no_safepoint_check_flag);
AbstractDecoder* decoder = error_handling_thread ?
get_error_handler_instance(): get_shared_instance();
assert(decoder != NULL, "null decoder");
@ -112,9 +108,9 @@ bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const cha
}
bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const void* base) {
assert(_shared_decoder_lock != NULL, "Just check");
bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid;
MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true);
MutexLockerEx locker(error_handling_thread ? NULL : shared_decoder_lock(),
Mutex::_no_safepoint_check_flag);
AbstractDecoder* decoder = error_handling_thread ?
get_error_handler_instance(): get_shared_instance();
assert(decoder != NULL, "null decoder");
@ -124,9 +120,9 @@ bool Decoder::decode(address addr, char* buf, int buflen, int* offset, const voi
bool Decoder::demangle(const char* symbol, char* buf, int buflen) {
assert(_shared_decoder_lock != NULL, "Just check");
bool error_handling_thread = os::current_thread_id() == VMError::first_error_tid;
MutexLockerEx locker(error_handling_thread ? NULL : _shared_decoder_lock, true);
MutexLockerEx locker(error_handling_thread ? NULL : shared_decoder_lock(),
Mutex::_no_safepoint_check_flag);
AbstractDecoder* decoder = error_handling_thread ?
get_error_handler_instance(): get_shared_instance();
assert(decoder != NULL, "null decoder");

View File

@ -131,7 +131,6 @@ private:
static NullDecoder _do_nothing_decoder;
protected:
static Mutex* _shared_decoder_lock;
static Mutex* shared_decoder_lock();
friend class DecoderLocker;