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