1 /*
2 * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 // Mutexes used in the VM.
26
27 extern Mutex* Patching_lock; // a lock used to guard code patching of compiled code
28 extern Monitor* SystemDictionary_lock; // a lock on the system dictonary
29 extern Mutex* PackageTable_lock; // a lock on the class loader package table
30 extern Mutex* CompiledIC_lock; // a lock used to guard compiled IC patching and access
31 extern Mutex* InlineCacheBuffer_lock; // a lock used to guard the InlineCacheBuffer
32 extern Mutex* VMStatistic_lock; // a lock used to guard statistics count increment
33 extern Mutex* JNIGlobalHandle_lock; // a lock on creating JNI global handles
34 extern Mutex* JNIHandleBlockFreeList_lock; // a lock on the JNI handle block free list
35 extern Mutex* JNICachedItableIndex_lock; // a lock on caching an itable index during JNI invoke
36 extern Mutex* JmethodIdCreation_lock; // a lock on creating JNI method identifiers
37 extern Mutex* JfieldIdCreation_lock; // a lock on creating JNI static field identifiers
38 extern Monitor* JNICritical_lock; // a lock used while entering and exiting JNI critical regions, allows GC to sometimes get in
39 extern Mutex* JvmtiThreadState_lock; // a lock on modification of JVMTI thread data
40 extern Monitor* JvmtiPendingEvent_lock; // a lock on the JVMTI pending events list
41 extern Monitor* Heap_lock; // a lock on the heap
42 extern Mutex* ExpandHeap_lock; // a lock on expanding the heap
43 extern Mutex* AdapterHandlerLibrary_lock; // a lock on the AdapterHandlerLibrary
44 extern Mutex* SignatureHandlerLibrary_lock; // a lock on the SignatureHandlerLibrary
326 bool _reentrant;
327 public:
328 VerifyMutexLocker(Monitor * mutex) {
329 _mutex = mutex;
330 _reentrant = mutex->owned_by_self();
331 if (!_reentrant) {
332 // We temp. diable strict safepoint checking, while we require the lock
333 FlagSetting fs(StrictSafepointChecks, false);
334 _mutex->lock();
335 }
336 }
337
338 ~VerifyMutexLocker() {
339 if (!_reentrant) {
340 _mutex->unlock();
341 }
342 }
343 };
344
345 #endif
|
1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_RUNTIME_MUTEXLOCKER_HPP
26 #define SHARE_VM_RUNTIME_MUTEXLOCKER_HPP
27
28 #include "memory/allocation.hpp"
29 #include "runtime/mutex.hpp"
30 #ifdef TARGET_OS_FAMILY_linux
31 # include "os_linux.inline.hpp"
32 #endif
33 #ifdef TARGET_OS_FAMILY_solaris
34 # include "os_solaris.inline.hpp"
35 #endif
36 #ifdef TARGET_OS_FAMILY_windows
37 # include "os_windows.inline.hpp"
38 #endif
39
40 // Mutexes used in the VM.
41
42 extern Mutex* Patching_lock; // a lock used to guard code patching of compiled code
43 extern Monitor* SystemDictionary_lock; // a lock on the system dictonary
44 extern Mutex* PackageTable_lock; // a lock on the class loader package table
45 extern Mutex* CompiledIC_lock; // a lock used to guard compiled IC patching and access
46 extern Mutex* InlineCacheBuffer_lock; // a lock used to guard the InlineCacheBuffer
47 extern Mutex* VMStatistic_lock; // a lock used to guard statistics count increment
48 extern Mutex* JNIGlobalHandle_lock; // a lock on creating JNI global handles
49 extern Mutex* JNIHandleBlockFreeList_lock; // a lock on the JNI handle block free list
50 extern Mutex* JNICachedItableIndex_lock; // a lock on caching an itable index during JNI invoke
51 extern Mutex* JmethodIdCreation_lock; // a lock on creating JNI method identifiers
52 extern Mutex* JfieldIdCreation_lock; // a lock on creating JNI static field identifiers
53 extern Monitor* JNICritical_lock; // a lock used while entering and exiting JNI critical regions, allows GC to sometimes get in
54 extern Mutex* JvmtiThreadState_lock; // a lock on modification of JVMTI thread data
55 extern Monitor* JvmtiPendingEvent_lock; // a lock on the JVMTI pending events list
56 extern Monitor* Heap_lock; // a lock on the heap
57 extern Mutex* ExpandHeap_lock; // a lock on expanding the heap
58 extern Mutex* AdapterHandlerLibrary_lock; // a lock on the AdapterHandlerLibrary
59 extern Mutex* SignatureHandlerLibrary_lock; // a lock on the SignatureHandlerLibrary
341 bool _reentrant;
342 public:
343 VerifyMutexLocker(Monitor * mutex) {
344 _mutex = mutex;
345 _reentrant = mutex->owned_by_self();
346 if (!_reentrant) {
347 // We temp. diable strict safepoint checking, while we require the lock
348 FlagSetting fs(StrictSafepointChecks, false);
349 _mutex->lock();
350 }
351 }
352
353 ~VerifyMutexLocker() {
354 if (!_reentrant) {
355 _mutex->unlock();
356 }
357 }
358 };
359
360 #endif
361
362 #endif // SHARE_VM_RUNTIME_MUTEXLOCKER_HPP
|