/* * Copyright (c) 1997, 2022, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
// Mutexes used in the VM (see comment in mutexLocker.hpp): // // Note that the following pointers are effectively final -- after having been // set at JVM startup-time, they should never be subsequently mutated. // Instead of using pointers to malloc()ed monitors and mutexes we should consider // eliminating the indirection and using instances instead. // Consider using GCC's __read_mostly.
#ifdef ASSERT void assert_locked_or_safepoint(const Mutex* lock) { // check if this thread owns the lock (common case)
assert(lock != NULL, "Need non-NULL lock"); if (lock->owned_by_self()) return; if (SafepointSynchronize::is_at_safepoint()) return; if (!Universe::is_fully_initialized()) return;
fatal("must own lock %s", lock->name());
}
// a weaker assertion than the above void assert_locked_or_safepoint_weak(const Mutex* lock) {
assert(lock != NULL, "Need non-NULL lock"); if (lock->is_locked()) return; if (SafepointSynchronize::is_at_safepoint()) return; if (!Universe::is_fully_initialized()) return;
fatal("must own lock %s", lock->name());
}
// a stronger assertion than the above void assert_lock_strong(const Mutex* lock) {
assert(lock != NULL, "Need non-NULL lock"); if (lock->owned_by_self()) return;
fatal("must own lock %s", lock->name());
} #endif
// Using Padded subclasses to prevent false sharing of these global monitors and mutexes. void mutex_init() {
def(tty_lock , PaddedMutex , tty); // allow to lock in VM
def(STS_lock , PaddedMonitor, nosafepoint);
if (UseG1GC) {
def(CGC_lock , PaddedMonitor, nosafepoint);
def(Patching_lock , PaddedMutex , nosafepoint); // used for safepointing and code patching.
def(MonitorDeflation_lock , PaddedMonitor, nosafepoint); // used for monitor deflation thread operations
def(Service_lock , PaddedMonitor, service); // used for service thread operations
if (UseNotificationThread) {
def(Notification_lock , PaddedMonitor, service); // used for notification thread operations
} else {
Notification_lock = Service_lock;
}
def(JvmtiThreadState_lock , PaddedMutex , safepoint); // Used by JvmtiThreadState/JvmtiEventController
def(EscapeBarrier_lock , PaddedMonitor, nosafepoint); // Used to synchronize object reallocation/relocking triggered by JVMTI
def(JvmtiVTMSTransition_lock , PaddedMonitor, nosafepoint); // used for Virtual Thread Mount State transition management
def(Management_lock , PaddedMutex , safepoint); // used for JVM management
#if INCLUDE_JVMCI // JVMCIRuntime::_lock must be acquired before JVMCI_lock to avoid deadlock
def(JVMCIRuntime_lock , PaddedMonitor, safepoint, true); #endif
// These locks have relative rankings, and inherit safepoint checking attributes from that rank.
defl(InlineCacheBuffer_lock , PaddedMutex , CompiledIC_lock);
defl(VtableStubs_lock , PaddedMutex , CompiledIC_lock); // Also holds DumpTimeTable_lock
defl(CodeCache_lock , PaddedMonitor, VtableStubs_lock);
defl(CompiledMethod_lock , PaddedMutex , CodeCache_lock);
// Print all mutexes/monitors that are currently owned by a thread; called // by fatal error handler. void print_owned_locks_on_error(outputStream* st) {
st->print("VM Mutex/Monitor currently owned by a thread: "); bool none = true; for (int i = 0; i < _num_mutex; i++) { // see if it has an owner if (_mutex_array[i]->owner() != NULL) { if (none) { // print format used by Mutex::print_on_error()
st->print_cr(" ([mutex/lock_event])");
none = false;
}
_mutex_array[i]->print_on_error(st);
st->cr();
}
} if (none) st->print_cr("None");
}
#ifdef ASSERT // Be extra defensive and figure out the bounds on // ranks right here. This also saves a bit of time // in the #ranks*#mutexes loop below. int min_rank = INT_MAX; int max_rank = INT_MIN; for (int i = 0; i < _num_mutex; i++) {
Mutex* m = _mutex_array[i]; int r = (int) m->rank(); if (min_rank > r) min_rank = r; if (max_rank < r) max_rank = r;
}
// Print the listings rank by rank for (int r = min_rank; r <= max_rank; r++) { bool first = true; for (int i = 0; i < _num_mutex; i++) {
Mutex* m = _mutex_array[i]; if (r != (int) m->rank()) continue;
if (first) {
st->cr();
st->print_cr("Rank \"%s\":", m->rank_name());
first = false;
}
st->print_cr(" %s", m->name());
}
} #else
st->print_cr(" Only known in debug builds."); #endif// ASSERT
}
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.