annotate src/share/vm/runtime/interfaceSupport.hpp @ 6842:b9a9ed0f8eeb

7197424: update copyright year to match last edit in jdk8 hotspot repository Summary: Update copyright year to 2012 for relevant files Reviewed-by: dholmes, coleenp
author mikael
date Tue, 09 Oct 2012 10:09:34 -0700
parents da4be62fb889
children f34d701e952e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6842
b9a9ed0f8eeb 7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents: 5903
diff changeset
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_RUNTIME_INTERFACESUPPORT_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_RUNTIME_INTERFACESUPPORT_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/gcLocker.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "runtime/handles.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "runtime/mutexLocker.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "runtime/orderAccess.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "runtime/os.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "runtime/safepoint.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #include "runtime/vmThread.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 #include "utilities/globalDefinitions.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36 #include "utilities/preserveException.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
37 #include "utilities/top.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
38 #ifdef TARGET_OS_FAMILY_linux
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
39 # include "thread_linux.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
40 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
41 #ifdef TARGET_OS_FAMILY_solaris
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
42 # include "thread_solaris.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
43 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
44 #ifdef TARGET_OS_FAMILY_windows
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
45 # include "thread_windows.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
46 #endif
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 2426
diff changeset
47 #ifdef TARGET_OS_FAMILY_bsd
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 2426
diff changeset
48 # include "thread_bsd.inline.hpp"
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 2426
diff changeset
49 #endif
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
50
0
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // Wrapper for all entry points to the virtual machine.
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // The HandleMarkCleaner is a faster version of HandleMark.
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // It relies on the fact that there is a HandleMark further
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // down the stack (in JavaCalls::call_helper), and just resets
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // to the saved values in that HandleMark.
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 class HandleMarkCleaner: public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
59 Thread* _thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
61 HandleMarkCleaner(Thread* thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 _thread = thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 _thread->last_handle_mark()->push();
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65 ~HandleMarkCleaner() {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 _thread->last_handle_mark()->pop_and_restore();
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
70 inline void* operator new(size_t size, void* ptr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 return ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73 };
a61af66fc99e Initial load
duke
parents:
diff changeset
74
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
75 // InterfaceSupport provides functionality used by the VM_LEAF_BASE and
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
76 // VM_ENTRY_BASE macros. These macros are used to guard entry points into
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
77 // the VM and perform checks upon leave of the VM.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 class InterfaceSupport: AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 # ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
82 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
83 static long _scavenge_alot_counter;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 static long _fullgc_alot_counter;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 static long _number_of_calls;
a61af66fc99e Initial load
duke
parents:
diff changeset
86 static long _fullgc_alot_invocation;
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // tracing
a61af66fc99e Initial load
duke
parents:
diff changeset
89 static void trace(const char* result_type, const char* header);
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // Helper methods used to implement +ScavengeALot and +FullGCALot
a61af66fc99e Initial load
duke
parents:
diff changeset
92 static void check_gc_alot() { if (ScavengeALot || FullGCALot) gc_alot(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
93 static void gc_alot();
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 static void walk_stack_from(vframe* start_vf);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 static void walk_stack();
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 # ifdef ENABLE_ZAP_DEAD_LOCALS
a61af66fc99e Initial load
duke
parents:
diff changeset
99 static void zap_dead_locals_old();
a61af66fc99e Initial load
duke
parents:
diff changeset
100 # endif
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 static void zombieAll();
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
103 static void unlinkSymbols();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
104 static void deoptimizeAll();
a61af66fc99e Initial load
duke
parents:
diff changeset
105 static void stress_derived_pointers();
a61af66fc99e Initial load
duke
parents:
diff changeset
106 static void verify_stack();
a61af66fc99e Initial load
duke
parents:
diff changeset
107 static void verify_last_frame();
a61af66fc99e Initial load
duke
parents:
diff changeset
108 # endif
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // OS dependent stuff
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
112 #ifdef TARGET_OS_FAMILY_linux
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
113 # include "interfaceSupport_linux.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
114 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
115 #ifdef TARGET_OS_FAMILY_solaris
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
116 # include "interfaceSupport_solaris.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
117 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
118 #ifdef TARGET_OS_FAMILY_windows
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
119 # include "interfaceSupport_windows.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
120 #endif
3960
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 2426
diff changeset
121 #ifdef TARGET_OS_FAMILY_bsd
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 2426
diff changeset
122 # include "interfaceSupport_bsd.hpp"
f08d439fab8c 7089790: integrate bsd-port changes
never
parents: 2426
diff changeset
123 #endif
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
124
0
a61af66fc99e Initial load
duke
parents:
diff changeset
125 };
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // Basic class for all thread transition classes.
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 class ThreadStateTransition : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
132 JavaThread* _thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
134 ThreadStateTransition(JavaThread *thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 _thread = thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 assert(thread != NULL && thread->is_Java_thread(), "must be Java thread");
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // Change threadstate in a manner, so safepoint can detect changes.
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // Time-critical: called on exit from every runtime routine
a61af66fc99e Initial load
duke
parents:
diff changeset
141 static inline void transition(JavaThread *thread, JavaThreadState from, JavaThreadState to) {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 assert(from != _thread_in_Java, "use transition_from_java");
a61af66fc99e Initial load
duke
parents:
diff changeset
143 assert(from != _thread_in_native, "use transition_from_native");
a61af66fc99e Initial load
duke
parents:
diff changeset
144 assert((from & 1) == 0 && (to & 1) == 0, "odd numbers are transitions states");
a61af66fc99e Initial load
duke
parents:
diff changeset
145 assert(thread->thread_state() == from, "coming from wrong thread state");
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // Change to transition state (assumes total store ordering! -Urs)
a61af66fc99e Initial load
duke
parents:
diff changeset
147 thread->set_thread_state((JavaThreadState)(from + 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // Make sure new state is seen by VM thread
a61af66fc99e Initial load
duke
parents:
diff changeset
150 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 if (UseMembar) {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // Force a fence between the write above and read below
a61af66fc99e Initial load
duke
parents:
diff changeset
153 OrderAccess::fence();
a61af66fc99e Initial load
duke
parents:
diff changeset
154 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // store to serialize page so VM thread can do pseudo remote membar
a61af66fc99e Initial load
duke
parents:
diff changeset
156 os::write_memory_serialize_page(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 if (SafepointSynchronize::do_call_back()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 SafepointSynchronize::block(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163 thread->set_thread_state(to);
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();)
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // transition_and_fence must be used on any thread state transition
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // where there might not be a Java call stub on the stack, in
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // particular on Windows where the Structured Exception Handler is
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // set up in the call stub. os::write_memory_serialize_page() can
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // fault and we can't recover from it on Windows without a SEH in
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // place.
a61af66fc99e Initial load
duke
parents:
diff changeset
174 static inline void transition_and_fence(JavaThread *thread, JavaThreadState from, JavaThreadState to) {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 assert(thread->thread_state() == from, "coming from wrong thread state");
a61af66fc99e Initial load
duke
parents:
diff changeset
176 assert((from & 1) == 0 && (to & 1) == 0, "odd numbers are transitions states");
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // Change to transition state (assumes total store ordering! -Urs)
a61af66fc99e Initial load
duke
parents:
diff changeset
178 thread->set_thread_state((JavaThreadState)(from + 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // Make sure new state is seen by VM thread
a61af66fc99e Initial load
duke
parents:
diff changeset
181 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
182 if (UseMembar) {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 // Force a fence between the write above and read below
a61af66fc99e Initial load
duke
parents:
diff changeset
184 OrderAccess::fence();
a61af66fc99e Initial load
duke
parents:
diff changeset
185 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // Must use this rather than serialization page in particular on Windows
a61af66fc99e Initial load
duke
parents:
diff changeset
187 InterfaceSupport::serialize_memory(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 if (SafepointSynchronize::do_call_back()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 SafepointSynchronize::block(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194 thread->set_thread_state(to);
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();)
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // Same as above, but assumes from = _thread_in_Java. This is simpler, since we
a61af66fc99e Initial load
duke
parents:
diff changeset
200 // never block on entry to the VM. This will break the code, since e.g. preserve arguments
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // have not been setup.
a61af66fc99e Initial load
duke
parents:
diff changeset
202 static inline void transition_from_java(JavaThread *thread, JavaThreadState to) {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 assert(thread->thread_state() == _thread_in_Java, "coming from wrong thread state");
a61af66fc99e Initial load
duke
parents:
diff changeset
204 thread->set_thread_state(to);
a61af66fc99e Initial load
duke
parents:
diff changeset
205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 static inline void transition_from_native(JavaThread *thread, JavaThreadState to) {
a61af66fc99e Initial load
duke
parents:
diff changeset
208 assert((to & 1) == 0, "odd numbers are transitions states");
a61af66fc99e Initial load
duke
parents:
diff changeset
209 assert(thread->thread_state() == _thread_in_native, "coming from wrong thread state");
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // Change to transition state (assumes total store ordering! -Urs)
a61af66fc99e Initial load
duke
parents:
diff changeset
211 thread->set_thread_state(_thread_in_native_trans);
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // Make sure new state is seen by GC thread
a61af66fc99e Initial load
duke
parents:
diff changeset
214 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 if (UseMembar) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // Force a fence between the write above and read below
a61af66fc99e Initial load
duke
parents:
diff changeset
217 OrderAccess::fence();
a61af66fc99e Initial load
duke
parents:
diff changeset
218 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 // Must use this rather than serialization page in particular on Windows
a61af66fc99e Initial load
duke
parents:
diff changeset
220 InterfaceSupport::serialize_memory(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // We never install asynchronous exceptions when coming (back) in
a61af66fc99e Initial load
duke
parents:
diff changeset
225 // to the runtime from native code because the runtime is not set
a61af66fc99e Initial load
duke
parents:
diff changeset
226 // up to handle exceptions floating around at arbitrary points.
a61af66fc99e Initial load
duke
parents:
diff changeset
227 if (SafepointSynchronize::do_call_back() || thread->is_suspend_after_native()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
228 JavaThread::check_safepoint_and_suspend_for_native_trans(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
229
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // Clear unhandled oops anywhere where we could block, even if we don't.
a61af66fc99e Initial load
duke
parents:
diff changeset
231 CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();)
a61af66fc99e Initial load
duke
parents:
diff changeset
232 }
a61af66fc99e Initial load
duke
parents:
diff changeset
233
a61af66fc99e Initial load
duke
parents:
diff changeset
234 thread->set_thread_state(to);
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
237 void trans(JavaThreadState from, JavaThreadState to) { transition(_thread, from, to); }
a61af66fc99e Initial load
duke
parents:
diff changeset
238 void trans_from_java(JavaThreadState to) { transition_from_java(_thread, to); }
a61af66fc99e Initial load
duke
parents:
diff changeset
239 void trans_from_native(JavaThreadState to) { transition_from_native(_thread, to); }
a61af66fc99e Initial load
duke
parents:
diff changeset
240 void trans_and_fence(JavaThreadState from, JavaThreadState to) { transition_and_fence(_thread, from, to); }
a61af66fc99e Initial load
duke
parents:
diff changeset
241 };
a61af66fc99e Initial load
duke
parents:
diff changeset
242
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 class ThreadInVMfromJava : public ThreadStateTransition {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
246 ThreadInVMfromJava(JavaThread* thread) : ThreadStateTransition(thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
247 trans_from_java(_thread_in_vm);
a61af66fc99e Initial load
duke
parents:
diff changeset
248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
249 ~ThreadInVMfromJava() {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 trans(_thread_in_vm, _thread_in_Java);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 // Check for pending. async. exceptions or suspends.
a61af66fc99e Initial load
duke
parents:
diff changeset
252 if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition();
a61af66fc99e Initial load
duke
parents:
diff changeset
253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
254 };
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256
a61af66fc99e Initial load
duke
parents:
diff changeset
257 class ThreadInVMfromUnknown {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
259 JavaThread* _thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
260 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
261 ThreadInVMfromUnknown() : _thread(NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 Thread* t = Thread::current();
a61af66fc99e Initial load
duke
parents:
diff changeset
263 if (t->is_Java_thread()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
264 JavaThread* t2 = (JavaThread*) t;
a61af66fc99e Initial load
duke
parents:
diff changeset
265 if (t2->thread_state() == _thread_in_native) {
a61af66fc99e Initial load
duke
parents:
diff changeset
266 _thread = t2;
a61af66fc99e Initial load
duke
parents:
diff changeset
267 ThreadStateTransition::transition_from_native(t2, _thread_in_vm);
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // Used to have a HandleMarkCleaner but that is dangerous as
a61af66fc99e Initial load
duke
parents:
diff changeset
269 // it could free a handle in our (indirect, nested) caller.
a61af66fc99e Initial load
duke
parents:
diff changeset
270 // We expect any handles will be short lived and figure we
a61af66fc99e Initial load
duke
parents:
diff changeset
271 // don't need an actual HandleMark.
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
275 ~ThreadInVMfromUnknown() {
a61af66fc99e Initial load
duke
parents:
diff changeset
276 if (_thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
277 ThreadStateTransition::transition_and_fence(_thread, _thread_in_vm, _thread_in_native);
a61af66fc99e Initial load
duke
parents:
diff changeset
278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
280 };
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282
a61af66fc99e Initial load
duke
parents:
diff changeset
283 class ThreadInVMfromNative : public ThreadStateTransition {
a61af66fc99e Initial load
duke
parents:
diff changeset
284 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
285 ThreadInVMfromNative(JavaThread* thread) : ThreadStateTransition(thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 trans_from_native(_thread_in_vm);
a61af66fc99e Initial load
duke
parents:
diff changeset
287 }
a61af66fc99e Initial load
duke
parents:
diff changeset
288 ~ThreadInVMfromNative() {
a61af66fc99e Initial load
duke
parents:
diff changeset
289 trans_and_fence(_thread_in_vm, _thread_in_native);
a61af66fc99e Initial load
duke
parents:
diff changeset
290 }
a61af66fc99e Initial load
duke
parents:
diff changeset
291 };
a61af66fc99e Initial load
duke
parents:
diff changeset
292
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 class ThreadToNativeFromVM : public ThreadStateTransition {
a61af66fc99e Initial load
duke
parents:
diff changeset
295 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
296 ThreadToNativeFromVM(JavaThread *thread) : ThreadStateTransition(thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
297 // We are leaving the VM at this point and going directly to native code.
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // Block, if we are in the middle of a safepoint synchronization.
a61af66fc99e Initial load
duke
parents:
diff changeset
299 assert(!thread->owns_locks(), "must release all locks when leaving VM");
a61af66fc99e Initial load
duke
parents:
diff changeset
300 thread->frame_anchor()->make_walkable(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
301 trans_and_fence(_thread_in_vm, _thread_in_native);
a61af66fc99e Initial load
duke
parents:
diff changeset
302 // Check for pending. async. exceptions or suspends.
a61af66fc99e Initial load
duke
parents:
diff changeset
303 if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
304 }
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306 ~ThreadToNativeFromVM() {
a61af66fc99e Initial load
duke
parents:
diff changeset
307 trans_from_native(_thread_in_vm);
a61af66fc99e Initial load
duke
parents:
diff changeset
308 // We don't need to clear_walkable because it will happen automagically when we return to java
a61af66fc99e Initial load
duke
parents:
diff changeset
309 }
a61af66fc99e Initial load
duke
parents:
diff changeset
310 };
a61af66fc99e Initial load
duke
parents:
diff changeset
311
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 class ThreadBlockInVM : public ThreadStateTransition {
a61af66fc99e Initial load
duke
parents:
diff changeset
314 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
315 ThreadBlockInVM(JavaThread *thread)
a61af66fc99e Initial load
duke
parents:
diff changeset
316 : ThreadStateTransition(thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
317 // Once we are blocked vm expects stack to be walkable
a61af66fc99e Initial load
duke
parents:
diff changeset
318 thread->frame_anchor()->make_walkable(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
319 trans_and_fence(_thread_in_vm, _thread_blocked);
a61af66fc99e Initial load
duke
parents:
diff changeset
320 }
a61af66fc99e Initial load
duke
parents:
diff changeset
321 ~ThreadBlockInVM() {
a61af66fc99e Initial load
duke
parents:
diff changeset
322 trans_and_fence(_thread_blocked, _thread_in_vm);
a61af66fc99e Initial load
duke
parents:
diff changeset
323 // We don't need to clear_walkable because it will happen automagically when we return to java
a61af66fc99e Initial load
duke
parents:
diff changeset
324 }
a61af66fc99e Initial load
duke
parents:
diff changeset
325 };
a61af66fc99e Initial load
duke
parents:
diff changeset
326
a61af66fc99e Initial load
duke
parents:
diff changeset
327
a61af66fc99e Initial load
duke
parents:
diff changeset
328 // This special transition class is only used to prevent asynchronous exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
329 // from being installed on vm exit in situations where we can't tolerate them.
a61af66fc99e Initial load
duke
parents:
diff changeset
330 // See bugs: 4324348, 4854693, 4998314, 5040492, 5050705.
a61af66fc99e Initial load
duke
parents:
diff changeset
331 class ThreadInVMfromJavaNoAsyncException : public ThreadStateTransition {
a61af66fc99e Initial load
duke
parents:
diff changeset
332 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
333 ThreadInVMfromJavaNoAsyncException(JavaThread* thread) : ThreadStateTransition(thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
334 trans_from_java(_thread_in_vm);
a61af66fc99e Initial load
duke
parents:
diff changeset
335 }
a61af66fc99e Initial load
duke
parents:
diff changeset
336 ~ThreadInVMfromJavaNoAsyncException() {
a61af66fc99e Initial load
duke
parents:
diff changeset
337 trans(_thread_in_vm, _thread_in_Java);
a61af66fc99e Initial load
duke
parents:
diff changeset
338 // NOTE: We do not check for pending. async. exceptions.
a61af66fc99e Initial load
duke
parents:
diff changeset
339 // If we did and moved the pending async exception over into the
a61af66fc99e Initial load
duke
parents:
diff changeset
340 // pending exception field, we would need to deopt (currently C2
a61af66fc99e Initial load
duke
parents:
diff changeset
341 // only). However, to do so would require that we transition back
a61af66fc99e Initial load
duke
parents:
diff changeset
342 // to the _thread_in_vm state. Instead we postpone the handling of
a61af66fc99e Initial load
duke
parents:
diff changeset
343 // the async exception.
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345 // Check for pending. suspends only.
a61af66fc99e Initial load
duke
parents:
diff changeset
346 if (_thread->has_special_runtime_exit_condition())
a61af66fc99e Initial load
duke
parents:
diff changeset
347 _thread->handle_special_runtime_exit_condition(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
348 }
a61af66fc99e Initial load
duke
parents:
diff changeset
349 };
a61af66fc99e Initial load
duke
parents:
diff changeset
350
a61af66fc99e Initial load
duke
parents:
diff changeset
351 // Debug class instantiated in JRT_ENTRY and ITR_ENTRY macro.
a61af66fc99e Initial load
duke
parents:
diff changeset
352 // Can be used to verify properties on enter/exit of the VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
353
a61af66fc99e Initial load
duke
parents:
diff changeset
354 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
355 class VMEntryWrapper {
a61af66fc99e Initial load
duke
parents:
diff changeset
356 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
357 VMEntryWrapper() {
a61af66fc99e Initial load
duke
parents:
diff changeset
358 if (VerifyLastFrame) {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 InterfaceSupport::verify_last_frame();
a61af66fc99e Initial load
duke
parents:
diff changeset
360 }
a61af66fc99e Initial load
duke
parents:
diff changeset
361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
362
a61af66fc99e Initial load
duke
parents:
diff changeset
363 ~VMEntryWrapper() {
a61af66fc99e Initial load
duke
parents:
diff changeset
364 InterfaceSupport::check_gc_alot();
a61af66fc99e Initial load
duke
parents:
diff changeset
365 if (WalkStackALot) {
a61af66fc99e Initial load
duke
parents:
diff changeset
366 InterfaceSupport::walk_stack();
a61af66fc99e Initial load
duke
parents:
diff changeset
367 }
a61af66fc99e Initial load
duke
parents:
diff changeset
368 #ifdef ENABLE_ZAP_DEAD_LOCALS
a61af66fc99e Initial load
duke
parents:
diff changeset
369 if (ZapDeadLocalsOld) {
a61af66fc99e Initial load
duke
parents:
diff changeset
370 InterfaceSupport::zap_dead_locals_old();
a61af66fc99e Initial load
duke
parents:
diff changeset
371 }
a61af66fc99e Initial load
duke
parents:
diff changeset
372 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
373 #ifdef COMPILER2
a61af66fc99e Initial load
duke
parents:
diff changeset
374 // This option is not used by Compiler 1
a61af66fc99e Initial load
duke
parents:
diff changeset
375 if (StressDerivedPointers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
376 InterfaceSupport::stress_derived_pointers();
a61af66fc99e Initial load
duke
parents:
diff changeset
377 }
a61af66fc99e Initial load
duke
parents:
diff changeset
378 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
379 if (DeoptimizeALot || DeoptimizeRandom) {
a61af66fc99e Initial load
duke
parents:
diff changeset
380 InterfaceSupport::deoptimizeAll();
a61af66fc99e Initial load
duke
parents:
diff changeset
381 }
a61af66fc99e Initial load
duke
parents:
diff changeset
382 if (ZombieALot) {
a61af66fc99e Initial load
duke
parents:
diff changeset
383 InterfaceSupport::zombieAll();
a61af66fc99e Initial load
duke
parents:
diff changeset
384 }
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
385 if (UnlinkSymbolsALot) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
386 InterfaceSupport::unlinkSymbols();
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
387 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
388 // do verification AFTER potential deoptimization
a61af66fc99e Initial load
duke
parents:
diff changeset
389 if (VerifyStack) {
a61af66fc99e Initial load
duke
parents:
diff changeset
390 InterfaceSupport::verify_stack();
a61af66fc99e Initial load
duke
parents:
diff changeset
391 }
a61af66fc99e Initial load
duke
parents:
diff changeset
392
a61af66fc99e Initial load
duke
parents:
diff changeset
393 }
a61af66fc99e Initial load
duke
parents:
diff changeset
394 };
a61af66fc99e Initial load
duke
parents:
diff changeset
395
a61af66fc99e Initial load
duke
parents:
diff changeset
396
a61af66fc99e Initial load
duke
parents:
diff changeset
397 class VMNativeEntryWrapper {
a61af66fc99e Initial load
duke
parents:
diff changeset
398 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
399 VMNativeEntryWrapper() {
a61af66fc99e Initial load
duke
parents:
diff changeset
400 if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot();
a61af66fc99e Initial load
duke
parents:
diff changeset
401 }
a61af66fc99e Initial load
duke
parents:
diff changeset
402
a61af66fc99e Initial load
duke
parents:
diff changeset
403 ~VMNativeEntryWrapper() {
a61af66fc99e Initial load
duke
parents:
diff changeset
404 if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot();
a61af66fc99e Initial load
duke
parents:
diff changeset
405 }
a61af66fc99e Initial load
duke
parents:
diff changeset
406 };
a61af66fc99e Initial load
duke
parents:
diff changeset
407
a61af66fc99e Initial load
duke
parents:
diff changeset
408 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
409
a61af66fc99e Initial load
duke
parents:
diff changeset
410
a61af66fc99e Initial load
duke
parents:
diff changeset
411 // VM-internal runtime interface support
a61af66fc99e Initial load
duke
parents:
diff changeset
412
a61af66fc99e Initial load
duke
parents:
diff changeset
413 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
414
a61af66fc99e Initial load
duke
parents:
diff changeset
415 class RuntimeHistogramElement : public HistogramElement {
a61af66fc99e Initial load
duke
parents:
diff changeset
416 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
417 RuntimeHistogramElement(const char* name);
a61af66fc99e Initial load
duke
parents:
diff changeset
418 };
a61af66fc99e Initial load
duke
parents:
diff changeset
419
a61af66fc99e Initial load
duke
parents:
diff changeset
420 #define TRACE_CALL(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
421 InterfaceSupport::_number_of_calls++; \
a61af66fc99e Initial load
duke
parents:
diff changeset
422 if (TraceRuntimeCalls) \
a61af66fc99e Initial load
duke
parents:
diff changeset
423 InterfaceSupport::trace(#result_type, #header); \
a61af66fc99e Initial load
duke
parents:
diff changeset
424 if (CountRuntimeCalls) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
425 static RuntimeHistogramElement* e = new RuntimeHistogramElement(#header); \
a61af66fc99e Initial load
duke
parents:
diff changeset
426 if (e != NULL) e->increment_count(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
427 }
a61af66fc99e Initial load
duke
parents:
diff changeset
428 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
429 #define TRACE_CALL(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
430 /* do nothing */
a61af66fc99e Initial load
duke
parents:
diff changeset
431 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
432
a61af66fc99e Initial load
duke
parents:
diff changeset
433
a61af66fc99e Initial load
duke
parents:
diff changeset
434 // LEAF routines do not lock, GC or throw exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
435
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
436 #define VM_LEAF_BASE(result_type, header) \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
437 TRACE_CALL(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
438 debug_only(NoHandleMark __hm;) \
5903
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 4045
diff changeset
439 os::verify_stack_alignment(); \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
440 /* begin of body */
a61af66fc99e Initial load
duke
parents:
diff changeset
441
a61af66fc99e Initial load
duke
parents:
diff changeset
442
a61af66fc99e Initial load
duke
parents:
diff changeset
443 // ENTRY routines may lock, GC and throw exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
444
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
445 #define VM_ENTRY_BASE(result_type, header, thread) \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
446 TRACE_CALL(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
447 HandleMarkCleaner __hm(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
448 Thread* THREAD = thread; \
5903
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 4045
diff changeset
449 os::verify_stack_alignment(); \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
450 /* begin of body */
a61af66fc99e Initial load
duke
parents:
diff changeset
451
a61af66fc99e Initial load
duke
parents:
diff changeset
452
a61af66fc99e Initial load
duke
parents:
diff changeset
453 // QUICK_ENTRY routines behave like ENTRY but without a handle mark
a61af66fc99e Initial load
duke
parents:
diff changeset
454
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
455 #define VM_QUICK_ENTRY_BASE(result_type, header, thread) \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
456 TRACE_CALL(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
457 debug_only(NoHandleMark __hm;) \
a61af66fc99e Initial load
duke
parents:
diff changeset
458 Thread* THREAD = thread; \
5903
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 4045
diff changeset
459 os::verify_stack_alignment(); \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
460 /* begin of body */
a61af66fc99e Initial load
duke
parents:
diff changeset
461
a61af66fc99e Initial load
duke
parents:
diff changeset
462
a61af66fc99e Initial load
duke
parents:
diff changeset
463 // Definitions for IRT (Interpreter Runtime)
a61af66fc99e Initial load
duke
parents:
diff changeset
464 // (thread is an argument passed in to all these routines)
a61af66fc99e Initial load
duke
parents:
diff changeset
465
a61af66fc99e Initial load
duke
parents:
diff changeset
466 #define IRT_ENTRY(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
467 result_type header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
468 ThreadInVMfromJava __tiv(thread); \
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
469 VM_ENTRY_BASE(result_type, header, thread) \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
470 debug_only(VMEntryWrapper __vew;)
a61af66fc99e Initial load
duke
parents:
diff changeset
471
a61af66fc99e Initial load
duke
parents:
diff changeset
472
a61af66fc99e Initial load
duke
parents:
diff changeset
473 #define IRT_LEAF(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
474 result_type header { \
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
475 VM_LEAF_BASE(result_type, header) \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
476 debug_only(No_Safepoint_Verifier __nspv(true);)
a61af66fc99e Initial load
duke
parents:
diff changeset
477
a61af66fc99e Initial load
duke
parents:
diff changeset
478
a61af66fc99e Initial load
duke
parents:
diff changeset
479 #define IRT_ENTRY_NO_ASYNC(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
480 result_type header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
481 ThreadInVMfromJavaNoAsyncException __tiv(thread); \
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
482 VM_ENTRY_BASE(result_type, header, thread) \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
483 debug_only(VMEntryWrapper __vew;)
a61af66fc99e Initial load
duke
parents:
diff changeset
484
a61af66fc99e Initial load
duke
parents:
diff changeset
485 // Another special case for nmethod_entry_point so the nmethod that the
a61af66fc99e Initial load
duke
parents:
diff changeset
486 // interpreter is about to branch to doesn't get flushed before as we
a61af66fc99e Initial load
duke
parents:
diff changeset
487 // branch to it's interpreter_entry_point. Skip stress testing here too.
a61af66fc99e Initial load
duke
parents:
diff changeset
488 // Also we don't allow async exceptions because it is just too painful.
a61af66fc99e Initial load
duke
parents:
diff changeset
489 #define IRT_ENTRY_FOR_NMETHOD(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
490 result_type header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
491 nmethodLocker _nmlock(nm); \
a61af66fc99e Initial load
duke
parents:
diff changeset
492 ThreadInVMfromJavaNoAsyncException __tiv(thread); \
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
493 VM_ENTRY_BASE(result_type, header, thread)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
494
a61af66fc99e Initial load
duke
parents:
diff changeset
495 #define IRT_END }
a61af66fc99e Initial load
duke
parents:
diff changeset
496
a61af66fc99e Initial load
duke
parents:
diff changeset
497
a61af66fc99e Initial load
duke
parents:
diff changeset
498 // Definitions for JRT (Java (Compiler/Shared) Runtime)
a61af66fc99e Initial load
duke
parents:
diff changeset
499
a61af66fc99e Initial load
duke
parents:
diff changeset
500 #define JRT_ENTRY(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
501 result_type header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
502 ThreadInVMfromJava __tiv(thread); \
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
503 VM_ENTRY_BASE(result_type, header, thread) \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
504 debug_only(VMEntryWrapper __vew;)
a61af66fc99e Initial load
duke
parents:
diff changeset
505
a61af66fc99e Initial load
duke
parents:
diff changeset
506
a61af66fc99e Initial load
duke
parents:
diff changeset
507 #define JRT_LEAF(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
508 result_type header { \
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
509 VM_LEAF_BASE(result_type, header) \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
510 debug_only(JRT_Leaf_Verifier __jlv;)
a61af66fc99e Initial load
duke
parents:
diff changeset
511
a61af66fc99e Initial load
duke
parents:
diff changeset
512
a61af66fc99e Initial load
duke
parents:
diff changeset
513 #define JRT_ENTRY_NO_ASYNC(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
514 result_type header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
515 ThreadInVMfromJavaNoAsyncException __tiv(thread); \
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
516 VM_ENTRY_BASE(result_type, header, thread) \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
517 debug_only(VMEntryWrapper __vew;)
a61af66fc99e Initial load
duke
parents:
diff changeset
518
a61af66fc99e Initial load
duke
parents:
diff changeset
519 // Same as JRT Entry but allows for return value after the safepoint
a61af66fc99e Initial load
duke
parents:
diff changeset
520 // to get back into Java from the VM
a61af66fc99e Initial load
duke
parents:
diff changeset
521 #define JRT_BLOCK_ENTRY(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
522 result_type header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
523 TRACE_CALL(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
524 HandleMarkCleaner __hm(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
525
a61af66fc99e Initial load
duke
parents:
diff changeset
526 #define JRT_BLOCK \
a61af66fc99e Initial load
duke
parents:
diff changeset
527 { \
a61af66fc99e Initial load
duke
parents:
diff changeset
528 ThreadInVMfromJava __tiv(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
529 Thread* THREAD = thread; \
a61af66fc99e Initial load
duke
parents:
diff changeset
530 debug_only(VMEntryWrapper __vew;)
a61af66fc99e Initial load
duke
parents:
diff changeset
531
a61af66fc99e Initial load
duke
parents:
diff changeset
532 #define JRT_BLOCK_END }
a61af66fc99e Initial load
duke
parents:
diff changeset
533
a61af66fc99e Initial load
duke
parents:
diff changeset
534 #define JRT_END }
a61af66fc99e Initial load
duke
parents:
diff changeset
535
a61af66fc99e Initial load
duke
parents:
diff changeset
536 // Definitions for JNI
a61af66fc99e Initial load
duke
parents:
diff changeset
537
a61af66fc99e Initial load
duke
parents:
diff changeset
538 #define JNI_ENTRY(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
539 JNI_ENTRY_NO_PRESERVE(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
540 WeakPreserveExceptionMark __wem(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
541
a61af66fc99e Initial load
duke
parents:
diff changeset
542 #define JNI_ENTRY_NO_PRESERVE(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
543 extern "C" { \
a61af66fc99e Initial load
duke
parents:
diff changeset
544 result_type JNICALL header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
545 JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
a61af66fc99e Initial load
duke
parents:
diff changeset
546 assert( !VerifyJNIEnvThread || (thread == Thread::current()), "JNIEnv is only valid in same thread"); \
a61af66fc99e Initial load
duke
parents:
diff changeset
547 ThreadInVMfromNative __tiv(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
548 debug_only(VMNativeEntryWrapper __vew;) \
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
549 VM_ENTRY_BASE(result_type, header, thread)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
550
a61af66fc99e Initial load
duke
parents:
diff changeset
551
a61af66fc99e Initial load
duke
parents:
diff changeset
552 // Ensure that the VMNativeEntryWrapper constructor, which can cause
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
553 // a GC, is called outside the NoHandleMark (set via VM_QUICK_ENTRY_BASE).
0
a61af66fc99e Initial load
duke
parents:
diff changeset
554 #define JNI_QUICK_ENTRY(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
555 extern "C" { \
a61af66fc99e Initial load
duke
parents:
diff changeset
556 result_type JNICALL header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
557 JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
a61af66fc99e Initial load
duke
parents:
diff changeset
558 assert( !VerifyJNIEnvThread || (thread == Thread::current()), "JNIEnv is only valid in same thread"); \
a61af66fc99e Initial load
duke
parents:
diff changeset
559 ThreadInVMfromNative __tiv(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
560 debug_only(VMNativeEntryWrapper __vew;) \
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
561 VM_QUICK_ENTRY_BASE(result_type, header, thread)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
562
a61af66fc99e Initial load
duke
parents:
diff changeset
563
a61af66fc99e Initial load
duke
parents:
diff changeset
564 #define JNI_LEAF(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
565 extern "C" { \
a61af66fc99e Initial load
duke
parents:
diff changeset
566 result_type JNICALL header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
567 JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
a61af66fc99e Initial load
duke
parents:
diff changeset
568 assert( !VerifyJNIEnvThread || (thread == Thread::current()), "JNIEnv is only valid in same thread"); \
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
569 VM_LEAF_BASE(result_type, header)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
570
a61af66fc99e Initial load
duke
parents:
diff changeset
571
a61af66fc99e Initial load
duke
parents:
diff changeset
572 // Close the routine and the extern "C"
a61af66fc99e Initial load
duke
parents:
diff changeset
573 #define JNI_END } }
a61af66fc99e Initial load
duke
parents:
diff changeset
574
a61af66fc99e Initial load
duke
parents:
diff changeset
575
a61af66fc99e Initial load
duke
parents:
diff changeset
576
a61af66fc99e Initial load
duke
parents:
diff changeset
577 // Definitions for JVM
a61af66fc99e Initial load
duke
parents:
diff changeset
578
a61af66fc99e Initial load
duke
parents:
diff changeset
579 #define JVM_ENTRY(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
580 extern "C" { \
a61af66fc99e Initial load
duke
parents:
diff changeset
581 result_type JNICALL header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
582 JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
a61af66fc99e Initial load
duke
parents:
diff changeset
583 ThreadInVMfromNative __tiv(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
584 debug_only(VMNativeEntryWrapper __vew;) \
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
585 VM_ENTRY_BASE(result_type, header, thread)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
586
a61af66fc99e Initial load
duke
parents:
diff changeset
587
a61af66fc99e Initial load
duke
parents:
diff changeset
588 #define JVM_ENTRY_NO_ENV(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
589 extern "C" { \
a61af66fc99e Initial load
duke
parents:
diff changeset
590 result_type JNICALL header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
591 JavaThread* thread = (JavaThread*)ThreadLocalStorage::thread(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
592 ThreadInVMfromNative __tiv(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
593 debug_only(VMNativeEntryWrapper __vew;) \
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
594 VM_ENTRY_BASE(result_type, header, thread)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
595
a61af66fc99e Initial load
duke
parents:
diff changeset
596
a61af66fc99e Initial load
duke
parents:
diff changeset
597 #define JVM_QUICK_ENTRY(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
598 extern "C" { \
a61af66fc99e Initial load
duke
parents:
diff changeset
599 result_type JNICALL header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
600 JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
a61af66fc99e Initial load
duke
parents:
diff changeset
601 ThreadInVMfromNative __tiv(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
602 debug_only(VMNativeEntryWrapper __vew;) \
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
603 VM_QUICK_ENTRY_BASE(result_type, header, thread)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
604
a61af66fc99e Initial load
duke
parents:
diff changeset
605
a61af66fc99e Initial load
duke
parents:
diff changeset
606 #define JVM_LEAF(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
607 extern "C" { \
a61af66fc99e Initial load
duke
parents:
diff changeset
608 result_type JNICALL header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
609 VM_Exit::block_if_vm_exited(); \
4045
a6eef545f1a2 7103224: collision between __LEAF define in interfaceSupport.hpp and /usr/include/sys/cdefs.h with gcc
never
parents: 3960
diff changeset
610 VM_LEAF_BASE(result_type, header)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
611
a61af66fc99e Initial load
duke
parents:
diff changeset
612
a61af66fc99e Initial load
duke
parents:
diff changeset
613 #define JVM_END } }
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
614
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
615 #endif // SHARE_VM_RUNTIME_INTERFACESUPPORT_HPP