src/share/vm/runtime/mutex.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
*** old/src/share/vm/runtime/mutex.cpp Tue Dec 9 14:42:30 2014
--- new/src/share/vm/runtime/mutex.cpp Tue Dec 9 14:42:29 2014
*** 893,902 ****
--- 893,907 ----
// But of course the proper ultimate approach is to avoid schemes that require explicit
// sneaking or dependence on any any clever invariants or subtle implementation properties
// of Mutex-Monitor and instead directly address the underlying design flaw.
void Monitor::lock(Thread * Self) {
+ // Ensure that the Monitor requires/allows safepoint checks.
+ assert(this->_safepoint_check_required != Monitor::_safepoint_check_never,
+ err_msg("This lock should never have a safepoint check: %s",
+ this->name()));
+
#ifdef CHECK_UNHANDLED_OOPS
// Clear unhandled oops so we get a crash right away. Only clear for non-vm
// or GC threads.
if (Self->is_Java_thread()) {
Self->clear_unhandled_oops();
*** 951,960 ****
--- 956,969 ----
// Should ONLY be used by safepoint code and other code
// that is guaranteed not to block while running inside the VM. If this is called with
// thread state set to be in VM, the safepoint synchronization code will deadlock!
void Monitor::lock_without_safepoint_check(Thread * Self) {
+ // Ensure that the Monitor does not require or allow safepoint checks.
+ assert(this->_safepoint_check_required != Monitor::_safepoint_check_always,
+ err_msg("This lock should always have a safepoint check: %s",
+ this->name()));
assert(_owner != Self, "invariant");
ILock(Self);
assert(_owner == NULL, "invariant");
set_owner(Self);
}
*** 1080,1089 ****
--- 1089,1104 ----
IUnlock(false);
}
bool Monitor::wait(bool no_safepoint_check, long timeout,
bool as_suspend_equivalent) {
+ // Make sure safepoint checking is used properly.
+ assert(!(this->_safepoint_check_required == Monitor::_safepoint_check_never && no_safepoint_check == false),
+ err_msg("This lock should never have a safepoint check: %s", this->name()));
+ assert(!(this->_safepoint_check_required == Monitor::_safepoint_check_always && no_safepoint_check == true),
+ err_msg("This lock should always have a safepoint check: %s", this->name()));
+
Thread * const Self = Thread::current();
assert(_owner == Self, "invariant");
assert(ILocked(), "invariant");
// as_suspend_equivalent logically implies !no_safepoint_check
*** 1166,1192 ****
--- 1181,1211 ----
m->_WaitLock[0] = 0;
}
Monitor::Monitor() { ClearMonitor(this); }
! Monitor::Monitor(int Rank, const char * name, bool allow_vm_block) {
! Monitor::Monitor(int Rank, const char * name, bool allow_vm_block,
+ SafepointCheckRequired safepoint_check_required) {
ClearMonitor(this, name);
#ifdef ASSERT
_allow_vm_block = allow_vm_block;
_rank = Rank;
+ NOT_PRODUCT(_safepoint_check_required = safepoint_check_required;)
#endif
}
Mutex::~Mutex() {
assert((UNS(_owner)|UNS(_LockWord.FullWord)|UNS(_EntryList)|UNS(_WaitSet)|UNS(_OnDeck)) == 0, "");
}
! Mutex::Mutex(int Rank, const char * name, bool allow_vm_block) {
! Mutex::Mutex(int Rank, const char * name, bool allow_vm_block,
+ SafepointCheckRequired safepoint_check_required) {
ClearMonitor((Monitor *) this, name);
#ifdef ASSERT
_allow_vm_block = allow_vm_block;
_rank = Rank;
+ NOT_PRODUCT(_safepoint_check_required = safepoint_check_required;)
#endif
}
bool Monitor::owned_by_self() const {
bool ret = _owner == Thread::current();
src/share/vm/runtime/mutex.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File