author | coleenp |
Thu, 10 Jan 2019 15:13:51 -0500 | |
changeset 53244 | 9807daeb47c4 |
parent 52877 | 9e041366c764 |
child 53646 | 043ae846819f |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52877
diff
changeset
|
2 |
* Copyright (c) 1997, 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:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
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:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52877
diff
changeset
|
25 |
#ifndef SHARE_RUNTIME_INTERFACESUPPORT_INLINE_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52877
diff
changeset
|
26 |
#define SHARE_RUNTIME_INTERFACESUPPORT_INLINE_HPP |
7397 | 27 |
|
28 |
#include "runtime/handles.inline.hpp" |
|
29 |
#include "runtime/mutexLocker.hpp" |
|
30 |
#include "runtime/orderAccess.hpp" |
|
31 |
#include "runtime/os.hpp" |
|
47881
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
32 |
#include "runtime/safepointMechanism.inline.hpp" |
49594
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
33 |
#include "runtime/safepointVerifiers.hpp" |
49449
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
47881
diff
changeset
|
34 |
#include "runtime/thread.hpp" |
52877
9e041366c764
8214850: Rename vm_operations.?pp files to vmOperations.?pp files
tschatzl
parents:
52460
diff
changeset
|
35 |
#include "runtime/vmOperations.hpp" |
7397 | 36 |
#include "utilities/globalDefinitions.hpp" |
40010 | 37 |
#include "utilities/macros.hpp" |
7397 | 38 |
#include "utilities/preserveException.hpp" |
39 |
||
1 | 40 |
// Wrapper for all entry points to the virtual machine. |
41 |
||
10969
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
42 |
// InterfaceSupport provides functionality used by the VM_LEAF_BASE and |
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
43 |
// VM_ENTRY_BASE macros. These macros are used to guard entry points into |
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
44 |
// the VM and perform checks upon leave of the VM. |
1 | 45 |
|
46 |
||
47 |
class InterfaceSupport: AllStatic { |
|
48 |
# ifdef ASSERT |
|
49 |
public: |
|
50 |
static long _scavenge_alot_counter; |
|
51 |
static long _fullgc_alot_counter; |
|
52 |
static long _number_of_calls; |
|
53 |
static long _fullgc_alot_invocation; |
|
54 |
||
55 |
// Helper methods used to implement +ScavengeALot and +FullGCALot |
|
56 |
static void check_gc_alot() { if (ScavengeALot || FullGCALot) gc_alot(); } |
|
57 |
static void gc_alot(); |
|
58 |
||
59 |
static void walk_stack_from(vframe* start_vf); |
|
60 |
static void walk_stack(); |
|
61 |
||
62 |
static void zombieAll(); |
|
63 |
static void deoptimizeAll(); |
|
64 |
static void stress_derived_pointers(); |
|
65 |
static void verify_stack(); |
|
66 |
static void verify_last_frame(); |
|
67 |
# endif |
|
68 |
||
69 |
public: |
|
46604
d409276ee40c
8183198: Factor out thread state serialization into a proper helper function
mgerdin
parents:
46373
diff
changeset
|
70 |
static void serialize_thread_state_with_handler(JavaThread* thread) { |
d409276ee40c
8183198: Factor out thread state serialization into a proper helper function
mgerdin
parents:
46373
diff
changeset
|
71 |
serialize_thread_state_internal(thread, true); |
d409276ee40c
8183198: Factor out thread state serialization into a proper helper function
mgerdin
parents:
46373
diff
changeset
|
72 |
} |
d409276ee40c
8183198: Factor out thread state serialization into a proper helper function
mgerdin
parents:
46373
diff
changeset
|
73 |
|
d409276ee40c
8183198: Factor out thread state serialization into a proper helper function
mgerdin
parents:
46373
diff
changeset
|
74 |
// Should only call this if we know that we have a proper SEH set up. |
d409276ee40c
8183198: Factor out thread state serialization into a proper helper function
mgerdin
parents:
46373
diff
changeset
|
75 |
static void serialize_thread_state(JavaThread* thread) { |
d409276ee40c
8183198: Factor out thread state serialization into a proper helper function
mgerdin
parents:
46373
diff
changeset
|
76 |
serialize_thread_state_internal(thread, false); |
d409276ee40c
8183198: Factor out thread state serialization into a proper helper function
mgerdin
parents:
46373
diff
changeset
|
77 |
} |
40010 | 78 |
|
46604
d409276ee40c
8183198: Factor out thread state serialization into a proper helper function
mgerdin
parents:
46373
diff
changeset
|
79 |
private: |
d409276ee40c
8183198: Factor out thread state serialization into a proper helper function
mgerdin
parents:
46373
diff
changeset
|
80 |
static void serialize_thread_state_internal(JavaThread* thread, bool needs_exception_handler) { |
d409276ee40c
8183198: Factor out thread state serialization into a proper helper function
mgerdin
parents:
46373
diff
changeset
|
81 |
// Make sure new state is seen by VM thread |
52460 | 82 |
OrderAccess::fence(); |
46604
d409276ee40c
8183198: Factor out thread state serialization into a proper helper function
mgerdin
parents:
46373
diff
changeset
|
83 |
} |
1 | 84 |
}; |
85 |
||
86 |
||
87 |
// Basic class for all thread transition classes. |
|
88 |
||
89 |
class ThreadStateTransition : public StackObj { |
|
90 |
protected: |
|
91 |
JavaThread* _thread; |
|
92 |
public: |
|
93 |
ThreadStateTransition(JavaThread *thread) { |
|
94 |
_thread = thread; |
|
95 |
assert(thread != NULL && thread->is_Java_thread(), "must be Java thread"); |
|
96 |
} |
|
97 |
||
98 |
// Change threadstate in a manner, so safepoint can detect changes. |
|
99 |
// Time-critical: called on exit from every runtime routine |
|
100 |
static inline void transition(JavaThread *thread, JavaThreadState from, JavaThreadState to) { |
|
101 |
assert(from != _thread_in_Java, "use transition_from_java"); |
|
102 |
assert(from != _thread_in_native, "use transition_from_native"); |
|
103 |
assert((from & 1) == 0 && (to & 1) == 0, "odd numbers are transitions states"); |
|
104 |
assert(thread->thread_state() == from, "coming from wrong thread state"); |
|
46373
e8e9b36783f3
8166927: interfaceSupport.hpp has ancient comments about TSO
dholmes
parents:
41084
diff
changeset
|
105 |
// Change to transition state |
1 | 106 |
thread->set_thread_state((JavaThreadState)(from + 1)); |
107 |
||
46604
d409276ee40c
8183198: Factor out thread state serialization into a proper helper function
mgerdin
parents:
46373
diff
changeset
|
108 |
InterfaceSupport::serialize_thread_state(thread); |
1 | 109 |
|
47881
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
110 |
SafepointMechanism::block_if_requested(thread); |
1 | 111 |
thread->set_thread_state(to); |
112 |
||
113 |
CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();) |
|
114 |
} |
|
115 |
||
116 |
// transition_and_fence must be used on any thread state transition |
|
117 |
// where there might not be a Java call stub on the stack, in |
|
118 |
// particular on Windows where the Structured Exception Handler is |
|
52460 | 119 |
// set up in the call stub. |
1 | 120 |
static inline void transition_and_fence(JavaThread *thread, JavaThreadState from, JavaThreadState to) { |
121 |
assert(thread->thread_state() == from, "coming from wrong thread state"); |
|
122 |
assert((from & 1) == 0 && (to & 1) == 0, "odd numbers are transitions states"); |
|
46373
e8e9b36783f3
8166927: interfaceSupport.hpp has ancient comments about TSO
dholmes
parents:
41084
diff
changeset
|
123 |
// Change to transition state |
1 | 124 |
thread->set_thread_state((JavaThreadState)(from + 1)); |
125 |
||
46604
d409276ee40c
8183198: Factor out thread state serialization into a proper helper function
mgerdin
parents:
46373
diff
changeset
|
126 |
InterfaceSupport::serialize_thread_state_with_handler(thread); |
1 | 127 |
|
47881
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
128 |
SafepointMechanism::block_if_requested(thread); |
1 | 129 |
thread->set_thread_state(to); |
130 |
||
131 |
CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();) |
|
132 |
} |
|
133 |
||
134 |
// Same as above, but assumes from = _thread_in_Java. This is simpler, since we |
|
135 |
// never block on entry to the VM. This will break the code, since e.g. preserve arguments |
|
136 |
// have not been setup. |
|
137 |
static inline void transition_from_java(JavaThread *thread, JavaThreadState to) { |
|
138 |
assert(thread->thread_state() == _thread_in_Java, "coming from wrong thread state"); |
|
139 |
thread->set_thread_state(to); |
|
140 |
} |
|
141 |
||
142 |
static inline void transition_from_native(JavaThread *thread, JavaThreadState to) { |
|
143 |
assert((to & 1) == 0, "odd numbers are transitions states"); |
|
144 |
assert(thread->thread_state() == _thread_in_native, "coming from wrong thread state"); |
|
46373
e8e9b36783f3
8166927: interfaceSupport.hpp has ancient comments about TSO
dholmes
parents:
41084
diff
changeset
|
145 |
// Change to transition state |
1 | 146 |
thread->set_thread_state(_thread_in_native_trans); |
147 |
||
46604
d409276ee40c
8183198: Factor out thread state serialization into a proper helper function
mgerdin
parents:
46373
diff
changeset
|
148 |
InterfaceSupport::serialize_thread_state_with_handler(thread); |
1 | 149 |
|
150 |
// We never install asynchronous exceptions when coming (back) in |
|
151 |
// to the runtime from native code because the runtime is not set |
|
152 |
// up to handle exceptions floating around at arbitrary points. |
|
52450 | 153 |
if (SafepointMechanism::should_block(thread) || thread->is_suspend_after_native()) { |
1 | 154 |
JavaThread::check_safepoint_and_suspend_for_native_trans(thread); |
155 |
||
156 |
// Clear unhandled oops anywhere where we could block, even if we don't. |
|
157 |
CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();) |
|
158 |
} |
|
159 |
||
160 |
thread->set_thread_state(to); |
|
161 |
} |
|
162 |
protected: |
|
163 |
void trans(JavaThreadState from, JavaThreadState to) { transition(_thread, from, to); } |
|
164 |
void trans_from_java(JavaThreadState to) { transition_from_java(_thread, to); } |
|
165 |
void trans_from_native(JavaThreadState to) { transition_from_native(_thread, to); } |
|
166 |
void trans_and_fence(JavaThreadState from, JavaThreadState to) { transition_and_fence(_thread, from, to); } |
|
167 |
}; |
|
168 |
||
47881
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
169 |
class ThreadInVMForHandshake : public ThreadStateTransition { |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
170 |
const JavaThreadState _original_state; |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
171 |
|
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
172 |
void transition_back() { |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
173 |
// This can be invoked from transition states and must return to the original state properly |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
174 |
assert(_thread->thread_state() == _thread_in_vm, "should only call when leaving VM after handshake"); |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
175 |
_thread->set_thread_state(_thread_in_vm_trans); |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
176 |
|
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
177 |
InterfaceSupport::serialize_thread_state(_thread); |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
178 |
|
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
179 |
SafepointMechanism::block_if_requested(_thread); |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
180 |
|
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
181 |
_thread->set_thread_state(_original_state); |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
182 |
} |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
183 |
|
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
184 |
public: |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
185 |
|
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
186 |
ThreadInVMForHandshake(JavaThread* thread) : ThreadStateTransition(thread), |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
187 |
_original_state(thread->thread_state()) { |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
188 |
|
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
189 |
if (thread->has_last_Java_frame()) { |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
190 |
thread->frame_anchor()->make_walkable(thread); |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
191 |
} |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
192 |
|
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
193 |
thread->set_thread_state(_thread_in_vm); |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
194 |
} |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
195 |
|
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
196 |
~ThreadInVMForHandshake() { |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
197 |
transition_back(); |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
198 |
} |
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
199 |
|
0ce0ac68ace7
8189941: Implementation JEP 312: Thread-local handshake
rehn
parents:
47216
diff
changeset
|
200 |
}; |
1 | 201 |
|
202 |
class ThreadInVMfromJava : public ThreadStateTransition { |
|
203 |
public: |
|
204 |
ThreadInVMfromJava(JavaThread* thread) : ThreadStateTransition(thread) { |
|
205 |
trans_from_java(_thread_in_vm); |
|
206 |
} |
|
207 |
~ThreadInVMfromJava() { |
|
40926
2fd1cf3e70e9
8137035: nsk/stress/stack/stack tests got EXCEPTION_STACK_OVERFLOW on Windows 64 bit
fparain
parents:
40010
diff
changeset
|
208 |
if (_thread->stack_yellow_reserved_zone_disabled()) { |
2fd1cf3e70e9
8137035: nsk/stress/stack/stack tests got EXCEPTION_STACK_OVERFLOW on Windows 64 bit
fparain
parents:
40010
diff
changeset
|
209 |
_thread->enable_stack_yellow_reserved_zone(); |
2fd1cf3e70e9
8137035: nsk/stress/stack/stack tests got EXCEPTION_STACK_OVERFLOW on Windows 64 bit
fparain
parents:
40010
diff
changeset
|
210 |
} |
1 | 211 |
trans(_thread_in_vm, _thread_in_Java); |
212 |
// Check for pending. async. exceptions or suspends. |
|
213 |
if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition(); |
|
214 |
} |
|
215 |
}; |
|
216 |
||
217 |
||
218 |
class ThreadInVMfromUnknown { |
|
219 |
private: |
|
220 |
JavaThread* _thread; |
|
221 |
public: |
|
222 |
ThreadInVMfromUnknown() : _thread(NULL) { |
|
223 |
Thread* t = Thread::current(); |
|
224 |
if (t->is_Java_thread()) { |
|
225 |
JavaThread* t2 = (JavaThread*) t; |
|
226 |
if (t2->thread_state() == _thread_in_native) { |
|
227 |
_thread = t2; |
|
228 |
ThreadStateTransition::transition_from_native(t2, _thread_in_vm); |
|
229 |
// Used to have a HandleMarkCleaner but that is dangerous as |
|
230 |
// it could free a handle in our (indirect, nested) caller. |
|
231 |
// We expect any handles will be short lived and figure we |
|
232 |
// don't need an actual HandleMark. |
|
233 |
} |
|
234 |
} |
|
235 |
} |
|
236 |
~ThreadInVMfromUnknown() { |
|
237 |
if (_thread) { |
|
238 |
ThreadStateTransition::transition_and_fence(_thread, _thread_in_vm, _thread_in_native); |
|
239 |
} |
|
240 |
} |
|
241 |
}; |
|
242 |
||
243 |
||
244 |
class ThreadInVMfromNative : public ThreadStateTransition { |
|
245 |
public: |
|
246 |
ThreadInVMfromNative(JavaThread* thread) : ThreadStateTransition(thread) { |
|
247 |
trans_from_native(_thread_in_vm); |
|
248 |
} |
|
249 |
~ThreadInVMfromNative() { |
|
250 |
trans_and_fence(_thread_in_vm, _thread_in_native); |
|
251 |
} |
|
252 |
}; |
|
253 |
||
254 |
||
255 |
class ThreadToNativeFromVM : public ThreadStateTransition { |
|
256 |
public: |
|
257 |
ThreadToNativeFromVM(JavaThread *thread) : ThreadStateTransition(thread) { |
|
258 |
// We are leaving the VM at this point and going directly to native code. |
|
259 |
// Block, if we are in the middle of a safepoint synchronization. |
|
260 |
assert(!thread->owns_locks(), "must release all locks when leaving VM"); |
|
261 |
thread->frame_anchor()->make_walkable(thread); |
|
262 |
trans_and_fence(_thread_in_vm, _thread_in_native); |
|
263 |
// Check for pending. async. exceptions or suspends. |
|
264 |
if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition(false); |
|
265 |
} |
|
266 |
||
267 |
~ThreadToNativeFromVM() { |
|
268 |
trans_from_native(_thread_in_vm); |
|
41084
fc5db29fa08e
8164086: Checked JNI pending exception check should be cleared when returning to Java frame
dsimms
parents:
40926
diff
changeset
|
269 |
assert(!_thread->is_pending_jni_exception_check(), "Pending JNI Exception Check"); |
1 | 270 |
// We don't need to clear_walkable because it will happen automagically when we return to java |
271 |
} |
|
272 |
}; |
|
273 |
||
274 |
||
275 |
class ThreadBlockInVM : public ThreadStateTransition { |
|
276 |
public: |
|
277 |
ThreadBlockInVM(JavaThread *thread) |
|
278 |
: ThreadStateTransition(thread) { |
|
279 |
// Once we are blocked vm expects stack to be walkable |
|
280 |
thread->frame_anchor()->make_walkable(thread); |
|
281 |
trans_and_fence(_thread_in_vm, _thread_blocked); |
|
282 |
} |
|
283 |
~ThreadBlockInVM() { |
|
284 |
trans_and_fence(_thread_blocked, _thread_in_vm); |
|
285 |
// We don't need to clear_walkable because it will happen automagically when we return to java |
|
286 |
} |
|
287 |
}; |
|
288 |
||
289 |
||
290 |
// This special transition class is only used to prevent asynchronous exceptions |
|
291 |
// from being installed on vm exit in situations where we can't tolerate them. |
|
292 |
// See bugs: 4324348, 4854693, 4998314, 5040492, 5050705. |
|
293 |
class ThreadInVMfromJavaNoAsyncException : public ThreadStateTransition { |
|
294 |
public: |
|
295 |
ThreadInVMfromJavaNoAsyncException(JavaThread* thread) : ThreadStateTransition(thread) { |
|
296 |
trans_from_java(_thread_in_vm); |
|
297 |
} |
|
298 |
~ThreadInVMfromJavaNoAsyncException() { |
|
40926
2fd1cf3e70e9
8137035: nsk/stress/stack/stack tests got EXCEPTION_STACK_OVERFLOW on Windows 64 bit
fparain
parents:
40010
diff
changeset
|
299 |
if (_thread->stack_yellow_reserved_zone_disabled()) { |
2fd1cf3e70e9
8137035: nsk/stress/stack/stack tests got EXCEPTION_STACK_OVERFLOW on Windows 64 bit
fparain
parents:
40010
diff
changeset
|
300 |
_thread->enable_stack_yellow_reserved_zone(); |
2fd1cf3e70e9
8137035: nsk/stress/stack/stack tests got EXCEPTION_STACK_OVERFLOW on Windows 64 bit
fparain
parents:
40010
diff
changeset
|
301 |
} |
1 | 302 |
trans(_thread_in_vm, _thread_in_Java); |
303 |
// NOTE: We do not check for pending. async. exceptions. |
|
304 |
// If we did and moved the pending async exception over into the |
|
305 |
// pending exception field, we would need to deopt (currently C2 |
|
306 |
// only). However, to do so would require that we transition back |
|
307 |
// to the _thread_in_vm state. Instead we postpone the handling of |
|
308 |
// the async exception. |
|
309 |
||
40926
2fd1cf3e70e9
8137035: nsk/stress/stack/stack tests got EXCEPTION_STACK_OVERFLOW on Windows 64 bit
fparain
parents:
40010
diff
changeset
|
310 |
|
1 | 311 |
// Check for pending. suspends only. |
312 |
if (_thread->has_special_runtime_exit_condition()) |
|
313 |
_thread->handle_special_runtime_exit_condition(false); |
|
314 |
} |
|
315 |
}; |
|
316 |
||
317 |
// Debug class instantiated in JRT_ENTRY and ITR_ENTRY macro. |
|
318 |
// Can be used to verify properties on enter/exit of the VM. |
|
319 |
||
320 |
#ifdef ASSERT |
|
321 |
class VMEntryWrapper { |
|
322 |
public: |
|
49449
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
47881
diff
changeset
|
323 |
VMEntryWrapper(); |
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
47881
diff
changeset
|
324 |
~VMEntryWrapper(); |
1 | 325 |
}; |
326 |
||
327 |
||
328 |
class VMNativeEntryWrapper { |
|
329 |
public: |
|
330 |
VMNativeEntryWrapper() { |
|
331 |
if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot(); |
|
332 |
} |
|
333 |
||
334 |
~VMNativeEntryWrapper() { |
|
335 |
if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot(); |
|
336 |
} |
|
337 |
}; |
|
338 |
||
339 |
#endif |
|
340 |
||
341 |
||
342 |
// VM-internal runtime interface support |
|
343 |
||
49594
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
344 |
// Definitions for JRT (Java (Compiler/Shared) Runtime) |
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
345 |
|
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
346 |
// JRT_LEAF currently can be called from either _thread_in_Java or |
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
347 |
// _thread_in_native mode. In _thread_in_native, it is ok |
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
348 |
// for another thread to trigger GC. The rest of the JRT_LEAF |
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
349 |
// rules apply. |
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
350 |
class JRTLeafVerifier : public NoSafepointVerifier { |
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
351 |
static bool should_verify_GC(); |
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
352 |
public: |
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
353 |
#ifdef ASSERT |
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
354 |
JRTLeafVerifier(); |
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
355 |
~JRTLeafVerifier(); |
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
356 |
#else |
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
357 |
JRTLeafVerifier() {} |
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
358 |
~JRTLeafVerifier() {} |
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
359 |
#endif |
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
360 |
}; |
898ef81cbc0e
8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
49449
diff
changeset
|
361 |
|
1 | 362 |
#ifdef ASSERT |
363 |
||
364 |
class RuntimeHistogramElement : public HistogramElement { |
|
365 |
public: |
|
366 |
RuntimeHistogramElement(const char* name); |
|
367 |
}; |
|
368 |
||
369 |
#define TRACE_CALL(result_type, header) \ |
|
370 |
InterfaceSupport::_number_of_calls++; \ |
|
371 |
if (CountRuntimeCalls) { \ |
|
372 |
static RuntimeHistogramElement* e = new RuntimeHistogramElement(#header); \ |
|
373 |
if (e != NULL) e->increment_count(); \ |
|
374 |
} |
|
375 |
#else |
|
376 |
#define TRACE_CALL(result_type, header) \ |
|
377 |
/* do nothing */ |
|
378 |
#endif |
|
379 |
||
380 |
||
381 |
// LEAF routines do not lock, GC or throw exceptions |
|
382 |
||
10969
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
383 |
#define VM_LEAF_BASE(result_type, header) \ |
1 | 384 |
TRACE_CALL(result_type, header) \ |
385 |
debug_only(NoHandleMark __hm;) \ |
|
11961
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
10969
diff
changeset
|
386 |
os::verify_stack_alignment(); \ |
1 | 387 |
/* begin of body */ |
388 |
||
36086 | 389 |
#define VM_ENTRY_BASE_FROM_LEAF(result_type, header, thread) \ |
390 |
TRACE_CALL(result_type, header) \ |
|
391 |
debug_only(ResetNoHandleMark __rnhm;) \ |
|
392 |
HandleMarkCleaner __hm(thread); \ |
|
393 |
Thread* THREAD = thread; \ |
|
394 |
os::verify_stack_alignment(); \ |
|
395 |
/* begin of body */ |
|
396 |
||
1 | 397 |
|
398 |
// ENTRY routines may lock, GC and throw exceptions |
|
399 |
||
10969
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
400 |
#define VM_ENTRY_BASE(result_type, header, thread) \ |
1 | 401 |
TRACE_CALL(result_type, header) \ |
402 |
HandleMarkCleaner __hm(thread); \ |
|
403 |
Thread* THREAD = thread; \ |
|
11961
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
10969
diff
changeset
|
404 |
os::verify_stack_alignment(); \ |
1 | 405 |
/* begin of body */ |
406 |
||
407 |
||
408 |
// QUICK_ENTRY routines behave like ENTRY but without a handle mark |
|
409 |
||
10969
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
410 |
#define VM_QUICK_ENTRY_BASE(result_type, header, thread) \ |
1 | 411 |
TRACE_CALL(result_type, header) \ |
412 |
debug_only(NoHandleMark __hm;) \ |
|
413 |
Thread* THREAD = thread; \ |
|
11961
0abd4cd26e5a
7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents:
10969
diff
changeset
|
414 |
os::verify_stack_alignment(); \ |
1 | 415 |
/* begin of body */ |
416 |
||
417 |
||
418 |
// Definitions for IRT (Interpreter Runtime) |
|
419 |
// (thread is an argument passed in to all these routines) |
|
420 |
||
421 |
#define IRT_ENTRY(result_type, header) \ |
|
422 |
result_type header { \ |
|
423 |
ThreadInVMfromJava __tiv(thread); \ |
|
10969
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
424 |
VM_ENTRY_BASE(result_type, header, thread) \ |
1 | 425 |
debug_only(VMEntryWrapper __vew;) |
426 |
||
427 |
||
428 |
#define IRT_LEAF(result_type, header) \ |
|
429 |
result_type header { \ |
|
10969
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
430 |
VM_LEAF_BASE(result_type, header) \ |
35492
c8c0273e6b91
8146690: Make all classes in GC follow the naming convention.
david
parents:
34633
diff
changeset
|
431 |
debug_only(NoSafepointVerifier __nspv(true);) |
1 | 432 |
|
433 |
||
434 |
#define IRT_ENTRY_NO_ASYNC(result_type, header) \ |
|
435 |
result_type header { \ |
|
436 |
ThreadInVMfromJavaNoAsyncException __tiv(thread); \ |
|
10969
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
437 |
VM_ENTRY_BASE(result_type, header, thread) \ |
1 | 438 |
debug_only(VMEntryWrapper __vew;) |
439 |
||
440 |
#define IRT_END } |
|
441 |
||
442 |
#define JRT_ENTRY(result_type, header) \ |
|
443 |
result_type header { \ |
|
444 |
ThreadInVMfromJava __tiv(thread); \ |
|
10969
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
445 |
VM_ENTRY_BASE(result_type, header, thread) \ |
1 | 446 |
debug_only(VMEntryWrapper __vew;) |
447 |
||
448 |
||
449 |
#define JRT_LEAF(result_type, header) \ |
|
450 |
result_type header { \ |
|
10969
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
451 |
VM_LEAF_BASE(result_type, header) \ |
35492
c8c0273e6b91
8146690: Make all classes in GC follow the naming convention.
david
parents:
34633
diff
changeset
|
452 |
debug_only(JRTLeafVerifier __jlv;) |
1 | 453 |
|
454 |
||
455 |
#define JRT_ENTRY_NO_ASYNC(result_type, header) \ |
|
456 |
result_type header { \ |
|
457 |
ThreadInVMfromJavaNoAsyncException __tiv(thread); \ |
|
10969
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
458 |
VM_ENTRY_BASE(result_type, header, thread) \ |
1 | 459 |
debug_only(VMEntryWrapper __vew;) |
460 |
||
461 |
// Same as JRT Entry but allows for return value after the safepoint |
|
462 |
// to get back into Java from the VM |
|
463 |
#define JRT_BLOCK_ENTRY(result_type, header) \ |
|
464 |
result_type header { \ |
|
465 |
TRACE_CALL(result_type, header) \ |
|
466 |
HandleMarkCleaner __hm(thread); |
|
467 |
||
468 |
#define JRT_BLOCK \ |
|
469 |
{ \ |
|
470 |
ThreadInVMfromJava __tiv(thread); \ |
|
471 |
Thread* THREAD = thread; \ |
|
472 |
debug_only(VMEntryWrapper __vew;) |
|
473 |
||
29070 | 474 |
#define JRT_BLOCK_NO_ASYNC \ |
475 |
{ \ |
|
476 |
ThreadInVMfromJavaNoAsyncException __tiv(thread); \ |
|
477 |
Thread* THREAD = thread; \ |
|
478 |
debug_only(VMEntryWrapper __vew;) |
|
479 |
||
1 | 480 |
#define JRT_BLOCK_END } |
481 |
||
482 |
#define JRT_END } |
|
483 |
||
484 |
// Definitions for JNI |
|
485 |
||
486 |
#define JNI_ENTRY(result_type, header) \ |
|
487 |
JNI_ENTRY_NO_PRESERVE(result_type, header) \ |
|
488 |
WeakPreserveExceptionMark __wem(thread); |
|
489 |
||
36551 | 490 |
#define JNI_ENTRY_NO_PRESERVE(result_type, header) \ |
1 | 491 |
extern "C" { \ |
36551 | 492 |
result_type JNICALL header { \ |
1 | 493 |
JavaThread* thread=JavaThread::thread_from_jni_environment(env); \ |
494 |
assert( !VerifyJNIEnvThread || (thread == Thread::current()), "JNIEnv is only valid in same thread"); \ |
|
495 |
ThreadInVMfromNative __tiv(thread); \ |
|
496 |
debug_only(VMNativeEntryWrapper __vew;) \ |
|
10969
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
497 |
VM_ENTRY_BASE(result_type, header, thread) |
1 | 498 |
|
499 |
||
500 |
// Ensure that the VMNativeEntryWrapper constructor, which can cause |
|
10969
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
501 |
// a GC, is called outside the NoHandleMark (set via VM_QUICK_ENTRY_BASE). |
1 | 502 |
#define JNI_QUICK_ENTRY(result_type, header) \ |
503 |
extern "C" { \ |
|
36551 | 504 |
result_type JNICALL header { \ |
1 | 505 |
JavaThread* thread=JavaThread::thread_from_jni_environment(env); \ |
506 |
assert( !VerifyJNIEnvThread || (thread == Thread::current()), "JNIEnv is only valid in same thread"); \ |
|
507 |
ThreadInVMfromNative __tiv(thread); \ |
|
508 |
debug_only(VMNativeEntryWrapper __vew;) \ |
|
10969
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
509 |
VM_QUICK_ENTRY_BASE(result_type, header, thread) |
1 | 510 |
|
511 |
||
512 |
#define JNI_LEAF(result_type, header) \ |
|
513 |
extern "C" { \ |
|
36551 | 514 |
result_type JNICALL header { \ |
1 | 515 |
JavaThread* thread=JavaThread::thread_from_jni_environment(env); \ |
516 |
assert( !VerifyJNIEnvThread || (thread == Thread::current()), "JNIEnv is only valid in same thread"); \ |
|
10969
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
517 |
VM_LEAF_BASE(result_type, header) |
1 | 518 |
|
519 |
||
520 |
// Close the routine and the extern "C" |
|
521 |
#define JNI_END } } |
|
522 |
||
523 |
||
524 |
||
525 |
// Definitions for JVM |
|
526 |
||
527 |
#define JVM_ENTRY(result_type, header) \ |
|
528 |
extern "C" { \ |
|
529 |
result_type JNICALL header { \ |
|
530 |
JavaThread* thread=JavaThread::thread_from_jni_environment(env); \ |
|
531 |
ThreadInVMfromNative __tiv(thread); \ |
|
532 |
debug_only(VMNativeEntryWrapper __vew;) \ |
|
10969
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
533 |
VM_ENTRY_BASE(result_type, header, thread) |
1 | 534 |
|
535 |
||
536 |
#define JVM_ENTRY_NO_ENV(result_type, header) \ |
|
537 |
extern "C" { \ |
|
538 |
result_type JNICALL header { \ |
|
34633
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
34285
diff
changeset
|
539 |
JavaThread* thread = JavaThread::current(); \ |
1 | 540 |
ThreadInVMfromNative __tiv(thread); \ |
541 |
debug_only(VMNativeEntryWrapper __vew;) \ |
|
10969
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
542 |
VM_ENTRY_BASE(result_type, header, thread) |
1 | 543 |
|
544 |
||
545 |
#define JVM_QUICK_ENTRY(result_type, header) \ |
|
546 |
extern "C" { \ |
|
547 |
result_type JNICALL header { \ |
|
548 |
JavaThread* thread=JavaThread::thread_from_jni_environment(env); \ |
|
549 |
ThreadInVMfromNative __tiv(thread); \ |
|
550 |
debug_only(VMNativeEntryWrapper __vew;) \ |
|
10969
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
551 |
VM_QUICK_ENTRY_BASE(result_type, header, thread) |
1 | 552 |
|
553 |
||
554 |
#define JVM_LEAF(result_type, header) \ |
|
555 |
extern "C" { \ |
|
556 |
result_type JNICALL header { \ |
|
557 |
VM_Exit::block_if_vm_exited(); \ |
|
10969
3ecf25293e5a
7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents:
10565
diff
changeset
|
558 |
VM_LEAF_BASE(result_type, header) |
1 | 559 |
|
560 |
||
36086 | 561 |
#define JVM_ENTRY_FROM_LEAF(env, result_type, header) \ |
562 |
{ { \ |
|
563 |
JavaThread* thread=JavaThread::thread_from_jni_environment(env); \ |
|
564 |
ThreadInVMfromNative __tiv(thread); \ |
|
565 |
debug_only(VMNativeEntryWrapper __vew;) \ |
|
566 |
VM_ENTRY_BASE_FROM_LEAF(result_type, header, thread) |
|
567 |
||
568 |
||
1 | 569 |
#define JVM_END } } |
7397 | 570 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52877
diff
changeset
|
571 |
#endif // SHARE_RUNTIME_INTERFACESUPPORT_INLINE_HPP |