8273915: Create 'nosafepoint' rank

Reviewed-by: dholmes, iklam
This commit is contained in:
Coleen Phillimore 2021-09-21 11:37:49 +00:00
parent 7acec3f161
commit 111d5e1a93
25 changed files with 90 additions and 76 deletions

View File

@ -133,7 +133,7 @@ void ClassLoaderData::initialize_name(Handle class_loader) {
ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool has_class_mirror_holder) :
_metaspace(NULL),
_metaspace_lock(new Mutex(Mutex::leaf-2, "MetaspaceAllocation_lock",
_metaspace_lock(new Mutex(Mutex::nosafepoint-2, "MetaspaceAllocation_lock",
Mutex::_safepoint_check_never)),
_unloading(false), _has_class_mirror_holder(has_class_mirror_holder),
_modified_oops(true),

View File

@ -40,8 +40,8 @@ void G1SentinelTask::execute() {
G1ServiceThread::G1ServiceThread() :
ConcurrentGCThread(),
_monitor(Mutex::leaf,
"G1ServiceThread monitor",
_monitor(Mutex::nosafepoint,
"G1ServiceThread_lock",
Monitor::_safepoint_check_never),
_task_queue() {
set_name("G1 Service");

View File

@ -92,7 +92,7 @@ void ParCompactionManager::initialize(ParMarkBitMap* mbm) {
_shadow_region_array = new (ResourceObj::C_HEAP, mtGC) GrowableArray<size_t >(10, mtGC);
_shadow_region_monitor = new Monitor(Mutex::barrier, "CompactionManager monitor",
_shadow_region_monitor = new Monitor(Mutex::nosafepoint, "CompactionManager_lock",
Monitor::_safepoint_check_never);
}

View File

@ -72,7 +72,7 @@ TaskTerminator::TaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set) :
_n_threads(n_threads),
_queue_set(queue_set),
_offered_termination(0),
_blocker(Mutex::leaf, "TaskTerminator", Monitor::_safepoint_check_never),
_blocker(Mutex::nosafepoint, "TaskTerminator_lock", Monitor::_safepoint_check_never),
_spin_master(NULL) { }
TaskTerminator::~TaskTerminator() {

View File

@ -245,7 +245,7 @@ void GangWorker::loop() {
// *** WorkGangBarrierSync
WorkGangBarrierSync::WorkGangBarrierSync()
: _monitor(Mutex::safepoint, "work gang barrier sync",
: _monitor(Mutex::nosafepoint, "WorkGangBarrierSync_lock",
Monitor::_safepoint_check_never),
_n_workers(0), _n_completed(0), _should_reset(false), _aborted(false) {
}

View File

@ -66,8 +66,8 @@ public:
template <typename T>
inline ZMessagePort<T>::ZMessagePort() :
_monitor(Monitor::leaf,
"ZMessagePort",
_monitor(Monitor::nosafepoint,
"ZMessagePort_lock",
Monitor::_safepoint_check_never),
_has_message(false),
_seqnum(0),

View File

@ -28,7 +28,7 @@
#include "utilities/ticks.hpp"
ZMetronome::ZMetronome(uint64_t hz) :
_monitor(Monitor::leaf, "ZMetronome", Monitor::_safepoint_check_never),
_monitor(Monitor::nosafepoint, "ZMetronome_lock", Monitor::_safepoint_check_never),
_interval_ms(MILLIUNITS / hz),
_start_ms(0),
_nticks(0),

View File

@ -245,7 +245,7 @@ class ParHeapInspectTask : public AbstractGangTask {
_filter(filter),
_missed_count(0),
_success(true),
_mutex(Mutex::leaf, "ParHeapInspectTask_lock", Mutex::_safepoint_check_never) {}
_mutex(Mutex::nosafepoint, "ParHeapInspectTask_lock", Mutex::_safepoint_check_never) {}
uintx missed_count() const {
return _missed_count;

View File

@ -92,7 +92,7 @@ MetaspaceTestContext::~MetaspaceTestContext() {
// Create an arena, feeding off this area.
MetaspaceTestArena* MetaspaceTestContext::create_arena(Metaspace::MetaspaceType type) {
const ArenaGrowthPolicy* growth_policy = ArenaGrowthPolicy::policy_for_space_type(type, false);
Mutex* lock = new Mutex(Monitor::leaf, "MetaspaceTestArea-lock", Monitor::_safepoint_check_never);
Mutex* lock = new Mutex(Monitor::nosafepoint, "MetaspaceTestArea_lock", Monitor::_safepoint_check_never);
MetaspaceArena* arena = NULL;
{
MutexLocker ml(lock, Mutex::_no_safepoint_check_flag);

View File

@ -72,7 +72,7 @@ bool JvmtiTagMap::_has_object_free_events = false;
// create a JvmtiTagMap
JvmtiTagMap::JvmtiTagMap(JvmtiEnv* env) :
_env(env),
_lock(Mutex::leaf, "JvmtiTagMap_lock", Mutex::_safepoint_check_never),
_lock(Mutex::nosafepoint, "JvmtiTagMap_lock", Mutex::_safepoint_check_never),
_needs_rehashing(false),
_needs_cleaning(false) {

View File

@ -408,7 +408,7 @@ void Handshake::execute(AsyncHandshakeClosure* hs_cl, JavaThread* target) {
HandshakeState::HandshakeState(JavaThread* target) :
_handshakee(target),
_queue(),
_lock(Monitor::leaf, "HandshakeState", Monitor::_safepoint_check_never),
_lock(Monitor::nosafepoint, "HandshakeState_lock", Monitor::_safepoint_check_never),
_active_handshaker(),
_suspended(false),
_async_suspend_handshake(false)

View File

@ -98,7 +98,7 @@ void Mutex::lock_contended(Thread* self) {
// Is it a JavaThread participating in the safepoint protocol.
if (is_active_Java_thread) {
InFlightMutexRelease ifmr(this);
assert(rank() > Mutex::special, "Potential deadlock with special or lesser rank mutex");
assert(rank() > Mutex::nosafepoint, "Potential deadlock with nosafepoint or lesser rank mutex");
{
ThreadBlockInVMPreprocess<InFlightMutexRelease> tbivmdc(JavaThread::cast(self), ifmr);
_lock.lock();
@ -285,11 +285,11 @@ Mutex::Mutex(int Rank, const char * name, SafepointCheckRequired safepoint_check
_safepoint_check_required = safepoint_check_required;
_skip_rank_check = false;
assert(_rank < nonleaf || _safepoint_check_required == _safepoint_check_always,
"higher than nonleaf should safepoint %s", name);
assert(_rank > nosafepoint || _safepoint_check_required == _safepoint_check_never,
"Locks below nosafepoint rank should never safepoint: %s", name);
assert(_rank > special || _safepoint_check_required == _safepoint_check_never,
"Special locks or below should never safepoint: %s", name);
assert(_rank <= nosafepoint || _safepoint_check_required == _safepoint_check_always,
"Locks above nosafepoint rank should safepoint: %s", name);
// The allow_vm_block also includes allowing other non-Java threads to block or
// allowing Java threads to block in native.
@ -384,13 +384,14 @@ void Mutex::check_rank(Thread* thread) {
if (owned_by_self()) {
// wait() case
Mutex* least = get_least_ranked_lock_besides_this(locks_owned);
// We enforce not holding locks of rank special or lower while waiting.
// We enforce not holding locks of rank nosafepoint or lower while waiting.
// Also "this" should be the monitor with lowest rank owned by this thread.
if (least != NULL && (least->rank() <= special || least->rank() <= this->rank())) {
if (least != NULL && (least->rank() <= nosafepoint || least->rank() <= this->rank())) {
assert(false, "Attempting to wait on monitor %s/%d while holding lock %s/%d -- "
"possible deadlock. %s", name(), rank(), least->name(), least->rank(),
least->rank() <= this->rank() ? "Should wait on the least ranked monitor from "
"all owned locks." : "Should not block(wait) while holding a lock of rank special.");
least->rank() <= this->rank() ?
"Should wait on the least ranked monitor from all owned locks." :
"Should not block(wait) while holding a lock of rank nosafepoint or below.");
}
} else {
// lock()/lock_without_safepoint_check()/try_lock() case

View File

@ -39,20 +39,23 @@
// The underlying PlatformMutex may support recursive locking but this is not exposed
// and we account for that possibility in try_lock.
// A thread is not allowed to safepoint while holding a mutex whose rank
// is nosafepoint or lower.
class Mutex : public CHeapObj<mtSynchronizer> {
public:
// Special low level locks are given names and ranges avoid overlap.
enum lock_types {
enum Rank {
event,
service = event + 6,
stackwatermark = service + 3,
tty = stackwatermark + 3,
special = tty + 3,
oopstorage = special + 3,
leaf = oopstorage + 10,
safepoint = leaf + 10,
barrier = safepoint + 1,
nosafepoint = oopstorage + 6,
leaf = nosafepoint + 6,
barrier = leaf + 10,
nonleaf = barrier + 1,
max_nonleaf = nonleaf + 900
};

View File

@ -204,33 +204,33 @@ void assert_locked_or_safepoint_or_handshake(const Mutex* lock, const JavaThread
void mutex_init() {
def(tty_lock , PaddedMutex , tty, true, _safepoint_check_never); // allow to lock in VM
def(STS_lock , PaddedMonitor, leaf, true, _safepoint_check_never);
def(STS_lock , PaddedMonitor, nosafepoint, true, _safepoint_check_never);
if (UseG1GC) {
def(CGC_lock , PaddedMonitor, leaf, true, _safepoint_check_never);
def(CGC_lock , PaddedMonitor, nosafepoint, true, _safepoint_check_never);
def(G1OldGCCount_lock , PaddedMonitor, leaf, true, _safepoint_check_always);
def(G1DetachedRefinementStats_lock, PaddedMutex, leaf-2, true, _safepoint_check_never);
def(G1DetachedRefinementStats_lock, PaddedMutex, nosafepoint-2, true, _safepoint_check_never);
def(FreeList_lock , PaddedMutex , service-1, true, _safepoint_check_never);
def(OldSets_lock , PaddedMutex , leaf, true, _safepoint_check_never);
def(OldSets_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never);
def(Uncommit_lock , PaddedMutex , service-2, true, _safepoint_check_never);
def(RootRegionScan_lock , PaddedMonitor, leaf-1, true, _safepoint_check_never);
def(RootRegionScan_lock , PaddedMonitor, nosafepoint-1, true, _safepoint_check_never);
def(MarkStackFreeList_lock , PaddedMutex , leaf , true, _safepoint_check_never);
def(MarkStackChunkList_lock , PaddedMutex , leaf , true, _safepoint_check_never);
def(MarkStackFreeList_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never);
def(MarkStackChunkList_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never);
def(MonitoringSupport_lock , PaddedMutex , service-1, true, _safepoint_check_never); // used for serviceability monitoring support
}
def(StringDedup_lock , PaddedMonitor, leaf, true, _safepoint_check_never);
def(StringDedupIntern_lock , PaddedMutex , leaf, true, _safepoint_check_never);
def(StringDedup_lock , PaddedMonitor, nosafepoint, true, _safepoint_check_never);
def(StringDedupIntern_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never);
def(ParGCRareEvent_lock , PaddedMutex , leaf, true, _safepoint_check_always);
def(CodeCache_lock , PaddedMonitor, special, true, _safepoint_check_never);
def(CodeSweeper_lock , PaddedMonitor, special-2, true, _safepoint_check_never);
def(RawMonitor_lock , PaddedMutex , special, true, _safepoint_check_never);
def(OopMapCacheAlloc_lock , PaddedMutex , leaf, true, _safepoint_check_always); // used for oop_map_cache allocation.
def(Metaspace_lock , PaddedMutex , leaf-3, true, _safepoint_check_never);
def(Metaspace_lock , PaddedMutex , nosafepoint-3, true, _safepoint_check_never);
def(ClassLoaderDataGraph_lock , PaddedMutex , nonleaf, false, _safepoint_check_always);
def(Patching_lock , PaddedMutex , special, true, _safepoint_check_never); // used for safepointing and code patching.
@ -250,12 +250,12 @@ void mutex_init() {
def(SharedDictionary_lock , PaddedMutex , leaf, true, _safepoint_check_always);
def(ClassInitError_lock , PaddedMonitor, leaf+1, true, _safepoint_check_always);
def(Module_lock , PaddedMutex , leaf+2, false, _safepoint_check_always);
def(InlineCacheBuffer_lock , PaddedMutex , leaf, true, _safepoint_check_never);
def(InlineCacheBuffer_lock , PaddedMutex , nosafepoint-1, true, _safepoint_check_never);
def(VMStatistic_lock , PaddedMutex , leaf, false, _safepoint_check_always);
def(ExpandHeap_lock , PaddedMutex , leaf, true, _safepoint_check_always); // Used during compilation by VM thread
def(JNIHandleBlockFreeList_lock , PaddedMutex , leaf-1, true, _safepoint_check_never); // handles are used by VM thread
def(JNIHandleBlockFreeList_lock , PaddedMutex , nosafepoint-1, true, _safepoint_check_never); // handles are used by VM thread
def(SignatureHandlerLibrary_lock , PaddedMutex , leaf, false, _safepoint_check_always);
def(SymbolArena_lock , PaddedMutex , leaf+2, true, _safepoint_check_never);
def(SymbolArena_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never);
def(ExceptionCache_lock , PaddedMutex , leaf, false, _safepoint_check_always);
#ifndef PRODUCT
def(FullGCALot_lock , PaddedMutex , leaf, false, _safepoint_check_always); // a lock to make FullGCALot MT safe
@ -265,14 +265,14 @@ void mutex_init() {
def(PerfDataManager_lock , PaddedMutex , leaf, true, _safepoint_check_always); // used for synchronized access to PerfDataManager resources
def(Threads_lock , PaddedMonitor, barrier, true, _safepoint_check_always); // Used for safepoint protocol.
def(NonJavaThreadsList_lock , PaddedMutex, leaf-1, true, _safepoint_check_never);
def(NonJavaThreadsListSync_lock , PaddedMutex, leaf, true, _safepoint_check_never);
def(NonJavaThreadsList_lock , PaddedMutex, nosafepoint-1, true, _safepoint_check_never);
def(NonJavaThreadsListSync_lock , PaddedMutex, nosafepoint, true, _safepoint_check_never);
def(VMOperation_lock , PaddedMonitor, nonleaf, true, _safepoint_check_always); // VM_thread allowed to block on these
def(RetData_lock , PaddedMutex , nonleaf, false, _safepoint_check_always);
def(Terminator_lock , PaddedMonitor, nonleaf, true, _safepoint_check_always);
def(InitCompleted_lock , PaddedMonitor, leaf, true, _safepoint_check_never);
def(VtableStubs_lock , PaddedMutex , leaf-2, true, _safepoint_check_never);
def(InitCompleted_lock , PaddedMonitor, nosafepoint, true, _safepoint_check_never);
def(VtableStubs_lock , PaddedMutex , nosafepoint-2, true, _safepoint_check_never);
def(Notify_lock , PaddedMonitor, nonleaf, true, _safepoint_check_always);
def(JNICritical_lock , PaddedMonitor, nonleaf, true, _safepoint_check_always); // used for JNI critical regions
def(AdapterHandlerLibrary_lock , PaddedMutex , nonleaf, true, _safepoint_check_always);
@ -280,14 +280,14 @@ void mutex_init() {
def(Heap_lock , PaddedMonitor, nonleaf+1, false, _safepoint_check_always); // Doesn't safepoint check during termination.
def(JfieldIdCreation_lock , PaddedMutex , nonleaf+1, true, _safepoint_check_always); // jfieldID, Used in VM_Operation
def(CompiledIC_lock , PaddedMutex , leaf+2, true, _safepoint_check_never); // locks VtableStubs_lock, InlineCacheBuffer_lock
def(CompiledIC_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never); // locks VtableStubs_lock, InlineCacheBuffer_lock
def(CompileTaskAlloc_lock , PaddedMutex , nonleaf+2, true, _safepoint_check_always);
def(CompileStatistics_lock , PaddedMutex , nonleaf+2, false, _safepoint_check_always);
def(DirectivesStack_lock , PaddedMutex , special, true, _safepoint_check_never);
def(MultiArray_lock , PaddedMutex , nonleaf+2, false, _safepoint_check_always);
def(JvmtiThreadState_lock , PaddedMutex , nonleaf+2, false, _safepoint_check_always); // Used by JvmtiThreadState/JvmtiEventController
def(EscapeBarrier_lock , PaddedMonitor, leaf, true, _safepoint_check_never); // Used to synchronize object reallocation/relocking triggered by JVMTI
def(EscapeBarrier_lock , PaddedMonitor, nosafepoint, true, _safepoint_check_never); // Used to synchronize object reallocation/relocking triggered by JVMTI
def(Management_lock , PaddedMutex , nonleaf+2, false, _safepoint_check_always); // used for JVM management
def(ConcurrentGCBreakpoints_lock , PaddedMonitor, nonleaf, true, _safepoint_check_always);
@ -300,17 +300,17 @@ void mutex_init() {
def(PeriodicTask_lock , PaddedMonitor, nonleaf+5, true, _safepoint_check_always);
def(RedefineClasses_lock , PaddedMonitor, nonleaf+5, true, _safepoint_check_always);
def(Verify_lock , PaddedMutex, nonleaf+5, true, _safepoint_check_always);
def(Zip_lock , PaddedMonitor, leaf-2, true, _safepoint_check_never);
def(Zip_lock , PaddedMonitor, nosafepoint-2, true, _safepoint_check_never);
if (WhiteBoxAPI) {
def(Compilation_lock , PaddedMonitor, leaf, true, _safepoint_check_never);
def(Compilation_lock , PaddedMonitor, nosafepoint, true, _safepoint_check_never);
}
#if INCLUDE_JFR
def(JfrMsg_lock , PaddedMonitor, leaf, true, _safepoint_check_always);
def(JfrBuffer_lock , PaddedMutex , leaf, true, _safepoint_check_never);
def(JfrBuffer_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never);
def(JfrStacktrace_lock , PaddedMutex , stackwatermark-1, true, _safepoint_check_never);
def(JfrThreadSampler_lock , PaddedMonitor, leaf, true, _safepoint_check_never);
def(JfrThreadSampler_lock , PaddedMonitor, nosafepoint, true, _safepoint_check_never);
#endif
#ifndef SUPPORTS_NATIVE_CX8
@ -322,7 +322,7 @@ void mutex_init() {
def(ThreadsSMRDelete_lock , PaddedMonitor, special, true, _safepoint_check_never);
def(ThreadIdTableCreate_lock , PaddedMutex , leaf, false, _safepoint_check_always);
def(SharedDecoder_lock , PaddedMutex , tty-1, true, _safepoint_check_never);
def(DCmdFactory_lock , PaddedMutex , leaf, true, _safepoint_check_never);
def(DCmdFactory_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never);
#if INCLUDE_NMT
def(NMTQuery_lock , PaddedMutex , max_nonleaf, false, _safepoint_check_always);
#endif
@ -330,13 +330,13 @@ void mutex_init() {
#if INCLUDE_JVMTI
def(CDSClassFileStream_lock , PaddedMutex , max_nonleaf, false, _safepoint_check_always);
#endif
def(DumpTimeTable_lock , PaddedMutex , leaf-1, true, _safepoint_check_never);
def(CDSLambda_lock , PaddedMutex , leaf, true, _safepoint_check_never);
def(DumpRegion_lock , PaddedMutex , leaf, true, _safepoint_check_never);
def(ClassListFile_lock , PaddedMutex , leaf, true, _safepoint_check_never);
def(DumpTimeTable_lock , PaddedMutex , nosafepoint-1, true, _safepoint_check_never);
def(CDSLambda_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never);
def(DumpRegion_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never);
def(ClassListFile_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never);
def(LambdaFormInvokers_lock , PaddedMutex , nonleaf+2, false, _safepoint_check_always);
#endif // INCLUDE_CDS
def(Bootclasspath_lock , PaddedMutex , leaf, true, _safepoint_check_never);
def(Bootclasspath_lock , PaddedMutex , nosafepoint, true, _safepoint_check_never);
#if INCLUDE_JVMCI
def(JVMCI_lock , PaddedMonitor, nonleaf+2, true, _safepoint_check_always);

View File

@ -368,7 +368,7 @@ int VM_Exit::wait_for_threads_in_native_to_block() {
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint already");
Thread * thr_cur = Thread::current();
Monitor timer(Mutex::leaf, "VM_Exit timer", Monitor::_safepoint_check_never);
Monitor timer(Mutex::nosafepoint, "VM_ExitTimer_lock", Monitor::_safepoint_check_never);
// Compiler threads need longer wait because they can access VM data directly
// while in native. If they are active and some structures being used are

View File

@ -128,7 +128,7 @@ void VMThread::create() {
assert(_timeout_task == NULL, "sanity");
}
_terminate_lock = new Monitor(Mutex::safepoint, "VMThread::_terminate_lock",
_terminate_lock = new Monitor(Mutex::nosafepoint, "VMThreadTerminate_lock",
Monitor::_safepoint_check_never);
if (UsePerfData) {

View File

@ -200,7 +200,7 @@ CompressionBackend::CompressionBackend(AbstractWriter* writer,
_written(0),
_writer(writer),
_compressor(compressor),
_lock(new (std::nothrow) PaddedMonitor(Mutex::leaf, "HProf Compression Backend",
_lock(new (std::nothrow) PaddedMonitor(Mutex::nosafepoint, "HProfCompressionBackend_lock",
Mutex::_safepoint_check_never)) {
if (_writer == NULL) {
set_error("Could not allocate writer");

View File

@ -174,7 +174,7 @@ GCMemoryManager::GCMemoryManager(const char* name, const char* gc_end_message) :
MemoryManager(name), _gc_end_message(gc_end_message) {
_num_collections = 0;
_last_gc_stat = NULL;
_last_gc_lock = new Mutex(Mutex::leaf, "_last_gc_lock",
_last_gc_lock = new Mutex(Mutex::nosafepoint, "GCMemoryManager_lock",
Mutex::_safepoint_check_never);
_current_gc_stat = NULL;
_num_gc_threads = 1;

View File

@ -1014,7 +1014,7 @@ inline ConcurrentHashTable<CONFIG, F>::
{
_stats_rate = TableRateStatistics();
_resize_lock =
new Mutex(Mutex::leaf-2, "ConcurrentHashTableResize_lock",
new Mutex(Mutex::nosafepoint-2, "ConcurrentHashTableResize_lock",
Mutex::_safepoint_check_never);
_table = new InternalTable(log2size);
assert(log2size_limit >= log2size, "bad ergo");

View File

@ -49,7 +49,7 @@ public:
}
void do_test(Metaspace::MetadataType mdType) {
_lock = new Mutex(Monitor::leaf, "gtest-IsMetaspaceObjTest-lock", Monitor::_safepoint_check_never);
_lock = new Mutex(Monitor::nosafepoint, "gtest-IsMetaspaceObjTest_lock", Monitor::_safepoint_check_never);
{
MutexLocker ml(_lock, Mutex::_no_safepoint_check_flag);
_ms = new ClassLoaderMetaspace(_lock, Metaspace::StandardMetaspaceType);

View File

@ -66,7 +66,7 @@ class MetaspaceArenaTestHelper {
void initialize(const ArenaGrowthPolicy* growth_policy, const char* name = "gtest-MetaspaceArena") {
_growth_policy = growth_policy;
_lock = new Mutex(Monitor::leaf, "gtest-MetaspaceArenaTest-lock", Monitor::_safepoint_check_never);
_lock = new Mutex(Monitor::nosafepoint, "gtest-MetaspaceArenaTest_lock", Monitor::_safepoint_check_never);
// Lock during space creation, since this is what happens in the VM too
// (see ClassLoaderData::metaspace_non_null(), which we mimick here).
{

View File

@ -142,7 +142,7 @@ public:
_alloc_count(),
_dealloc_count()
{
_lock = new Mutex(Monitor::leaf, "gtest-MetaspaceArenaTestBed-lock", Monitor::_safepoint_check_never);
_lock = new Mutex(Monitor::nosafepoint, "gtest-MetaspaceArenaTestBed_lock", Monitor::_safepoint_check_never);
// Lock during space creation, since this is what happens in the VM too
// (see ClassLoaderData::metaspace_non_null(), which we mimick here).
MutexLocker ml(_lock, Mutex::_no_safepoint_check_flag);

View File

@ -35,7 +35,7 @@ static Mutex* m[iterations];
static int i = 0;
static void create_mutex(Thread* thr) {
m[i] = new Mutex(Mutex::leaf, FormatBuffer<128>("MyLock lock #%u", i), Mutex::_safepoint_check_never);
m[i] = new Mutex(Mutex::nosafepoint, FormatBuffer<128>("MyLock#%u_lock", i), Mutex::_safepoint_check_never);
i++;
}
@ -46,7 +46,7 @@ TEST_VM(MutexName, mutex_name) {
nomt_test_doer(create_mutex);
}
for (int i = 0; i < iterations; i++) {
FormatBuffer<128> f("MyLock lock #%u", i);
FormatBuffer<128> f("MyLock#%u_lock", i);
ASSERT_STREQ(m[i]->name(), f.buffer()) << "Wrong name!";
}
}
@ -128,18 +128,18 @@ TEST_VM_ASSERT_MSG(MutexRank, mutex_trylock_rank_out_of_orderB,
mutex_rankA->unlock();
}
TEST_VM_ASSERT_MSG(MutexRank, mutex_lock_event_leaf,
".* Attempting to acquire lock mutex_rank_leaf/.* out of order with lock mutex_rank_event/0 "
TEST_VM_ASSERT_MSG(MutexRank, mutex_lock_event_nosafepoint,
".* Attempting to acquire lock mutex_rank_nosafepoint/.* out of order with lock mutex_rank_event/0 "
"-- possible deadlock") {
JavaThread* THREAD = JavaThread::current();
ThreadInVMfromNative invm(THREAD);
Mutex* mutex_rank_event = new Mutex(Mutex::event, "mutex_rank_event", Mutex::_safepoint_check_never);
Mutex* mutex_rank_leaf = new Mutex(Mutex::leaf, "mutex_rank_leaf", Mutex::_safepoint_check_never);
Mutex* mutex_rank_nonleaf = new Mutex(Mutex::nosafepoint, "mutex_rank_nosafepoint", Mutex::_safepoint_check_never);
mutex_rank_event->lock_without_safepoint_check();
mutex_rank_leaf->lock_without_safepoint_check();
mutex_rank_leaf->unlock();
mutex_rank_nonleaf->lock_without_safepoint_check();
mutex_rank_nonleaf->unlock();
mutex_rank_event->unlock();
}
@ -206,7 +206,7 @@ TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_rank_out_of_order_trylock,
TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_rank_special,
".* Attempting to wait on monitor monitor_rank_special_minus_one/.* while holding lock monitor_rank_special/.*"
"-- possible deadlock. Should not block\\(wait\\) while holding a lock of rank special.") {
"-- possible deadlock. Should not block\\(wait\\) while holding a lock of rank nosafepoint or below.") {
JavaThread* THREAD = JavaThread::current();
ThreadInVMfromNative invm(THREAD);
@ -222,7 +222,7 @@ TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_rank_special,
TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_event_tty,
".* Attempting to wait on monitor monitor_rank_event/0 while holding lock monitor_rank_tty/.*"
"-- possible deadlock. Should not block\\(wait\\) while holding a lock of rank special.") {
"-- possible deadlock. Should not block\\(wait\\) while holding a lock of rank nosafepoint or below.") {
JavaThread* THREAD = JavaThread::current();
ThreadInVMfromNative invm(THREAD);
@ -238,7 +238,7 @@ TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_event_tty,
TEST_VM_ASSERT_MSG(MutexRank, monitor_wait_tty_special,
".* Attempting to wait on monitor monitor_rank_tty/.* while holding lock monitor_rank_special/.*"
"-- possible deadlock. Should not block\\(wait\\) while holding a lock of rank special.") {
"-- possible deadlock. Should not block\\(wait\\) while holding a lock of rank nosafepoint or below.") {
JavaThread* THREAD = JavaThread::current();
ThreadInVMfromNative invm(THREAD);
@ -271,4 +271,14 @@ TEST_VM_ASSERT_MSG(MutexRank, monitor_negative_rank,
monitor_rank_broken->lock_without_safepoint_check();
monitor_rank_broken->unlock();
}
TEST_VM_ASSERT_MSG(MutexRank, monitor_nosafepoint_rank,
".*failed: Locks above nosafepoint rank should safepoint: monitor_rank_leaf") {
JavaThread* THREAD = JavaThread::current();
ThreadInVMfromNative invm(THREAD);
Monitor* monitor_rank_leaf = new Monitor(Mutex::leaf, "monitor_rank_leaf", Mutex::_safepoint_check_never);
monitor_rank_leaf->lock_without_safepoint_check();
monitor_rank_leaf->unlock();
}
#endif // ASSERT

View File

@ -38,12 +38,12 @@ TEST_VM_ASSERT_MSG(SafepointLockAssertTest, always_check,
TEST_VM_ASSERT_MSG(SafepointLockAssertTest, never_check,
".*This lock should never have a safepoint check for Java threads: SFPT_Test_lock") {
MutexLocker ml(new Mutex(Mutex::leaf, "SFPT_Test_lock", Mutex::_safepoint_check_never),
MutexLocker ml(new Mutex(Mutex::nosafepoint, "SFPT_Test_lock", Mutex::_safepoint_check_never),
Mutex::_safepoint_check_flag);
}
TEST_VM_ASSERT_MSG(SafepointLockAssertTest, special_locks,
".*Special locks or below should never safepoint") {
".*Locks below nosafepoint rank should never safepoint: SpecialTest_lock") {
MutexLocker ml(new Mutex(Mutex::special, "SpecialTest_lock", Mutex::_safepoint_check_always),
Mutex::_safepoint_check_flag);
}

View File

@ -196,7 +196,7 @@ public:
TEST_VM(FilterQueue, stress) {
FilterQueue<uintptr_t> queue;
Mutex lock(Mutex::leaf, "Test Lock", Mutex::_safepoint_check_never);
Mutex lock(Mutex::nosafepoint, "Test_lock", Mutex::_safepoint_check_never);
static const int nthreads = 4;
Semaphore post;
FilterQueueTestThread* threads[nthreads] = {};