annotate src/share/vm/runtime/interfaceSupport.hpp @ 1091:6aa7255741f3

6906727: UseCompressedOops: some card-marking fixes related to object arrays Summary: Introduced a new write_ref_array(HeapWords* start, size_t count) method that does the requisite MemRegion range calculation so (some of the) clients of the erstwhile write_ref_array(MemRegion mr) do not need to worry. This removed all external uses of array_size(), which was also simplified and made private. Asserts were added to catch other possible issues. Further, less essential, fixes stemming from this investigation are deferred to CR 6904516 (to follow shortly in hs17). Reviewed-by: kvn, coleenp, jmasa
author ysr
date Thu, 03 Dec 2009 15:01:57 -0800
parents a61af66fc99e
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // Wrapper for all entry points to the virtual machine.
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // The HandleMarkCleaner is a faster version of HandleMark.
a61af66fc99e Initial load
duke
parents:
diff changeset
27 // It relies on the fact that there is a HandleMark further
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // down the stack (in JavaCalls::call_helper), and just resets
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // to the saved values in that HandleMark.
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 class HandleMarkCleaner: public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
32 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
33 Thread* _thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
35 HandleMarkCleaner(Thread* thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
36 _thread = thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 _thread->last_handle_mark()->push();
a61af66fc99e Initial load
duke
parents:
diff changeset
38 }
a61af66fc99e Initial load
duke
parents:
diff changeset
39 ~HandleMarkCleaner() {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 _thread->last_handle_mark()->pop_and_restore();
a61af66fc99e Initial load
duke
parents:
diff changeset
41 }
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
44 inline void* operator new(size_t size, void* ptr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 return ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 }
a61af66fc99e Initial load
duke
parents:
diff changeset
47 };
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // InterfaceSupport provides functionality used by the __LEAF and __ENTRY
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // macros. These macros are used to guard entry points into the VM and
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // perform checks upon leave of the VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 class InterfaceSupport: AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 # ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
56 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
57 static long _scavenge_alot_counter;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 static long _fullgc_alot_counter;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 static long _number_of_calls;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 static long _fullgc_alot_invocation;
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // tracing
a61af66fc99e Initial load
duke
parents:
diff changeset
63 static void trace(const char* result_type, const char* header);
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // Helper methods used to implement +ScavengeALot and +FullGCALot
a61af66fc99e Initial load
duke
parents:
diff changeset
66 static void check_gc_alot() { if (ScavengeALot || FullGCALot) gc_alot(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 static void gc_alot();
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 static void walk_stack_from(vframe* start_vf);
a61af66fc99e Initial load
duke
parents:
diff changeset
70 static void walk_stack();
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 # ifdef ENABLE_ZAP_DEAD_LOCALS
a61af66fc99e Initial load
duke
parents:
diff changeset
73 static void zap_dead_locals_old();
a61af66fc99e Initial load
duke
parents:
diff changeset
74 # endif
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 static void zombieAll();
a61af66fc99e Initial load
duke
parents:
diff changeset
77 static void deoptimizeAll();
a61af66fc99e Initial load
duke
parents:
diff changeset
78 static void stress_derived_pointers();
a61af66fc99e Initial load
duke
parents:
diff changeset
79 static void verify_stack();
a61af66fc99e Initial load
duke
parents:
diff changeset
80 static void verify_last_frame();
a61af66fc99e Initial load
duke
parents:
diff changeset
81 # endif
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // OS dependent stuff
a61af66fc99e Initial load
duke
parents:
diff changeset
85 #include "incls/_interfaceSupport_pd.hpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
86 };
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // Basic class for all thread transition classes.
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 class ThreadStateTransition : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
93 JavaThread* _thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
95 ThreadStateTransition(JavaThread *thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 _thread = thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 assert(thread != NULL && thread->is_Java_thread(), "must be Java thread");
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // Change threadstate in a manner, so safepoint can detect changes.
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // Time-critical: called on exit from every runtime routine
a61af66fc99e Initial load
duke
parents:
diff changeset
102 static inline void transition(JavaThread *thread, JavaThreadState from, JavaThreadState to) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 assert(from != _thread_in_Java, "use transition_from_java");
a61af66fc99e Initial load
duke
parents:
diff changeset
104 assert(from != _thread_in_native, "use transition_from_native");
a61af66fc99e Initial load
duke
parents:
diff changeset
105 assert((from & 1) == 0 && (to & 1) == 0, "odd numbers are transitions states");
a61af66fc99e Initial load
duke
parents:
diff changeset
106 assert(thread->thread_state() == from, "coming from wrong thread state");
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // Change to transition state (assumes total store ordering! -Urs)
a61af66fc99e Initial load
duke
parents:
diff changeset
108 thread->set_thread_state((JavaThreadState)(from + 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // Make sure new state is seen by VM thread
a61af66fc99e Initial load
duke
parents:
diff changeset
111 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 if (UseMembar) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // Force a fence between the write above and read below
a61af66fc99e Initial load
duke
parents:
diff changeset
114 OrderAccess::fence();
a61af66fc99e Initial load
duke
parents:
diff changeset
115 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // store to serialize page so VM thread can do pseudo remote membar
a61af66fc99e Initial load
duke
parents:
diff changeset
117 os::write_memory_serialize_page(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 if (SafepointSynchronize::do_call_back()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 SafepointSynchronize::block(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124 thread->set_thread_state(to);
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();)
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // transition_and_fence must be used on any thread state transition
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // where there might not be a Java call stub on the stack, in
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // particular on Windows where the Structured Exception Handler is
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // set up in the call stub. os::write_memory_serialize_page() can
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // fault and we can't recover from it on Windows without a SEH in
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // place.
a61af66fc99e Initial load
duke
parents:
diff changeset
135 static inline void transition_and_fence(JavaThread *thread, JavaThreadState from, JavaThreadState to) {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 assert(thread->thread_state() == from, "coming from wrong thread state");
a61af66fc99e Initial load
duke
parents:
diff changeset
137 assert((from & 1) == 0 && (to & 1) == 0, "odd numbers are transitions states");
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // Change to transition state (assumes total store ordering! -Urs)
a61af66fc99e Initial load
duke
parents:
diff changeset
139 thread->set_thread_state((JavaThreadState)(from + 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // Make sure new state is seen by VM thread
a61af66fc99e Initial load
duke
parents:
diff changeset
142 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 if (UseMembar) {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // Force a fence between the write above and read below
a61af66fc99e Initial load
duke
parents:
diff changeset
145 OrderAccess::fence();
a61af66fc99e Initial load
duke
parents:
diff changeset
146 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // Must use this rather than serialization page in particular on Windows
a61af66fc99e Initial load
duke
parents:
diff changeset
148 InterfaceSupport::serialize_memory(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 if (SafepointSynchronize::do_call_back()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 SafepointSynchronize::block(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155 thread->set_thread_state(to);
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();)
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // Same as above, but assumes from = _thread_in_Java. This is simpler, since we
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // never block on entry to the VM. This will break the code, since e.g. preserve arguments
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // have not been setup.
a61af66fc99e Initial load
duke
parents:
diff changeset
163 static inline void transition_from_java(JavaThread *thread, JavaThreadState to) {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 assert(thread->thread_state() == _thread_in_Java, "coming from wrong thread state");
a61af66fc99e Initial load
duke
parents:
diff changeset
165 thread->set_thread_state(to);
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 static inline void transition_from_native(JavaThread *thread, JavaThreadState to) {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 assert((to & 1) == 0, "odd numbers are transitions states");
a61af66fc99e Initial load
duke
parents:
diff changeset
170 assert(thread->thread_state() == _thread_in_native, "coming from wrong thread state");
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // Change to transition state (assumes total store ordering! -Urs)
a61af66fc99e Initial load
duke
parents:
diff changeset
172 thread->set_thread_state(_thread_in_native_trans);
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // Make sure new state is seen by GC thread
a61af66fc99e Initial load
duke
parents:
diff changeset
175 if (os::is_MP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 if (UseMembar) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // Force a fence between the write above and read below
a61af66fc99e Initial load
duke
parents:
diff changeset
178 OrderAccess::fence();
a61af66fc99e Initial load
duke
parents:
diff changeset
179 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // Must use this rather than serialization page in particular on Windows
a61af66fc99e Initial load
duke
parents:
diff changeset
181 InterfaceSupport::serialize_memory(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183 }
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // We never install asynchronous exceptions when coming (back) in
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // to the runtime from native code because the runtime is not set
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // up to handle exceptions floating around at arbitrary points.
a61af66fc99e Initial load
duke
parents:
diff changeset
188 if (SafepointSynchronize::do_call_back() || thread->is_suspend_after_native()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
189 JavaThread::check_safepoint_and_suspend_for_native_trans(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // Clear unhandled oops anywhere where we could block, even if we don't.
a61af66fc99e Initial load
duke
parents:
diff changeset
192 CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();)
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 thread->set_thread_state(to);
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
198 void trans(JavaThreadState from, JavaThreadState to) { transition(_thread, from, to); }
a61af66fc99e Initial load
duke
parents:
diff changeset
199 void trans_from_java(JavaThreadState to) { transition_from_java(_thread, to); }
a61af66fc99e Initial load
duke
parents:
diff changeset
200 void trans_from_native(JavaThreadState to) { transition_from_native(_thread, to); }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 void trans_and_fence(JavaThreadState from, JavaThreadState to) { transition_and_fence(_thread, from, to); }
a61af66fc99e Initial load
duke
parents:
diff changeset
202 };
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 class ThreadInVMfromJava : public ThreadStateTransition {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
207 ThreadInVMfromJava(JavaThread* thread) : ThreadStateTransition(thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
208 trans_from_java(_thread_in_vm);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210 ~ThreadInVMfromJava() {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 trans(_thread_in_vm, _thread_in_Java);
a61af66fc99e Initial load
duke
parents:
diff changeset
212 // Check for pending. async. exceptions or suspends.
a61af66fc99e Initial load
duke
parents:
diff changeset
213 if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition();
a61af66fc99e Initial load
duke
parents:
diff changeset
214 }
a61af66fc99e Initial load
duke
parents:
diff changeset
215 };
a61af66fc99e Initial load
duke
parents:
diff changeset
216
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 class ThreadInVMfromUnknown {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
220 JavaThread* _thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
222 ThreadInVMfromUnknown() : _thread(NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 Thread* t = Thread::current();
a61af66fc99e Initial load
duke
parents:
diff changeset
224 if (t->is_Java_thread()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
225 JavaThread* t2 = (JavaThread*) t;
a61af66fc99e Initial load
duke
parents:
diff changeset
226 if (t2->thread_state() == _thread_in_native) {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 _thread = t2;
a61af66fc99e Initial load
duke
parents:
diff changeset
228 ThreadStateTransition::transition_from_native(t2, _thread_in_vm);
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // Used to have a HandleMarkCleaner but that is dangerous as
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // it could free a handle in our (indirect, nested) caller.
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // We expect any handles will be short lived and figure we
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // don't need an actual HandleMark.
a61af66fc99e Initial load
duke
parents:
diff changeset
233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236 ~ThreadInVMfromUnknown() {
a61af66fc99e Initial load
duke
parents:
diff changeset
237 if (_thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 ThreadStateTransition::transition_and_fence(_thread, _thread_in_vm, _thread_in_native);
a61af66fc99e Initial load
duke
parents:
diff changeset
239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }
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 ThreadInVMfromNative : public ThreadStateTransition {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
246 ThreadInVMfromNative(JavaThread* thread) : ThreadStateTransition(thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
247 trans_from_native(_thread_in_vm);
a61af66fc99e Initial load
duke
parents:
diff changeset
248 }
a61af66fc99e Initial load
duke
parents:
diff changeset
249 ~ThreadInVMfromNative() {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 trans_and_fence(_thread_in_vm, _thread_in_native);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
252 };
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 class ThreadToNativeFromVM : public ThreadStateTransition {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
257 ThreadToNativeFromVM(JavaThread *thread) : ThreadStateTransition(thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // We are leaving the VM at this point and going directly to native code.
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // Block, if we are in the middle of a safepoint synchronization.
a61af66fc99e Initial load
duke
parents:
diff changeset
260 assert(!thread->owns_locks(), "must release all locks when leaving VM");
a61af66fc99e Initial load
duke
parents:
diff changeset
261 thread->frame_anchor()->make_walkable(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
262 trans_and_fence(_thread_in_vm, _thread_in_native);
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // Check for pending. async. exceptions or suspends.
a61af66fc99e Initial load
duke
parents:
diff changeset
264 if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 ~ThreadToNativeFromVM() {
a61af66fc99e Initial load
duke
parents:
diff changeset
268 trans_from_native(_thread_in_vm);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 // We don't need to clear_walkable because it will happen automagically when we return to java
a61af66fc99e Initial load
duke
parents:
diff changeset
270 }
a61af66fc99e Initial load
duke
parents:
diff changeset
271 };
a61af66fc99e Initial load
duke
parents:
diff changeset
272
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274 class ThreadBlockInVM : public ThreadStateTransition {
a61af66fc99e Initial load
duke
parents:
diff changeset
275 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
276 ThreadBlockInVM(JavaThread *thread)
a61af66fc99e Initial load
duke
parents:
diff changeset
277 : ThreadStateTransition(thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // Once we are blocked vm expects stack to be walkable
a61af66fc99e Initial load
duke
parents:
diff changeset
279 thread->frame_anchor()->make_walkable(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
280 trans_and_fence(_thread_in_vm, _thread_blocked);
a61af66fc99e Initial load
duke
parents:
diff changeset
281 }
a61af66fc99e Initial load
duke
parents:
diff changeset
282 ~ThreadBlockInVM() {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 trans_and_fence(_thread_blocked, _thread_in_vm);
a61af66fc99e Initial load
duke
parents:
diff changeset
284 // We don't need to clear_walkable because it will happen automagically when we return to java
a61af66fc99e Initial load
duke
parents:
diff changeset
285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
286 };
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288
a61af66fc99e Initial load
duke
parents:
diff changeset
289 // This special transition class is only used to prevent asynchronous exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
290 // from being installed on vm exit in situations where we can't tolerate them.
a61af66fc99e Initial load
duke
parents:
diff changeset
291 // See bugs: 4324348, 4854693, 4998314, 5040492, 5050705.
a61af66fc99e Initial load
duke
parents:
diff changeset
292 class ThreadInVMfromJavaNoAsyncException : public ThreadStateTransition {
a61af66fc99e Initial load
duke
parents:
diff changeset
293 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
294 ThreadInVMfromJavaNoAsyncException(JavaThread* thread) : ThreadStateTransition(thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
295 trans_from_java(_thread_in_vm);
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297 ~ThreadInVMfromJavaNoAsyncException() {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 trans(_thread_in_vm, _thread_in_Java);
a61af66fc99e Initial load
duke
parents:
diff changeset
299 // NOTE: We do not check for pending. async. exceptions.
a61af66fc99e Initial load
duke
parents:
diff changeset
300 // If we did and moved the pending async exception over into the
a61af66fc99e Initial load
duke
parents:
diff changeset
301 // pending exception field, we would need to deopt (currently C2
a61af66fc99e Initial load
duke
parents:
diff changeset
302 // only). However, to do so would require that we transition back
a61af66fc99e Initial load
duke
parents:
diff changeset
303 // to the _thread_in_vm state. Instead we postpone the handling of
a61af66fc99e Initial load
duke
parents:
diff changeset
304 // the async exception.
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306 // Check for pending. suspends only.
a61af66fc99e Initial load
duke
parents:
diff changeset
307 if (_thread->has_special_runtime_exit_condition())
a61af66fc99e Initial load
duke
parents:
diff changeset
308 _thread->handle_special_runtime_exit_condition(false);
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 // Debug class instantiated in JRT_ENTRY and ITR_ENTRY macro.
a61af66fc99e Initial load
duke
parents:
diff changeset
313 // Can be used to verify properties on enter/exit of the VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
314
a61af66fc99e Initial load
duke
parents:
diff changeset
315 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
316 class VMEntryWrapper {
a61af66fc99e Initial load
duke
parents:
diff changeset
317 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
318 VMEntryWrapper() {
a61af66fc99e Initial load
duke
parents:
diff changeset
319 if (VerifyLastFrame) {
a61af66fc99e Initial load
duke
parents:
diff changeset
320 InterfaceSupport::verify_last_frame();
a61af66fc99e Initial load
duke
parents:
diff changeset
321 }
a61af66fc99e Initial load
duke
parents:
diff changeset
322 }
a61af66fc99e Initial load
duke
parents:
diff changeset
323
a61af66fc99e Initial load
duke
parents:
diff changeset
324 ~VMEntryWrapper() {
a61af66fc99e Initial load
duke
parents:
diff changeset
325 InterfaceSupport::check_gc_alot();
a61af66fc99e Initial load
duke
parents:
diff changeset
326 if (WalkStackALot) {
a61af66fc99e Initial load
duke
parents:
diff changeset
327 InterfaceSupport::walk_stack();
a61af66fc99e Initial load
duke
parents:
diff changeset
328 }
a61af66fc99e Initial load
duke
parents:
diff changeset
329 #ifdef ENABLE_ZAP_DEAD_LOCALS
a61af66fc99e Initial load
duke
parents:
diff changeset
330 if (ZapDeadLocalsOld) {
a61af66fc99e Initial load
duke
parents:
diff changeset
331 InterfaceSupport::zap_dead_locals_old();
a61af66fc99e Initial load
duke
parents:
diff changeset
332 }
a61af66fc99e Initial load
duke
parents:
diff changeset
333 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
334 #ifdef COMPILER2
a61af66fc99e Initial load
duke
parents:
diff changeset
335 // This option is not used by Compiler 1
a61af66fc99e Initial load
duke
parents:
diff changeset
336 if (StressDerivedPointers) {
a61af66fc99e Initial load
duke
parents:
diff changeset
337 InterfaceSupport::stress_derived_pointers();
a61af66fc99e Initial load
duke
parents:
diff changeset
338 }
a61af66fc99e Initial load
duke
parents:
diff changeset
339 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
340 if (DeoptimizeALot || DeoptimizeRandom) {
a61af66fc99e Initial load
duke
parents:
diff changeset
341 InterfaceSupport::deoptimizeAll();
a61af66fc99e Initial load
duke
parents:
diff changeset
342 }
a61af66fc99e Initial load
duke
parents:
diff changeset
343 if (ZombieALot) {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 InterfaceSupport::zombieAll();
a61af66fc99e Initial load
duke
parents:
diff changeset
345 }
a61af66fc99e Initial load
duke
parents:
diff changeset
346 // do verification AFTER potential deoptimization
a61af66fc99e Initial load
duke
parents:
diff changeset
347 if (VerifyStack) {
a61af66fc99e Initial load
duke
parents:
diff changeset
348 InterfaceSupport::verify_stack();
a61af66fc99e Initial load
duke
parents:
diff changeset
349 }
a61af66fc99e Initial load
duke
parents:
diff changeset
350
a61af66fc99e Initial load
duke
parents:
diff changeset
351 }
a61af66fc99e Initial load
duke
parents:
diff changeset
352 };
a61af66fc99e Initial load
duke
parents:
diff changeset
353
a61af66fc99e Initial load
duke
parents:
diff changeset
354
a61af66fc99e Initial load
duke
parents:
diff changeset
355 class VMNativeEntryWrapper {
a61af66fc99e Initial load
duke
parents:
diff changeset
356 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
357 VMNativeEntryWrapper() {
a61af66fc99e Initial load
duke
parents:
diff changeset
358 if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot();
a61af66fc99e Initial load
duke
parents:
diff changeset
359 }
a61af66fc99e Initial load
duke
parents:
diff changeset
360
a61af66fc99e Initial load
duke
parents:
diff changeset
361 ~VMNativeEntryWrapper() {
a61af66fc99e Initial load
duke
parents:
diff changeset
362 if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot();
a61af66fc99e Initial load
duke
parents:
diff changeset
363 }
a61af66fc99e Initial load
duke
parents:
diff changeset
364 };
a61af66fc99e Initial load
duke
parents:
diff changeset
365
a61af66fc99e Initial load
duke
parents:
diff changeset
366 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
367
a61af66fc99e Initial load
duke
parents:
diff changeset
368
a61af66fc99e Initial load
duke
parents:
diff changeset
369 // VM-internal runtime interface support
a61af66fc99e Initial load
duke
parents:
diff changeset
370
a61af66fc99e Initial load
duke
parents:
diff changeset
371 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
372
a61af66fc99e Initial load
duke
parents:
diff changeset
373 class RuntimeHistogramElement : public HistogramElement {
a61af66fc99e Initial load
duke
parents:
diff changeset
374 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
375 RuntimeHistogramElement(const char* name);
a61af66fc99e Initial load
duke
parents:
diff changeset
376 };
a61af66fc99e Initial load
duke
parents:
diff changeset
377
a61af66fc99e Initial load
duke
parents:
diff changeset
378 #define TRACE_CALL(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
379 InterfaceSupport::_number_of_calls++; \
a61af66fc99e Initial load
duke
parents:
diff changeset
380 if (TraceRuntimeCalls) \
a61af66fc99e Initial load
duke
parents:
diff changeset
381 InterfaceSupport::trace(#result_type, #header); \
a61af66fc99e Initial load
duke
parents:
diff changeset
382 if (CountRuntimeCalls) { \
a61af66fc99e Initial load
duke
parents:
diff changeset
383 static RuntimeHistogramElement* e = new RuntimeHistogramElement(#header); \
a61af66fc99e Initial load
duke
parents:
diff changeset
384 if (e != NULL) e->increment_count(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
385 }
a61af66fc99e Initial load
duke
parents:
diff changeset
386 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
387 #define TRACE_CALL(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
388 /* do nothing */
a61af66fc99e Initial load
duke
parents:
diff changeset
389 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
390
a61af66fc99e Initial load
duke
parents:
diff changeset
391
a61af66fc99e Initial load
duke
parents:
diff changeset
392 // LEAF routines do not lock, GC or throw exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
393
a61af66fc99e Initial load
duke
parents:
diff changeset
394 #define __LEAF(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
395 TRACE_CALL(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
396 debug_only(NoHandleMark __hm;) \
a61af66fc99e Initial load
duke
parents:
diff changeset
397 /* begin of body */
a61af66fc99e Initial load
duke
parents:
diff changeset
398
a61af66fc99e Initial load
duke
parents:
diff changeset
399
a61af66fc99e Initial load
duke
parents:
diff changeset
400 // ENTRY routines may lock, GC and throw exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
401
a61af66fc99e Initial load
duke
parents:
diff changeset
402 #define __ENTRY(result_type, header, thread) \
a61af66fc99e Initial load
duke
parents:
diff changeset
403 TRACE_CALL(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
404 HandleMarkCleaner __hm(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
405 Thread* THREAD = thread; \
a61af66fc99e Initial load
duke
parents:
diff changeset
406 /* begin of body */
a61af66fc99e Initial load
duke
parents:
diff changeset
407
a61af66fc99e Initial load
duke
parents:
diff changeset
408
a61af66fc99e Initial load
duke
parents:
diff changeset
409 // QUICK_ENTRY routines behave like ENTRY but without a handle mark
a61af66fc99e Initial load
duke
parents:
diff changeset
410
a61af66fc99e Initial load
duke
parents:
diff changeset
411 #define __QUICK_ENTRY(result_type, header, thread) \
a61af66fc99e Initial load
duke
parents:
diff changeset
412 TRACE_CALL(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
413 debug_only(NoHandleMark __hm;) \
a61af66fc99e Initial load
duke
parents:
diff changeset
414 Thread* THREAD = thread; \
a61af66fc99e Initial load
duke
parents:
diff changeset
415 /* begin of body */
a61af66fc99e Initial load
duke
parents:
diff changeset
416
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418 // Definitions for IRT (Interpreter Runtime)
a61af66fc99e Initial load
duke
parents:
diff changeset
419 // (thread is an argument passed in to all these routines)
a61af66fc99e Initial load
duke
parents:
diff changeset
420
a61af66fc99e Initial load
duke
parents:
diff changeset
421 #define IRT_ENTRY(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
422 result_type header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
423 ThreadInVMfromJava __tiv(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
424 __ENTRY(result_type, header, thread) \
a61af66fc99e Initial load
duke
parents:
diff changeset
425 debug_only(VMEntryWrapper __vew;)
a61af66fc99e Initial load
duke
parents:
diff changeset
426
a61af66fc99e Initial load
duke
parents:
diff changeset
427
a61af66fc99e Initial load
duke
parents:
diff changeset
428 #define IRT_LEAF(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
429 result_type header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
430 __LEAF(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
431 debug_only(No_Safepoint_Verifier __nspv(true);)
a61af66fc99e Initial load
duke
parents:
diff changeset
432
a61af66fc99e Initial load
duke
parents:
diff changeset
433
a61af66fc99e Initial load
duke
parents:
diff changeset
434 #define IRT_ENTRY_NO_ASYNC(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
435 result_type header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
436 ThreadInVMfromJavaNoAsyncException __tiv(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
437 __ENTRY(result_type, header, thread) \
a61af66fc99e Initial load
duke
parents:
diff changeset
438 debug_only(VMEntryWrapper __vew;)
a61af66fc99e Initial load
duke
parents:
diff changeset
439
a61af66fc99e Initial load
duke
parents:
diff changeset
440 // Another special case for nmethod_entry_point so the nmethod that the
a61af66fc99e Initial load
duke
parents:
diff changeset
441 // interpreter is about to branch to doesn't get flushed before as we
a61af66fc99e Initial load
duke
parents:
diff changeset
442 // branch to it's interpreter_entry_point. Skip stress testing here too.
a61af66fc99e Initial load
duke
parents:
diff changeset
443 // Also we don't allow async exceptions because it is just too painful.
a61af66fc99e Initial load
duke
parents:
diff changeset
444 #define IRT_ENTRY_FOR_NMETHOD(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
445 result_type header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
446 nmethodLocker _nmlock(nm); \
a61af66fc99e Initial load
duke
parents:
diff changeset
447 ThreadInVMfromJavaNoAsyncException __tiv(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
448 __ENTRY(result_type, header, thread)
a61af66fc99e Initial load
duke
parents:
diff changeset
449
a61af66fc99e Initial load
duke
parents:
diff changeset
450 #define IRT_END }
a61af66fc99e Initial load
duke
parents:
diff changeset
451
a61af66fc99e Initial load
duke
parents:
diff changeset
452
a61af66fc99e Initial load
duke
parents:
diff changeset
453 // Definitions for JRT (Java (Compiler/Shared) Runtime)
a61af66fc99e Initial load
duke
parents:
diff changeset
454
a61af66fc99e Initial load
duke
parents:
diff changeset
455 #define JRT_ENTRY(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
456 result_type header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
457 ThreadInVMfromJava __tiv(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
458 __ENTRY(result_type, header, thread) \
a61af66fc99e Initial load
duke
parents:
diff changeset
459 debug_only(VMEntryWrapper __vew;)
a61af66fc99e Initial load
duke
parents:
diff changeset
460
a61af66fc99e Initial load
duke
parents:
diff changeset
461
a61af66fc99e Initial load
duke
parents:
diff changeset
462 #define JRT_LEAF(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
463 result_type header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
464 __LEAF(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
465 debug_only(JRT_Leaf_Verifier __jlv;)
a61af66fc99e Initial load
duke
parents:
diff changeset
466
a61af66fc99e Initial load
duke
parents:
diff changeset
467
a61af66fc99e Initial load
duke
parents:
diff changeset
468 #define JRT_ENTRY_NO_ASYNC(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
469 result_type header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
470 ThreadInVMfromJavaNoAsyncException __tiv(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
471 __ENTRY(result_type, header, thread) \
a61af66fc99e Initial load
duke
parents:
diff changeset
472 debug_only(VMEntryWrapper __vew;)
a61af66fc99e Initial load
duke
parents:
diff changeset
473
a61af66fc99e Initial load
duke
parents:
diff changeset
474 // Same as JRT Entry but allows for return value after the safepoint
a61af66fc99e Initial load
duke
parents:
diff changeset
475 // to get back into Java from the VM
a61af66fc99e Initial load
duke
parents:
diff changeset
476 #define JRT_BLOCK_ENTRY(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
477 result_type header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
478 TRACE_CALL(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
479 HandleMarkCleaner __hm(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
480
a61af66fc99e Initial load
duke
parents:
diff changeset
481 #define JRT_BLOCK \
a61af66fc99e Initial load
duke
parents:
diff changeset
482 { \
a61af66fc99e Initial load
duke
parents:
diff changeset
483 ThreadInVMfromJava __tiv(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
484 Thread* THREAD = thread; \
a61af66fc99e Initial load
duke
parents:
diff changeset
485 debug_only(VMEntryWrapper __vew;)
a61af66fc99e Initial load
duke
parents:
diff changeset
486
a61af66fc99e Initial load
duke
parents:
diff changeset
487 #define JRT_BLOCK_END }
a61af66fc99e Initial load
duke
parents:
diff changeset
488
a61af66fc99e Initial load
duke
parents:
diff changeset
489 #define JRT_END }
a61af66fc99e Initial load
duke
parents:
diff changeset
490
a61af66fc99e Initial load
duke
parents:
diff changeset
491 // Definitions for JNI
a61af66fc99e Initial load
duke
parents:
diff changeset
492
a61af66fc99e Initial load
duke
parents:
diff changeset
493 #define JNI_ENTRY(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
494 JNI_ENTRY_NO_PRESERVE(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
495 WeakPreserveExceptionMark __wem(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
496
a61af66fc99e Initial load
duke
parents:
diff changeset
497 #define JNI_ENTRY_NO_PRESERVE(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
498 extern "C" { \
a61af66fc99e Initial load
duke
parents:
diff changeset
499 result_type JNICALL header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
500 JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
a61af66fc99e Initial load
duke
parents:
diff changeset
501 assert( !VerifyJNIEnvThread || (thread == Thread::current()), "JNIEnv is only valid in same thread"); \
a61af66fc99e Initial load
duke
parents:
diff changeset
502 ThreadInVMfromNative __tiv(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
503 debug_only(VMNativeEntryWrapper __vew;) \
a61af66fc99e Initial load
duke
parents:
diff changeset
504 __ENTRY(result_type, header, thread)
a61af66fc99e Initial load
duke
parents:
diff changeset
505
a61af66fc99e Initial load
duke
parents:
diff changeset
506
a61af66fc99e Initial load
duke
parents:
diff changeset
507 // Ensure that the VMNativeEntryWrapper constructor, which can cause
a61af66fc99e Initial load
duke
parents:
diff changeset
508 // a GC, is called outside the NoHandleMark (set via __QUICK_ENTRY).
a61af66fc99e Initial load
duke
parents:
diff changeset
509 #define JNI_QUICK_ENTRY(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
510 extern "C" { \
a61af66fc99e Initial load
duke
parents:
diff changeset
511 result_type JNICALL header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
512 JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
a61af66fc99e Initial load
duke
parents:
diff changeset
513 assert( !VerifyJNIEnvThread || (thread == Thread::current()), "JNIEnv is only valid in same thread"); \
a61af66fc99e Initial load
duke
parents:
diff changeset
514 ThreadInVMfromNative __tiv(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
515 debug_only(VMNativeEntryWrapper __vew;) \
a61af66fc99e Initial load
duke
parents:
diff changeset
516 __QUICK_ENTRY(result_type, header, thread)
a61af66fc99e Initial load
duke
parents:
diff changeset
517
a61af66fc99e Initial load
duke
parents:
diff changeset
518
a61af66fc99e Initial load
duke
parents:
diff changeset
519 #define JNI_LEAF(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
520 extern "C" { \
a61af66fc99e Initial load
duke
parents:
diff changeset
521 result_type JNICALL header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
522 JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
a61af66fc99e Initial load
duke
parents:
diff changeset
523 assert( !VerifyJNIEnvThread || (thread == Thread::current()), "JNIEnv is only valid in same thread"); \
a61af66fc99e Initial load
duke
parents:
diff changeset
524 __LEAF(result_type, header)
a61af66fc99e Initial load
duke
parents:
diff changeset
525
a61af66fc99e Initial load
duke
parents:
diff changeset
526
a61af66fc99e Initial load
duke
parents:
diff changeset
527 // Close the routine and the extern "C"
a61af66fc99e Initial load
duke
parents:
diff changeset
528 #define JNI_END } }
a61af66fc99e Initial load
duke
parents:
diff changeset
529
a61af66fc99e Initial load
duke
parents:
diff changeset
530
a61af66fc99e Initial load
duke
parents:
diff changeset
531
a61af66fc99e Initial load
duke
parents:
diff changeset
532 // Definitions for JVM
a61af66fc99e Initial load
duke
parents:
diff changeset
533
a61af66fc99e Initial load
duke
parents:
diff changeset
534 #define JVM_ENTRY(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
535 extern "C" { \
a61af66fc99e Initial load
duke
parents:
diff changeset
536 result_type JNICALL header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
537 JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
a61af66fc99e Initial load
duke
parents:
diff changeset
538 ThreadInVMfromNative __tiv(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
539 debug_only(VMNativeEntryWrapper __vew;) \
a61af66fc99e Initial load
duke
parents:
diff changeset
540 __ENTRY(result_type, header, thread)
a61af66fc99e Initial load
duke
parents:
diff changeset
541
a61af66fc99e Initial load
duke
parents:
diff changeset
542
a61af66fc99e Initial load
duke
parents:
diff changeset
543 #define JVM_ENTRY_NO_ENV(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
544 extern "C" { \
a61af66fc99e Initial load
duke
parents:
diff changeset
545 result_type JNICALL header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
546 JavaThread* thread = (JavaThread*)ThreadLocalStorage::thread(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
547 ThreadInVMfromNative __tiv(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
548 debug_only(VMNativeEntryWrapper __vew;) \
a61af66fc99e Initial load
duke
parents:
diff changeset
549 __ENTRY(result_type, header, thread)
a61af66fc99e Initial load
duke
parents:
diff changeset
550
a61af66fc99e Initial load
duke
parents:
diff changeset
551
a61af66fc99e Initial load
duke
parents:
diff changeset
552 #define JVM_QUICK_ENTRY(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
553 extern "C" { \
a61af66fc99e Initial load
duke
parents:
diff changeset
554 result_type JNICALL header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
555 JavaThread* thread=JavaThread::thread_from_jni_environment(env); \
a61af66fc99e Initial load
duke
parents:
diff changeset
556 ThreadInVMfromNative __tiv(thread); \
a61af66fc99e Initial load
duke
parents:
diff changeset
557 debug_only(VMNativeEntryWrapper __vew;) \
a61af66fc99e Initial load
duke
parents:
diff changeset
558 __QUICK_ENTRY(result_type, header, thread)
a61af66fc99e Initial load
duke
parents:
diff changeset
559
a61af66fc99e Initial load
duke
parents:
diff changeset
560
a61af66fc99e Initial load
duke
parents:
diff changeset
561 #define JVM_LEAF(result_type, header) \
a61af66fc99e Initial load
duke
parents:
diff changeset
562 extern "C" { \
a61af66fc99e Initial load
duke
parents:
diff changeset
563 result_type JNICALL header { \
a61af66fc99e Initial load
duke
parents:
diff changeset
564 VM_Exit::block_if_vm_exited(); \
a61af66fc99e Initial load
duke
parents:
diff changeset
565 __LEAF(result_type, header)
a61af66fc99e Initial load
duke
parents:
diff changeset
566
a61af66fc99e Initial load
duke
parents:
diff changeset
567
a61af66fc99e Initial load
duke
parents:
diff changeset
568 #define JVM_END } }