/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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.
*
*/
#ifndef SHARE_VM_RUNTIME_MUTEXLOCKER_HPP
#define SHARE_VM_RUNTIME_MUTEXLOCKER_HPP
#include "memory/allocation.hpp"
#ifdef TARGET_OS_FAMILY_linux
# include "os_linux.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_solaris
# include "os_solaris.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_windows
# include "os_windows.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_bsd
# include "os_bsd.inline.hpp"
#endif
// Mutexes used in the VM.
extern Monitor* JNICritical_lock; // a lock used while entering and exiting JNI critical regions, allows GC to sometimes get in
extern Monitor* VMOperationRequest_lock; // a lock on Threads waiting for a vm_operation to terminate
// (also used by Safepoints too to block threads creation/destruction)
// fore- & background GC threads.
// buffer free list.
// completed buffer queue.
// queue shared by
// non-Java threads.
// buffer free list.
// completed buffer queue.
// queue shared by
// non-Java threads.
// (see option ExplicitGCInvokesConcurrent)
extern Mutex* Compile_lock; // a lock held when Compilation is updating code (used to block CodeCache traversal, CHA updates, etc)
extern Monitor* MethodCompileQueue_lock; // a lock held when method compilations are enqueued, dequeued
extern Monitor* CompileThread_lock; // a lock held by compile threads during compilation system initialization
#ifndef PRODUCT
#endif // PRODUCT
extern Mutex* Debug3_lock;
extern Mutex* RawMonitor_lock;
extern Mutex* PerfDataMemAlloc_lock; // a lock on the allocator for PerfData memory for performance data
extern Mutex* ParkerFreeList_lock;
extern Monitor* RootRegionScan_lock; // used to notify that the CM threads have finished scanning the IM snapshot regions
// tracker data structures
// A MutexLocker provides mutual exclusion with respect to a given mutex
// for the scope which contains the locker. The lock is an OS lock, not
// an object lock, and the two do not interoperate. Do not use Mutex-based
// locks to lock on Java objects, because they will not be respected if a
// that object is locked using the Java locking mechanism.
//
// NOTE WELL!!
//
// See orderAccess.hpp. We assume throughout the VM that MutexLocker's
// and friends constructors do a fence, a lock and an acquire *in that
// order*. And that their destructors do a release and unlock, in *that*
// order. If their implementations change such that these assumptions
// are violated, a whole lot of code will break.
// by fatal error handler.
private:
public:
"Special ranked mutex should only use MutexLockerEx");
}
// Overloaded constructor passing current thread
"Special ranked mutex should only use MutexLockerEx");
}
~MutexLocker() {
}
};
// for debugging: check that we're already owning this lock (or are at a safepoint)
#ifdef ASSERT
#else
#endif
// A MutexLockerEx behaves like a MutexLocker when its constructor is
// called with a Mutex. Unlike a MutexLocker, its constructor can also be
// called with NULL, in which case the MutexLockerEx is a no-op. There
// is also a corresponding MutexUnlockerEx. We want to keep the
// basic MutexLocker as fast as possible. MutexLockerEx can also lock
// without safepoint check.
private:
public:
"Mutexes with rank special or lower should not do safepoint checks");
if (no_safepoint_check)
else
}
}
~MutexLockerEx() {
}
}
};
// A MonitorLockerEx is like a MutexLockerEx above, except it takes
// delegated to the underlying Monitor.
private:
public:
// Superclass constructor did locking
}
~MonitorLockerEx() {
#ifdef ASSERT
}
#endif // ASSERT
// Superclass destructor will do unlocking
}
long timeout = 0,
}
return false;
}
bool notify_all() {
return _monitor->notify_all();
}
return true;
}
bool notify() {
}
return true;
}
};
// A GCMutexLocker is usually initialized with a mutex that is
// automatically acquired in order to do GC. The function that
// synchronizes using a GCMutexLocker may be called both during and between
// GC's. Thus, it must acquire the mutex if GC is not in progress, but not
// if GC is in progress (since the mutex is already held on its behalf.)
private:
bool _locked;
public:
};
// A MutexUnlocker temporarily exits a previously
// entered mutex for the scope which contains the unlocker.
private:
public:
}
~MutexUnlocker() {
}
};
// A MutexUnlockerEx temporarily exits a previously
// entered mutex for the scope which contains the unlocker.
private:
bool _no_safepoint_check;
public:
}
~MutexUnlockerEx() {
} else {
}
}
};
#ifndef PRODUCT
//
// A special MutexLocker that allows:
// - reentrant locking
// - locking out of order
//
// Only too be used for verify code, where we can relaxe out dead-lock
// dection code a bit (unsafe, but probably ok). This code is NEVER to
// be included in a product version.
//
private:
bool _reentrant;
public:
if (!_reentrant) {
// We temp. diable strict safepoint checking, while we require the lock
}
}
~VerifyMutexLocker() {
if (!_reentrant) {
}
}
};
#endif
#endif // SHARE_VM_RUNTIME_MUTEXLOCKER_HPP