author | jprovino |
Mon, 04 Apr 2016 12:57:48 -0400 | |
changeset 37248 | 11a660dbbb8e |
parent 36805 | 626399e1ebf2 |
child 37267 | ad8c0e8de29f |
permissions | -rw-r--r-- |
33160 | 1 |
/* |
35498
392b50de06c6
8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents:
35216
diff
changeset
|
2 |
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. |
33160 | 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" |
|
25 |
#include "asm/codeBuffer.hpp" |
|
35498
392b50de06c6
8146401: Clean up oop.hpp: add inline directives and fix header files
goetz
parents:
35216
diff
changeset
|
26 |
#include "classfile/javaClasses.inline.hpp" |
33160 | 27 |
#include "code/codeCache.hpp" |
28 |
#include "compiler/compileBroker.hpp" |
|
29 |
#include "compiler/disassembler.hpp" |
|
30 |
#include "jvmci/jvmciRuntime.hpp" |
|
31 |
#include "jvmci/jvmciCompilerToVM.hpp" |
|
32 |
#include "jvmci/jvmciCompiler.hpp" |
|
33 |
#include "jvmci/jvmciJavaClasses.hpp" |
|
34 |
#include "jvmci/jvmciEnv.hpp" |
|
35216
71c463a17b3b
8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents:
35071
diff
changeset
|
35 |
#include "logging/log.hpp" |
33160 | 36 |
#include "memory/oopFactory.hpp" |
37248 | 37 |
#include "memory/resourceArea.hpp" |
33160 | 38 |
#include "oops/oop.inline.hpp" |
39 |
#include "oops/objArrayOop.inline.hpp" |
|
40 |
#include "prims/jvm.h" |
|
41 |
#include "runtime/biasedLocking.hpp" |
|
42 |
#include "runtime/interfaceSupport.hpp" |
|
43 |
#include "runtime/reflection.hpp" |
|
44 |
#include "runtime/sharedRuntime.hpp" |
|
45 |
#include "utilities/debug.hpp" |
|
46 |
#include "utilities/defaultStream.hpp" |
|
47 |
||
48 |
#if defined(_MSC_VER) |
|
49 |
#define strtoll _strtoi64 |
|
50 |
#endif |
|
51 |
||
52 |
jobject JVMCIRuntime::_HotSpotJVMCIRuntime_instance = NULL; |
|
53 |
bool JVMCIRuntime::_HotSpotJVMCIRuntime_initialized = false; |
|
54 |
bool JVMCIRuntime::_well_known_classes_initialized = false; |
|
33632 | 55 |
int JVMCIRuntime::_trivial_prefixes_count = 0; |
56 |
char** JVMCIRuntime::_trivial_prefixes = NULL; |
|
33160 | 57 |
bool JVMCIRuntime::_shutdown_called = false; |
58 |
||
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
59 |
BasicType JVMCIRuntime::kindToBasicType(Handle kind, TRAPS) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
60 |
if (kind.is_null()) { |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
61 |
THROW_(vmSymbols::java_lang_NullPointerException(), T_ILLEGAL); |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
62 |
} |
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
63 |
jchar ch = JavaKind::typeChar(kind); |
33160 | 64 |
switch(ch) { |
65 |
case 'z': return T_BOOLEAN; |
|
66 |
case 'b': return T_BYTE; |
|
67 |
case 's': return T_SHORT; |
|
68 |
case 'c': return T_CHAR; |
|
69 |
case 'i': return T_INT; |
|
70 |
case 'f': return T_FLOAT; |
|
71 |
case 'j': return T_LONG; |
|
72 |
case 'd': return T_DOUBLE; |
|
73 |
case 'a': return T_OBJECT; |
|
74 |
case '-': return T_ILLEGAL; |
|
75 |
default: |
|
34153
cbcfa2a6fe0b
8139589: [JVMCI] throw exceptions in faulty code installation operations
twisti
parents:
33632
diff
changeset
|
76 |
JVMCI_ERROR_(T_ILLEGAL, "unexpected Kind: %c", ch); |
33160 | 77 |
} |
78 |
} |
|
79 |
||
80 |
// Simple helper to see if the caller of a runtime stub which |
|
81 |
// entered the VM has been deoptimized |
|
82 |
||
83 |
static bool caller_is_deopted() { |
|
84 |
JavaThread* thread = JavaThread::current(); |
|
85 |
RegisterMap reg_map(thread, false); |
|
86 |
frame runtime_frame = thread->last_frame(); |
|
87 |
frame caller_frame = runtime_frame.sender(®_map); |
|
88 |
assert(caller_frame.is_compiled_frame(), "must be compiled"); |
|
89 |
return caller_frame.is_deoptimized_frame(); |
|
90 |
} |
|
91 |
||
92 |
// Stress deoptimization |
|
93 |
static void deopt_caller() { |
|
94 |
if ( !caller_is_deopted()) { |
|
95 |
JavaThread* thread = JavaThread::current(); |
|
96 |
RegisterMap reg_map(thread, false); |
|
97 |
frame runtime_frame = thread->last_frame(); |
|
98 |
frame caller_frame = runtime_frame.sender(®_map); |
|
99 |
Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint); |
|
100 |
assert(caller_is_deopted(), "Must be deoptimized"); |
|
101 |
} |
|
102 |
} |
|
103 |
||
104 |
JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_instance(JavaThread* thread, Klass* klass)) |
|
105 |
JRT_BLOCK; |
|
106 |
assert(klass->is_klass(), "not a class"); |
|
36603
0bc3ad031d60
8141420: Compiler runtime entries don't hold Klass* from being GCed
vlivanov
parents:
36594
diff
changeset
|
107 |
Handle holder(THREAD, klass->klass_holder()); // keep the klass alive |
33160 | 108 |
instanceKlassHandle h(thread, klass); |
109 |
h->check_valid_for_instantiation(true, CHECK); |
|
110 |
// make sure klass is initialized |
|
111 |
h->initialize(CHECK); |
|
112 |
// allocate instance and return via TLS |
|
113 |
oop obj = h->allocate_instance(CHECK); |
|
114 |
thread->set_vm_result(obj); |
|
115 |
JRT_BLOCK_END; |
|
116 |
||
117 |
if (ReduceInitialCardMarks) { |
|
118 |
new_store_pre_barrier(thread); |
|
119 |
} |
|
120 |
JRT_END |
|
121 |
||
122 |
JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_array(JavaThread* thread, Klass* array_klass, jint length)) |
|
123 |
JRT_BLOCK; |
|
124 |
// Note: no handle for klass needed since they are not used |
|
125 |
// anymore after new_objArray() and no GC can happen before. |
|
126 |
// (This may have to change if this code changes!) |
|
127 |
assert(array_klass->is_klass(), "not a class"); |
|
128 |
oop obj; |
|
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33198
diff
changeset
|
129 |
if (array_klass->is_typeArray_klass()) { |
33160 | 130 |
BasicType elt_type = TypeArrayKlass::cast(array_klass)->element_type(); |
131 |
obj = oopFactory::new_typeArray(elt_type, length, CHECK); |
|
132 |
} else { |
|
36603
0bc3ad031d60
8141420: Compiler runtime entries don't hold Klass* from being GCed
vlivanov
parents:
36594
diff
changeset
|
133 |
Handle holder(THREAD, array_klass->klass_holder()); // keep the klass alive |
33160 | 134 |
Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass(); |
135 |
obj = oopFactory::new_objArray(elem_klass, length, CHECK); |
|
136 |
} |
|
137 |
thread->set_vm_result(obj); |
|
138 |
// This is pretty rare but this runtime patch is stressful to deoptimization |
|
139 |
// if we deoptimize here so force a deopt to stress the path. |
|
140 |
if (DeoptimizeALot) { |
|
141 |
static int deopts = 0; |
|
142 |
// Alternate between deoptimizing and raising an error (which will also cause a deopt) |
|
143 |
if (deopts++ % 2 == 0) { |
|
144 |
ResourceMark rm(THREAD); |
|
145 |
THROW(vmSymbols::java_lang_OutOfMemoryError()); |
|
146 |
} else { |
|
147 |
deopt_caller(); |
|
148 |
} |
|
149 |
} |
|
150 |
JRT_BLOCK_END; |
|
151 |
||
152 |
if (ReduceInitialCardMarks) { |
|
153 |
new_store_pre_barrier(thread); |
|
154 |
} |
|
155 |
JRT_END |
|
156 |
||
157 |
void JVMCIRuntime::new_store_pre_barrier(JavaThread* thread) { |
|
158 |
// After any safepoint, just before going back to compiled code, |
|
159 |
// we inform the GC that we will be doing initializing writes to |
|
160 |
// this object in the future without emitting card-marks, so |
|
161 |
// GC may take any compensating steps. |
|
162 |
// NOTE: Keep this code consistent with GraphKit::store_barrier. |
|
163 |
||
164 |
oop new_obj = thread->vm_result(); |
|
165 |
if (new_obj == NULL) return; |
|
166 |
||
167 |
assert(Universe::heap()->can_elide_tlab_store_barriers(), |
|
168 |
"compiler must check this first"); |
|
169 |
// GC may decide to give back a safer copy of new_obj. |
|
170 |
new_obj = Universe::heap()->new_store_pre_barrier(thread, new_obj); |
|
171 |
thread->set_vm_result(new_obj); |
|
172 |
} |
|
173 |
||
174 |
JRT_ENTRY(void, JVMCIRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims)) |
|
175 |
assert(klass->is_klass(), "not a class"); |
|
176 |
assert(rank >= 1, "rank must be nonzero"); |
|
36603
0bc3ad031d60
8141420: Compiler runtime entries don't hold Klass* from being GCed
vlivanov
parents:
36594
diff
changeset
|
177 |
Handle holder(THREAD, klass->klass_holder()); // keep the klass alive |
33160 | 178 |
oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK); |
179 |
thread->set_vm_result(obj); |
|
180 |
JRT_END |
|
181 |
||
182 |
JRT_ENTRY(void, JVMCIRuntime::dynamic_new_array(JavaThread* thread, oopDesc* element_mirror, jint length)) |
|
183 |
oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK); |
|
184 |
thread->set_vm_result(obj); |
|
185 |
JRT_END |
|
186 |
||
187 |
JRT_ENTRY(void, JVMCIRuntime::dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror)) |
|
188 |
instanceKlassHandle klass(THREAD, java_lang_Class::as_Klass(type_mirror)); |
|
189 |
||
190 |
if (klass == NULL) { |
|
191 |
ResourceMark rm(THREAD); |
|
192 |
THROW(vmSymbols::java_lang_InstantiationException()); |
|
193 |
} |
|
194 |
||
195 |
// Create new instance (the receiver) |
|
196 |
klass->check_valid_for_instantiation(false, CHECK); |
|
197 |
||
198 |
// Make sure klass gets initialized |
|
199 |
klass->initialize(CHECK); |
|
200 |
||
201 |
oop obj = klass->allocate_instance(CHECK); |
|
202 |
thread->set_vm_result(obj); |
|
203 |
JRT_END |
|
204 |
||
205 |
extern void vm_exit(int code); |
|
206 |
||
207 |
// Enter this method from compiled code handler below. This is where we transition |
|
208 |
// to VM mode. This is done as a helper routine so that the method called directly |
|
209 |
// from compiled code does not have to transition to VM. This allows the entry |
|
210 |
// method to see if the nmethod that we have just looked up a handler for has |
|
211 |
// been deoptimized while we were in the vm. This simplifies the assembly code |
|
212 |
// cpu directories. |
|
213 |
// |
|
214 |
// We are entering here from exception stub (via the entry method below) |
|
215 |
// If there is a compiled exception handler in this method, we will continue there; |
|
216 |
// otherwise we will unwind the stack and continue at the caller of top frame method |
|
217 |
// Note: we enter in Java using a special JRT wrapper. This wrapper allows us to |
|
218 |
// control the area where we can allow a safepoint. After we exit the safepoint area we can |
|
219 |
// check to see if the handler we are going to return is now in a nmethod that has |
|
220 |
// been deoptimized. If that is the case we return the deopt blob |
|
221 |
// unpack_with_exception entry instead. This makes life for the exception blob easier |
|
222 |
// because making that same check and diverting is painful from assembly language. |
|
223 |
JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* thread, oopDesc* ex, address pc, nmethod*& nm)) |
|
224 |
// Reset method handle flag. |
|
225 |
thread->set_is_method_handle_return(false); |
|
226 |
||
227 |
Handle exception(thread, ex); |
|
228 |
nm = CodeCache::find_nmethod(pc); |
|
229 |
assert(nm != NULL, "this is not a compiled method"); |
|
230 |
// Adjust the pc as needed/ |
|
231 |
if (nm->is_deopt_pc(pc)) { |
|
232 |
RegisterMap map(thread, false); |
|
233 |
frame exception_frame = thread->last_frame().sender(&map); |
|
234 |
// if the frame isn't deopted then pc must not correspond to the caller of last_frame |
|
235 |
assert(exception_frame.is_deoptimized_frame(), "must be deopted"); |
|
236 |
pc = exception_frame.pc(); |
|
237 |
} |
|
238 |
#ifdef ASSERT |
|
239 |
assert(exception.not_null(), "NULL exceptions should be handled by throw_exception"); |
|
240 |
assert(exception->is_oop(), "just checking"); |
|
241 |
// Check that exception is a subclass of Throwable, otherwise we have a VerifyError |
|
242 |
if (!(exception->is_a(SystemDictionary::Throwable_klass()))) { |
|
243 |
if (ExitVMOnVerifyError) vm_exit(-1); |
|
244 |
ShouldNotReachHere(); |
|
245 |
} |
|
246 |
#endif |
|
247 |
||
248 |
// Check the stack guard pages and reenable them if necessary and there is |
|
249 |
// enough space on the stack to do so. Use fast exceptions only if the guard |
|
250 |
// pages are enabled. |
|
35071
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
34192
diff
changeset
|
251 |
bool guard_pages_enabled = thread->stack_guards_enabled(); |
33160 | 252 |
if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack(); |
253 |
||
254 |
if (JvmtiExport::can_post_on_exceptions()) { |
|
255 |
// To ensure correct notification of exception catches and throws |
|
256 |
// we have to deoptimize here. If we attempted to notify the |
|
257 |
// catches and throws during this exception lookup it's possible |
|
258 |
// we could deoptimize on the way out of the VM and end back in |
|
259 |
// the interpreter at the throw site. This would result in double |
|
260 |
// notifications since the interpreter would also notify about |
|
261 |
// these same catches and throws as it unwound the frame. |
|
262 |
||
263 |
RegisterMap reg_map(thread); |
|
264 |
frame stub_frame = thread->last_frame(); |
|
265 |
frame caller_frame = stub_frame.sender(®_map); |
|
266 |
||
267 |
// We don't really want to deoptimize the nmethod itself since we |
|
268 |
// can actually continue in the exception handler ourselves but I |
|
269 |
// don't see an easy way to have the desired effect. |
|
270 |
Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint); |
|
271 |
assert(caller_is_deopted(), "Must be deoptimized"); |
|
272 |
||
273 |
return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); |
|
274 |
} |
|
275 |
||
276 |
// ExceptionCache is used only for exceptions at call sites and not for implicit exceptions |
|
277 |
if (guard_pages_enabled) { |
|
278 |
address fast_continuation = nm->handler_for_exception_and_pc(exception, pc); |
|
279 |
if (fast_continuation != NULL) { |
|
280 |
// Set flag if return address is a method handle call site. |
|
281 |
thread->set_is_method_handle_return(nm->is_method_handle_return(pc)); |
|
282 |
return fast_continuation; |
|
283 |
} |
|
284 |
} |
|
285 |
||
286 |
// If the stack guard pages are enabled, check whether there is a handler in |
|
287 |
// the current method. Otherwise (guard pages disabled), force an unwind and |
|
288 |
// skip the exception cache update (i.e., just leave continuation==NULL). |
|
289 |
address continuation = NULL; |
|
290 |
if (guard_pages_enabled) { |
|
291 |
||
292 |
// New exception handling mechanism can support inlined methods |
|
293 |
// with exception handlers since the mappings are from PC to PC |
|
294 |
||
295 |
// debugging support |
|
296 |
// tracing |
|
35216
71c463a17b3b
8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents:
35071
diff
changeset
|
297 |
if (log_is_enabled(Info, exceptions)) { |
33160 | 298 |
ResourceMark rm; |
36333
dcca1e98a2ab
8150738: [JVMCI] runtime/CommandLine/TraceExceptionsTest.java fails with: java.lang.RuntimeException: '<a 'java/lang/ClassNotFoundException': NoClassFound>' missing
twisti
parents:
35835
diff
changeset
|
299 |
stringStream tempst; |
dcca1e98a2ab
8150738: [JVMCI] runtime/CommandLine/TraceExceptionsTest.java fails with: java.lang.RuntimeException: '<a 'java/lang/ClassNotFoundException': NoClassFound>' missing
twisti
parents:
35835
diff
changeset
|
300 |
tempst.print("compiled method <%s>\n" |
dcca1e98a2ab
8150738: [JVMCI] runtime/CommandLine/TraceExceptionsTest.java fails with: java.lang.RuntimeException: '<a 'java/lang/ClassNotFoundException': NoClassFound>' missing
twisti
parents:
35835
diff
changeset
|
301 |
" at PC" INTPTR_FORMAT " for thread " INTPTR_FORMAT, |
dcca1e98a2ab
8150738: [JVMCI] runtime/CommandLine/TraceExceptionsTest.java fails with: java.lang.RuntimeException: '<a 'java/lang/ClassNotFoundException': NoClassFound>' missing
twisti
parents:
35835
diff
changeset
|
302 |
nm->method()->print_value_string(), p2i(pc), p2i(thread)); |
dcca1e98a2ab
8150738: [JVMCI] runtime/CommandLine/TraceExceptionsTest.java fails with: java.lang.RuntimeException: '<a 'java/lang/ClassNotFoundException': NoClassFound>' missing
twisti
parents:
35835
diff
changeset
|
303 |
Exceptions::log_exception(exception, tempst); |
33160 | 304 |
} |
305 |
// for AbortVMOnException flag |
|
306 |
NOT_PRODUCT(Exceptions::debug_check_abort(exception)); |
|
307 |
||
308 |
// Clear out the exception oop and pc since looking up an |
|
309 |
// exception handler can cause class loading, which might throw an |
|
310 |
// exception and those fields are expected to be clear during |
|
311 |
// normal bytecode execution. |
|
312 |
thread->clear_exception_oop_and_pc(); |
|
313 |
||
314 |
continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false); |
|
315 |
// If an exception was thrown during exception dispatch, the exception oop may have changed |
|
316 |
thread->set_exception_oop(exception()); |
|
317 |
thread->set_exception_pc(pc); |
|
318 |
||
319 |
// the exception cache is used only by non-implicit exceptions |
|
320 |
if (continuation != NULL && !SharedRuntime::deopt_blob()->contains(continuation)) { |
|
321 |
nm->add_handler_for_exception_and_pc(exception, pc, continuation); |
|
322 |
} |
|
323 |
} |
|
324 |
||
325 |
// Set flag if return address is a method handle call site. |
|
326 |
thread->set_is_method_handle_return(nm->is_method_handle_return(pc)); |
|
327 |
||
35216
71c463a17b3b
8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents:
35071
diff
changeset
|
328 |
if (log_is_enabled(Info, exceptions)) { |
33160 | 329 |
ResourceMark rm; |
35216
71c463a17b3b
8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents:
35071
diff
changeset
|
330 |
log_info(exceptions)("Thread " PTR_FORMAT " continuing at PC " PTR_FORMAT |
71c463a17b3b
8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents:
35071
diff
changeset
|
331 |
" for exception thrown at PC " PTR_FORMAT, |
71c463a17b3b
8141211: Convert TraceExceptions to Unified Logging
rprotacio
parents:
35071
diff
changeset
|
332 |
p2i(thread), p2i(continuation), p2i(pc)); |
33160 | 333 |
} |
334 |
||
335 |
return continuation; |
|
336 |
JRT_END |
|
337 |
||
338 |
// Enter this method from compiled code only if there is a Java exception handler |
|
339 |
// in the method handling the exception. |
|
340 |
// We are entering here from exception stub. We don't do a normal VM transition here. |
|
341 |
// We do it in a helper. This is so we can check to see if the nmethod we have just |
|
342 |
// searched for an exception handler has been deoptimized in the meantime. |
|
343 |
address JVMCIRuntime::exception_handler_for_pc(JavaThread* thread) { |
|
344 |
oop exception = thread->exception_oop(); |
|
345 |
address pc = thread->exception_pc(); |
|
346 |
// Still in Java mode |
|
347 |
DEBUG_ONLY(ResetNoHandleMark rnhm); |
|
348 |
nmethod* nm = NULL; |
|
349 |
address continuation = NULL; |
|
350 |
{ |
|
351 |
// Enter VM mode by calling the helper |
|
352 |
ResetNoHandleMark rnhm; |
|
353 |
continuation = exception_handler_for_pc_helper(thread, exception, pc, nm); |
|
354 |
} |
|
355 |
// Back in JAVA, use no oops DON'T safepoint |
|
356 |
||
357 |
// Now check to see if the compiled method we were called from is now deoptimized. |
|
358 |
// If so we must return to the deopt blob and deoptimize the nmethod |
|
359 |
if (nm != NULL && caller_is_deopted()) { |
|
360 |
continuation = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); |
|
361 |
} |
|
362 |
||
363 |
assert(continuation != NULL, "no handler found"); |
|
364 |
return continuation; |
|
365 |
} |
|
366 |
||
367 |
JRT_ENTRY(void, JVMCIRuntime::create_null_exception(JavaThread* thread)) |
|
368 |
SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_NullPointerException()); |
|
369 |
thread->set_vm_result(PENDING_EXCEPTION); |
|
370 |
CLEAR_PENDING_EXCEPTION; |
|
371 |
JRT_END |
|
372 |
||
373 |
JRT_ENTRY(void, JVMCIRuntime::create_out_of_bounds_exception(JavaThread* thread, jint index)) |
|
374 |
char message[jintAsStringSize]; |
|
375 |
sprintf(message, "%d", index); |
|
376 |
SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), message); |
|
377 |
thread->set_vm_result(PENDING_EXCEPTION); |
|
378 |
CLEAR_PENDING_EXCEPTION; |
|
379 |
JRT_END |
|
380 |
||
381 |
JRT_ENTRY_NO_ASYNC(void, JVMCIRuntime::monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock)) |
|
382 |
IF_TRACE_jvmci_3 { |
|
383 |
char type[O_BUFLEN]; |
|
384 |
obj->klass()->name()->as_C_string(type, O_BUFLEN); |
|
385 |
markOop mark = obj->mark(); |
|
386 |
TRACE_jvmci_3("%s: entered locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), p2i(obj), type, p2i(mark), p2i(lock)); |
|
387 |
tty->flush(); |
|
388 |
} |
|
389 |
#ifdef ASSERT |
|
390 |
if (PrintBiasedLockingStatistics) { |
|
391 |
Atomic::inc(BiasedLocking::slow_path_entry_count_addr()); |
|
392 |
} |
|
393 |
#endif |
|
394 |
Handle h_obj(thread, obj); |
|
395 |
assert(h_obj()->is_oop(), "must be NULL or an object"); |
|
396 |
if (UseBiasedLocking) { |
|
397 |
// Retry fast entry if bias is revoked to avoid unnecessary inflation |
|
398 |
ObjectSynchronizer::fast_enter(h_obj, lock, true, CHECK); |
|
399 |
} else { |
|
400 |
if (JVMCIUseFastLocking) { |
|
401 |
// When using fast locking, the compiled code has already tried the fast case |
|
402 |
ObjectSynchronizer::slow_enter(h_obj, lock, THREAD); |
|
403 |
} else { |
|
404 |
ObjectSynchronizer::fast_enter(h_obj, lock, false, THREAD); |
|
405 |
} |
|
406 |
} |
|
407 |
TRACE_jvmci_3("%s: exiting locking slow with obj=" INTPTR_FORMAT, thread->name(), p2i(obj)); |
|
408 |
JRT_END |
|
409 |
||
410 |
JRT_LEAF(void, JVMCIRuntime::monitorexit(JavaThread* thread, oopDesc* obj, BasicLock* lock)) |
|
411 |
assert(thread == JavaThread::current(), "threads must correspond"); |
|
412 |
assert(thread->last_Java_sp(), "last_Java_sp must be set"); |
|
413 |
// monitorexit is non-blocking (leaf routine) => no exceptions can be thrown |
|
414 |
EXCEPTION_MARK; |
|
415 |
||
416 |
#ifdef DEBUG |
|
417 |
if (!obj->is_oop()) { |
|
418 |
ResetNoHandleMark rhm; |
|
419 |
nmethod* method = thread->last_frame().cb()->as_nmethod_or_null(); |
|
420 |
if (method != NULL) { |
|
421 |
tty->print_cr("ERROR in monitorexit in method %s wrong obj " INTPTR_FORMAT, method->name(), p2i(obj)); |
|
422 |
} |
|
423 |
thread->print_stack_on(tty); |
|
424 |
assert(false, "invalid lock object pointer dected"); |
|
425 |
} |
|
426 |
#endif |
|
427 |
||
428 |
if (JVMCIUseFastLocking) { |
|
429 |
// When using fast locking, the compiled code has already tried the fast case |
|
430 |
ObjectSynchronizer::slow_exit(obj, lock, THREAD); |
|
431 |
} else { |
|
432 |
ObjectSynchronizer::fast_exit(obj, lock, THREAD); |
|
433 |
} |
|
434 |
IF_TRACE_jvmci_3 { |
|
435 |
char type[O_BUFLEN]; |
|
436 |
obj->klass()->name()->as_C_string(type, O_BUFLEN); |
|
437 |
TRACE_jvmci_3("%s: exited locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), p2i(obj), type, p2i(obj->mark()), p2i(lock)); |
|
438 |
tty->flush(); |
|
439 |
} |
|
440 |
JRT_END |
|
441 |
||
33632 | 442 |
JRT_LEAF(void, JVMCIRuntime::log_object(JavaThread* thread, oopDesc* obj, bool as_string, bool newline)) |
443 |
ttyLocker ttyl; |
|
444 |
||
445 |
if (obj == NULL) { |
|
446 |
tty->print("NULL"); |
|
447 |
} else if (obj->is_oop_or_null(true) && (!as_string || !java_lang_String::is_instance(obj))) { |
|
448 |
if (obj->is_oop_or_null(true)) { |
|
33160 | 449 |
char buf[O_BUFLEN]; |
450 |
tty->print("%s@" INTPTR_FORMAT, obj->klass()->name()->as_C_string(buf, O_BUFLEN), p2i(obj)); |
|
451 |
} else { |
|
452 |
tty->print(INTPTR_FORMAT, p2i(obj)); |
|
453 |
} |
|
454 |
} else { |
|
455 |
ResourceMark rm; |
|
456 |
assert(obj != NULL && java_lang_String::is_instance(obj), "must be"); |
|
457 |
char *buf = java_lang_String::as_utf8_string(obj); |
|
458 |
tty->print_raw(buf); |
|
459 |
} |
|
460 |
if (newline) { |
|
461 |
tty->cr(); |
|
462 |
} |
|
463 |
JRT_END |
|
464 |
||
465 |
JRT_LEAF(void, JVMCIRuntime::write_barrier_pre(JavaThread* thread, oopDesc* obj)) |
|
466 |
thread->satb_mark_queue().enqueue(obj); |
|
467 |
JRT_END |
|
468 |
||
469 |
JRT_LEAF(void, JVMCIRuntime::write_barrier_post(JavaThread* thread, void* card_addr)) |
|
470 |
thread->dirty_card_queue().enqueue(card_addr); |
|
471 |
JRT_END |
|
472 |
||
473 |
JRT_LEAF(jboolean, JVMCIRuntime::validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child)) |
|
474 |
bool ret = true; |
|
475 |
if(!Universe::heap()->is_in_closed_subset(parent)) { |
|
476 |
tty->print_cr("Parent Object " INTPTR_FORMAT " not in heap", p2i(parent)); |
|
477 |
parent->print(); |
|
478 |
ret=false; |
|
479 |
} |
|
480 |
if(!Universe::heap()->is_in_closed_subset(child)) { |
|
481 |
tty->print_cr("Child Object " INTPTR_FORMAT " not in heap", p2i(child)); |
|
482 |
child->print(); |
|
483 |
ret=false; |
|
484 |
} |
|
485 |
return (jint)ret; |
|
486 |
JRT_END |
|
487 |
||
488 |
JRT_ENTRY(void, JVMCIRuntime::vm_error(JavaThread* thread, jlong where, jlong format, jlong value)) |
|
489 |
ResourceMark rm; |
|
490 |
const char *error_msg = where == 0L ? "<internal JVMCI error>" : (char*) (address) where; |
|
491 |
char *detail_msg = NULL; |
|
492 |
if (format != 0L) { |
|
493 |
const char* buf = (char*) (address) format; |
|
494 |
size_t detail_msg_length = strlen(buf) * 2; |
|
495 |
detail_msg = (char *) NEW_RESOURCE_ARRAY(u_char, detail_msg_length); |
|
496 |
jio_snprintf(detail_msg, detail_msg_length, buf, value); |
|
33198 | 497 |
report_vm_error(__FILE__, __LINE__, error_msg, "%s", detail_msg); |
498 |
} else { |
|
499 |
report_vm_error(__FILE__, __LINE__, error_msg); |
|
33160 | 500 |
} |
501 |
JRT_END |
|
502 |
||
503 |
JRT_LEAF(oopDesc*, JVMCIRuntime::load_and_clear_exception(JavaThread* thread)) |
|
504 |
oop exception = thread->exception_oop(); |
|
505 |
assert(exception != NULL, "npe"); |
|
506 |
thread->set_exception_oop(NULL); |
|
507 |
thread->set_exception_pc(0); |
|
508 |
return exception; |
|
509 |
JRT_END |
|
510 |
||
511 |
PRAGMA_DIAG_PUSH |
|
512 |
PRAGMA_FORMAT_NONLITERAL_IGNORED |
|
513 |
JRT_LEAF(void, JVMCIRuntime::log_printf(JavaThread* thread, oopDesc* format, jlong v1, jlong v2, jlong v3)) |
|
514 |
ResourceMark rm; |
|
515 |
assert(format != NULL && java_lang_String::is_instance(format), "must be"); |
|
516 |
char *buf = java_lang_String::as_utf8_string(format); |
|
517 |
tty->print((const char*)buf, v1, v2, v3); |
|
518 |
JRT_END |
|
519 |
PRAGMA_DIAG_POP |
|
520 |
||
521 |
static void decipher(jlong v, bool ignoreZero) { |
|
522 |
if (v != 0 || !ignoreZero) { |
|
523 |
void* p = (void *)(address) v; |
|
524 |
CodeBlob* cb = CodeCache::find_blob(p); |
|
525 |
if (cb) { |
|
526 |
if (cb->is_nmethod()) { |
|
527 |
char buf[O_BUFLEN]; |
|
528 |
tty->print("%s [" INTPTR_FORMAT "+" JLONG_FORMAT "]", cb->as_nmethod_or_null()->method()->name_and_sig_as_C_string(buf, O_BUFLEN), p2i(cb->code_begin()), (jlong)((address)v - cb->code_begin())); |
|
529 |
return; |
|
530 |
} |
|
531 |
cb->print_value_on(tty); |
|
532 |
return; |
|
533 |
} |
|
534 |
if (Universe::heap()->is_in(p)) { |
|
535 |
oop obj = oop(p); |
|
536 |
obj->print_value_on(tty); |
|
537 |
return; |
|
538 |
} |
|
539 |
tty->print(INTPTR_FORMAT " [long: " JLONG_FORMAT ", double %lf, char %c]",p2i((void *)v), (jlong)v, (jdouble)v, (char)v); |
|
540 |
} |
|
541 |
} |
|
542 |
||
543 |
PRAGMA_DIAG_PUSH |
|
544 |
PRAGMA_FORMAT_NONLITERAL_IGNORED |
|
545 |
JRT_LEAF(void, JVMCIRuntime::vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3)) |
|
546 |
ResourceMark rm; |
|
547 |
const char *buf = (const char*) (address) format; |
|
548 |
if (vmError) { |
|
549 |
if (buf != NULL) { |
|
33198 | 550 |
fatal(buf, v1, v2, v3); |
33160 | 551 |
} else { |
552 |
fatal("<anonymous error>"); |
|
553 |
} |
|
554 |
} else if (buf != NULL) { |
|
555 |
tty->print(buf, v1, v2, v3); |
|
556 |
} else { |
|
557 |
assert(v2 == 0, "v2 != 0"); |
|
558 |
assert(v3 == 0, "v3 != 0"); |
|
559 |
decipher(v1, false); |
|
560 |
} |
|
561 |
JRT_END |
|
562 |
PRAGMA_DIAG_POP |
|
563 |
||
564 |
JRT_LEAF(void, JVMCIRuntime::log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline)) |
|
565 |
union { |
|
566 |
jlong l; |
|
567 |
jdouble d; |
|
568 |
jfloat f; |
|
569 |
} uu; |
|
570 |
uu.l = value; |
|
571 |
switch (typeChar) { |
|
572 |
case 'z': tty->print(value == 0 ? "false" : "true"); break; |
|
573 |
case 'b': tty->print("%d", (jbyte) value); break; |
|
574 |
case 'c': tty->print("%c", (jchar) value); break; |
|
575 |
case 's': tty->print("%d", (jshort) value); break; |
|
576 |
case 'i': tty->print("%d", (jint) value); break; |
|
577 |
case 'f': tty->print("%f", uu.f); break; |
|
578 |
case 'j': tty->print(JLONG_FORMAT, value); break; |
|
579 |
case 'd': tty->print("%lf", uu.d); break; |
|
580 |
default: assert(false, "unknown typeChar"); break; |
|
581 |
} |
|
582 |
if (newline) { |
|
583 |
tty->cr(); |
|
584 |
} |
|
585 |
JRT_END |
|
586 |
||
587 |
JRT_ENTRY(jint, JVMCIRuntime::identity_hash_code(JavaThread* thread, oopDesc* obj)) |
|
588 |
return (jint) obj->identity_hash(); |
|
589 |
JRT_END |
|
590 |
||
591 |
JRT_ENTRY(jboolean, JVMCIRuntime::thread_is_interrupted(JavaThread* thread, oopDesc* receiver, jboolean clear_interrupted)) |
|
592 |
// Ensure that the C++ Thread and OSThread structures aren't freed before we operate. |
|
593 |
// This locking requires thread_in_vm which is why this method cannot be JRT_LEAF. |
|
594 |
Handle receiverHandle(thread, receiver); |
|
595 |
MutexLockerEx ml(thread->threadObj() == (void*)receiver ? NULL : Threads_lock); |
|
596 |
JavaThread* receiverThread = java_lang_Thread::thread(receiverHandle()); |
|
597 |
if (receiverThread == NULL) { |
|
598 |
// The other thread may exit during this process, which is ok so return false. |
|
599 |
return JNI_FALSE; |
|
600 |
} else { |
|
601 |
return (jint) Thread::is_interrupted(receiverThread, clear_interrupted != 0); |
|
602 |
} |
|
603 |
JRT_END |
|
604 |
||
605 |
JRT_ENTRY(jint, JVMCIRuntime::test_deoptimize_call_int(JavaThread* thread, int value)) |
|
606 |
deopt_caller(); |
|
607 |
return value; |
|
608 |
JRT_END |
|
609 |
||
610 |
// private static JVMCIRuntime JVMCI.initializeRuntime() |
|
611 |
JVM_ENTRY(jobject, JVM_GetJVMCIRuntime(JNIEnv *env, jclass c)) |
|
612 |
if (!EnableJVMCI) { |
|
613 |
THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVMCI is not enabled") |
|
614 |
} |
|
615 |
JVMCIRuntime::initialize_HotSpotJVMCIRuntime(CHECK_NULL); |
|
616 |
jobject ret = JVMCIRuntime::get_HotSpotJVMCIRuntime_jobject(CHECK_NULL); |
|
617 |
return ret; |
|
618 |
JVM_END |
|
619 |
||
620 |
Handle JVMCIRuntime::callStatic(const char* className, const char* methodName, const char* signature, JavaCallArguments* args, TRAPS) { |
|
621 |
guarantee(!_HotSpotJVMCIRuntime_initialized, "cannot reinitialize HotSpotJVMCIRuntime"); |
|
622 |
||
623 |
TempNewSymbol name = SymbolTable::new_symbol(className, CHECK_(Handle())); |
|
624 |
KlassHandle klass = SystemDictionary::resolve_or_fail(name, true, CHECK_(Handle())); |
|
625 |
TempNewSymbol runtime = SymbolTable::new_symbol(methodName, CHECK_(Handle())); |
|
626 |
TempNewSymbol sig = SymbolTable::new_symbol(signature, CHECK_(Handle())); |
|
627 |
JavaValue result(T_OBJECT); |
|
628 |
if (args == NULL) { |
|
629 |
JavaCalls::call_static(&result, klass, runtime, sig, CHECK_(Handle())); |
|
630 |
} else { |
|
631 |
JavaCalls::call_static(&result, klass, runtime, sig, args, CHECK_(Handle())); |
|
632 |
} |
|
633 |
return Handle((oop)result.get_jobject()); |
|
634 |
} |
|
635 |
||
636 |
void JVMCIRuntime::initialize_HotSpotJVMCIRuntime(TRAPS) { |
|
637 |
if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) { |
|
35835
7fade08f69b2
8149076: [JVMCI] missing ResourceMark in JVMCIRuntime::initialize_HotSpotJVMCIRuntime
never
parents:
35499
diff
changeset
|
638 |
ResourceMark rm; |
33160 | 639 |
#ifdef ASSERT |
640 |
// This should only be called in the context of the JVMCI class being initialized |
|
641 |
TempNewSymbol name = SymbolTable::new_symbol("jdk/vm/ci/runtime/JVMCI", CHECK); |
|
642 |
Klass* k = SystemDictionary::resolve_or_null(name, CHECK); |
|
643 |
instanceKlassHandle klass = InstanceKlass::cast(k); |
|
644 |
assert(klass->is_being_initialized() && klass->is_reentrant_initialization(THREAD), |
|
645 |
"HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization"); |
|
646 |
#endif |
|
647 |
||
648 |
Handle result = callStatic("jdk/vm/ci/hotspot/HotSpotJVMCIRuntime", |
|
649 |
"runtime", |
|
650 |
"()Ljdk/vm/ci/hotspot/HotSpotJVMCIRuntime;", NULL, CHECK); |
|
33632 | 651 |
objArrayOop trivial_prefixes = HotSpotJVMCIRuntime::trivialPrefixes(result); |
652 |
if (trivial_prefixes != NULL) { |
|
653 |
char** prefixes = NEW_C_HEAP_ARRAY(char*, trivial_prefixes->length(), mtCompiler); |
|
654 |
for (int i = 0; i < trivial_prefixes->length(); i++) { |
|
655 |
oop str = trivial_prefixes->obj_at(i); |
|
656 |
if (str == NULL) { |
|
657 |
THROW(vmSymbols::java_lang_NullPointerException()); |
|
658 |
} else { |
|
659 |
prefixes[i] = strdup(java_lang_String::as_utf8_string(str)); |
|
660 |
} |
|
661 |
} |
|
662 |
_trivial_prefixes = prefixes; |
|
663 |
_trivial_prefixes_count = trivial_prefixes->length(); |
|
664 |
} |
|
33160 | 665 |
_HotSpotJVMCIRuntime_initialized = true; |
666 |
_HotSpotJVMCIRuntime_instance = JNIHandles::make_global(result()); |
|
667 |
} |
|
668 |
} |
|
669 |
||
670 |
void JVMCIRuntime::initialize_JVMCI(TRAPS) { |
|
671 |
if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) { |
|
672 |
callStatic("jdk/vm/ci/runtime/JVMCI", |
|
673 |
"getRuntime", |
|
674 |
"()Ljdk/vm/ci/runtime/JVMCIRuntime;", NULL, CHECK); |
|
675 |
} |
|
676 |
assert(_HotSpotJVMCIRuntime_initialized == true, "what?"); |
|
677 |
} |
|
678 |
||
679 |
void JVMCIRuntime::initialize_well_known_classes(TRAPS) { |
|
680 |
if (JVMCIRuntime::_well_known_classes_initialized == false) { |
|
681 |
SystemDictionary::WKID scan = SystemDictionary::FIRST_JVMCI_WKID; |
|
682 |
SystemDictionary::initialize_wk_klasses_through(SystemDictionary::LAST_JVMCI_WKID, scan, CHECK); |
|
34192
6da4892d7cd5
8142511: [JVMCI] must eagerly initialize classes with static fields accessed by JVMCI native code
twisti
parents:
34185
diff
changeset
|
683 |
JVMCIJavaClasses::compute_offsets(CHECK); |
33160 | 684 |
JVMCIRuntime::_well_known_classes_initialized = true; |
685 |
} |
|
686 |
} |
|
687 |
||
688 |
void JVMCIRuntime::metadata_do(void f(Metadata*)) { |
|
689 |
// For simplicity, the existence of HotSpotJVMCIMetaAccessContext in |
|
690 |
// the SystemDictionary well known classes should ensure the other |
|
691 |
// classes have already been loaded, so make sure their order in the |
|
692 |
// table enforces that. |
|
693 |
assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotResolvedJavaMethodImpl) < |
|
694 |
SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier"); |
|
695 |
assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotConstantPool) < |
|
696 |
SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier"); |
|
697 |
assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl) < |
|
698 |
SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier"); |
|
699 |
||
700 |
if (HotSpotJVMCIMetaAccessContext::klass() == NULL || |
|
701 |
!HotSpotJVMCIMetaAccessContext::klass()->is_linked()) { |
|
702 |
// Nothing could be registered yet |
|
703 |
return; |
|
704 |
} |
|
705 |
||
706 |
// WeakReference<HotSpotJVMCIMetaAccessContext>[] |
|
707 |
objArrayOop allContexts = HotSpotJVMCIMetaAccessContext::allContexts(); |
|
708 |
if (allContexts == NULL) { |
|
709 |
return; |
|
710 |
} |
|
711 |
||
712 |
// These must be loaded at this point but the linking state doesn't matter. |
|
713 |
assert(SystemDictionary::HotSpotResolvedJavaMethodImpl_klass() != NULL, "must be loaded"); |
|
714 |
assert(SystemDictionary::HotSpotConstantPool_klass() != NULL, "must be loaded"); |
|
715 |
assert(SystemDictionary::HotSpotResolvedObjectTypeImpl_klass() != NULL, "must be loaded"); |
|
716 |
||
717 |
for (int i = 0; i < allContexts->length(); i++) { |
|
718 |
oop ref = allContexts->obj_at(i); |
|
719 |
if (ref != NULL) { |
|
720 |
oop referent = java_lang_ref_Reference::referent(ref); |
|
721 |
if (referent != NULL) { |
|
722 |
// Chunked Object[] with last element pointing to next chunk |
|
723 |
objArrayOop metadataRoots = HotSpotJVMCIMetaAccessContext::metadataRoots(referent); |
|
724 |
while (metadataRoots != NULL) { |
|
725 |
for (int typeIndex = 0; typeIndex < metadataRoots->length() - 1; typeIndex++) { |
|
726 |
oop reference = metadataRoots->obj_at(typeIndex); |
|
727 |
if (reference == NULL) { |
|
728 |
continue; |
|
729 |
} |
|
730 |
oop metadataRoot = java_lang_ref_Reference::referent(reference); |
|
731 |
if (metadataRoot == NULL) { |
|
732 |
continue; |
|
733 |
} |
|
734 |
if (metadataRoot->is_a(SystemDictionary::HotSpotResolvedJavaMethodImpl_klass())) { |
|
735 |
Method* method = CompilerToVM::asMethod(metadataRoot); |
|
736 |
f(method); |
|
737 |
} else if (metadataRoot->is_a(SystemDictionary::HotSpotConstantPool_klass())) { |
|
738 |
ConstantPool* constantPool = CompilerToVM::asConstantPool(metadataRoot); |
|
739 |
f(constantPool); |
|
740 |
} else if (metadataRoot->is_a(SystemDictionary::HotSpotResolvedObjectTypeImpl_klass())) { |
|
741 |
Klass* klass = CompilerToVM::asKlass(metadataRoot); |
|
742 |
f(klass); |
|
743 |
} else { |
|
744 |
metadataRoot->print(); |
|
745 |
ShouldNotReachHere(); |
|
746 |
} |
|
747 |
} |
|
748 |
metadataRoots = (objArrayOop)metadataRoots->obj_at(metadataRoots->length() - 1); |
|
749 |
assert(metadataRoots == NULL || metadataRoots->is_objArray(), "wrong type"); |
|
750 |
} |
|
751 |
} |
|
752 |
} |
|
753 |
} |
|
754 |
} |
|
755 |
||
756 |
// private static void CompilerToVM.registerNatives() |
|
757 |
JVM_ENTRY(void, JVM_RegisterJVMCINatives(JNIEnv *env, jclass c2vmClass)) |
|
758 |
if (!EnableJVMCI) { |
|
759 |
THROW_MSG(vmSymbols::java_lang_InternalError(), "JVMCI is not enabled"); |
|
760 |
} |
|
761 |
||
762 |
#ifdef _LP64 |
|
33178
f77a432b90f6
8139545: JVMCI : guarantee(heap_end < allocation_end) failed on some sparcv9 hosts
twisti
parents:
33160
diff
changeset
|
763 |
#ifndef TARGET_ARCH_sparc |
33160 | 764 |
uintptr_t heap_end = (uintptr_t) Universe::heap()->reserved_region().end(); |
765 |
uintptr_t allocation_end = heap_end + ((uintptr_t)16) * 1024 * 1024 * 1024; |
|
766 |
guarantee(heap_end < allocation_end, "heap end too close to end of address space (might lead to erroneous TLAB allocations)"); |
|
33178
f77a432b90f6
8139545: JVMCI : guarantee(heap_end < allocation_end) failed on some sparcv9 hosts
twisti
parents:
33160
diff
changeset
|
767 |
#endif // TARGET_ARCH_sparc |
33160 | 768 |
#else |
769 |
fatal("check TLAB allocation code for address space conflicts"); |
|
770 |
#endif |
|
771 |
||
772 |
JVMCIRuntime::initialize_well_known_classes(CHECK); |
|
773 |
||
774 |
{ |
|
775 |
ThreadToNativeFromVM trans(thread); |
|
776 |
env->RegisterNatives(c2vmClass, CompilerToVM::methods, CompilerToVM::methods_count()); |
|
777 |
} |
|
778 |
JVM_END |
|
779 |
||
780 |
#define CHECK_WARN_ABORT_(message) THREAD); \ |
|
781 |
if (HAS_PENDING_EXCEPTION) { \ |
|
782 |
warning(message); \ |
|
783 |
char buf[512]; \ |
|
784 |
jio_snprintf(buf, 512, "Uncaught exception at %s:%d", __FILE__, __LINE__); \ |
|
785 |
JVMCIRuntime::abort_on_pending_exception(PENDING_EXCEPTION, buf); \ |
|
786 |
return; \ |
|
787 |
} \ |
|
788 |
(void)(0 |
|
789 |
||
35143
33daaea9d5c2
8145435: [JVMCI] some tests on Windows fail with: assert(!thread->is_Java_thread()) failed: must not be java thread
twisti
parents:
35135
diff
changeset
|
790 |
void JVMCIRuntime::shutdown(TRAPS) { |
33160 | 791 |
if (_HotSpotJVMCIRuntime_instance != NULL) { |
792 |
_shutdown_called = true; |
|
793 |
HandleMark hm(THREAD); |
|
35143
33daaea9d5c2
8145435: [JVMCI] some tests on Windows fail with: assert(!thread->is_Java_thread()) failed: must not be java thread
twisti
parents:
35135
diff
changeset
|
794 |
Handle receiver = get_HotSpotJVMCIRuntime(CHECK); |
33160 | 795 |
JavaValue result(T_VOID); |
796 |
JavaCallArguments args; |
|
797 |
args.push_oop(receiver); |
|
35143
33daaea9d5c2
8145435: [JVMCI] some tests on Windows fail with: assert(!thread->is_Java_thread()) failed: must not be java thread
twisti
parents:
35135
diff
changeset
|
798 |
JavaCalls::call_special(&result, receiver->klass(), vmSymbols::shutdown_method_name(), vmSymbols::void_method_signature(), &args, CHECK); |
33160 | 799 |
} |
800 |
} |
|
801 |
||
33632 | 802 |
bool JVMCIRuntime::treat_as_trivial(Method* method) { |
803 |
if (_HotSpotJVMCIRuntime_initialized) { |
|
36805
626399e1ebf2
8151723: [JVMCI] JVMCIRuntime::treat_as_trivial: Don't limit trivial prefixes to boot class path
twisti
parents:
36603
diff
changeset
|
804 |
for (int i = 0; i < _trivial_prefixes_count; i++) { |
626399e1ebf2
8151723: [JVMCI] JVMCIRuntime::treat_as_trivial: Don't limit trivial prefixes to boot class path
twisti
parents:
36603
diff
changeset
|
805 |
if (method->method_holder()->name()->starts_with(_trivial_prefixes[i])) { |
626399e1ebf2
8151723: [JVMCI] JVMCIRuntime::treat_as_trivial: Don't limit trivial prefixes to boot class path
twisti
parents:
36603
diff
changeset
|
806 |
return true; |
33632 | 807 |
} |
808 |
} |
|
809 |
} |
|
810 |
return false; |
|
811 |
} |