author | goetz |
Wed, 04 Jun 2014 11:56:44 +0200 | |
changeset 25351 | 7c198a690050 |
parent 24424 | 2658d7834c6e |
child 30154 | 39cd4e2ccf1c |
permissions | -rw-r--r-- |
1 | 1 |
/* |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
2 |
* Copyright (c) 1997, 2014, 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:
670
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
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:
670
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "memory/gcLocker.inline.hpp" |
|
27 |
#include "memory/resourceArea.hpp" |
|
28 |
#include "memory/sharedHeap.hpp" |
|
25351
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
24424
diff
changeset
|
29 |
#include "runtime/atomic.inline.hpp" |
24351
61b33cc6d3cf
8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents:
23540
diff
changeset
|
30 |
#include "runtime/thread.inline.hpp" |
1 | 31 |
|
32 |
volatile jint GC_locker::_jni_lock_count = 0; |
|
33 |
volatile bool GC_locker::_needs_gc = false; |
|
34 |
volatile bool GC_locker::_doing_gc = false; |
|
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
35 |
|
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
36 |
#ifdef ASSERT |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
37 |
volatile jint GC_locker::_debug_jni_lock_count = 0; |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
38 |
#endif |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
39 |
|
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
40 |
|
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
41 |
#ifdef ASSERT |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
42 |
void GC_locker::verify_critical_count() { |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
43 |
if (SafepointSynchronize::is_at_safepoint()) { |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
44 |
assert(!needs_gc() || _debug_jni_lock_count == _jni_lock_count, "must agree"); |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
45 |
int count = 0; |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
46 |
// Count the number of threads with critical operations in progress |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
47 |
for (JavaThread* thr = Threads::first(); thr; thr = thr->next()) { |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
48 |
if (thr->in_critical()) { |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
49 |
count++; |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
50 |
} |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
51 |
} |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
52 |
if (_jni_lock_count != count) { |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
53 |
tty->print_cr("critical counts don't match: %d != %d", _jni_lock_count, count); |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
54 |
for (JavaThread* thr = Threads::first(); thr; thr = thr->next()) { |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
55 |
if (thr->in_critical()) { |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
56 |
tty->print_cr(INTPTR_FORMAT " in_critical %d", p2i(thr), thr->in_critical()); |
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
57 |
} |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
58 |
} |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
59 |
} |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
60 |
assert(_jni_lock_count == count, "must be equal"); |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
61 |
} |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
62 |
} |
25351
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
24424
diff
changeset
|
63 |
|
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
24424
diff
changeset
|
64 |
// In debug mode track the locking state at all times |
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
24424
diff
changeset
|
65 |
void GC_locker::increment_debug_jni_lock_count() { |
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
24424
diff
changeset
|
66 |
assert(_debug_jni_lock_count >= 0, "bad value"); |
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
24424
diff
changeset
|
67 |
Atomic::inc(&_debug_jni_lock_count); |
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
24424
diff
changeset
|
68 |
} |
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
24424
diff
changeset
|
69 |
|
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
24424
diff
changeset
|
70 |
void GC_locker::decrement_debug_jni_lock_count() { |
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
24424
diff
changeset
|
71 |
assert(_debug_jni_lock_count > 0, "bad value"); |
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
24424
diff
changeset
|
72 |
Atomic::dec(&_debug_jni_lock_count); |
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
24424
diff
changeset
|
73 |
} |
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
74 |
#endif |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
75 |
|
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
76 |
bool GC_locker::check_active_before_gc() { |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
77 |
assert(SafepointSynchronize::is_at_safepoint(), "only read at safepoint"); |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
78 |
if (is_active() && !_needs_gc) { |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
79 |
verify_critical_count(); |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
80 |
_needs_gc = true; |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
81 |
if (PrintJNIGCStalls && PrintGCDetails) { |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
82 |
ResourceMark rm; // JavaThread::name() allocates to convert to UTF8 |
11788 | 83 |
gclog_or_tty->print_cr("%.3f: Setting _needs_gc. Thread \"%s\" %d locked.", |
84 |
gclog_or_tty->time_stamp().seconds(), Thread::current()->name(), _jni_lock_count); |
|
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
85 |
} |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
86 |
|
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
87 |
} |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
88 |
return is_active(); |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
89 |
} |
1 | 90 |
|
91 |
void GC_locker::stall_until_clear() { |
|
92 |
assert(!JavaThread::current()->in_critical(), "Would deadlock"); |
|
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
93 |
MutexLocker ml(JNICritical_lock); |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
94 |
|
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
95 |
if (needs_gc()) { |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
96 |
if (PrintJNIGCStalls && PrintGCDetails) { |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
97 |
ResourceMark rm; // JavaThread::name() allocates to convert to UTF8 |
11788 | 98 |
gclog_or_tty->print_cr("%.3f: Allocation failed. Thread \"%s\" is stalled by JNI critical section, %d locked.", |
99 |
gclog_or_tty->time_stamp().seconds(), Thread::current()->name(), _jni_lock_count); |
|
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
100 |
} |
386
7f121b1192f2
6539517: CR 6186200 should be extended to perm gen allocation to prevent spurious OOM's from perm gen
apetrusenko
parents:
1
diff
changeset
|
101 |
} |
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
102 |
|
1 | 103 |
// Wait for _needs_gc to be cleared |
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
104 |
while (needs_gc()) { |
1 | 105 |
JNICritical_lock->wait(); |
106 |
} |
|
107 |
} |
|
108 |
||
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
109 |
void GC_locker::jni_lock(JavaThread* thread) { |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
110 |
assert(!thread->in_critical(), "shouldn't currently be in a critical region"); |
1 | 111 |
MutexLocker mu(JNICritical_lock); |
112 |
// Block entering threads if we know at least one thread is in a |
|
113 |
// JNI critical region and we need a GC. |
|
114 |
// We check that at least one thread is in a critical region before |
|
115 |
// blocking because blocked threads are woken up by a thread exiting |
|
116 |
// a JNI critical region. |
|
23540
06f7d6e1f654
8028498: runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java asserts in RT_Baseline
sjohanss
parents:
22234
diff
changeset
|
117 |
while (is_active_and_needs_gc() || _doing_gc) { |
1 | 118 |
JNICritical_lock->wait(); |
119 |
} |
|
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
120 |
thread->enter_critical(); |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
121 |
_jni_lock_count++; |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
122 |
increment_debug_jni_lock_count(); |
1 | 123 |
} |
124 |
||
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
125 |
void GC_locker::jni_unlock(JavaThread* thread) { |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
126 |
assert(thread->in_last_critical(), "should be exiting critical region"); |
1 | 127 |
MutexLocker mu(JNICritical_lock); |
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
128 |
_jni_lock_count--; |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
129 |
decrement_debug_jni_lock_count(); |
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
130 |
thread->exit_critical(); |
23540
06f7d6e1f654
8028498: runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java asserts in RT_Baseline
sjohanss
parents:
22234
diff
changeset
|
131 |
if (needs_gc() && !is_active_internal()) { |
1 | 132 |
// We're the last thread out. Cause a GC to occur. |
23540
06f7d6e1f654
8028498: runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java asserts in RT_Baseline
sjohanss
parents:
22234
diff
changeset
|
133 |
_doing_gc = true; |
06f7d6e1f654
8028498: runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java asserts in RT_Baseline
sjohanss
parents:
22234
diff
changeset
|
134 |
{ |
06f7d6e1f654
8028498: runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java asserts in RT_Baseline
sjohanss
parents:
22234
diff
changeset
|
135 |
// Must give up the lock while at a safepoint |
06f7d6e1f654
8028498: runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java asserts in RT_Baseline
sjohanss
parents:
22234
diff
changeset
|
136 |
MutexUnlocker munlock(JNICritical_lock); |
06f7d6e1f654
8028498: runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java asserts in RT_Baseline
sjohanss
parents:
22234
diff
changeset
|
137 |
if (PrintJNIGCStalls && PrintGCDetails) { |
06f7d6e1f654
8028498: runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java asserts in RT_Baseline
sjohanss
parents:
22234
diff
changeset
|
138 |
ResourceMark rm; // JavaThread::name() allocates to convert to UTF8 |
06f7d6e1f654
8028498: runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java asserts in RT_Baseline
sjohanss
parents:
22234
diff
changeset
|
139 |
gclog_or_tty->print_cr("%.3f: Thread \"%s\" is performing GC after exiting critical section, %d locked", |
06f7d6e1f654
8028498: runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java asserts in RT_Baseline
sjohanss
parents:
22234
diff
changeset
|
140 |
gclog_or_tty->time_stamp().seconds(), Thread::current()->name(), _jni_lock_count); |
1 | 141 |
} |
23540
06f7d6e1f654
8028498: runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java asserts in RT_Baseline
sjohanss
parents:
22234
diff
changeset
|
142 |
Universe::heap()->collect(GCCause::_gc_locker); |
1 | 143 |
} |
23540
06f7d6e1f654
8028498: runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java asserts in RT_Baseline
sjohanss
parents:
22234
diff
changeset
|
144 |
_doing_gc = false; |
11631
33813f69207b
7129164: JNI Get/ReleasePrimitiveArrayCritical doesn't scale
never
parents:
7397
diff
changeset
|
145 |
_needs_gc = false; |
1 | 146 |
JNICritical_lock->notify_all(); |
147 |
} |
|
148 |
} |
|
149 |
||
150 |
// Implementation of No_GC_Verifier |
|
151 |
||
152 |
#ifdef ASSERT |
|
153 |
||
154 |
No_GC_Verifier::No_GC_Verifier(bool verifygc) { |
|
155 |
_verifygc = verifygc; |
|
156 |
if (_verifygc) { |
|
157 |
CollectedHeap* h = Universe::heap(); |
|
158 |
assert(!h->is_gc_active(), "GC active during No_GC_Verifier"); |
|
159 |
_old_invocations = h->total_collections(); |
|
160 |
} |
|
161 |
} |
|
162 |
||
163 |
||
164 |
No_GC_Verifier::~No_GC_Verifier() { |
|
165 |
if (_verifygc) { |
|
166 |
CollectedHeap* h = Universe::heap(); |
|
167 |
assert(!h->is_gc_active(), "GC active during No_GC_Verifier"); |
|
168 |
if (_old_invocations != h->total_collections()) { |
|
169 |
fatal("collection in a No_GC_Verifier secured function"); |
|
170 |
} |
|
171 |
} |
|
172 |
} |
|
173 |
||
174 |
Pause_No_GC_Verifier::Pause_No_GC_Verifier(No_GC_Verifier * ngcv) { |
|
175 |
_ngcv = ngcv; |
|
176 |
if (_ngcv->_verifygc) { |
|
177 |
// if we were verifying, then make sure that nothing is |
|
178 |
// wrong before we "pause" verification |
|
179 |
CollectedHeap* h = Universe::heap(); |
|
180 |
assert(!h->is_gc_active(), "GC active during No_GC_Verifier"); |
|
181 |
if (_ngcv->_old_invocations != h->total_collections()) { |
|
182 |
fatal("collection in a No_GC_Verifier secured function"); |
|
183 |
} |
|
184 |
} |
|
185 |
} |
|
186 |
||
187 |
||
188 |
Pause_No_GC_Verifier::~Pause_No_GC_Verifier() { |
|
189 |
if (_ngcv->_verifygc) { |
|
190 |
// if we were verifying before, then reenable verification |
|
191 |
CollectedHeap* h = Universe::heap(); |
|
192 |
assert(!h->is_gc_active(), "GC active during No_GC_Verifier"); |
|
193 |
_ngcv->_old_invocations = h->total_collections(); |
|
194 |
} |
|
195 |
} |
|
196 |
||
197 |
||
198 |
// JRT_LEAF rules: |
|
199 |
// A JRT_LEAF method may not interfere with safepointing by |
|
200 |
// 1) acquiring or blocking on a Mutex or JavaLock - checked |
|
201 |
// 2) allocating heap memory - checked |
|
202 |
// 3) executing a VM operation - checked |
|
203 |
// 4) executing a system call (including malloc) that could block or grab a lock |
|
204 |
// 5) invoking GC |
|
205 |
// 6) reaching a safepoint |
|
206 |
// 7) running too long |
|
207 |
// Nor may any method it calls. |
|
208 |
JRT_Leaf_Verifier::JRT_Leaf_Verifier() |
|
209 |
: No_Safepoint_Verifier(true, JRT_Leaf_Verifier::should_verify_GC()) |
|
210 |
{ |
|
211 |
} |
|
212 |
||
213 |
JRT_Leaf_Verifier::~JRT_Leaf_Verifier() |
|
214 |
{ |
|
215 |
} |
|
216 |
||
217 |
bool JRT_Leaf_Verifier::should_verify_GC() { |
|
218 |
switch (JavaThread::current()->thread_state()) { |
|
219 |
case _thread_in_Java: |
|
220 |
// is in a leaf routine, there must be no safepoint. |
|
221 |
return true; |
|
222 |
case _thread_in_native: |
|
223 |
// A native thread is not subject to safepoints. |
|
224 |
// Even while it is in a leaf routine, GC is ok |
|
225 |
return false; |
|
226 |
default: |
|
227 |
// Leaf routines cannot be called from other contexts. |
|
228 |
ShouldNotReachHere(); |
|
229 |
return false; |
|
230 |
} |
|
231 |
} |
|
232 |
#endif |