Mercurial > hg > truffle
annotate src/share/vm/graal/graalRuntime.cpp @ 12372:2dfccd93510a
Merge
author | Christos Kotselidis <christos.kotselidis@oracle.com> |
---|---|
date | Fri, 11 Oct 2013 21:41:42 +0200 |
parents | 0991c12c4186 359f7e70ae7f |
children | 370b5f07f9e2 808348377021 |
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" |
10542
554f67e4ff3f
Use slow-path stub call instead of deopt in lowering of DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
10475
diff
changeset
|
32 #include "runtime/reflection.hpp" |
8499
96a337d307bd
-More progress in G1 WBs
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
8496
diff
changeset
|
33 #include "utilities/debug.hpp" |
7221 | 34 |
35 // Simple helper to see if the caller of a runtime stub which | |
36 // entered the VM has been deoptimized | |
37 | |
38 static bool caller_is_deopted() { | |
39 JavaThread* thread = JavaThread::current(); | |
40 RegisterMap reg_map(thread, false); | |
41 frame runtime_frame = thread->last_frame(); | |
42 frame caller_frame = runtime_frame.sender(®_map); | |
43 assert(caller_frame.is_compiled_frame(), "must be compiled"); | |
44 return caller_frame.is_deoptimized_frame(); | |
45 } | |
46 | |
47 // Stress deoptimization | |
48 static void deopt_caller() { | |
49 if ( !caller_is_deopted()) { | |
50 JavaThread* thread = JavaThread::current(); | |
51 RegisterMap reg_map(thread, false); | |
52 frame runtime_frame = thread->last_frame(); | |
53 frame caller_frame = runtime_frame.sender(®_map); | |
54 Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint); | |
55 assert(caller_is_deopted(), "Must be deoptimized"); | |
56 } | |
57 } | |
58 | |
59 JRT_ENTRY(void, GraalRuntime::new_instance(JavaThread* thread, Klass* klass)) | |
60 assert(klass->is_klass(), "not a class"); | |
61 instanceKlassHandle h(thread, klass); | |
62 h->check_valid_for_instantiation(true, CHECK); | |
63 // make sure klass is initialized | |
64 h->initialize(CHECK); | |
65 // allocate instance and return via TLS | |
66 oop obj = h->allocate_instance(CHECK); | |
12366
0991c12c4186
Defer barriers upon slow-path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10953
diff
changeset
|
67 if (GraalDeferredInitBarriers) { |
0991c12c4186
Defer barriers upon slow-path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10953
diff
changeset
|
68 obj = Universe::heap()->new_store_pre_barrier(thread, obj); |
0991c12c4186
Defer barriers upon slow-path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10953
diff
changeset
|
69 } |
7221 | 70 thread->set_vm_result(obj); |
71 JRT_END | |
72 | |
73 JRT_ENTRY(void, GraalRuntime::new_array(JavaThread* thread, Klass* array_klass, jint length)) | |
74 // Note: no handle for klass needed since they are not used | |
75 // anymore after new_objArray() and no GC can happen before. | |
76 // (This may have to change if this code changes!) | |
77 assert(array_klass->is_klass(), "not a class"); | |
78 oop obj; | |
79 if (array_klass->oop_is_typeArray()) { | |
80 BasicType elt_type = TypeArrayKlass::cast(array_klass)->element_type(); | |
81 obj = oopFactory::new_typeArray(elt_type, length, CHECK); | |
82 } else { | |
83 Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass(); | |
84 obj = oopFactory::new_objArray(elem_klass, length, CHECK); | |
85 } | |
12366
0991c12c4186
Defer barriers upon slow-path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10953
diff
changeset
|
86 if (GraalDeferredInitBarriers) { |
0991c12c4186
Defer barriers upon slow-path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10953
diff
changeset
|
87 obj = Universe::heap()->new_store_pre_barrier(thread, obj); |
0991c12c4186
Defer barriers upon slow-path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10953
diff
changeset
|
88 } |
7221 | 89 thread->set_vm_result(obj); |
90 // This is pretty rare but this runtime patch is stressful to deoptimization | |
91 // if we deoptimize here so force a deopt to stress the path. | |
92 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
|
93 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
|
94 // 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
|
95 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
|
96 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
|
97 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
|
98 } 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
|
99 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
|
100 } |
7221 | 101 } |
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
|
102 JRT_END |
7221 | 103 |
104 JRT_ENTRY(void, GraalRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims)) | |
105 assert(klass->is_klass(), "not a class"); | |
106 assert(rank >= 1, "rank must be nonzero"); | |
107 oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK); | |
108 thread->set_vm_result(obj); | |
109 JRT_END | |
110 | |
10542
554f67e4ff3f
Use slow-path stub call instead of deopt in lowering of DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
10475
diff
changeset
|
111 JRT_ENTRY(void, GraalRuntime::dynamic_new_array(JavaThread* thread, oop element_mirror, jint length)) |
554f67e4ff3f
Use slow-path stub call instead of deopt in lowering of DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
10475
diff
changeset
|
112 oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK); |
554f67e4ff3f
Use slow-path stub call instead of deopt in lowering of DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
10475
diff
changeset
|
113 thread->set_vm_result(obj); |
554f67e4ff3f
Use slow-path stub call instead of deopt in lowering of DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
10475
diff
changeset
|
114 JRT_END |
554f67e4ff3f
Use slow-path stub call instead of deopt in lowering of DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
10475
diff
changeset
|
115 |
7221 | 116 extern void vm_exit(int code); |
117 | |
118 // Enter this method from compiled code handler below. This is where we transition | |
119 // to VM mode. This is done as a helper routine so that the method called directly | |
120 // from compiled code does not have to transition to VM. This allows the entry | |
121 // method to see if the nmethod that we have just looked up a handler for has | |
122 // been deoptimized while we were in the vm. This simplifies the assembly code | |
123 // cpu directories. | |
124 // | |
125 // We are entering here from exception stub (via the entry method below) | |
126 // If there is a compiled exception handler in this method, we will continue there; | |
127 // otherwise we will unwind the stack and continue at the caller of top frame method | |
128 // Note: we enter in Java using a special JRT wrapper. This wrapper allows us to | |
129 // control the area where we can allow a safepoint. After we exit the safepoint area we can | |
130 // check to see if the handler we are going to return is now in a nmethod that has | |
131 // been deoptimized. If that is the case we return the deopt blob | |
132 // unpack_with_exception entry instead. This makes life for the exception blob easier | |
133 // because making that same check and diverting is painful from assembly language. | |
134 JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* thread, oopDesc* ex, address pc, nmethod*& nm)) | |
135 // Reset method handle flag. | |
136 thread->set_is_method_handle_return(false); | |
137 | |
138 Handle exception(thread, ex); | |
139 nm = CodeCache::find_nmethod(pc); | |
140 assert(nm != NULL, "this is not an nmethod"); | |
141 // Adjust the pc as needed/ | |
142 if (nm->is_deopt_pc(pc)) { | |
143 RegisterMap map(thread, false); | |
144 frame exception_frame = thread->last_frame().sender(&map); | |
145 // if the frame isn't deopted then pc must not correspond to the caller of last_frame | |
146 assert(exception_frame.is_deoptimized_frame(), "must be deopted"); | |
147 pc = exception_frame.pc(); | |
148 } | |
149 #ifdef ASSERT | |
150 assert(exception.not_null(), "NULL exceptions should be handled by throw_exception"); | |
151 assert(exception->is_oop(), "just checking"); | |
152 // Check that exception is a subclass of Throwable, otherwise we have a VerifyError | |
153 if (!(exception->is_a(SystemDictionary::Throwable_klass()))) { | |
154 if (ExitVMOnVerifyError) vm_exit(-1); | |
155 ShouldNotReachHere(); | |
156 } | |
157 #endif | |
158 | |
159 // Check the stack guard pages and reenable them if necessary and there is | |
160 // enough space on the stack to do so. Use fast exceptions only if the guard | |
161 // pages are enabled. | |
162 bool guard_pages_enabled = thread->stack_yellow_zone_enabled(); | |
163 if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack(); | |
164 | |
165 if (JvmtiExport::can_post_on_exceptions()) { | |
166 // To ensure correct notification of exception catches and throws | |
167 // we have to deoptimize here. If we attempted to notify the | |
168 // catches and throws during this exception lookup it's possible | |
169 // we could deoptimize on the way out of the VM and end back in | |
170 // the interpreter at the throw site. This would result in double | |
171 // notifications since the interpreter would also notify about | |
172 // these same catches and throws as it unwound the frame. | |
173 | |
174 RegisterMap reg_map(thread); | |
175 frame stub_frame = thread->last_frame(); | |
176 frame caller_frame = stub_frame.sender(®_map); | |
177 | |
178 // We don't really want to deoptimize the nmethod itself since we | |
179 // can actually continue in the exception handler ourselves but I | |
180 // don't see an easy way to have the desired effect. | |
181 Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint); | |
182 assert(caller_is_deopted(), "Must be deoptimized"); | |
183 | |
184 return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); | |
185 } | |
186 | |
187 // ExceptionCache is used only for exceptions at call sites and not for implicit exceptions | |
188 if (guard_pages_enabled) { | |
189 address fast_continuation = nm->handler_for_exception_and_pc(exception, pc); | |
190 if (fast_continuation != NULL) { | |
191 // Set flag if return address is a method handle call site. | |
192 thread->set_is_method_handle_return(nm->is_method_handle_return(pc)); | |
193 return fast_continuation; | |
194 } | |
195 } | |
196 | |
197 // If the stack guard pages are enabled, check whether there is a handler in | |
198 // the current method. Otherwise (guard pages disabled), force an unwind and | |
199 // skip the exception cache update (i.e., just leave continuation==NULL). | |
200 address continuation = NULL; | |
201 if (guard_pages_enabled) { | |
202 | |
203 // New exception handling mechanism can support inlined methods | |
204 // with exception handlers since the mappings are from PC to PC | |
205 | |
206 // debugging support | |
207 // tracing | |
208 if (TraceExceptions) { | |
209 ttyLocker ttyl; | |
210 ResourceMark rm; | |
211 int offset = pc - nm->code_begin(); | |
212 tty->print_cr("Exception <%s> (0x%x) thrown in compiled method <%s> at PC " PTR_FORMAT " [" PTR_FORMAT "+%d] for thread 0x%x", | |
213 exception->print_value_string(), (address)exception(), nm->method()->print_value_string(), pc, nm->code_begin(), offset, thread); | |
214 } | |
215 // for AbortVMOnException flag | |
216 NOT_PRODUCT(Exceptions::debug_check_abort(exception)); | |
217 | |
218 // Clear out the exception oop and pc since looking up an | |
219 // exception handler can cause class loading, which might throw an | |
220 // exception and those fields are expected to be clear during | |
221 // normal bytecode execution. | |
222 thread->set_exception_oop(NULL); | |
223 thread->set_exception_pc(NULL); | |
224 | |
225 continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false); | |
226 // If an exception was thrown during exception dispatch, the exception oop may have changed | |
227 thread->set_exception_oop(exception()); | |
228 thread->set_exception_pc(pc); | |
229 | |
230 // the exception cache is used only by non-implicit exceptions | |
231 if (continuation != NULL && !SharedRuntime::deopt_blob()->contains(continuation)) { | |
232 nm->add_handler_for_exception_and_pc(exception, pc, continuation); | |
233 } | |
234 } | |
235 | |
236 // Set flag if return address is a method handle call site. | |
237 thread->set_is_method_handle_return(nm->is_method_handle_return(pc)); | |
238 | |
239 if (TraceExceptions) { | |
240 ttyLocker ttyl; | |
241 ResourceMark rm; | |
242 tty->print_cr("Thread " PTR_FORMAT " continuing at PC " PTR_FORMAT " for exception thrown at PC " PTR_FORMAT, | |
243 thread, continuation, pc); | |
244 } | |
245 | |
246 return continuation; | |
247 JRT_END | |
248 | |
249 // Enter this method from compiled code only if there is a Java exception handler | |
250 // in the method handling the exception. | |
251 // We are entering here from exception stub. We don't do a normal VM transition here. | |
252 // We do it in a helper. This is so we can check to see if the nmethod we have just | |
253 // searched for an exception handler has been deoptimized in the meantime. | |
254 address GraalRuntime::exception_handler_for_pc(JavaThread* thread) { | |
255 oop exception = thread->exception_oop(); | |
256 address pc = thread->exception_pc(); | |
257 // Still in Java mode | |
258 DEBUG_ONLY(ResetNoHandleMark rnhm); | |
259 nmethod* nm = NULL; | |
260 address continuation = NULL; | |
261 { | |
262 // Enter VM mode by calling the helper | |
263 ResetNoHandleMark rnhm; | |
264 continuation = exception_handler_for_pc_helper(thread, exception, pc, nm); | |
265 } | |
266 // Back in JAVA, use no oops DON'T safepoint | |
267 | |
268 // Now check to see if the nmethod we were called from is now deoptimized. | |
269 // If so we must return to the deopt blob and deoptimize the nmethod | |
270 if (nm != NULL && caller_is_deopted()) { | |
271 continuation = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); | |
272 } | |
273 | |
274 assert(continuation != NULL, "no handler found"); | |
275 return continuation; | |
276 } | |
277 | |
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
|
278 JRT_ENTRY(void, GraalRuntime::create_null_exception(JavaThread* thread)) |
7221 | 279 thread->set_vm_result(Exceptions::new_exception(thread, vmSymbols::java_lang_NullPointerException(), NULL)()); |
280 JRT_END | |
281 | |
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
|
282 JRT_ENTRY(void, GraalRuntime::create_out_of_bounds_exception(JavaThread* thread, jint index)) |
7221 | 283 char message[jintAsStringSize]; |
284 sprintf(message, "%d", index); | |
285 thread->set_vm_result(Exceptions::new_exception(thread, vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), message)()); | |
286 JRT_END | |
287 | |
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
|
288 JRT_ENTRY_NO_ASYNC(void, GraalRuntime::monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock)) |
7221 | 289 if (TraceGraal >= 3) { |
290 char type[O_BUFLEN]; | |
291 obj->klass()->name()->as_C_string(type, O_BUFLEN); | |
292 markOop mark = obj->mark(); | |
293 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); | |
294 tty->flush(); | |
295 } | |
296 #ifdef ASSERT | |
297 if (PrintBiasedLockingStatistics) { | |
298 Atomic::inc(BiasedLocking::slow_path_entry_count_addr()); | |
299 } | |
300 #endif | |
301 Handle h_obj(thread, obj); | |
302 assert(h_obj()->is_oop(), "must be NULL or an object"); | |
303 if (UseBiasedLocking) { | |
304 // Retry fast entry if bias is revoked to avoid unnecessary inflation | |
305 ObjectSynchronizer::fast_enter(h_obj, lock, true, CHECK); | |
306 } else { | |
7226 | 307 if (GraalUseFastLocking) { |
7221 | 308 // When using fast locking, the compiled code has already tried the fast case |
309 ObjectSynchronizer::slow_enter(h_obj, lock, THREAD); | |
310 } else { | |
311 ObjectSynchronizer::fast_enter(h_obj, lock, false, THREAD); | |
312 } | |
313 } | |
314 if (TraceGraal >= 3) { | |
315 tty->print_cr("%s: exiting locking slow with obj=" INTPTR_FORMAT, thread->name(), obj); | |
316 } | |
317 JRT_END | |
318 | |
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
|
319 JRT_LEAF(void, GraalRuntime::monitorexit(JavaThread* thread, oopDesc* obj, BasicLock* lock)) |
7221 | 320 assert(thread == JavaThread::current(), "threads must correspond"); |
321 assert(thread->last_Java_sp(), "last_Java_sp must be set"); | |
322 // monitorexit is non-blocking (leaf routine) => no exceptions can be thrown | |
323 EXCEPTION_MARK; | |
324 | |
325 #ifdef DEBUG | |
326 if (!obj->is_oop()) { | |
327 ResetNoHandleMark rhm; | |
328 nmethod* method = thread->last_frame().cb()->as_nmethod_or_null(); | |
329 if (method != NULL) { | |
330 tty->print_cr("ERROR in monitorexit in method %s wrong obj " INTPTR_FORMAT, method->name(), obj); | |
331 } | |
332 thread->print_stack_on(tty); | |
333 assert(false, "invalid lock object pointer dected"); | |
334 } | |
335 #endif | |
336 | |
7226 | 337 if (GraalUseFastLocking) { |
7221 | 338 // When using fast locking, the compiled code has already tried the fast case |
339 ObjectSynchronizer::slow_exit(obj, lock, THREAD); | |
340 } else { | |
341 ObjectSynchronizer::fast_exit(obj, lock, THREAD); | |
342 } | |
343 if (TraceGraal >= 3) { | |
344 char type[O_BUFLEN]; | |
345 obj->klass()->name()->as_C_string(type, O_BUFLEN); | |
346 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); | |
347 tty->flush(); | |
348 } | |
349 JRT_END | |
350 | |
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
|
351 JRT_ENTRY(void, GraalRuntime::log_object(JavaThread* thread, oop obj, jint flags)) |
7221 | 352 bool string = mask_bits_are_true(flags, LOG_OBJECT_STRING); |
12356
359f7e70ae7f
Reduce HotSpot diff and fix previous merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
10953
diff
changeset
|
353 bool addr = mask_bits_are_true(flags, LOG_OBJECT_ADDRESS); |
7221 | 354 bool newline = mask_bits_are_true(flags, LOG_OBJECT_NEWLINE); |
355 if (!string) { | |
12356
359f7e70ae7f
Reduce HotSpot diff and fix previous merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
10953
diff
changeset
|
356 if (!addr && obj->is_oop_or_null(true)) { |
7221 | 357 char buf[O_BUFLEN]; |
12356
359f7e70ae7f
Reduce HotSpot diff and fix previous merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
10953
diff
changeset
|
358 tty->print("%s@%p", obj->klass()->name()->as_C_string(buf, O_BUFLEN), (address)obj); |
7221 | 359 } else { |
12356
359f7e70ae7f
Reduce HotSpot diff and fix previous merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
10953
diff
changeset
|
360 tty->print("%p", (address)obj); |
7221 | 361 } |
362 } else { | |
363 ResourceMark rm; | |
364 assert(obj != NULL && java_lang_String::is_instance(obj), "must be"); | |
365 char *buf = java_lang_String::as_utf8_string(obj); | |
366 tty->print(buf); | |
367 } | |
368 if (newline) { | |
369 tty->cr(); | |
370 } | |
371 JRT_END | |
372 | |
10434
8b22524df53b
Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10072
diff
changeset
|
373 JRT_LEAF(void, GraalRuntime::write_barrier_pre(JavaThread* thread, oopDesc* obj)) |
8b22524df53b
Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10072
diff
changeset
|
374 thread->satb_mark_queue().enqueue(obj); |
8b22524df53b
Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10072
diff
changeset
|
375 JRT_END |
8b22524df53b
Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10072
diff
changeset
|
376 |
8b22524df53b
Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10072
diff
changeset
|
377 JRT_LEAF(void, GraalRuntime::write_barrier_post(JavaThread* thread, void* card_addr)) |
8b22524df53b
Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10072
diff
changeset
|
378 thread->dirty_card_queue().enqueue(card_addr); |
8b22524df53b
Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10072
diff
changeset
|
379 JRT_END |
8b22524df53b
Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10072
diff
changeset
|
380 |
12356
359f7e70ae7f
Reduce HotSpot diff and fix previous merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
10953
diff
changeset
|
381 JRT_LEAF(jboolean, GraalRuntime::validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child)) |
10953
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
382 bool ret = true; |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
383 if(!Universe::heap()->is_in_closed_subset(parent)) { |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
384 tty->print_cr("Parent Object "INTPTR_FORMAT" not in heap", parent); |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
385 parent->print(); |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
386 ret=false; |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
387 } |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
388 if(!Universe::heap()->is_in_closed_subset(child)) { |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
389 tty->print_cr("Child Object "INTPTR_FORMAT" not in heap", child); |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
390 child->print(); |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
391 ret=false; |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
392 } |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
393 return (jint)ret; |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
394 JRT_END |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
395 |
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
|
396 JRT_ENTRY(void, GraalRuntime::vm_error(JavaThread* thread, oop where, oop format, jlong value)) |
7221 | 397 ResourceMark rm; |
398 assert(where == NULL || java_lang_String::is_instance(where), "must be"); | |
399 const char *error_msg = where == NULL ? "<internal Graal error>" : java_lang_String::as_utf8_string(where); | |
400 char *detail_msg = NULL; | |
401 if (format != NULL) { | |
402 const char* buf = java_lang_String::as_utf8_string(format); | |
403 size_t detail_msg_length = strlen(buf) * 2; | |
404 detail_msg = (char *) NEW_RESOURCE_ARRAY(u_char, detail_msg_length); | |
405 jio_snprintf(detail_msg, detail_msg_length, buf, value); | |
406 } | |
407 report_vm_error(__FILE__, __LINE__, error_msg, detail_msg); | |
408 JRT_END | |
409 | |
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
|
410 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
|
411 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
|
412 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
|
413 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
|
414 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
|
415 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
|
416 JRT_END |
8506 | 417 |
418 JRT_LEAF(void, GraalRuntime::log_printf(JavaThread* thread, oop format, jlong v1, jlong v2, jlong v3)) | |
7221 | 419 ResourceMark rm; |
420 assert(format != NULL && java_lang_String::is_instance(format), "must be"); | |
421 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
|
422 tty->print(buf, v1, v2, v3); |
7221 | 423 JRT_END |
424 | |
9573
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
425 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
|
426 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
|
427 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
|
428 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
|
429 if (cb) { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
430 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
|
431 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
|
432 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
|
433 return; |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
434 } |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
435 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
|
436 return; |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
437 } |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
438 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
|
439 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
|
440 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
|
441 return; |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
442 } |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
443 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
|
444 } |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
445 } |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
446 |
9471
5fa54bf57f8c
replaced exception_handler_nofpu assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9457
diff
changeset
|
447 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
|
448 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
|
449 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
|
450 if (vmError) { |
9573
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
451 if (buf != NULL) { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
452 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
|
453 } else { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
454 fatal("<anonymous error>"); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
455 } |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
456 } 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
|
457 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
|
458 } else { |
9573
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
459 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
|
460 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
|
461 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
|
462 } |
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
|
463 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
|
464 |
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
|
465 JRT_ENTRY(void, GraalRuntime::log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline)) |
7221 | 466 union { |
467 jlong l; | |
468 jdouble d; | |
469 jfloat f; | |
470 } uu; | |
471 uu.l = value; | |
472 switch (typeChar) { | |
473 case 'z': tty->print(value == 0 ? "false" : "true"); break; | |
474 case 'b': tty->print("%d", (jbyte) value); break; | |
475 case 'c': tty->print("%c", (jchar) value); break; | |
476 case 's': tty->print("%d", (jshort) value); break; | |
477 case 'i': tty->print("%d", (jint) value); break; | |
478 case 'f': tty->print("%f", uu.f); break; | |
479 case 'j': tty->print(INT64_FORMAT, value); break; | |
480 case 'd': tty->print("%lf", uu.d); break; | |
481 default: assert(false, "unknown typeChar"); break; | |
482 } | |
483 if (newline) { | |
484 tty->cr(); | |
485 } | |
486 JRT_END | |
487 | |
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
|
488 JRT_ENTRY(jint, GraalRuntime::identity_hash_code(JavaThread* thread, oop obj)) |
7221 | 489 return (jint) obj->identity_hash(); |
490 JRT_END | |
491 | |
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
|
492 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
|
493 // 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
|
494 Handle receiverHandle(thread, receiver); |
7386
707e9cca11de
fixed HotSpot windows build
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7235
diff
changeset
|
495 MutexLockerEx ml(thread->threadObj() == receiver ? NULL : Threads_lock); |
707e9cca11de
fixed HotSpot windows build
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7235
diff
changeset
|
496 JavaThread* receiverThread = java_lang_Thread::thread(receiverHandle()); |
707e9cca11de
fixed HotSpot windows build
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7235
diff
changeset
|
497 return (jint) Thread::is_interrupted(receiverThread, clear_interrupted != 0); |
7221 | 498 JRT_END |
499 | |
500 // JVM_InitializeGraalRuntime | |
501 JVM_ENTRY(jobject, JVM_InitializeGraalRuntime(JNIEnv *env, jclass graalclass)) | |
502 return VMToCompiler::graalRuntimePermObject(); | |
503 JVM_END | |
10475
3489047ffea2
Restructure the handling of HotSpotInstalledCode and their link to nmethods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10434
diff
changeset
|
504 |
3489047ffea2
Restructure the handling of HotSpotInstalledCode and their link to nmethods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10434
diff
changeset
|
505 // JVM_InitializeTruffleRuntime |
3489047ffea2
Restructure the handling of HotSpotInstalledCode and their link to nmethods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10434
diff
changeset
|
506 JVM_ENTRY(jobject, JVM_InitializeTruffleRuntime(JNIEnv *env, jclass graalclass)) |
3489047ffea2
Restructure the handling of HotSpotInstalledCode and their link to nmethods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10434
diff
changeset
|
507 return JNIHandles::make_local(VMToCompiler::truffleRuntime()()); |
3489047ffea2
Restructure the handling of HotSpotInstalledCode and their link to nmethods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10434
diff
changeset
|
508 JVM_END |