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