author | goetz |
Thu, 26 Jun 2014 16:05:15 +0200 | |
changeset 25468 | 5331df506290 |
parent 25351 | 7c198a690050 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
22234
da823d78ad65
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
20079
diff
changeset
|
2 |
* Copyright (c) 1997, 2013, 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:
3261
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3261
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:
3261
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_MEMORY_GCLOCKER_HPP |
26 |
#define SHARE_VM_MEMORY_GCLOCKER_HPP |
|
27 |
||
28 |
#include "gc_interface/collectedHeap.hpp" |
|
29 |
#include "memory/genCollectedHeap.hpp" |
|
30 |
#include "memory/universe.hpp" |
|
31 |
#include "oops/oop.hpp" |
|
32 |
||
1 | 33 |
// The direct lock/unlock calls do not force a collection if an unlock |
34 |
// decrements the count to zero. Avoid calling these if at all possible. |
|
35 |
||
36 |
class GC_locker: public AllStatic { |
|
37 |
private: |
|
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
38 |
// The _jni_lock_count keeps track of the number of threads that are |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
39 |
// currently in a critical region. It's only kept up to date when |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
40 |
// _needs_gc is true. The current value is computed during |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
41 |
// safepointing and decremented during the slow path of GC_locker |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
42 |
// unlocking. |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
43 |
static volatile jint _jni_lock_count; // number of jni active instances. |
1 | 44 |
static volatile bool _needs_gc; // heap is filling, we need a GC |
45 |
// note: bool is typedef'd as jint |
|
46 |
static volatile bool _doing_gc; // unlock_critical() is doing a GC |
|
47 |
||
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
48 |
#ifdef ASSERT |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
49 |
// This lock count is updated for all operations and is used to |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
50 |
// validate the jni_lock_count that is computed during safepoints. |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
51 |
static volatile jint _debug_jni_lock_count; |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
52 |
#endif |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
53 |
|
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
54 |
// At a safepoint, visit all threads and count the number of active |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
55 |
// critical sections. This is used to ensure that all active |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
56 |
// critical sections are exited before a new one is started. |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
57 |
static void verify_critical_count() NOT_DEBUG_RETURN; |
1 | 58 |
|
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
59 |
static void jni_lock(JavaThread* thread); |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
60 |
static void jni_unlock(JavaThread* thread); |
1 | 61 |
|
11793
49aa0b2124b6
7144318: GCLocker assert failure: assert(_needs_gc || SafepointSynchronize::is_at_safepoint(
never
parents:
11788
diff
changeset
|
62 |
static bool is_active_internal() { |
49aa0b2124b6
7144318: GCLocker assert failure: assert(_needs_gc || SafepointSynchronize::is_at_safepoint(
never
parents:
11788
diff
changeset
|
63 |
verify_critical_count(); |
23540
06f7d6e1f654
8028498: runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java asserts in RT_Baseline
sjohanss
parents:
22234
diff
changeset
|
64 |
return _jni_lock_count > 0; |
11793
49aa0b2124b6
7144318: GCLocker assert failure: assert(_needs_gc || SafepointSynchronize::is_at_safepoint(
never
parents:
11788
diff
changeset
|
65 |
} |
49aa0b2124b6
7144318: GCLocker assert failure: assert(_needs_gc || SafepointSynchronize::is_at_safepoint(
never
parents:
11788
diff
changeset
|
66 |
|
1 | 67 |
public: |
68 |
// Accessors |
|
11793
49aa0b2124b6
7144318: GCLocker assert failure: assert(_needs_gc || SafepointSynchronize::is_at_safepoint(
never
parents:
11788
diff
changeset
|
69 |
static bool is_active() { |
20079 | 70 |
assert(SafepointSynchronize::is_at_safepoint(), "only read at safepoint"); |
11793
49aa0b2124b6
7144318: GCLocker assert failure: assert(_needs_gc || SafepointSynchronize::is_at_safepoint(
never
parents:
11788
diff
changeset
|
71 |
return is_active_internal(); |
49aa0b2124b6
7144318: GCLocker assert failure: assert(_needs_gc || SafepointSynchronize::is_at_safepoint(
never
parents:
11788
diff
changeset
|
72 |
} |
1 | 73 |
static bool needs_gc() { return _needs_gc; } |
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
74 |
|
1 | 75 |
// Shorthand |
11793
49aa0b2124b6
7144318: GCLocker assert failure: assert(_needs_gc || SafepointSynchronize::is_at_safepoint(
never
parents:
11788
diff
changeset
|
76 |
static bool is_active_and_needs_gc() { |
49aa0b2124b6
7144318: GCLocker assert failure: assert(_needs_gc || SafepointSynchronize::is_at_safepoint(
never
parents:
11788
diff
changeset
|
77 |
// Use is_active_internal since _needs_gc can change from true to |
49aa0b2124b6
7144318: GCLocker assert failure: assert(_needs_gc || SafepointSynchronize::is_at_safepoint(
never
parents:
11788
diff
changeset
|
78 |
// false outside of a safepoint, triggering the assert in |
49aa0b2124b6
7144318: GCLocker assert failure: assert(_needs_gc || SafepointSynchronize::is_at_safepoint(
never
parents:
11788
diff
changeset
|
79 |
// is_active. |
49aa0b2124b6
7144318: GCLocker assert failure: assert(_needs_gc || SafepointSynchronize::is_at_safepoint(
never
parents:
11788
diff
changeset
|
80 |
return needs_gc() && is_active_internal(); |
49aa0b2124b6
7144318: GCLocker assert failure: assert(_needs_gc || SafepointSynchronize::is_at_safepoint(
never
parents:
11788
diff
changeset
|
81 |
} |
1 | 82 |
|
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
83 |
// In debug mode track the locking state at all times |
25351
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
23540
diff
changeset
|
84 |
static void increment_debug_jni_lock_count() NOT_DEBUG_RETURN; |
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
23540
diff
changeset
|
85 |
static void decrement_debug_jni_lock_count() NOT_DEBUG_RETURN; |
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
86 |
|
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
87 |
// Set the current lock count |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
88 |
static void set_jni_lock_count(int count) { |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
89 |
_jni_lock_count = count; |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
90 |
verify_critical_count(); |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
91 |
} |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
92 |
|
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
93 |
// Sets _needs_gc if is_active() is true. Returns is_active(). |
1 | 94 |
static bool check_active_before_gc(); |
95 |
||
96 |
// Stalls the caller (who should not be in a jni critical section) |
|
97 |
// until needs_gc() clears. Note however that needs_gc() may be |
|
98 |
// set at a subsequent safepoint and/or cleared under the |
|
99 |
// JNICritical_lock, so the caller may not safely assert upon |
|
100 |
// return from this method that "!needs_gc()" since that is |
|
101 |
// not a stable predicate. |
|
102 |
static void stall_until_clear(); |
|
103 |
||
104 |
// The following two methods are used for JNI critical regions. |
|
105 |
// If we find that we failed to perform a GC because the GC_locker |
|
106 |
// was active, arrange for one as soon as possible by allowing |
|
107 |
// all threads in critical regions to complete, but not allowing |
|
108 |
// other critical regions to be entered. The reasons for that are: |
|
109 |
// 1) a GC request won't be starved by overlapping JNI critical |
|
110 |
// region activities, which can cause unnecessary OutOfMemory errors. |
|
111 |
// 2) even if allocation requests can still be satisfied before GC locker |
|
112 |
// becomes inactive, for example, in tenured generation possibly with |
|
113 |
// heap expansion, those allocations can trigger lots of safepointing |
|
114 |
// attempts (ineffective GC attempts) and require Heap_lock which |
|
115 |
// slow down allocations tremendously. |
|
116 |
// |
|
117 |
// Note that critical regions can be nested in a single thread, so |
|
118 |
// we must allow threads already in critical regions to continue. |
|
119 |
// |
|
120 |
// JNI critical regions are the only participants in this scheme |
|
121 |
// because they are, by spec, well bounded while in a critical region. |
|
122 |
// |
|
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
123 |
// Each of the following two method is split into a fast path and a |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
124 |
// slow path. JNICritical_lock is only grabbed in the slow path. |
1 | 125 |
// _needs_gc is initially false and every java thread will go |
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
126 |
// through the fast path, which simply increments or decrements the |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
127 |
// current thread's critical count. When GC happens at a safepoint, |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
128 |
// GC_locker::is_active() is checked. Since there is no safepoint in |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
129 |
// the fast path of lock_critical() and unlock_critical(), there is |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
130 |
// no race condition between the fast path and GC. After _needs_gc |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
131 |
// is set at a safepoint, every thread will go through the slow path |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
132 |
// after the safepoint. Since after a safepoint, each of the |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
133 |
// following two methods is either entered from the method entry and |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
134 |
// falls into the slow path, or is resumed from the safepoints in |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
135 |
// the method, which only exist in the slow path. So when _needs_gc |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
10565
diff
changeset
|
136 |
// is set, the slow path is always taken, till _needs_gc is cleared. |
1 | 137 |
static void lock_critical(JavaThread* thread); |
138 |
static void unlock_critical(JavaThread* thread); |
|
11637
030466036615
7013347: allow crypto functions to be called inline to enhance performance
never
parents:
11631
diff
changeset
|
139 |
|
030466036615
7013347: allow crypto functions to be called inline to enhance performance
never
parents:
11631
diff
changeset
|
140 |
static address needs_gc_address() { return (address) &_needs_gc; } |
1 | 141 |
}; |
142 |
||
143 |
||
144 |
// A No_GC_Verifier object can be placed in methods where one assumes that |
|
145 |
// no garbage collection will occur. The destructor will verify this property |
|
146 |
// unless the constructor is called with argument false (not verifygc). |
|
147 |
// |
|
148 |
// The check will only be done in debug mode and if verifygc true. |
|
149 |
||
150 |
class No_GC_Verifier: public StackObj { |
|
151 |
friend class Pause_No_GC_Verifier; |
|
152 |
||
153 |
protected: |
|
154 |
bool _verifygc; |
|
155 |
unsigned int _old_invocations; |
|
156 |
||
157 |
public: |
|
158 |
#ifdef ASSERT |
|
159 |
No_GC_Verifier(bool verifygc = true); |
|
160 |
~No_GC_Verifier(); |
|
161 |
#else |
|
162 |
No_GC_Verifier(bool verifygc = true) {} |
|
163 |
~No_GC_Verifier() {} |
|
164 |
#endif |
|
165 |
}; |
|
166 |
||
167 |
// A Pause_No_GC_Verifier is used to temporarily pause the behavior |
|
168 |
// of a No_GC_Verifier object. If we are not in debug mode or if the |
|
169 |
// No_GC_Verifier object has a _verifygc value of false, then there |
|
170 |
// is nothing to do. |
|
171 |
||
172 |
class Pause_No_GC_Verifier: public StackObj { |
|
173 |
private: |
|
174 |
No_GC_Verifier * _ngcv; |
|
175 |
||
176 |
public: |
|
177 |
#ifdef ASSERT |
|
178 |
Pause_No_GC_Verifier(No_GC_Verifier * ngcv); |
|
179 |
~Pause_No_GC_Verifier(); |
|
180 |
#else |
|
181 |
Pause_No_GC_Verifier(No_GC_Verifier * ngcv) {} |
|
182 |
~Pause_No_GC_Verifier() {} |
|
183 |
#endif |
|
184 |
}; |
|
185 |
||
186 |
||
187 |
// A No_Safepoint_Verifier object will throw an assertion failure if |
|
188 |
// the current thread passes a possible safepoint while this object is |
|
189 |
// instantiated. A safepoint, will either be: an oop allocation, blocking |
|
190 |
// on a Mutex or JavaLock, or executing a VM operation. |
|
191 |
// |
|
192 |
// If StrictSafepointChecks is turned off, it degrades into a No_GC_Verifier |
|
193 |
// |
|
194 |
class No_Safepoint_Verifier : public No_GC_Verifier { |
|
195 |
friend class Pause_No_Safepoint_Verifier; |
|
196 |
||
197 |
private: |
|
198 |
bool _activated; |
|
199 |
Thread *_thread; |
|
200 |
public: |
|
201 |
#ifdef ASSERT |
|
345
8a4c345e460c
6679708: No_Safepoint_Verifier and BacktraceBuilder have uninitialized fields
never
parents:
1
diff
changeset
|
202 |
No_Safepoint_Verifier(bool activated = true, bool verifygc = true ) : |
8a4c345e460c
6679708: No_Safepoint_Verifier and BacktraceBuilder have uninitialized fields
never
parents:
1
diff
changeset
|
203 |
No_GC_Verifier(verifygc), |
8a4c345e460c
6679708: No_Safepoint_Verifier and BacktraceBuilder have uninitialized fields
never
parents:
1
diff
changeset
|
204 |
_activated(activated) { |
1 | 205 |
_thread = Thread::current(); |
206 |
if (_activated) { |
|
207 |
_thread->_allow_allocation_count++; |
|
208 |
_thread->_allow_safepoint_count++; |
|
209 |
} |
|
210 |
} |
|
211 |
||
212 |
~No_Safepoint_Verifier() { |
|
213 |
if (_activated) { |
|
214 |
_thread->_allow_allocation_count--; |
|
215 |
_thread->_allow_safepoint_count--; |
|
216 |
} |
|
217 |
} |
|
218 |
#else |
|
219 |
No_Safepoint_Verifier(bool activated = true, bool verifygc = true) : No_GC_Verifier(verifygc){} |
|
220 |
~No_Safepoint_Verifier() {} |
|
221 |
#endif |
|
222 |
}; |
|
223 |
||
224 |
// A Pause_No_Safepoint_Verifier is used to temporarily pause the |
|
225 |
// behavior of a No_Safepoint_Verifier object. If we are not in debug |
|
226 |
// mode then there is nothing to do. If the No_Safepoint_Verifier |
|
227 |
// object has an _activated value of false, then there is nothing to |
|
228 |
// do for safepoint and allocation checking, but there may still be |
|
229 |
// something to do for the underlying No_GC_Verifier object. |
|
230 |
||
231 |
class Pause_No_Safepoint_Verifier : public Pause_No_GC_Verifier { |
|
232 |
private: |
|
233 |
No_Safepoint_Verifier * _nsv; |
|
234 |
||
235 |
public: |
|
236 |
#ifdef ASSERT |
|
237 |
Pause_No_Safepoint_Verifier(No_Safepoint_Verifier * nsv) |
|
238 |
: Pause_No_GC_Verifier(nsv) { |
|
239 |
||
240 |
_nsv = nsv; |
|
241 |
if (_nsv->_activated) { |
|
242 |
_nsv->_thread->_allow_allocation_count--; |
|
243 |
_nsv->_thread->_allow_safepoint_count--; |
|
244 |
} |
|
245 |
} |
|
246 |
||
247 |
~Pause_No_Safepoint_Verifier() { |
|
248 |
if (_nsv->_activated) { |
|
249 |
_nsv->_thread->_allow_allocation_count++; |
|
250 |
_nsv->_thread->_allow_safepoint_count++; |
|
251 |
} |
|
252 |
} |
|
253 |
#else |
|
254 |
Pause_No_Safepoint_Verifier(No_Safepoint_Verifier * nsv) |
|
255 |
: Pause_No_GC_Verifier(nsv) {} |
|
256 |
~Pause_No_Safepoint_Verifier() {} |
|
257 |
#endif |
|
258 |
}; |
|
259 |
||
2995
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
260 |
// A SkipGCALot object is used to elide the usual effect of gc-a-lot |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
261 |
// over a section of execution by a thread. Currently, it's used only to |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
262 |
// prevent re-entrant calls to GC. |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
263 |
class SkipGCALot : public StackObj { |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
264 |
private: |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
265 |
bool _saved; |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
266 |
Thread* _t; |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
267 |
|
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
268 |
public: |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
269 |
#ifdef ASSERT |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
270 |
SkipGCALot(Thread* t) : _t(t) { |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
271 |
_saved = _t->skip_gcalot(); |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
272 |
_t->set_skip_gcalot(true); |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
273 |
} |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
274 |
|
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
275 |
~SkipGCALot() { |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
276 |
assert(_t->skip_gcalot(), "Save-restore protocol invariant"); |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
277 |
_t->set_skip_gcalot(_saved); |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
278 |
} |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
279 |
#else |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
280 |
SkipGCALot(Thread* t) { } |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
281 |
~SkipGCALot() { } |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
282 |
#endif |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
283 |
}; |
d8283445992a
6820167: GCALotAtAllSafepoints + FullGCALot(ScavengeALot) options crash JVM
ysr
parents:
670
diff
changeset
|
284 |
|
1 | 285 |
// JRT_LEAF currently can be called from either _thread_in_Java or |
286 |
// _thread_in_native mode. In _thread_in_native, it is ok |
|
287 |
// for another thread to trigger GC. The rest of the JRT_LEAF |
|
288 |
// rules apply. |
|
289 |
class JRT_Leaf_Verifier : public No_Safepoint_Verifier { |
|
290 |
static bool should_verify_GC(); |
|
291 |
public: |
|
292 |
#ifdef ASSERT |
|
293 |
JRT_Leaf_Verifier(); |
|
294 |
~JRT_Leaf_Verifier(); |
|
295 |
#else |
|
296 |
JRT_Leaf_Verifier() {} |
|
297 |
~JRT_Leaf_Verifier() {} |
|
298 |
#endif |
|
299 |
}; |
|
300 |
||
301 |
// A No_Alloc_Verifier object can be placed in methods where one assumes that |
|
302 |
// no allocation will occur. The destructor will verify this property |
|
303 |
// unless the constructor is called with argument false (not activated). |
|
304 |
// |
|
305 |
// The check will only be done in debug mode and if activated. |
|
306 |
// Note: this only makes sense at safepoints (otherwise, other threads may |
|
307 |
// allocate concurrently.) |
|
308 |
||
309 |
class No_Alloc_Verifier : public StackObj { |
|
310 |
private: |
|
311 |
bool _activated; |
|
312 |
||
313 |
public: |
|
314 |
#ifdef ASSERT |
|
315 |
No_Alloc_Verifier(bool activated = true) { |
|
316 |
_activated = activated; |
|
317 |
if (_activated) Thread::current()->_allow_allocation_count++; |
|
318 |
} |
|
319 |
||
320 |
~No_Alloc_Verifier() { |
|
321 |
if (_activated) Thread::current()->_allow_allocation_count--; |
|
322 |
} |
|
323 |
#else |
|
324 |
No_Alloc_Verifier(bool activated = true) {} |
|
325 |
~No_Alloc_Verifier() {} |
|
326 |
#endif |
|
327 |
}; |
|
7397 | 328 |
|
329 |
#endif // SHARE_VM_MEMORY_GCLOCKER_HPP |