author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 58454 | d873ce07465d |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52913
diff
changeset
|
2 |
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4013
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4013
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4013
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52913
diff
changeset
|
25 |
#ifndef SHARE_RUNTIME_MUTEX_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52913
diff
changeset
|
26 |
#define SHARE_RUNTIME_MUTEX_HPP |
7397 | 27 |
|
28 |
#include "memory/allocation.hpp" |
|
29 |
#include "runtime/os.hpp" |
|
1 | 30 |
|
53646
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53244
diff
changeset
|
31 |
// A Mutex/Monitor is a simple wrapper around a native lock plus condition |
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53244
diff
changeset
|
32 |
// variable that supports lock ownership tracking, lock ranking for deadlock |
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53244
diff
changeset
|
33 |
// detection and coordinates with the safepoint protocol. |
1 | 34 |
|
57840 | 35 |
// The default length of mutex name was originally chosen to be 64 to avoid |
36 |
// false sharing. Now, PaddedMutex and PaddedMonitor are available for this purpose. |
|
37 |
// TODO: Check if _name[MUTEX_NAME_LEN] should better get replaced by const char*. |
|
38 |
static const int MUTEX_NAME_LEN = 64; |
|
228
69939fa91efd
6610420: Debug VM crashes during monitor lock rank checking
xlu
parents:
1
diff
changeset
|
39 |
|
57840 | 40 |
class Mutex : public CHeapObj<mtSynchronizer> { |
1 | 41 |
|
42 |
public: |
|
43 |
// A special lock: Is a lock where you are guaranteed not to block while you are |
|
46685
b218dfc2853a
8182703: Correct G1 barrier queue lock orderings
eosterlund
parents:
41710
diff
changeset
|
44 |
// holding it, i.e., no vm operation can happen, taking other (blocking) locks, etc. |
b218dfc2853a
8182703: Correct G1 barrier queue lock orderings
eosterlund
parents:
41710
diff
changeset
|
45 |
// The rank 'access' is similar to 'special' and has the same restrictions on usage. |
b218dfc2853a
8182703: Correct G1 barrier queue lock orderings
eosterlund
parents:
41710
diff
changeset
|
46 |
// It is reserved for locks that may be required in order to perform memory accesses |
b218dfc2853a
8182703: Correct G1 barrier queue lock orderings
eosterlund
parents:
41710
diff
changeset
|
47 |
// that require special barriers, e.g. SATB GC barriers, that in turn uses locks. |
52913
bf2f2560dd53
8214315: G1: fatal error: acquiring lock SATB_Q_FL_lock/1 out of order with lock tty_lock/0
kbarrett
parents:
52555
diff
changeset
|
48 |
// The rank 'tty' is also similar to 'special' and has the same restrictions. |
bf2f2560dd53
8214315: G1: fatal error: acquiring lock SATB_Q_FL_lock/1 out of order with lock tty_lock/0
kbarrett
parents:
52555
diff
changeset
|
49 |
// It is reserved for the tty_lock. |
46685
b218dfc2853a
8182703: Correct G1 barrier queue lock orderings
eosterlund
parents:
41710
diff
changeset
|
50 |
// Since memory accesses should be able to be performed pretty much anywhere |
b218dfc2853a
8182703: Correct G1 barrier queue lock orderings
eosterlund
parents:
41710
diff
changeset
|
51 |
// in the code, that requires locks required for performing accesses being |
b218dfc2853a
8182703: Correct G1 barrier queue lock orderings
eosterlund
parents:
41710
diff
changeset
|
52 |
// inherently a bit more special than even locks of the 'special' rank. |
1 | 53 |
// NOTE: It is critical that the rank 'special' be the lowest (earliest) |
46685
b218dfc2853a
8182703: Correct G1 barrier queue lock orderings
eosterlund
parents:
41710
diff
changeset
|
54 |
// (except for "event" and "access") for the deadlock detection to work correctly. |
57751
7284b00e6db3
8228858: Reimplement JVM_RawMonitors to use PlatformMutex
dholmes
parents:
57668
diff
changeset
|
55 |
// The rank native was only for use in Mutexes created by JVM_RawMonitorCreate, |
7284b00e6db3
8228858: Reimplement JVM_RawMonitors to use PlatformMutex
dholmes
parents:
57668
diff
changeset
|
56 |
// which being external to the VM are not subject to deadlock detection, |
7284b00e6db3
8228858: Reimplement JVM_RawMonitors to use PlatformMutex
dholmes
parents:
57668
diff
changeset
|
57 |
// however it has now been used by other locks that don't fit into the |
7284b00e6db3
8228858: Reimplement JVM_RawMonitors to use PlatformMutex
dholmes
parents:
57668
diff
changeset
|
58 |
// deadlock detection scheme. |
53775 | 59 |
// While at a safepoint no mutexes of rank safepoint are held by any thread. |
1 | 60 |
// The rank named "leaf" is probably historical (and should |
61 |
// be changed) -- mutexes of this rank aren't really leaf mutexes |
|
62 |
// at all. |
|
63 |
enum lock_types { |
|
64 |
event, |
|
46685
b218dfc2853a
8182703: Correct G1 barrier queue lock orderings
eosterlund
parents:
41710
diff
changeset
|
65 |
access = event + 1, |
52913
bf2f2560dd53
8214315: G1: fatal error: acquiring lock SATB_Q_FL_lock/1 out of order with lock tty_lock/0
kbarrett
parents:
52555
diff
changeset
|
66 |
tty = access + 2, |
58226 | 67 |
special = tty + 2, |
46685
b218dfc2853a
8182703: Correct G1 barrier queue lock orderings
eosterlund
parents:
41710
diff
changeset
|
68 |
suspend_resume = special + 1, |
55740 | 69 |
oopstorage = suspend_resume + 2, |
70 |
leaf = oopstorage + 2, |
|
46685
b218dfc2853a
8182703: Correct G1 barrier queue lock orderings
eosterlund
parents:
41710
diff
changeset
|
71 |
safepoint = leaf + 10, |
b218dfc2853a
8182703: Correct G1 barrier queue lock orderings
eosterlund
parents:
41710
diff
changeset
|
72 |
barrier = safepoint + 1, |
b218dfc2853a
8182703: Correct G1 barrier queue lock orderings
eosterlund
parents:
41710
diff
changeset
|
73 |
nonleaf = barrier + 1, |
b218dfc2853a
8182703: Correct G1 barrier queue lock orderings
eosterlund
parents:
41710
diff
changeset
|
74 |
max_nonleaf = nonleaf + 900, |
b218dfc2853a
8182703: Correct G1 barrier queue lock orderings
eosterlund
parents:
41710
diff
changeset
|
75 |
native = max_nonleaf + 1 |
1 | 76 |
}; |
77 |
||
78 |
protected: // Monitor-Mutex metadata |
|
79 |
Thread * volatile _owner; // The owner of the lock |
|
53646
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53244
diff
changeset
|
80 |
os::PlatformMonitor _lock; // Native monitor implementation |
57840 | 81 |
char _name[MUTEX_NAME_LEN]; // Name of mutex/monitor |
1 | 82 |
|
83 |
// Debugging fields for naming, deadlock detection, etc. (some only used in debug mode) |
|
58291
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
84 |
#ifdef ASSERT |
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
85 |
bool _allow_vm_block; |
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
86 |
int _rank; // rank (to avoid/detect potential deadlocks) |
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
87 |
Mutex* _next; // Used by a Thread to link up owned locks |
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
88 |
Thread* _last_owner; // the last thread to own the lock |
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
89 |
static bool contains(Mutex* locks, Mutex* lock); |
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
90 |
static Mutex* get_least_ranked_lock(Mutex* locks); |
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
91 |
Mutex* get_least_ranked_lock_besides_this(Mutex* locks); |
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
92 |
#endif // ASSERT |
1 | 93 |
|
58291
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
94 |
void set_owner_implementation(Thread* owner) NOT_DEBUG({ _owner = owner;}); |
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
95 |
void check_block_state (Thread* thread) NOT_DEBUG_RETURN; |
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
96 |
void check_safepoint_state (Thread* thread) NOT_DEBUG_RETURN; |
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
97 |
void check_no_safepoint_state(Thread* thread) NOT_DEBUG_RETURN; |
53646
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53244
diff
changeset
|
98 |
void assert_owner (Thread* expected) NOT_DEBUG_RETURN; |
58291
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
99 |
void no_safepoint_verifier (Thread* thread, bool enable) NOT_DEBUG_RETURN; |
1 | 100 |
|
101 |
public: |
|
102 |
enum { |
|
103 |
_allow_vm_block_flag = true, |
|
104 |
_as_suspend_equivalent_flag = true |
|
105 |
}; |
|
106 |
||
54663
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
107 |
// Locks can be acquired with or without a safepoint check. NonJavaThreads do not follow |
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
108 |
// the safepoint protocol when acquiring locks. |
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
109 |
|
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
110 |
// Each lock can be acquired by only JavaThreads, only NonJavaThreads, or shared between |
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
111 |
// Java and NonJavaThreads. When the lock is initialized with _safepoint_check_always, |
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
112 |
// that means that whenever the lock is acquired by a JavaThread, it will verify that |
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
113 |
// it is done with a safepoint check. In corollary, when the lock is initialized with |
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
114 |
// _safepoint_check_never, that means that whenever the lock is acquired by a JavaThread |
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
115 |
// it will verify that it is done without a safepoint check. |
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
116 |
|
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
117 |
|
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
118 |
// There are a couple of existing locks that will sometimes have a safepoint check and |
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
119 |
// sometimes not when acquired by a JavaThread, but these locks are set up carefully |
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
120 |
// to avoid deadlocks. TODO: Fix these locks and remove _safepoint_check_sometimes. |
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
121 |
|
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
122 |
// TODO: Locks that are shared between JavaThreads and NonJavaThreads |
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
123 |
// should never encounter a safepoint check while they are held, or else a |
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
124 |
// deadlock can occur. We should check this by noting which |
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
125 |
// locks are shared, and walk held locks during safepoint checking. |
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
126 |
|
54623
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54347
diff
changeset
|
127 |
enum SafepointCheckFlag { |
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54347
diff
changeset
|
128 |
_safepoint_check_flag, |
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54347
diff
changeset
|
129 |
_no_safepoint_check_flag |
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54347
diff
changeset
|
130 |
}; |
1126f0607c70
8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents:
54347
diff
changeset
|
131 |
|
28163
322d55d167be
8047290: Make Mutex::_no_safepoint_check_flag locks verify that this lock never checks for safepoint
coleenp
parents:
22551
diff
changeset
|
132 |
enum SafepointCheckRequired { |
57840 | 133 |
_safepoint_check_never, // Mutexes with this value will cause errors |
54663
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
134 |
// when acquired by a JavaThread with a safepoint check. |
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
135 |
_safepoint_check_sometimes, // A couple of special locks are acquired by JavaThreads sometimes |
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
136 |
// with and sometimes without safepoint checks. These |
28163
322d55d167be
8047290: Make Mutex::_no_safepoint_check_flag locks verify that this lock never checks for safepoint
coleenp
parents:
22551
diff
changeset
|
137 |
// locks will not produce errors when locked. |
57840 | 138 |
_safepoint_check_always // Mutexes with this value will cause errors |
54663
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
139 |
// when acquired by a JavaThread without a safepoint check. |
28163
322d55d167be
8047290: Make Mutex::_no_safepoint_check_flag locks verify that this lock never checks for safepoint
coleenp
parents:
22551
diff
changeset
|
140 |
}; |
322d55d167be
8047290: Make Mutex::_no_safepoint_check_flag locks verify that this lock never checks for safepoint
coleenp
parents:
22551
diff
changeset
|
141 |
|
322d55d167be
8047290: Make Mutex::_no_safepoint_check_flag locks verify that this lock never checks for safepoint
coleenp
parents:
22551
diff
changeset
|
142 |
NOT_PRODUCT(SafepointCheckRequired _safepoint_check_required;) |
322d55d167be
8047290: Make Mutex::_no_safepoint_check_flag locks verify that this lock never checks for safepoint
coleenp
parents:
22551
diff
changeset
|
143 |
|
1 | 144 |
public: |
57840 | 145 |
Mutex(int rank, const char *name, bool allow_vm_block = false, |
146 |
SafepointCheckRequired safepoint_check_required = _safepoint_check_always); |
|
147 |
~Mutex(); |
|
1 | 148 |
|
149 |
void lock(); // prints out warning if VM thread blocks |
|
150 |
void lock(Thread *thread); // overloaded with current thread |
|
151 |
void unlock(); |
|
152 |
bool is_locked() const { return _owner != NULL; } |
|
153 |
||
154 |
bool try_lock(); // Like lock(), but unblocking. It returns false instead |
|
58454 | 155 |
private: |
156 |
void lock_contended(Thread *thread); // contended slow-path |
|
157 |
public: |
|
1 | 158 |
|
53646
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53244
diff
changeset
|
159 |
void release_for_safepoint(); |
043ae846819f
8210832: Remove sneaky locking in class Monitor
pchilanomate
parents:
53244
diff
changeset
|
160 |
|
1 | 161 |
// Lock without safepoint check. Should ONLY be used by safepoint code and other code |
162 |
// that is guaranteed not to block while running inside the VM. |
|
163 |
void lock_without_safepoint_check(); |
|
54663
f03d5a093093
8074355: make MutexLocker smarter about non-JavaThreads
coleenp
parents:
54623
diff
changeset
|
164 |
void lock_without_safepoint_check(Thread* self); |
1 | 165 |
|
166 |
// Current owner - not not MT-safe. Can only be used to guarantee that |
|
167 |
// the current running thread owns the lock |
|
168 |
Thread* owner() const { return _owner; } |
|
169 |
bool owned_by_self() const; |
|
170 |
||
171 |
const char *name() const { return _name; } |
|
172 |
||
173 |
void print_on_error(outputStream* st) const; |
|
174 |
||
175 |
#ifndef PRODUCT |
|
176 |
void print_on(outputStream* st) const; |
|
52913
bf2f2560dd53
8214315: G1: fatal error: acquiring lock SATB_Q_FL_lock/1 out of order with lock tty_lock/0
kbarrett
parents:
52555
diff
changeset
|
177 |
void print() const { print_on(::tty); } |
1 | 178 |
#endif |
58291
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
179 |
#ifdef ASSERT |
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
180 |
int rank() const { return _rank; } |
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
181 |
bool allow_vm_block() { return _allow_vm_block; } |
1 | 182 |
|
58291
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
183 |
Mutex *next() const { return _next; } |
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
184 |
void set_next(Mutex *next) { _next = next; } |
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
185 |
#endif // ASSERT |
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
186 |
|
a013100f7a35
8213150: Add verification for locking by VMThread
coleenp
parents:
58226
diff
changeset
|
187 |
void set_owner(Thread* owner) { set_owner_implementation(owner); } |
57840 | 188 |
}; |
1 | 189 |
|
57840 | 190 |
class Monitor : public Mutex { |
191 |
void assert_wait_lock_state (Thread* self) NOT_DEBUG_RETURN; |
|
192 |
public: |
|
193 |
Monitor(int rank, const char *name, bool allow_vm_block = false, |
|
194 |
SafepointCheckRequired safepoint_check_required = _safepoint_check_always); |
|
195 |
// default destructor |
|
196 |
||
197 |
// Wait until monitor is notified (or times out). |
|
198 |
// Defaults are to make safepoint checks, wait time is forever (i.e., |
|
199 |
// zero), and not a suspend-equivalent condition. Returns true if wait |
|
200 |
// times out; otherwise returns false. |
|
201 |
bool wait(long timeout = 0, |
|
202 |
bool as_suspend_equivalent = !_as_suspend_equivalent_flag); |
|
203 |
bool wait_without_safepoint_check(long timeout = 0); |
|
204 |
void notify(); |
|
205 |
void notify_all(); |
|
206 |
}; |
|
207 |
||
208 |
||
209 |
class PaddedMutex : public Mutex { |
|
210 |
enum { |
|
211 |
CACHE_LINE_PADDING = (int)DEFAULT_CACHE_LINE_SIZE - (int)sizeof(Mutex), |
|
212 |
PADDING_LEN = CACHE_LINE_PADDING > 0 ? CACHE_LINE_PADDING : 1 |
|
213 |
}; |
|
214 |
char _padding[PADDING_LEN]; |
|
215 |
public: |
|
216 |
PaddedMutex(int rank, const char *name, bool allow_vm_block = false, |
|
217 |
SafepointCheckRequired safepoint_check_required = _safepoint_check_always) : |
|
218 |
Mutex(rank, name, allow_vm_block, safepoint_check_required) {}; |
|
1 | 219 |
}; |
220 |
||
41710
b830f5141dbb
8166970: Adapt mutex padding according to DEFAULT_CACHE_LINE_SIZE
mdoerr
parents:
28163
diff
changeset
|
221 |
class PaddedMonitor : public Monitor { |
b830f5141dbb
8166970: Adapt mutex padding according to DEFAULT_CACHE_LINE_SIZE
mdoerr
parents:
28163
diff
changeset
|
222 |
enum { |
b830f5141dbb
8166970: Adapt mutex padding according to DEFAULT_CACHE_LINE_SIZE
mdoerr
parents:
28163
diff
changeset
|
223 |
CACHE_LINE_PADDING = (int)DEFAULT_CACHE_LINE_SIZE - (int)sizeof(Monitor), |
b830f5141dbb
8166970: Adapt mutex padding according to DEFAULT_CACHE_LINE_SIZE
mdoerr
parents:
28163
diff
changeset
|
224 |
PADDING_LEN = CACHE_LINE_PADDING > 0 ? CACHE_LINE_PADDING : 1 |
b830f5141dbb
8166970: Adapt mutex padding according to DEFAULT_CACHE_LINE_SIZE
mdoerr
parents:
28163
diff
changeset
|
225 |
}; |
b830f5141dbb
8166970: Adapt mutex padding according to DEFAULT_CACHE_LINE_SIZE
mdoerr
parents:
28163
diff
changeset
|
226 |
char _padding[PADDING_LEN]; |
b830f5141dbb
8166970: Adapt mutex padding according to DEFAULT_CACHE_LINE_SIZE
mdoerr
parents:
28163
diff
changeset
|
227 |
public: |
b830f5141dbb
8166970: Adapt mutex padding according to DEFAULT_CACHE_LINE_SIZE
mdoerr
parents:
28163
diff
changeset
|
228 |
PaddedMonitor(int rank, const char *name, bool allow_vm_block = false, |
b830f5141dbb
8166970: Adapt mutex padding according to DEFAULT_CACHE_LINE_SIZE
mdoerr
parents:
28163
diff
changeset
|
229 |
SafepointCheckRequired safepoint_check_required = _safepoint_check_always) : |
b830f5141dbb
8166970: Adapt mutex padding according to DEFAULT_CACHE_LINE_SIZE
mdoerr
parents:
28163
diff
changeset
|
230 |
Monitor(rank, name, allow_vm_block, safepoint_check_required) {}; |
b830f5141dbb
8166970: Adapt mutex padding according to DEFAULT_CACHE_LINE_SIZE
mdoerr
parents:
28163
diff
changeset
|
231 |
}; |
b830f5141dbb
8166970: Adapt mutex padding according to DEFAULT_CACHE_LINE_SIZE
mdoerr
parents:
28163
diff
changeset
|
232 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52913
diff
changeset
|
233 |
#endif // SHARE_RUNTIME_MUTEX_HPP |