Mercurial > hg > graal-jvmci-8
annotate src/share/vm/graal/graalRuntime.cpp @ 10409:36bcc10e01c0
merge fixes
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 19 Jun 2013 15:37:32 +0200 |
parents | 62ea8789b88a |
children | 8b22524df53b |
rev | line source |
---|---|
7221 | 1 /* |
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 | |
24 #include "precompiled.hpp" | |
7735 | 25 #include "asm/codeBuffer.hpp" |
7221 | 26 #include "graal/graalRuntime.hpp" |
27 #include "graal/graalVMToCompiler.hpp" | |
7735 | 28 #include "memory/oopFactory.hpp" |
29 #include "prims/jvm.h" | |
7221 | 30 #include "runtime/biasedLocking.hpp" |
7735 | 31 #include "runtime/interfaceSupport.hpp" |
8499
96a337d307bd
-More progress in G1 WBs
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
8496
diff
changeset
|
32 #include "utilities/debug.hpp" |
7221 | 33 |
34 // Simple helper to see if the caller of a runtime stub which | |
35 // entered the VM has been deoptimized | |
36 | |
37 static bool caller_is_deopted() { | |
38 JavaThread* thread = JavaThread::current(); | |
39 RegisterMap reg_map(thread, false); | |
40 frame runtime_frame = thread->last_frame(); | |
41 frame caller_frame = runtime_frame.sender(®_map); | |
42 assert(caller_frame.is_compiled_frame(), "must be compiled"); | |
43 return caller_frame.is_deoptimized_frame(); | |
44 } | |
45 | |
46 // Stress deoptimization | |
47 static void deopt_caller() { | |
48 if ( !caller_is_deopted()) { | |
49 JavaThread* thread = JavaThread::current(); | |
50 RegisterMap reg_map(thread, false); | |
51 frame runtime_frame = thread->last_frame(); | |
52 frame caller_frame = runtime_frame.sender(®_map); | |
53 Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint); | |
54 assert(caller_is_deopted(), "Must be deoptimized"); | |
55 } | |
56 } | |
57 | |
58 JRT_ENTRY(void, GraalRuntime::new_instance(JavaThread* thread, Klass* klass)) | |
59 assert(klass->is_klass(), "not a class"); | |
60 instanceKlassHandle h(thread, klass); | |
61 h->check_valid_for_instantiation(true, CHECK); | |
62 // make sure klass is initialized | |
63 h->initialize(CHECK); | |
64 // allocate instance and return via TLS | |
65 oop obj = h->allocate_instance(CHECK); | |
66 thread->set_vm_result(obj); | |
67 JRT_END | |
68 | |
69 JRT_ENTRY(void, GraalRuntime::new_array(JavaThread* thread, Klass* array_klass, jint length)) | |
70 // Note: no handle for klass needed since they are not used | |
71 // anymore after new_objArray() and no GC can happen before. | |
72 // (This may have to change if this code changes!) | |
73 assert(array_klass->is_klass(), "not a class"); | |
74 oop obj; | |
75 if (array_klass->oop_is_typeArray()) { | |
76 BasicType elt_type = TypeArrayKlass::cast(array_klass)->element_type(); | |
77 obj = oopFactory::new_typeArray(elt_type, length, CHECK); | |
78 } else { | |
79 Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass(); | |
80 obj = oopFactory::new_objArray(elem_klass, length, CHECK); | |
81 } | |
82 thread->set_vm_result(obj); | |
83 // This is pretty rare but this runtime patch is stressful to deoptimization | |
84 // if we deoptimize here so force a deopt to stress the path. | |
85 if (DeoptimizeALot) { | |
9338
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
86 static int deopts = 0; |
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
87 // Alternate between deoptimizing and raising an error (which will also cause a deopt) |
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
88 if (deopts++ % 2 == 0) { |
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
89 ResourceMark rm(THREAD); |
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
90 THROW(vmSymbols::java_lang_OutOfMemoryError()); |
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
91 } else { |
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
92 deopt_caller(); |
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
93 } |
7221 | 94 } |
9338
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
95 JRT_END |
7221 | 96 |
97 JRT_ENTRY(void, GraalRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims)) | |
98 assert(klass->is_klass(), "not a class"); | |
99 assert(rank >= 1, "rank must be nonzero"); | |
100 oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK); | |
101 thread->set_vm_result(obj); | |
102 JRT_END | |
103 | |
104 extern void vm_exit(int code); | |
105 | |
106 // Enter this method from compiled code handler below. This is where we transition | |
107 // to VM mode. This is done as a helper routine so that the method called directly | |
108 // from compiled code does not have to transition to VM. This allows the entry | |
109 // method to see if the nmethod that we have just looked up a handler for has | |
110 // been deoptimized while we were in the vm. This simplifies the assembly code | |
111 // cpu directories. | |
112 // | |
113 // We are entering here from exception stub (via the entry method below) | |
114 // If there is a compiled exception handler in this method, we will continue there; | |
115 // otherwise we will unwind the stack and continue at the caller of top frame method | |
116 // Note: we enter in Java using a special JRT wrapper. This wrapper allows us to | |
117 // control the area where we can allow a safepoint. After we exit the safepoint area we can | |
118 // check to see if the handler we are going to return is now in a nmethod that has | |
119 // been deoptimized. If that is the case we return the deopt blob | |
120 // unpack_with_exception entry instead. This makes life for the exception blob easier | |
121 // because making that same check and diverting is painful from assembly language. | |
122 JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* thread, oopDesc* ex, address pc, nmethod*& nm)) | |
123 // Reset method handle flag. | |
124 thread->set_is_method_handle_return(false); | |
125 | |
126 Handle exception(thread, ex); | |
127 nm = CodeCache::find_nmethod(pc); | |
128 assert(nm != NULL, "this is not an nmethod"); | |
129 // Adjust the pc as needed/ | |
130 if (nm->is_deopt_pc(pc)) { | |
131 RegisterMap map(thread, false); | |
132 frame exception_frame = thread->last_frame().sender(&map); | |
133 // if the frame isn't deopted then pc must not correspond to the caller of last_frame | |
134 assert(exception_frame.is_deoptimized_frame(), "must be deopted"); | |
135 pc = exception_frame.pc(); | |
136 } | |
137 #ifdef ASSERT | |
138 assert(exception.not_null(), "NULL exceptions should be handled by throw_exception"); | |
139 assert(exception->is_oop(), "just checking"); | |
140 // Check that exception is a subclass of Throwable, otherwise we have a VerifyError | |
141 if (!(exception->is_a(SystemDictionary::Throwable_klass()))) { | |
142 if (ExitVMOnVerifyError) vm_exit(-1); | |
143 ShouldNotReachHere(); | |
144 } | |
145 #endif | |
146 | |
147 // Check the stack guard pages and reenable them if necessary and there is | |
148 // enough space on the stack to do so. Use fast exceptions only if the guard | |
149 // pages are enabled. | |
150 bool guard_pages_enabled = thread->stack_yellow_zone_enabled(); | |
151 if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack(); | |
152 | |
153 if (JvmtiExport::can_post_on_exceptions()) { | |
154 // To ensure correct notification of exception catches and throws | |
155 // we have to deoptimize here. If we attempted to notify the | |
156 // catches and throws during this exception lookup it's possible | |
157 // we could deoptimize on the way out of the VM and end back in | |
158 // the interpreter at the throw site. This would result in double | |
159 // notifications since the interpreter would also notify about | |
160 // these same catches and throws as it unwound the frame. | |
161 | |
162 RegisterMap reg_map(thread); | |
163 frame stub_frame = thread->last_frame(); | |
164 frame caller_frame = stub_frame.sender(®_map); | |
165 | |
166 // We don't really want to deoptimize the nmethod itself since we | |
167 // can actually continue in the exception handler ourselves but I | |
168 // don't see an easy way to have the desired effect. | |
169 Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint); | |
170 assert(caller_is_deopted(), "Must be deoptimized"); | |
171 | |
172 return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); | |
173 } | |
174 | |
175 // ExceptionCache is used only for exceptions at call sites and not for implicit exceptions | |
176 if (guard_pages_enabled) { | |
177 address fast_continuation = nm->handler_for_exception_and_pc(exception, pc); | |
178 if (fast_continuation != NULL) { | |
179 // Set flag if return address is a method handle call site. | |
180 thread->set_is_method_handle_return(nm->is_method_handle_return(pc)); | |
181 return fast_continuation; | |
182 } | |
183 } | |
184 | |
185 // If the stack guard pages are enabled, check whether there is a handler in | |
186 // the current method. Otherwise (guard pages disabled), force an unwind and | |
187 // skip the exception cache update (i.e., just leave continuation==NULL). | |
188 address continuation = NULL; | |
189 if (guard_pages_enabled) { | |
190 | |
191 // New exception handling mechanism can support inlined methods | |
192 // with exception handlers since the mappings are from PC to PC | |
193 | |
194 // debugging support | |
195 // tracing | |
196 if (TraceExceptions) { | |
197 ttyLocker ttyl; | |
198 ResourceMark rm; | |
199 int offset = pc - nm->code_begin(); | |
200 tty->print_cr("Exception <%s> (0x%x) thrown in compiled method <%s> at PC " PTR_FORMAT " [" PTR_FORMAT "+%d] for thread 0x%x", | |
201 exception->print_value_string(), (address)exception(), nm->method()->print_value_string(), pc, nm->code_begin(), offset, thread); | |
202 } | |
203 // for AbortVMOnException flag | |
204 NOT_PRODUCT(Exceptions::debug_check_abort(exception)); | |
205 | |
206 // Clear out the exception oop and pc since looking up an | |
207 // exception handler can cause class loading, which might throw an | |
208 // exception and those fields are expected to be clear during | |
209 // normal bytecode execution. | |
210 thread->set_exception_oop(NULL); | |
211 thread->set_exception_pc(NULL); | |
212 | |
213 continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false); | |
214 // If an exception was thrown during exception dispatch, the exception oop may have changed | |
215 thread->set_exception_oop(exception()); | |
216 thread->set_exception_pc(pc); | |
217 | |
218 // the exception cache is used only by non-implicit exceptions | |
219 if (continuation != NULL && !SharedRuntime::deopt_blob()->contains(continuation)) { | |
220 nm->add_handler_for_exception_and_pc(exception, pc, continuation); | |
221 } | |
222 } | |
223 | |
224 // Set flag if return address is a method handle call site. | |
225 thread->set_is_method_handle_return(nm->is_method_handle_return(pc)); | |
226 | |
227 if (TraceExceptions) { | |
228 ttyLocker ttyl; | |
229 ResourceMark rm; | |
230 tty->print_cr("Thread " PTR_FORMAT " continuing at PC " PTR_FORMAT " for exception thrown at PC " PTR_FORMAT, | |
231 thread, continuation, pc); | |
232 } | |
233 | |
234 return continuation; | |
235 JRT_END | |
236 | |
237 // Enter this method from compiled code only if there is a Java exception handler | |
238 // in the method handling the exception. | |
239 // We are entering here from exception stub. We don't do a normal VM transition here. | |
240 // We do it in a helper. This is so we can check to see if the nmethod we have just | |
241 // searched for an exception handler has been deoptimized in the meantime. | |
242 address GraalRuntime::exception_handler_for_pc(JavaThread* thread) { | |
243 oop exception = thread->exception_oop(); | |
244 address pc = thread->exception_pc(); | |
245 // Still in Java mode | |
246 DEBUG_ONLY(ResetNoHandleMark rnhm); | |
247 nmethod* nm = NULL; | |
248 address continuation = NULL; | |
249 { | |
250 // Enter VM mode by calling the helper | |
251 ResetNoHandleMark rnhm; | |
252 continuation = exception_handler_for_pc_helper(thread, exception, pc, nm); | |
253 } | |
254 // Back in JAVA, use no oops DON'T safepoint | |
255 | |
256 // Now check to see if the nmethod we were called from is now deoptimized. | |
257 // If so we must return to the deopt blob and deoptimize the nmethod | |
258 if (nm != NULL && caller_is_deopted()) { | |
259 continuation = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); | |
260 } | |
261 | |
262 assert(continuation != NULL, "no handler found"); | |
263 return continuation; | |
264 } | |
265 | |
7911
983f7bdb85ff
removed redundant graal_ prefix from Graal specific functions and variable in native code
Doug Simon <doug.simon@oracle.com>
parents:
7735
diff
changeset
|
266 JRT_ENTRY(void, GraalRuntime::create_null_exception(JavaThread* thread)) |
7221 | 267 thread->set_vm_result(Exceptions::new_exception(thread, vmSymbols::java_lang_NullPointerException(), NULL)()); |
268 JRT_END | |
269 | |
7911
983f7bdb85ff
removed redundant graal_ prefix from Graal specific functions and variable in native code
Doug Simon <doug.simon@oracle.com>
parents:
7735
diff
changeset
|
270 JRT_ENTRY(void, GraalRuntime::create_out_of_bounds_exception(JavaThread* thread, jint index)) |
7221 | 271 char message[jintAsStringSize]; |
272 sprintf(message, "%d", index); | |
273 thread->set_vm_result(Exceptions::new_exception(thread, vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), message)()); | |
274 JRT_END | |
275 | |
7911
983f7bdb85ff
removed redundant graal_ prefix from Graal specific functions and variable in native code
Doug Simon <doug.simon@oracle.com>
parents:
7735
diff
changeset
|
276 JRT_ENTRY_NO_ASYNC(void, GraalRuntime::monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock)) |
7221 | 277 if (TraceGraal >= 3) { |
278 char type[O_BUFLEN]; | |
279 obj->klass()->name()->as_C_string(type, O_BUFLEN); | |
280 markOop mark = obj->mark(); | |
281 tty->print_cr("%s: entered locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), obj, type, mark, lock); | |
282 tty->flush(); | |
283 } | |
284 #ifdef ASSERT | |
285 if (PrintBiasedLockingStatistics) { | |
286 Atomic::inc(BiasedLocking::slow_path_entry_count_addr()); | |
287 } | |
288 #endif | |
289 Handle h_obj(thread, obj); | |
290 assert(h_obj()->is_oop(), "must be NULL or an object"); | |
291 if (UseBiasedLocking) { | |
292 // Retry fast entry if bias is revoked to avoid unnecessary inflation | |
293 ObjectSynchronizer::fast_enter(h_obj, lock, true, CHECK); | |
294 } else { | |
7226 | 295 if (GraalUseFastLocking) { |
7221 | 296 // When using fast locking, the compiled code has already tried the fast case |
297 ObjectSynchronizer::slow_enter(h_obj, lock, THREAD); | |
298 } else { | |
299 ObjectSynchronizer::fast_enter(h_obj, lock, false, THREAD); | |
300 } | |
301 } | |
302 if (TraceGraal >= 3) { | |
303 tty->print_cr("%s: exiting locking slow with obj=" INTPTR_FORMAT, thread->name(), obj); | |
304 } | |
305 JRT_END | |
306 | |
7911
983f7bdb85ff
removed redundant graal_ prefix from Graal specific functions and variable in native code
Doug Simon <doug.simon@oracle.com>
parents:
7735
diff
changeset
|
307 JRT_LEAF(void, GraalRuntime::monitorexit(JavaThread* thread, oopDesc* obj, BasicLock* lock)) |
7221 | 308 assert(thread == JavaThread::current(), "threads must correspond"); |
309 assert(thread->last_Java_sp(), "last_Java_sp must be set"); | |
310 // monitorexit is non-blocking (leaf routine) => no exceptions can be thrown | |
311 EXCEPTION_MARK; | |
312 | |
313 #ifdef DEBUG | |
314 if (!obj->is_oop()) { | |
315 ResetNoHandleMark rhm; | |
316 nmethod* method = thread->last_frame().cb()->as_nmethod_or_null(); | |
317 if (method != NULL) { | |
318 tty->print_cr("ERROR in monitorexit in method %s wrong obj " INTPTR_FORMAT, method->name(), obj); | |
319 } | |
320 thread->print_stack_on(tty); | |
321 assert(false, "invalid lock object pointer dected"); | |
322 } | |
323 #endif | |
324 | |
7226 | 325 if (GraalUseFastLocking) { |
7221 | 326 // When using fast locking, the compiled code has already tried the fast case |
327 ObjectSynchronizer::slow_exit(obj, lock, THREAD); | |
328 } else { | |
329 ObjectSynchronizer::fast_exit(obj, lock, THREAD); | |
330 } | |
331 if (TraceGraal >= 3) { | |
332 char type[O_BUFLEN]; | |
333 obj->klass()->name()->as_C_string(type, O_BUFLEN); | |
334 tty->print_cr("%s: exited locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), obj, type, obj->mark(), lock); | |
335 tty->flush(); | |
336 } | |
337 JRT_END | |
338 | |
7911
983f7bdb85ff
removed redundant graal_ prefix from Graal specific functions and variable in native code
Doug Simon <doug.simon@oracle.com>
parents:
7735
diff
changeset
|
339 JRT_ENTRY(void, GraalRuntime::log_object(JavaThread* thread, oop obj, jint flags)) |
7221 | 340 bool string = mask_bits_are_true(flags, LOG_OBJECT_STRING); |
341 bool address = mask_bits_are_true(flags, LOG_OBJECT_ADDRESS); | |
342 bool newline = mask_bits_are_true(flags, LOG_OBJECT_NEWLINE); | |
343 if (!string) { | |
344 if (!address && obj->is_oop_or_null(true)) { | |
345 char buf[O_BUFLEN]; | |
346 tty->print("%s@%p", obj->klass()->name()->as_C_string(buf, O_BUFLEN), obj); | |
347 } else { | |
348 tty->print("%p", obj); | |
349 } | |
350 } else { | |
351 ResourceMark rm; | |
352 assert(obj != NULL && java_lang_String::is_instance(obj), "must be"); | |
353 char *buf = java_lang_String::as_utf8_string(obj); | |
354 tty->print(buf); | |
355 } | |
356 if (newline) { | |
357 tty->cr(); | |
358 } | |
359 JRT_END | |
360 | |
7911
983f7bdb85ff
removed redundant graal_ prefix from Graal specific functions and variable in native code
Doug Simon <doug.simon@oracle.com>
parents:
7735
diff
changeset
|
361 JRT_ENTRY(void, GraalRuntime::vm_error(JavaThread* thread, oop where, oop format, jlong value)) |
7221 | 362 ResourceMark rm; |
363 assert(where == NULL || java_lang_String::is_instance(where), "must be"); | |
364 const char *error_msg = where == NULL ? "<internal Graal error>" : java_lang_String::as_utf8_string(where); | |
365 char *detail_msg = NULL; | |
366 if (format != NULL) { | |
367 const char* buf = java_lang_String::as_utf8_string(format); | |
368 size_t detail_msg_length = strlen(buf) * 2; | |
369 detail_msg = (char *) NEW_RESOURCE_ARRAY(u_char, detail_msg_length); | |
370 jio_snprintf(detail_msg, detail_msg_length, buf, value); | |
371 } | |
372 report_vm_error(__FILE__, __LINE__, error_msg, detail_msg); | |
373 JRT_END | |
374 | |
9820
1b60f639ac4b
implemented alternative implementation for loading the exception object from the thread at the start of an exception dispatcher
Doug Simon <doug.simon@oracle.com>
parents:
9596
diff
changeset
|
375 JRT_LEAF(oop, GraalRuntime::load_and_clear_exception(JavaThread* thread)) |
1b60f639ac4b
implemented alternative implementation for loading the exception object from the thread at the start of an exception dispatcher
Doug Simon <doug.simon@oracle.com>
parents:
9596
diff
changeset
|
376 oop exception = thread->exception_oop(); |
1b60f639ac4b
implemented alternative implementation for loading the exception object from the thread at the start of an exception dispatcher
Doug Simon <doug.simon@oracle.com>
parents:
9596
diff
changeset
|
377 assert(exception != NULL, "npe"); |
1b60f639ac4b
implemented alternative implementation for loading the exception object from the thread at the start of an exception dispatcher
Doug Simon <doug.simon@oracle.com>
parents:
9596
diff
changeset
|
378 thread->set_exception_oop(NULL); |
1b60f639ac4b
implemented alternative implementation for loading the exception object from the thread at the start of an exception dispatcher
Doug Simon <doug.simon@oracle.com>
parents:
9596
diff
changeset
|
379 thread->set_exception_pc(0); |
1b60f639ac4b
implemented alternative implementation for loading the exception object from the thread at the start of an exception dispatcher
Doug Simon <doug.simon@oracle.com>
parents:
9596
diff
changeset
|
380 return exception; |
1b60f639ac4b
implemented alternative implementation for loading the exception object from the thread at the start of an exception dispatcher
Doug Simon <doug.simon@oracle.com>
parents:
9596
diff
changeset
|
381 JRT_END |
8506 | 382 |
383 JRT_LEAF(void, GraalRuntime::log_printf(JavaThread* thread, oop format, jlong v1, jlong v2, jlong v3)) | |
7221 | 384 ResourceMark rm; |
385 assert(format != NULL && java_lang_String::is_instance(format), "must be"); | |
386 char *buf = java_lang_String::as_utf8_string(format); | |
7235
a6bd253a770f
expanded LOG_PRINTF stub to handle up to 3 arguments in addition to the format string
Doug Simon <doug.simon@oracle.com>
parents:
7226
diff
changeset
|
387 tty->print(buf, v1, v2, v3); |
7221 | 388 JRT_END |
389 | |
9573
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
390 static void decipher(jlong v, bool ignoreZero) { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
391 if (v != 0 || !ignoreZero) { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
392 void* p = (void *)(address) v; |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
393 CodeBlob* cb = CodeCache::find_blob(p); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
394 if (cb) { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
395 if (cb->is_nmethod()) { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
396 char buf[O_BUFLEN]; |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
397 tty->print("%s [%p+%d]", cb->as_nmethod_or_null()->method()->name_and_sig_as_C_string(buf, O_BUFLEN), cb->code_begin(), (address)v - cb->code_begin()); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
398 return; |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
399 } |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
400 cb->print_value_on(tty); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
401 return; |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
402 } |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
403 if (Universe::heap()->is_in(p)) { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
404 oop obj = oop(p); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
405 obj->print_value_on(tty); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
406 return; |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
407 } |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
408 tty->print("%p [long: %d, double %f, char %c]", v, v, v, v); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
409 } |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
410 } |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
411 |
9471
5fa54bf57f8c
replaced exception_handler_nofpu assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9457
diff
changeset
|
412 JRT_LEAF(void, GraalRuntime::vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3)) |
9232
bb2447c64055
strings used in compiled stubs are lowered to malloc'ed C strings so that there are no embedded oops (for the strings) in the resulting installed code
Doug Simon <doug.simon@oracle.com>
parents:
8506
diff
changeset
|
413 ResourceMark rm; |
bb2447c64055
strings used in compiled stubs are lowered to malloc'ed C strings so that there are no embedded oops (for the strings) in the resulting installed code
Doug Simon <doug.simon@oracle.com>
parents:
8506
diff
changeset
|
414 char *buf = (char*) (address) format; |
9471
5fa54bf57f8c
replaced exception_handler_nofpu assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9457
diff
changeset
|
415 if (vmError) { |
9573
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
416 if (buf != NULL) { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
417 fatal(err_msg(buf, v1, v2, v3)); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
418 } else { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
419 fatal("<anonymous error>"); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
420 } |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
421 } else if (buf != NULL) { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
422 tty->print(buf, v1, v2, v3); |
9471
5fa54bf57f8c
replaced exception_handler_nofpu assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9457
diff
changeset
|
423 } else { |
9573
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
424 assert(v2 == 0, "v2 != 0"); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
425 assert(v3 == 0, "v3 != 0"); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
426 decipher(v1, false); |
9471
5fa54bf57f8c
replaced exception_handler_nofpu assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9457
diff
changeset
|
427 } |
9232
bb2447c64055
strings used in compiled stubs are lowered to malloc'ed C strings so that there are no embedded oops (for the strings) in the resulting installed code
Doug Simon <doug.simon@oracle.com>
parents:
8506
diff
changeset
|
428 JRT_END |
bb2447c64055
strings used in compiled stubs are lowered to malloc'ed C strings so that there are no embedded oops (for the strings) in the resulting installed code
Doug Simon <doug.simon@oracle.com>
parents:
8506
diff
changeset
|
429 |
7911
983f7bdb85ff
removed redundant graal_ prefix from Graal specific functions and variable in native code
Doug Simon <doug.simon@oracle.com>
parents:
7735
diff
changeset
|
430 JRT_ENTRY(void, GraalRuntime::log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline)) |
7221 | 431 union { |
432 jlong l; | |
433 jdouble d; | |
434 jfloat f; | |
435 } uu; | |
436 uu.l = value; | |
437 switch (typeChar) { | |
438 case 'z': tty->print(value == 0 ? "false" : "true"); break; | |
439 case 'b': tty->print("%d", (jbyte) value); break; | |
440 case 'c': tty->print("%c", (jchar) value); break; | |
441 case 's': tty->print("%d", (jshort) value); break; | |
442 case 'i': tty->print("%d", (jint) value); break; | |
443 case 'f': tty->print("%f", uu.f); break; | |
444 case 'j': tty->print(INT64_FORMAT, value); break; | |
445 case 'd': tty->print("%lf", uu.d); break; | |
446 default: assert(false, "unknown typeChar"); break; | |
447 } | |
448 if (newline) { | |
449 tty->cr(); | |
450 } | |
451 JRT_END | |
452 | |
7911
983f7bdb85ff
removed redundant graal_ prefix from Graal specific functions and variable in native code
Doug Simon <doug.simon@oracle.com>
parents:
7735
diff
changeset
|
453 JRT_ENTRY(jint, GraalRuntime::identity_hash_code(JavaThread* thread, oop obj)) |
7221 | 454 return (jint) obj->identity_hash(); |
455 JRT_END | |
456 | |
7911
983f7bdb85ff
removed redundant graal_ prefix from Graal specific functions and variable in native code
Doug Simon <doug.simon@oracle.com>
parents:
7735
diff
changeset
|
457 JRT_ENTRY(jboolean, GraalRuntime::thread_is_interrupted(JavaThread* thread, oop receiver, jboolean clear_interrupted)) |
7220
fcae6d960acd
added more compiler intrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7216
diff
changeset
|
458 // Ensure that the C++ Thread and OSThread structures aren't freed before we operate |
fcae6d960acd
added more compiler intrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7216
diff
changeset
|
459 Handle receiverHandle(thread, receiver); |
7386
707e9cca11de
fixed HotSpot windows build
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7235
diff
changeset
|
460 MutexLockerEx ml(thread->threadObj() == receiver ? NULL : Threads_lock); |
707e9cca11de
fixed HotSpot windows build
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7235
diff
changeset
|
461 JavaThread* receiverThread = java_lang_Thread::thread(receiverHandle()); |
707e9cca11de
fixed HotSpot windows build
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7235
diff
changeset
|
462 return (jint) Thread::is_interrupted(receiverThread, clear_interrupted != 0); |
7221 | 463 JRT_END |
464 | |
465 // JVM_InitializeGraalRuntime | |
466 JVM_ENTRY(jobject, JVM_InitializeGraalRuntime(JNIEnv *env, jclass graalclass)) | |
467 return VMToCompiler::graalRuntimePermObject(); | |
468 JVM_END |