1 /*
2 * Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "classfile/vmClasses.hpp"
26 #include "classfile/vmSymbols.hpp"
27 #include "code/codeCache.hpp"
28 #include "code/compiledIC.hpp"
29 #include "code/nmethod.hpp"
30 #include "code/pcDesc.hpp"
31 #include "code/scopeDesc.hpp"
32 #include "code/vtableStubs.hpp"
33 #include "compiler/compilationMemoryStatistic.hpp"
34 #include "compiler/compileBroker.hpp"
35 #include "compiler/compilerDefinitions.inline.hpp"
36 #include "compiler/oopMap.hpp"
37 #include "gc/g1/g1HeapRegion.hpp"
38 #include "gc/shared/barrierSet.hpp"
39 #include "gc/shared/collectedHeap.hpp"
40 #include "gc/shared/gcLocker.hpp"
41 #include "interpreter/bytecode.hpp"
42 #include "interpreter/interpreter.hpp"
43 #include "interpreter/linkResolver.hpp"
44 #include "logging/log.hpp"
45 #include "logging/logStream.hpp"
46 #include "memory/oopFactory.hpp"
47 #include "memory/resourceArea.hpp"
48 #include "oops/klass.inline.hpp"
49 #include "oops/objArrayKlass.hpp"
50 #include "oops/oop.inline.hpp"
51 #include "oops/typeArrayOop.inline.hpp"
52 #include "opto/ad.hpp"
53 #include "opto/addnode.hpp"
54 #include "opto/callnode.hpp"
55 #include "opto/cfgnode.hpp"
56 #include "opto/graphKit.hpp"
57 #include "opto/machnode.hpp"
58 #include "opto/matcher.hpp"
59 #include "opto/memnode.hpp"
60 #include "opto/mulnode.hpp"
61 #include "opto/output.hpp"
62 #include "opto/runtime.hpp"
63 #include "opto/subnode.hpp"
64 #include "prims/jvmtiExport.hpp"
65 #include "runtime/atomicAccess.hpp"
66 #include "runtime/frame.inline.hpp"
67 #include "runtime/handles.inline.hpp"
68 #include "runtime/interfaceSupport.inline.hpp"
69 #include "runtime/java.hpp"
70 #include "runtime/javaCalls.hpp"
71 #include "runtime/perfData.inline.hpp"
72 #include "runtime/sharedRuntime.hpp"
73 #include "runtime/signature.hpp"
74 #include "runtime/stackWatermarkSet.hpp"
75 #include "runtime/synchronizer.hpp"
76 #include "runtime/threadWXSetters.inline.hpp"
77 #include "runtime/vframe.hpp"
78 #include "runtime/vframe_hp.hpp"
79 #include "runtime/vframeArray.hpp"
80 #include "services/management.hpp"
81 #include "utilities/copy.hpp"
82 #include "utilities/preserveException.hpp"
83
84
85 // For debugging purposes:
86 // To force FullGCALot inside a runtime function, add the following two lines
87 //
88 // Universe::release_fullgc_alot_dummy();
89 // Universe::heap()->collect();
90 //
91 // At command line specify the parameters: -XX:+FullGCALot -XX:FullGCALotStart=100000000
92
93
94 #define C2_BLOB_FIELD_DEFINE(name, type) \
95 type* OptoRuntime:: BLOB_FIELD_NAME(name) = nullptr;
96 #define C2_STUB_FIELD_NAME(name) _ ## name ## _Java
97 #define C2_STUB_FIELD_DEFINE(name, f, t, r) \
98 address OptoRuntime:: C2_STUB_FIELD_NAME(name) = nullptr;
99 #define C2_JVMTI_STUB_FIELD_DEFINE(name) \
100 address OptoRuntime:: STUB_FIELD_NAME(name) = nullptr;
101 C2_STUBS_DO(C2_BLOB_FIELD_DEFINE, C2_STUB_FIELD_DEFINE, C2_JVMTI_STUB_FIELD_DEFINE)
102 #undef C2_BLOB_FIELD_DEFINE
103 #undef C2_STUB_FIELD_DEFINE
104 #undef C2_JVMTI_STUB_FIELD_DEFINE
105
106 address OptoRuntime::_vtable_must_compile_Java = nullptr;
107
108 PerfCounter* _perf_OptoRuntime_class_init_barrier_redundant_count = nullptr;
109
110 // This should be called in an assertion at the start of OptoRuntime routines
111 // which are entered from compiled code (all of them)
112 #ifdef ASSERT
113 static bool check_compiled_frame(JavaThread* thread) {
114 assert(thread->last_frame().is_runtime_frame(), "cannot call runtime directly from compiled code");
115 RegisterMap map(thread,
116 RegisterMap::UpdateMap::skip,
117 RegisterMap::ProcessFrames::include,
118 RegisterMap::WalkContinuation::skip);
119 frame caller = thread->last_frame().sender(&map);
120 assert(caller.is_compiled_frame(), "not being called from compiled like code");
121 return true;
122 }
123 #endif // ASSERT
124
125 /*
126 #define gen(env, var, type_func_gen, c_func, fancy_jump, pass_tls, return_pc) \
127 var = generate_stub(env, type_func_gen, CAST_FROM_FN_PTR(address, c_func), #var, fancy_jump, pass_tls, return_pc); \
128 if (var == nullptr) { return false; }
129 */
130
131 #define GEN_C2_BLOB(name, type) \
132 BLOB_FIELD_NAME(name) = \
133 generate_ ## name ## _blob(); \
134 if (BLOB_FIELD_NAME(name) == nullptr) { return false; }
135
136 // a few helper macros to conjure up generate_stub call arguments
137 #define C2_STUB_FIELD_NAME(name) _ ## name ## _Java
138 #define C2_STUB_TYPEFUNC(name) name ## _Type
139 #define C2_STUB_C_FUNC(name) CAST_FROM_FN_PTR(address, name ## _C)
140 #define C2_STUB_ID(name) StubId:: JOIN3(c2, name, id)
141 #define C2_STUB_NAME(name) stub_name(C2_STUB_ID(name))
142
143 // Almost all the C functions targeted from the generated stubs are
144 // implemented locally to OptoRuntime with names that can be generated
145 // from the stub name by appending suffix '_C'. However, in two cases
146 // a common target method also needs to be called from shared runtime
147 // stubs. In these two cases the opto stubs rely on method
148 // imlementations defined in class SharedRuntime. The following
149 // defines temporarily rebind the generated names to reference the
150 // relevant implementations.
151
152 #define GEN_C2_STUB(name, fancy_jump, pass_tls, pass_retpc ) \
153 C2_STUB_FIELD_NAME(name) = \
154 generate_stub(env, \
155 C2_STUB_TYPEFUNC(name), \
156 C2_STUB_C_FUNC(name), \
157 C2_STUB_NAME(name), \
158 C2_STUB_ID(name), \
159 fancy_jump, \
160 pass_tls, \
161 pass_retpc); \
162 if (C2_STUB_FIELD_NAME(name) == nullptr) { return false; } \
163
164 #define C2_JVMTI_STUB_C_FUNC(name) CAST_FROM_FN_PTR(address, SharedRuntime::name)
165
166 #define GEN_C2_JVMTI_STUB(name) \
167 STUB_FIELD_NAME(name) = \
168 generate_stub(env, \
169 notify_jvmti_vthread_Type, \
170 C2_JVMTI_STUB_C_FUNC(name), \
171 C2_STUB_NAME(name), \
172 C2_STUB_ID(name), \
173 0, \
174 true, \
175 false); \
176 if (STUB_FIELD_NAME(name) == nullptr) { return false; } \
177
178 bool OptoRuntime::generate(ciEnv* env) {
179 init_counters();
180
181 C2_STUBS_DO(GEN_C2_BLOB, GEN_C2_STUB, GEN_C2_JVMTI_STUB)
182
183 return true;
184 }
185
186 #undef GEN_C2_BLOB
187
188 #undef C2_STUB_FIELD_NAME
189 #undef C2_STUB_TYPEFUNC
190 #undef C2_STUB_C_FUNC
191 #undef C2_STUB_NAME
192 #undef GEN_C2_STUB
193
194 #undef C2_JVMTI_STUB_C_FUNC
195 #undef GEN_C2_JVMTI_STUB
196 // #undef gen
197
198 const TypeFunc* OptoRuntime::_new_instance_Type = nullptr;
199 const TypeFunc* OptoRuntime::_new_array_Type = nullptr;
200 const TypeFunc* OptoRuntime::_multianewarray2_Type = nullptr;
201 const TypeFunc* OptoRuntime::_multianewarray3_Type = nullptr;
202 const TypeFunc* OptoRuntime::_multianewarray4_Type = nullptr;
203 const TypeFunc* OptoRuntime::_multianewarray5_Type = nullptr;
204 const TypeFunc* OptoRuntime::_multianewarrayN_Type = nullptr;
205 const TypeFunc* OptoRuntime::_complete_monitor_enter_Type = nullptr;
206 const TypeFunc* OptoRuntime::_complete_monitor_exit_Type = nullptr;
207 const TypeFunc* OptoRuntime::_monitor_notify_Type = nullptr;
208 const TypeFunc* OptoRuntime::_uncommon_trap_Type = nullptr;
209 const TypeFunc* OptoRuntime::_athrow_Type = nullptr;
210 const TypeFunc* OptoRuntime::_rethrow_Type = nullptr;
211 const TypeFunc* OptoRuntime::_Math_D_D_Type = nullptr;
212 const TypeFunc* OptoRuntime::_Math_DD_D_Type = nullptr;
213 const TypeFunc* OptoRuntime::_modf_Type = nullptr;
214 const TypeFunc* OptoRuntime::_l2f_Type = nullptr;
215 const TypeFunc* OptoRuntime::_void_long_Type = nullptr;
216 const TypeFunc* OptoRuntime::_void_void_Type = nullptr;
217 const TypeFunc* OptoRuntime::_jfr_write_checkpoint_Type = nullptr;
218 const TypeFunc* OptoRuntime::_flush_windows_Type = nullptr;
219 const TypeFunc* OptoRuntime::_fast_arraycopy_Type = nullptr;
220 const TypeFunc* OptoRuntime::_checkcast_arraycopy_Type = nullptr;
221 const TypeFunc* OptoRuntime::_generic_arraycopy_Type = nullptr;
222 const TypeFunc* OptoRuntime::_slow_arraycopy_Type = nullptr;
223 const TypeFunc* OptoRuntime::_unsafe_setmemory_Type = nullptr;
224 const TypeFunc* OptoRuntime::_array_fill_Type = nullptr;
225 const TypeFunc* OptoRuntime::_array_sort_Type = nullptr;
226 const TypeFunc* OptoRuntime::_array_partition_Type = nullptr;
227 const TypeFunc* OptoRuntime::_aescrypt_block_Type = nullptr;
228 const TypeFunc* OptoRuntime::_cipherBlockChaining_aescrypt_Type = nullptr;
229 const TypeFunc* OptoRuntime::_electronicCodeBook_aescrypt_Type = nullptr;
230 const TypeFunc* OptoRuntime::_counterMode_aescrypt_Type = nullptr;
231 const TypeFunc* OptoRuntime::_galoisCounterMode_aescrypt_Type = nullptr;
232 const TypeFunc* OptoRuntime::_digestBase_implCompress_with_sha3_Type = nullptr;
233 const TypeFunc* OptoRuntime::_digestBase_implCompress_without_sha3_Type = nullptr;
234 const TypeFunc* OptoRuntime::_digestBase_implCompressMB_with_sha3_Type = nullptr;
235 const TypeFunc* OptoRuntime::_digestBase_implCompressMB_without_sha3_Type = nullptr;
236 const TypeFunc* OptoRuntime::_double_keccak_Type = nullptr;
237 const TypeFunc* OptoRuntime::_multiplyToLen_Type = nullptr;
238 const TypeFunc* OptoRuntime::_montgomeryMultiply_Type = nullptr;
239 const TypeFunc* OptoRuntime::_montgomerySquare_Type = nullptr;
240 const TypeFunc* OptoRuntime::_squareToLen_Type = nullptr;
241 const TypeFunc* OptoRuntime::_mulAdd_Type = nullptr;
242 const TypeFunc* OptoRuntime::_bigIntegerShift_Type = nullptr;
243 const TypeFunc* OptoRuntime::_vectorizedMismatch_Type = nullptr;
244 const TypeFunc* OptoRuntime::_ghash_processBlocks_Type = nullptr;
245 const TypeFunc* OptoRuntime::_chacha20Block_Type = nullptr;
246 const TypeFunc* OptoRuntime::_kyberNtt_Type = nullptr;
247 const TypeFunc* OptoRuntime::_kyberInverseNtt_Type = nullptr;
248 const TypeFunc* OptoRuntime::_kyberNttMult_Type = nullptr;
249 const TypeFunc* OptoRuntime::_kyberAddPoly_2_Type = nullptr;
250 const TypeFunc* OptoRuntime::_kyberAddPoly_3_Type = nullptr;
251 const TypeFunc* OptoRuntime::_kyber12To16_Type = nullptr;
252 const TypeFunc* OptoRuntime::_kyberBarrettReduce_Type = nullptr;
253 const TypeFunc* OptoRuntime::_dilithiumAlmostNtt_Type = nullptr;
254 const TypeFunc* OptoRuntime::_dilithiumAlmostInverseNtt_Type = nullptr;
255 const TypeFunc* OptoRuntime::_dilithiumNttMult_Type = nullptr;
256 const TypeFunc* OptoRuntime::_dilithiumMontMulByConstant_Type = nullptr;
257 const TypeFunc* OptoRuntime::_dilithiumDecomposePoly_Type = nullptr;
258 const TypeFunc* OptoRuntime::_base64_encodeBlock_Type = nullptr;
259 const TypeFunc* OptoRuntime::_base64_decodeBlock_Type = nullptr;
260 const TypeFunc* OptoRuntime::_string_IndexOf_Type = nullptr;
261 const TypeFunc* OptoRuntime::_poly1305_processBlocks_Type = nullptr;
262 const TypeFunc* OptoRuntime::_intpoly_montgomeryMult_P256_Type = nullptr;
263 const TypeFunc* OptoRuntime::_intpoly_assign_Type = nullptr;
264 const TypeFunc* OptoRuntime::_updateBytesCRC32_Type = nullptr;
265 const TypeFunc* OptoRuntime::_updateBytesCRC32C_Type = nullptr;
266 const TypeFunc* OptoRuntime::_updateBytesAdler32_Type = nullptr;
267 const TypeFunc* OptoRuntime::_osr_end_Type = nullptr;
268 const TypeFunc* OptoRuntime::_register_finalizer_Type = nullptr;
269 #if INCLUDE_JFR
270 const TypeFunc* OptoRuntime::_class_id_load_barrier_Type = nullptr;
271 #endif // INCLUDE_JFR
272 #if INCLUDE_JVMTI
273 const TypeFunc* OptoRuntime::_notify_jvmti_vthread_Type = nullptr;
274 #endif // INCLUDE_JVMTI
275 const TypeFunc* OptoRuntime::_dtrace_method_entry_exit_Type = nullptr;
276 const TypeFunc* OptoRuntime::_dtrace_object_alloc_Type = nullptr;
277
278 // Helper method to do generation of RunTimeStub's
279 address OptoRuntime::generate_stub(ciEnv* env,
280 TypeFunc_generator gen, address C_function,
281 const char *name, StubId stub_id,
282 int is_fancy_jump, bool pass_tls,
283 bool return_pc) {
284
285 // Matching the default directive, we currently have no method to match.
286 DirectiveSet* directive = DirectivesStack::getDefaultDirective(CompilerThread::current()->compiler());
287 CompilationMemoryStatisticMark cmsm(directive);
288 ResourceMark rm;
289 Compile C(env, gen, C_function, name, stub_id, is_fancy_jump, pass_tls, return_pc, directive);
290 DirectivesStack::release(directive);
291 return C.stub_entry_point();
292 }
293
294 const char* OptoRuntime::stub_name(address entry) {
295 #ifndef PRODUCT
296 CodeBlob* cb = CodeCache::find_blob(entry);
297 RuntimeStub* rs =(RuntimeStub *)cb;
298 assert(rs != nullptr && rs->is_runtime_stub(), "not a runtime stub");
299 return rs->name();
300 #else
301 // Fast implementation for product mode (maybe it should be inlined too)
302 return "runtime stub";
303 #endif
304 }
305
306 // local methods passed as arguments to stub generator that forward
307 // control to corresponding JRT methods of SharedRuntime
308
309 void OptoRuntime::slow_arraycopy_C(oopDesc* src, jint src_pos,
310 oopDesc* dest, jint dest_pos,
311 jint length, JavaThread* thread) {
312 SharedRuntime::slow_arraycopy_C(src, src_pos, dest, dest_pos, length, thread);
313 }
314
315 void OptoRuntime::complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* current) {
316 SharedRuntime::complete_monitor_locking_C(obj, lock, current);
317 }
318
319
320 //=============================================================================
321 // Opto compiler runtime routines
322 //=============================================================================
323
324
325 //=============================allocation======================================
326 // We failed the fast-path allocation. Now we need to do a scavenge or GC
327 // and try allocation again.
328
329 // object allocation
330 JRT_BLOCK_ENTRY_PROF(void, OptoRuntime, new_instance_C, OptoRuntime::new_instance_C(Klass* klass, JavaThread* current))
331 JRT_BLOCK;
332 #ifndef PRODUCT
333 SharedRuntime::_new_instance_ctr++; // new instance requires GC
334 #endif
335 assert(check_compiled_frame(current), "incorrect caller");
336
337 // These checks are cheap to make and support reflective allocation.
338 int lh = klass->layout_helper();
339 if (Klass::layout_helper_needs_slow_path(lh) || !InstanceKlass::cast(klass)->is_initialized()) {
340 Handle holder(current, klass->klass_holder()); // keep the klass alive
341 klass->check_valid_for_instantiation(false, THREAD);
342 if (!HAS_PENDING_EXCEPTION) {
343 InstanceKlass::cast(klass)->initialize(THREAD);
344 }
345 }
346
347 if (!HAS_PENDING_EXCEPTION) {
348 // Scavenge and allocate an instance.
349 Handle holder(current, klass->klass_holder()); // keep the klass alive
350 oop result = InstanceKlass::cast(klass)->allocate_instance(THREAD);
351 current->set_vm_result_oop(result);
352
353 // Pass oops back through thread local storage. Our apparent type to Java
354 // is that we return an oop, but we can block on exit from this routine and
355 // a GC can trash the oop in C's return register. The generated stub will
356 // fetch the oop from TLS after any possible GC.
357 }
358
359 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
360 JRT_BLOCK_END;
361
362 // inform GC that we won't do card marks for initializing writes.
363 SharedRuntime::on_slowpath_allocation_exit(current);
364 JRT_END
365
366
367 // array allocation
368 JRT_BLOCK_ENTRY_PROF(void, OptoRuntime, new_array_C, OptoRuntime::new_array_C(Klass* array_type, int len, JavaThread* current))
369 JRT_BLOCK;
370 #ifndef PRODUCT
371 SharedRuntime::_new_array_ctr++; // new array requires GC
372 #endif
373 assert(check_compiled_frame(current), "incorrect caller");
374
375 // Scavenge and allocate an instance.
376 oop result;
377
378 if (array_type->is_typeArray_klass()) {
379 // The oopFactory likes to work with the element type.
380 // (We could bypass the oopFactory, since it doesn't add much value.)
381 BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
382 result = oopFactory::new_typeArray(elem_type, len, THREAD);
383 } else {
384 // Although the oopFactory likes to work with the elem_type,
385 // the compiler prefers the array_type, since it must already have
386 // that latter value in hand for the fast path.
387 Handle holder(current, array_type->klass_holder()); // keep the array klass alive
388 Klass* elem_type = ObjArrayKlass::cast(array_type)->element_klass();
389 result = oopFactory::new_objArray(elem_type, len, THREAD);
390 }
391
392 // Pass oops back through thread local storage. Our apparent type to Java
393 // is that we return an oop, but we can block on exit from this routine and
394 // a GC can trash the oop in C's return register. The generated stub will
395 // fetch the oop from TLS after any possible GC.
396 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
397 current->set_vm_result_oop(result);
398 JRT_BLOCK_END;
399
400 // inform GC that we won't do card marks for initializing writes.
401 SharedRuntime::on_slowpath_allocation_exit(current);
402 JRT_END
403
404 // array allocation without zeroing
405 JRT_BLOCK_ENTRY_PROF(void, OptoRuntime, new_array_nozero_C, OptoRuntime::new_array_nozero_C(Klass* array_type, int len, JavaThread* current))
406 JRT_BLOCK;
407 #ifndef PRODUCT
408 SharedRuntime::_new_array_ctr++; // new array requires GC
409 #endif
410 assert(check_compiled_frame(current), "incorrect caller");
411
412 // Scavenge and allocate an instance.
413 oop result;
414
415 assert(array_type->is_typeArray_klass(), "should be called only for type array");
416 // The oopFactory likes to work with the element type.
417 BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
418 result = oopFactory::new_typeArray_nozero(elem_type, len, THREAD);
419
420 // Pass oops back through thread local storage. Our apparent type to Java
421 // is that we return an oop, but we can block on exit from this routine and
422 // a GC can trash the oop in C's return register. The generated stub will
423 // fetch the oop from TLS after any possible GC.
424 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
425 current->set_vm_result_oop(result);
426 JRT_BLOCK_END;
427
428
429 // inform GC that we won't do card marks for initializing writes.
430 SharedRuntime::on_slowpath_allocation_exit(current);
431
432 oop result = current->vm_result_oop();
433 if ((len > 0) && (result != nullptr) &&
434 is_deoptimized_caller_frame(current)) {
435 // Zero array here if the caller is deoptimized.
436 const size_t size = TypeArrayKlass::cast(array_type)->oop_size(result);
437 BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
438 size_t hs_bytes = arrayOopDesc::base_offset_in_bytes(elem_type);
439 assert(is_aligned(hs_bytes, BytesPerInt), "must be 4 byte aligned");
440 HeapWord* obj = cast_from_oop<HeapWord*>(result);
441 if (!is_aligned(hs_bytes, BytesPerLong)) {
442 *reinterpret_cast<jint*>(reinterpret_cast<char*>(obj) + hs_bytes) = 0;
443 hs_bytes += BytesPerInt;
444 }
445
446 // Optimized zeroing.
447 assert(is_aligned(hs_bytes, BytesPerLong), "must be 8-byte aligned");
448 const size_t aligned_hs = hs_bytes / BytesPerLong;
449 Copy::fill_to_aligned_words(obj+aligned_hs, size-aligned_hs);
450 }
451
452 JRT_END
453
454 // Note: multianewarray for one dimension is handled inline by GraphKit::new_array.
455
456 // multianewarray for 2 dimensions
457 JRT_ENTRY_PROF(void, OptoRuntime, multianewarray2_C, OptoRuntime::multianewarray2_C(Klass* elem_type, int len1, int len2, JavaThread* current))
458 #ifndef PRODUCT
459 SharedRuntime::_multi2_ctr++; // multianewarray for 1 dimension
460 #endif
461 assert(check_compiled_frame(current), "incorrect caller");
462 assert(elem_type->is_klass(), "not a class");
463 jint dims[2];
464 dims[0] = len1;
465 dims[1] = len2;
466 Handle holder(current, elem_type->klass_holder()); // keep the klass alive
467 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(2, dims, THREAD);
468 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
469 current->set_vm_result_oop(obj);
470 JRT_END
471
472 // multianewarray for 3 dimensions
473 JRT_ENTRY_PROF(void, OptoRuntime, multianewarray3_C, OptoRuntime::multianewarray3_C(Klass* elem_type, int len1, int len2, int len3, JavaThread* current))
474 #ifndef PRODUCT
475 SharedRuntime::_multi3_ctr++; // multianewarray for 1 dimension
476 #endif
477 assert(check_compiled_frame(current), "incorrect caller");
478 assert(elem_type->is_klass(), "not a class");
479 jint dims[3];
480 dims[0] = len1;
481 dims[1] = len2;
482 dims[2] = len3;
483 Handle holder(current, elem_type->klass_holder()); // keep the klass alive
484 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(3, dims, THREAD);
485 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
486 current->set_vm_result_oop(obj);
487 JRT_END
488
489 // multianewarray for 4 dimensions
490 JRT_ENTRY_PROF(void, OptoRuntime, multianewarray4_C, OptoRuntime::multianewarray4_C(Klass* elem_type, int len1, int len2, int len3, int len4, JavaThread* current))
491 #ifndef PRODUCT
492 SharedRuntime::_multi4_ctr++; // multianewarray for 1 dimension
493 #endif
494 assert(check_compiled_frame(current), "incorrect caller");
495 assert(elem_type->is_klass(), "not a class");
496 jint dims[4];
497 dims[0] = len1;
498 dims[1] = len2;
499 dims[2] = len3;
500 dims[3] = len4;
501 Handle holder(current, elem_type->klass_holder()); // keep the klass alive
502 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(4, dims, THREAD);
503 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
504 current->set_vm_result_oop(obj);
505 JRT_END
506
507 // multianewarray for 5 dimensions
508 JRT_ENTRY(void, OptoRuntime::multianewarray5_C(Klass* elem_type, int len1, int len2, int len3, int len4, int len5, JavaThread* current))
509 #ifndef PRODUCT
510 SharedRuntime::_multi5_ctr++; // multianewarray for 1 dimension
511 #endif
512 assert(check_compiled_frame(current), "incorrect caller");
513 assert(elem_type->is_klass(), "not a class");
514 jint dims[5];
515 dims[0] = len1;
516 dims[1] = len2;
517 dims[2] = len3;
518 dims[3] = len4;
519 dims[4] = len5;
520 Handle holder(current, elem_type->klass_holder()); // keep the klass alive
521 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(5, dims, THREAD);
522 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
523 current->set_vm_result_oop(obj);
524 JRT_END
525
526 JRT_ENTRY_PROF(void, OptoRuntime, multianewarrayN_C, OptoRuntime::multianewarrayN_C(Klass* elem_type, arrayOopDesc* dims, JavaThread* current))
527 assert(check_compiled_frame(current), "incorrect caller");
528 assert(elem_type->is_klass(), "not a class");
529 assert(oop(dims)->is_typeArray(), "not an array");
530
531 ResourceMark rm;
532 jint len = dims->length();
533 assert(len > 0, "Dimensions array should contain data");
534 jint *c_dims = NEW_RESOURCE_ARRAY(jint, len);
535 ArrayAccess<>::arraycopy_to_native<>(dims, typeArrayOopDesc::element_offset<jint>(0),
536 c_dims, len);
537
538 Handle holder(current, elem_type->klass_holder()); // keep the klass alive
539 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(len, c_dims, THREAD);
540 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
541 current->set_vm_result_oop(obj);
542 JRT_END
543
544 JRT_BLOCK_ENTRY_PROF(void, OptoRuntime, monitor_notify_C, OptoRuntime::monitor_notify_C(oopDesc* obj, JavaThread* current))
545
546 // Very few notify/notifyAll operations find any threads on the waitset, so
547 // the dominant fast-path is to simply return.
548 // Relatedly, it's critical that notify/notifyAll be fast in order to
549 // reduce lock hold times.
550 if (!SafepointSynchronize::is_synchronizing()) {
551 if (ObjectSynchronizer::quick_notify(obj, current, false)) {
552 return;
553 }
554 }
555
556 // This is the case the fast-path above isn't provisioned to handle.
557 // The fast-path is designed to handle frequently arising cases in an efficient manner.
558 // (The fast-path is just a degenerate variant of the slow-path).
559 // Perform the dreaded state transition and pass control into the slow-path.
560 JRT_BLOCK;
561 Handle h_obj(current, obj);
562 ObjectSynchronizer::notify(h_obj, CHECK);
563 JRT_BLOCK_END;
564 JRT_END
565
566 JRT_BLOCK_ENTRY_PROF(void, OptoRuntime, monitor_notifyAll_C, OptoRuntime::monitor_notifyAll_C(oopDesc* obj, JavaThread* current))
567
568 if (!SafepointSynchronize::is_synchronizing() ) {
569 if (ObjectSynchronizer::quick_notify(obj, current, true)) {
570 return;
571 }
572 }
573
574 // This is the case the fast-path above isn't provisioned to handle.
575 // The fast-path is designed to handle frequently arising cases in an efficient manner.
576 // (The fast-path is just a degenerate variant of the slow-path).
577 // Perform the dreaded state transition and pass control into the slow-path.
578 JRT_BLOCK;
579 Handle h_obj(current, obj);
580 ObjectSynchronizer::notifyall(h_obj, CHECK);
581 JRT_BLOCK_END;
582 JRT_END
583
584 static const TypeFunc* make_new_instance_Type() {
585 // create input type (domain)
586 const Type **fields = TypeTuple::fields(1);
587 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated
588 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
589
590 // create result type (range)
591 fields = TypeTuple::fields(1);
592 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
593
594 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
595
596 return TypeFunc::make(domain, range);
597 }
598
599 #if INCLUDE_JVMTI
600 static const TypeFunc* make_notify_jvmti_vthread_Type() {
601 // create input type (domain)
602 const Type **fields = TypeTuple::fields(2);
603 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // VirtualThread oop
604 fields[TypeFunc::Parms+1] = TypeInt::BOOL; // jboolean
605 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
606
607 // no result type needed
608 fields = TypeTuple::fields(1);
609 fields[TypeFunc::Parms+0] = nullptr; // void
610 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
611
612 return TypeFunc::make(domain,range);
613 }
614 #endif
615
616 static const TypeFunc* make_athrow_Type() {
617 // create input type (domain)
618 const Type **fields = TypeTuple::fields(1);
619 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated
620 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
621
622 // create result type (range)
623 fields = TypeTuple::fields(0);
624
625 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
626
627 return TypeFunc::make(domain, range);
628 }
629
630 static const TypeFunc* make_new_array_Type() {
631 // create input type (domain)
632 const Type **fields = TypeTuple::fields(2);
633 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass
634 fields[TypeFunc::Parms+1] = TypeInt::INT; // array size
635 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
636
637 // create result type (range)
638 fields = TypeTuple::fields(1);
639 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
640
641 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
642
643 return TypeFunc::make(domain, range);
644 }
645
646 const TypeFunc* OptoRuntime::multianewarray_Type(int ndim) {
647 // create input type (domain)
648 const int nargs = ndim + 1;
649 const Type **fields = TypeTuple::fields(nargs);
650 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass
651 for( int i = 1; i < nargs; i++ )
652 fields[TypeFunc::Parms + i] = TypeInt::INT; // array size
653 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+nargs, fields);
654
655 // create result type (range)
656 fields = TypeTuple::fields(1);
657 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
658 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
659
660 return TypeFunc::make(domain, range);
661 }
662
663 static const TypeFunc* make_multianewarrayN_Type() {
664 // create input type (domain)
665 const Type **fields = TypeTuple::fields(2);
666 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass
667 fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL; // array of dim sizes
668 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
669
670 // create result type (range)
671 fields = TypeTuple::fields(1);
672 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
673 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
674
675 return TypeFunc::make(domain, range);
676 }
677
678 static const TypeFunc* make_uncommon_trap_Type() {
679 // create input type (domain)
680 const Type **fields = TypeTuple::fields(1);
681 fields[TypeFunc::Parms+0] = TypeInt::INT; // trap_reason (deopt reason and action)
682 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
683
684 // create result type (range)
685 fields = TypeTuple::fields(0);
686 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
687
688 return TypeFunc::make(domain, range);
689 }
690
691 //-----------------------------------------------------------------------------
692 // Monitor Handling
693
694 static const TypeFunc* make_complete_monitor_enter_Type() {
695 // create input type (domain)
696 const Type **fields = TypeTuple::fields(2);
697 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked
698 fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock
699 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
700
701 // create result type (range)
702 fields = TypeTuple::fields(0);
703
704 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
705
706 return TypeFunc::make(domain,range);
707 }
708
709 //-----------------------------------------------------------------------------
710
711 static const TypeFunc* make_complete_monitor_exit_Type() {
712 // create input type (domain)
713 const Type **fields = TypeTuple::fields(3);
714 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked
715 fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock - BasicLock
716 fields[TypeFunc::Parms+2] = TypeRawPtr::BOTTOM; // Thread pointer (Self)
717 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+3, fields);
718
719 // create result type (range)
720 fields = TypeTuple::fields(0);
721
722 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
723
724 return TypeFunc::make(domain, range);
725 }
726
727 static const TypeFunc* make_monitor_notify_Type() {
728 // create input type (domain)
729 const Type **fields = TypeTuple::fields(1);
730 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked
731 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
732
733 // create result type (range)
734 fields = TypeTuple::fields(0);
735 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
736 return TypeFunc::make(domain, range);
737 }
738
739 static const TypeFunc* make_flush_windows_Type() {
740 // create input type (domain)
741 const Type** fields = TypeTuple::fields(1);
742 fields[TypeFunc::Parms+0] = nullptr; // void
743 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms, fields);
744
745 // create result type
746 fields = TypeTuple::fields(1);
747 fields[TypeFunc::Parms+0] = nullptr; // void
748 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
749
750 return TypeFunc::make(domain, range);
751 }
752
753 static const TypeFunc* make_l2f_Type() {
754 // create input type (domain)
755 const Type **fields = TypeTuple::fields(2);
756 fields[TypeFunc::Parms+0] = TypeLong::LONG;
757 fields[TypeFunc::Parms+1] = Type::HALF;
758 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
759
760 // create result type (range)
761 fields = TypeTuple::fields(1);
762 fields[TypeFunc::Parms+0] = Type::FLOAT;
763 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
764
765 return TypeFunc::make(domain, range);
766 }
767
768 static const TypeFunc* make_modf_Type() {
769 const Type **fields = TypeTuple::fields(2);
770 fields[TypeFunc::Parms+0] = Type::FLOAT;
771 fields[TypeFunc::Parms+1] = Type::FLOAT;
772 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
773
774 // create result type (range)
775 fields = TypeTuple::fields(1);
776 fields[TypeFunc::Parms+0] = Type::FLOAT;
777
778 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
779
780 return TypeFunc::make(domain, range);
781 }
782
783 static const TypeFunc* make_Math_D_D_Type() {
784 // create input type (domain)
785 const Type **fields = TypeTuple::fields(2);
786 // Symbol* name of class to be loaded
787 fields[TypeFunc::Parms+0] = Type::DOUBLE;
788 fields[TypeFunc::Parms+1] = Type::HALF;
789 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
790
791 // create result type (range)
792 fields = TypeTuple::fields(2);
793 fields[TypeFunc::Parms+0] = Type::DOUBLE;
794 fields[TypeFunc::Parms+1] = Type::HALF;
795 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields);
796
797 return TypeFunc::make(domain, range);
798 }
799
800 const TypeFunc* OptoRuntime::Math_Vector_Vector_Type(uint num_arg, const TypeVect* in_type, const TypeVect* out_type) {
801 // create input type (domain)
802 const Type **fields = TypeTuple::fields(num_arg);
803 // Symbol* name of class to be loaded
804 assert(num_arg > 0, "must have at least 1 input");
805 for (uint i = 0; i < num_arg; i++) {
806 fields[TypeFunc::Parms+i] = in_type;
807 }
808 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+num_arg, fields);
809
810 // create result type (range)
811 const uint num_ret = 1;
812 fields = TypeTuple::fields(num_ret);
813 fields[TypeFunc::Parms+0] = out_type;
814 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+num_ret, fields);
815
816 return TypeFunc::make(domain, range);
817 }
818
819 static const TypeFunc* make_Math_DD_D_Type() {
820 const Type **fields = TypeTuple::fields(4);
821 fields[TypeFunc::Parms+0] = Type::DOUBLE;
822 fields[TypeFunc::Parms+1] = Type::HALF;
823 fields[TypeFunc::Parms+2] = Type::DOUBLE;
824 fields[TypeFunc::Parms+3] = Type::HALF;
825 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+4, fields);
826
827 // create result type (range)
828 fields = TypeTuple::fields(2);
829 fields[TypeFunc::Parms+0] = Type::DOUBLE;
830 fields[TypeFunc::Parms+1] = Type::HALF;
831 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields);
832
833 return TypeFunc::make(domain, range);
834 }
835
836 //-------------- currentTimeMillis, currentTimeNanos, etc
837
838 static const TypeFunc* make_void_long_Type() {
839 // create input type (domain)
840 const Type **fields = TypeTuple::fields(0);
841 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+0, fields);
842
843 // create result type (range)
844 fields = TypeTuple::fields(2);
845 fields[TypeFunc::Parms+0] = TypeLong::LONG;
846 fields[TypeFunc::Parms+1] = Type::HALF;
847 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields);
848
849 return TypeFunc::make(domain, range);
850 }
851
852 static const TypeFunc* make_void_void_Type() {
853 // create input type (domain)
854 const Type **fields = TypeTuple::fields(0);
855 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+0, fields);
856
857 // create result type (range)
858 fields = TypeTuple::fields(0);
859 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
860 return TypeFunc::make(domain, range);
861 }
862
863 static const TypeFunc* make_jfr_write_checkpoint_Type() {
864 // create input type (domain)
865 const Type **fields = TypeTuple::fields(0);
866 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms, fields);
867
868 // create result type (range)
869 fields = TypeTuple::fields(0);
870 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
871 return TypeFunc::make(domain, range);
872 }
873
874
875 // Takes as parameters:
876 // void *dest
877 // long size
878 // uchar byte
879
880 static const TypeFunc* make_setmemory_Type() {
881 // create input type (domain)
882 int argcnt = NOT_LP64(3) LP64_ONLY(4);
883 const Type** fields = TypeTuple::fields(argcnt);
884 int argp = TypeFunc::Parms;
885 fields[argp++] = TypePtr::NOTNULL; // dest
886 fields[argp++] = TypeX_X; // size
887 LP64_ONLY(fields[argp++] = Type::HALF); // size
888 fields[argp++] = TypeInt::UBYTE; // bytevalue
889 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
890 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
891
892 // no result type needed
893 fields = TypeTuple::fields(1);
894 fields[TypeFunc::Parms+0] = nullptr; // void
895 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
896 return TypeFunc::make(domain, range);
897 }
898
899 // arraycopy stub variations:
900 enum ArrayCopyType {
901 ac_fast, // void(ptr, ptr, size_t)
902 ac_checkcast, // int(ptr, ptr, size_t, size_t, ptr)
903 ac_slow, // void(ptr, int, ptr, int, int)
904 ac_generic // int(ptr, int, ptr, int, int)
905 };
906
907 static const TypeFunc* make_arraycopy_Type(ArrayCopyType act) {
908 // create input type (domain)
909 int num_args = (act == ac_fast ? 3 : 5);
910 int num_size_args = (act == ac_fast ? 1 : act == ac_checkcast ? 2 : 0);
911 int argcnt = num_args;
912 LP64_ONLY(argcnt += num_size_args); // halfwords for lengths
913 const Type** fields = TypeTuple::fields(argcnt);
914 int argp = TypeFunc::Parms;
915 fields[argp++] = TypePtr::NOTNULL; // src
916 if (num_size_args == 0) {
917 fields[argp++] = TypeInt::INT; // src_pos
918 }
919 fields[argp++] = TypePtr::NOTNULL; // dest
920 if (num_size_args == 0) {
921 fields[argp++] = TypeInt::INT; // dest_pos
922 fields[argp++] = TypeInt::INT; // length
923 }
924 while (num_size_args-- > 0) {
925 fields[argp++] = TypeX_X; // size in whatevers (size_t)
926 LP64_ONLY(fields[argp++] = Type::HALF); // other half of long length
927 }
928 if (act == ac_checkcast) {
929 fields[argp++] = TypePtr::NOTNULL; // super_klass
930 }
931 assert(argp == TypeFunc::Parms+argcnt, "correct decoding of act");
932 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
933
934 // create result type if needed
935 int retcnt = (act == ac_checkcast || act == ac_generic ? 1 : 0);
936 fields = TypeTuple::fields(1);
937 if (retcnt == 0)
938 fields[TypeFunc::Parms+0] = nullptr; // void
939 else
940 fields[TypeFunc::Parms+0] = TypeInt::INT; // status result, if needed
941 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+retcnt, fields);
942 return TypeFunc::make(domain, range);
943 }
944
945 static const TypeFunc* make_array_fill_Type() {
946 const Type** fields;
947 int argp = TypeFunc::Parms;
948 // create input type (domain): pointer, int, size_t
949 fields = TypeTuple::fields(3 LP64_ONLY( + 1));
950 fields[argp++] = TypePtr::NOTNULL;
951 fields[argp++] = TypeInt::INT;
952 fields[argp++] = TypeX_X; // size in whatevers (size_t)
953 LP64_ONLY(fields[argp++] = Type::HALF); // other half of long length
954 const TypeTuple *domain = TypeTuple::make(argp, fields);
955
956 // create result type
957 fields = TypeTuple::fields(1);
958 fields[TypeFunc::Parms+0] = nullptr; // void
959 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
960
961 return TypeFunc::make(domain, range);
962 }
963
964 static const TypeFunc* make_array_partition_Type() {
965 // create input type (domain)
966 int num_args = 7;
967 int argcnt = num_args;
968 const Type** fields = TypeTuple::fields(argcnt);
969 int argp = TypeFunc::Parms;
970 fields[argp++] = TypePtr::NOTNULL; // array
971 fields[argp++] = TypeInt::INT; // element type
972 fields[argp++] = TypeInt::INT; // low
973 fields[argp++] = TypeInt::INT; // end
974 fields[argp++] = TypePtr::NOTNULL; // pivot_indices (int array)
975 fields[argp++] = TypeInt::INT; // indexPivot1
976 fields[argp++] = TypeInt::INT; // indexPivot2
977 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
978 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
979
980 // no result type needed
981 fields = TypeTuple::fields(1);
982 fields[TypeFunc::Parms+0] = nullptr; // void
983 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
984 return TypeFunc::make(domain, range);
985 }
986
987 static const TypeFunc* make_array_sort_Type() {
988 // create input type (domain)
989 int num_args = 4;
990 int argcnt = num_args;
991 const Type** fields = TypeTuple::fields(argcnt);
992 int argp = TypeFunc::Parms;
993 fields[argp++] = TypePtr::NOTNULL; // array
994 fields[argp++] = TypeInt::INT; // element type
995 fields[argp++] = TypeInt::INT; // fromIndex
996 fields[argp++] = TypeInt::INT; // toIndex
997 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
998 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
999
1000 // no result type needed
1001 fields = TypeTuple::fields(1);
1002 fields[TypeFunc::Parms+0] = nullptr; // void
1003 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1004 return TypeFunc::make(domain, range);
1005 }
1006
1007 static const TypeFunc* make_aescrypt_block_Type() {
1008 // create input type (domain)
1009 int num_args = 3;
1010 int argcnt = num_args;
1011 const Type** fields = TypeTuple::fields(argcnt);
1012 int argp = TypeFunc::Parms;
1013 fields[argp++] = TypePtr::NOTNULL; // src
1014 fields[argp++] = TypePtr::NOTNULL; // dest
1015 fields[argp++] = TypePtr::NOTNULL; // k array
1016 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1017 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1018
1019 // no result type needed
1020 fields = TypeTuple::fields(1);
1021 fields[TypeFunc::Parms+0] = nullptr; // void
1022 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1023 return TypeFunc::make(domain, range);
1024 }
1025
1026 static const TypeFunc* make_updateBytesCRC32_Type() {
1027 // create input type (domain)
1028 int num_args = 3;
1029 int argcnt = num_args;
1030 const Type** fields = TypeTuple::fields(argcnt);
1031 int argp = TypeFunc::Parms;
1032 fields[argp++] = TypeInt::INT; // crc
1033 fields[argp++] = TypePtr::NOTNULL; // src
1034 fields[argp++] = TypeInt::INT; // len
1035 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1036 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1037
1038 // result type needed
1039 fields = TypeTuple::fields(1);
1040 fields[TypeFunc::Parms+0] = TypeInt::INT; // crc result
1041 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
1042 return TypeFunc::make(domain, range);
1043 }
1044
1045 static const TypeFunc* make_updateBytesCRC32C_Type() {
1046 // create input type (domain)
1047 int num_args = 4;
1048 int argcnt = num_args;
1049 const Type** fields = TypeTuple::fields(argcnt);
1050 int argp = TypeFunc::Parms;
1051 fields[argp++] = TypeInt::INT; // crc
1052 fields[argp++] = TypePtr::NOTNULL; // buf
1053 fields[argp++] = TypeInt::INT; // len
1054 fields[argp++] = TypePtr::NOTNULL; // table
1055 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1056 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1057
1058 // result type needed
1059 fields = TypeTuple::fields(1);
1060 fields[TypeFunc::Parms+0] = TypeInt::INT; // crc result
1061 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
1062 return TypeFunc::make(domain, range);
1063 }
1064
1065 static const TypeFunc* make_updateBytesAdler32_Type() {
1066 // create input type (domain)
1067 int num_args = 3;
1068 int argcnt = num_args;
1069 const Type** fields = TypeTuple::fields(argcnt);
1070 int argp = TypeFunc::Parms;
1071 fields[argp++] = TypeInt::INT; // crc
1072 fields[argp++] = TypePtr::NOTNULL; // src + offset
1073 fields[argp++] = TypeInt::INT; // len
1074 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1075 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1076
1077 // result type needed
1078 fields = TypeTuple::fields(1);
1079 fields[TypeFunc::Parms+0] = TypeInt::INT; // crc result
1080 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
1081 return TypeFunc::make(domain, range);
1082 }
1083
1084 static const TypeFunc* make_cipherBlockChaining_aescrypt_Type() {
1085 // create input type (domain)
1086 int num_args = 5;
1087 int argcnt = num_args;
1088 const Type** fields = TypeTuple::fields(argcnt);
1089 int argp = TypeFunc::Parms;
1090 fields[argp++] = TypePtr::NOTNULL; // src
1091 fields[argp++] = TypePtr::NOTNULL; // dest
1092 fields[argp++] = TypePtr::NOTNULL; // k array
1093 fields[argp++] = TypePtr::NOTNULL; // r array
1094 fields[argp++] = TypeInt::INT; // src len
1095 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1096 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1097
1098 // returning cipher len (int)
1099 fields = TypeTuple::fields(1);
1100 fields[TypeFunc::Parms+0] = TypeInt::INT;
1101 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
1102 return TypeFunc::make(domain, range);
1103 }
1104
1105 static const TypeFunc* make_electronicCodeBook_aescrypt_Type() {
1106 // create input type (domain)
1107 int num_args = 4;
1108 int argcnt = num_args;
1109 const Type** fields = TypeTuple::fields(argcnt);
1110 int argp = TypeFunc::Parms;
1111 fields[argp++] = TypePtr::NOTNULL; // src
1112 fields[argp++] = TypePtr::NOTNULL; // dest
1113 fields[argp++] = TypePtr::NOTNULL; // k array
1114 fields[argp++] = TypeInt::INT; // src len
1115 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1116 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1117
1118 // returning cipher len (int)
1119 fields = TypeTuple::fields(1);
1120 fields[TypeFunc::Parms + 0] = TypeInt::INT;
1121 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1122 return TypeFunc::make(domain, range);
1123 }
1124
1125 static const TypeFunc* make_counterMode_aescrypt_Type() {
1126 // create input type (domain)
1127 int num_args = 7;
1128 int argcnt = num_args;
1129 const Type** fields = TypeTuple::fields(argcnt);
1130 int argp = TypeFunc::Parms;
1131 fields[argp++] = TypePtr::NOTNULL; // src
1132 fields[argp++] = TypePtr::NOTNULL; // dest
1133 fields[argp++] = TypePtr::NOTNULL; // k array
1134 fields[argp++] = TypePtr::NOTNULL; // counter array
1135 fields[argp++] = TypeInt::INT; // src len
1136 fields[argp++] = TypePtr::NOTNULL; // saved_encCounter
1137 fields[argp++] = TypePtr::NOTNULL; // saved used addr
1138 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1139 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1140 // returning cipher len (int)
1141 fields = TypeTuple::fields(1);
1142 fields[TypeFunc::Parms + 0] = TypeInt::INT;
1143 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1144 return TypeFunc::make(domain, range);
1145 }
1146
1147 static const TypeFunc* make_galoisCounterMode_aescrypt_Type() {
1148 // create input type (domain)
1149 int num_args = 8;
1150 int argcnt = num_args;
1151 const Type** fields = TypeTuple::fields(argcnt);
1152 int argp = TypeFunc::Parms;
1153 fields[argp++] = TypePtr::NOTNULL; // byte[] in + inOfs
1154 fields[argp++] = TypeInt::INT; // int len
1155 fields[argp++] = TypePtr::NOTNULL; // byte[] ct + ctOfs
1156 fields[argp++] = TypePtr::NOTNULL; // byte[] out + outOfs
1157 fields[argp++] = TypePtr::NOTNULL; // byte[] key from AESCrypt obj
1158 fields[argp++] = TypePtr::NOTNULL; // long[] state from GHASH obj
1159 fields[argp++] = TypePtr::NOTNULL; // long[] subkeyHtbl from GHASH obj
1160 fields[argp++] = TypePtr::NOTNULL; // byte[] counter from GCTR obj
1161
1162 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1163 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1164 // returning cipher len (int)
1165 fields = TypeTuple::fields(1);
1166 fields[TypeFunc::Parms + 0] = TypeInt::INT;
1167 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1168 return TypeFunc::make(domain, range);
1169 }
1170
1171 static const TypeFunc* make_digestBase_implCompress_Type(bool is_sha3) {
1172 // create input type (domain)
1173 int num_args = is_sha3 ? 3 : 2;
1174 int argcnt = num_args;
1175 const Type** fields = TypeTuple::fields(argcnt);
1176 int argp = TypeFunc::Parms;
1177 fields[argp++] = TypePtr::NOTNULL; // buf
1178 fields[argp++] = TypePtr::NOTNULL; // state
1179 if (is_sha3) fields[argp++] = TypeInt::INT; // block_size
1180 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1181 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1182
1183 // no result type needed
1184 fields = TypeTuple::fields(1);
1185 fields[TypeFunc::Parms+0] = nullptr; // void
1186 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1187 return TypeFunc::make(domain, range);
1188 }
1189
1190 /*
1191 * int implCompressMultiBlock(byte[] b, int ofs, int limit)
1192 */
1193 static const TypeFunc* make_digestBase_implCompressMB_Type(bool is_sha3) {
1194 // create input type (domain)
1195 int num_args = is_sha3 ? 5 : 4;
1196 int argcnt = num_args;
1197 const Type** fields = TypeTuple::fields(argcnt);
1198 int argp = TypeFunc::Parms;
1199 fields[argp++] = TypePtr::NOTNULL; // buf
1200 fields[argp++] = TypePtr::NOTNULL; // state
1201 if (is_sha3) fields[argp++] = TypeInt::INT; // block_size
1202 fields[argp++] = TypeInt::INT; // ofs
1203 fields[argp++] = TypeInt::INT; // limit
1204 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1205 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1206
1207 // returning ofs (int)
1208 fields = TypeTuple::fields(1);
1209 fields[TypeFunc::Parms+0] = TypeInt::INT; // ofs
1210 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
1211 return TypeFunc::make(domain, range);
1212 }
1213
1214 // SHAKE128Parallel doubleKeccak function
1215 static const TypeFunc* make_double_keccak_Type() {
1216 int argcnt = 2;
1217
1218 const Type** fields = TypeTuple::fields(argcnt);
1219 int argp = TypeFunc::Parms;
1220 fields[argp++] = TypePtr::NOTNULL; // status0
1221 fields[argp++] = TypePtr::NOTNULL; // status1
1222
1223 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1224 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1225
1226 // result type needed
1227 fields = TypeTuple::fields(1);
1228 fields[TypeFunc::Parms + 0] = TypeInt::INT;
1229 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1230 return TypeFunc::make(domain, range);
1231 }
1232
1233 static const TypeFunc* make_multiplyToLen_Type() {
1234 // create input type (domain)
1235 int num_args = 5;
1236 int argcnt = num_args;
1237 const Type** fields = TypeTuple::fields(argcnt);
1238 int argp = TypeFunc::Parms;
1239 fields[argp++] = TypePtr::NOTNULL; // x
1240 fields[argp++] = TypeInt::INT; // xlen
1241 fields[argp++] = TypePtr::NOTNULL; // y
1242 fields[argp++] = TypeInt::INT; // ylen
1243 fields[argp++] = TypePtr::NOTNULL; // z
1244 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1245 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1246
1247 // no result type needed
1248 fields = TypeTuple::fields(1);
1249 fields[TypeFunc::Parms+0] = nullptr;
1250 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1251 return TypeFunc::make(domain, range);
1252 }
1253
1254 static const TypeFunc* make_squareToLen_Type() {
1255 // create input type (domain)
1256 int num_args = 4;
1257 int argcnt = num_args;
1258 const Type** fields = TypeTuple::fields(argcnt);
1259 int argp = TypeFunc::Parms;
1260 fields[argp++] = TypePtr::NOTNULL; // x
1261 fields[argp++] = TypeInt::INT; // len
1262 fields[argp++] = TypePtr::NOTNULL; // z
1263 fields[argp++] = TypeInt::INT; // zlen
1264 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1265 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1266
1267 // no result type needed
1268 fields = TypeTuple::fields(1);
1269 fields[TypeFunc::Parms+0] = nullptr;
1270 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1271 return TypeFunc::make(domain, range);
1272 }
1273
1274 static const TypeFunc* make_mulAdd_Type() {
1275 // create input type (domain)
1276 int num_args = 5;
1277 int argcnt = num_args;
1278 const Type** fields = TypeTuple::fields(argcnt);
1279 int argp = TypeFunc::Parms;
1280 fields[argp++] = TypePtr::NOTNULL; // out
1281 fields[argp++] = TypePtr::NOTNULL; // in
1282 fields[argp++] = TypeInt::INT; // offset
1283 fields[argp++] = TypeInt::INT; // len
1284 fields[argp++] = TypeInt::INT; // k
1285 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1286 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1287
1288 // returning carry (int)
1289 fields = TypeTuple::fields(1);
1290 fields[TypeFunc::Parms+0] = TypeInt::INT;
1291 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
1292 return TypeFunc::make(domain, range);
1293 }
1294
1295 static const TypeFunc* make_montgomeryMultiply_Type() {
1296 // create input type (domain)
1297 int num_args = 7;
1298 int argcnt = num_args;
1299 const Type** fields = TypeTuple::fields(argcnt);
1300 int argp = TypeFunc::Parms;
1301 fields[argp++] = TypePtr::NOTNULL; // a
1302 fields[argp++] = TypePtr::NOTNULL; // b
1303 fields[argp++] = TypePtr::NOTNULL; // n
1304 fields[argp++] = TypeInt::INT; // len
1305 fields[argp++] = TypeLong::LONG; // inv
1306 fields[argp++] = Type::HALF;
1307 fields[argp++] = TypePtr::NOTNULL; // result
1308 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1309 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1310
1311 // result type needed
1312 fields = TypeTuple::fields(1);
1313 fields[TypeFunc::Parms+0] = TypePtr::NOTNULL;
1314
1315 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1316 return TypeFunc::make(domain, range);
1317 }
1318
1319 static const TypeFunc* make_montgomerySquare_Type() {
1320 // create input type (domain)
1321 int num_args = 6;
1322 int argcnt = num_args;
1323 const Type** fields = TypeTuple::fields(argcnt);
1324 int argp = TypeFunc::Parms;
1325 fields[argp++] = TypePtr::NOTNULL; // a
1326 fields[argp++] = TypePtr::NOTNULL; // n
1327 fields[argp++] = TypeInt::INT; // len
1328 fields[argp++] = TypeLong::LONG; // inv
1329 fields[argp++] = Type::HALF;
1330 fields[argp++] = TypePtr::NOTNULL; // result
1331 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1332 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1333
1334 // result type needed
1335 fields = TypeTuple::fields(1);
1336 fields[TypeFunc::Parms+0] = TypePtr::NOTNULL;
1337
1338 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1339 return TypeFunc::make(domain, range);
1340 }
1341
1342 static const TypeFunc* make_bigIntegerShift_Type() {
1343 int argcnt = 5;
1344 const Type** fields = TypeTuple::fields(argcnt);
1345 int argp = TypeFunc::Parms;
1346 fields[argp++] = TypePtr::NOTNULL; // newArr
1347 fields[argp++] = TypePtr::NOTNULL; // oldArr
1348 fields[argp++] = TypeInt::INT; // newIdx
1349 fields[argp++] = TypeInt::INT; // shiftCount
1350 fields[argp++] = TypeInt::INT; // numIter
1351 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1352 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1353
1354 // no result type needed
1355 fields = TypeTuple::fields(1);
1356 fields[TypeFunc::Parms + 0] = nullptr;
1357 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1358 return TypeFunc::make(domain, range);
1359 }
1360
1361 static const TypeFunc* make_vectorizedMismatch_Type() {
1362 // create input type (domain)
1363 int num_args = 4;
1364 int argcnt = num_args;
1365 const Type** fields = TypeTuple::fields(argcnt);
1366 int argp = TypeFunc::Parms;
1367 fields[argp++] = TypePtr::NOTNULL; // obja
1368 fields[argp++] = TypePtr::NOTNULL; // objb
1369 fields[argp++] = TypeInt::INT; // length, number of elements
1370 fields[argp++] = TypeInt::INT; // log2scale, element size
1371 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1372 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1373
1374 //return mismatch index (int)
1375 fields = TypeTuple::fields(1);
1376 fields[TypeFunc::Parms + 0] = TypeInt::INT;
1377 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1378 return TypeFunc::make(domain, range);
1379 }
1380
1381 static const TypeFunc* make_ghash_processBlocks_Type() {
1382 int argcnt = 4;
1383
1384 const Type** fields = TypeTuple::fields(argcnt);
1385 int argp = TypeFunc::Parms;
1386 fields[argp++] = TypePtr::NOTNULL; // state
1387 fields[argp++] = TypePtr::NOTNULL; // subkeyH
1388 fields[argp++] = TypePtr::NOTNULL; // data
1389 fields[argp++] = TypeInt::INT; // blocks
1390 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1391 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1392
1393 // result type needed
1394 fields = TypeTuple::fields(1);
1395 fields[TypeFunc::Parms+0] = nullptr; // void
1396 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1397 return TypeFunc::make(domain, range);
1398 }
1399
1400 static const TypeFunc* make_chacha20Block_Type() {
1401 int argcnt = 2;
1402
1403 const Type** fields = TypeTuple::fields(argcnt);
1404 int argp = TypeFunc::Parms;
1405 fields[argp++] = TypePtr::NOTNULL; // state
1406 fields[argp++] = TypePtr::NOTNULL; // result
1407
1408 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1409 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1410
1411 // result type needed
1412 fields = TypeTuple::fields(1);
1413 fields[TypeFunc::Parms + 0] = TypeInt::INT; // key stream outlen as int
1414 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1415 return TypeFunc::make(domain, range);
1416 }
1417
1418 // Kyber NTT function
1419 static const TypeFunc* make_kyberNtt_Type() {
1420 int argcnt = 2;
1421
1422 const Type** fields = TypeTuple::fields(argcnt);
1423 int argp = TypeFunc::Parms;
1424 fields[argp++] = TypePtr::NOTNULL; // coeffs
1425 fields[argp++] = TypePtr::NOTNULL; // NTT zetas
1426
1427 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1428 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1429
1430 // result type needed
1431 fields = TypeTuple::fields(1);
1432 fields[TypeFunc::Parms + 0] = TypeInt::INT;
1433 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1434 return TypeFunc::make(domain, range);
1435 }
1436
1437 // Kyber inverse NTT function
1438 static const TypeFunc* make_kyberInverseNtt_Type() {
1439 int argcnt = 2;
1440
1441 const Type** fields = TypeTuple::fields(argcnt);
1442 int argp = TypeFunc::Parms;
1443 fields[argp++] = TypePtr::NOTNULL; // coeffs
1444 fields[argp++] = TypePtr::NOTNULL; // inverse NTT zetas
1445
1446 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1447 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1448
1449 // result type needed
1450 fields = TypeTuple::fields(1);
1451 fields[TypeFunc::Parms + 0] = TypeInt::INT;
1452 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1453 return TypeFunc::make(domain, range);
1454 }
1455
1456 // Kyber NTT multiply function
1457 static const TypeFunc* make_kyberNttMult_Type() {
1458 int argcnt = 4;
1459
1460 const Type** fields = TypeTuple::fields(argcnt);
1461 int argp = TypeFunc::Parms;
1462 fields[argp++] = TypePtr::NOTNULL; // result
1463 fields[argp++] = TypePtr::NOTNULL; // ntta
1464 fields[argp++] = TypePtr::NOTNULL; // nttb
1465 fields[argp++] = TypePtr::NOTNULL; // NTT multiply zetas
1466
1467 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1468 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1469
1470 // result type needed
1471 fields = TypeTuple::fields(1);
1472 fields[TypeFunc::Parms + 0] = TypeInt::INT;
1473 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1474 return TypeFunc::make(domain, range);
1475 }
1476
1477 // Kyber add 2 polynomials function
1478 static const TypeFunc* make_kyberAddPoly_2_Type() {
1479 int argcnt = 3;
1480
1481 const Type** fields = TypeTuple::fields(argcnt);
1482 int argp = TypeFunc::Parms;
1483 fields[argp++] = TypePtr::NOTNULL; // result
1484 fields[argp++] = TypePtr::NOTNULL; // a
1485 fields[argp++] = TypePtr::NOTNULL; // b
1486
1487 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1488 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1489
1490 // result type needed
1491 fields = TypeTuple::fields(1);
1492 fields[TypeFunc::Parms + 0] = TypeInt::INT;
1493 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1494 return TypeFunc::make(domain, range);
1495 }
1496
1497
1498 // Kyber add 3 polynomials function
1499 static const TypeFunc* make_kyberAddPoly_3_Type() {
1500 int argcnt = 4;
1501
1502 const Type** fields = TypeTuple::fields(argcnt);
1503 int argp = TypeFunc::Parms;
1504 fields[argp++] = TypePtr::NOTNULL; // result
1505 fields[argp++] = TypePtr::NOTNULL; // a
1506 fields[argp++] = TypePtr::NOTNULL; // b
1507 fields[argp++] = TypePtr::NOTNULL; // c
1508
1509 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1510 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1511
1512 // result type needed
1513 fields = TypeTuple::fields(1);
1514 fields[TypeFunc::Parms + 0] = TypeInt::INT;
1515 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1516 return TypeFunc::make(domain, range);
1517 }
1518
1519
1520 // Kyber XOF output parsing into polynomial coefficients candidates
1521 // or decompress(12,...) function
1522 static const TypeFunc* make_kyber12To16_Type() {
1523 int argcnt = 4;
1524
1525 const Type** fields = TypeTuple::fields(argcnt);
1526 int argp = TypeFunc::Parms;
1527 fields[argp++] = TypePtr::NOTNULL; // condensed
1528 fields[argp++] = TypeInt::INT; // condensedOffs
1529 fields[argp++] = TypePtr::NOTNULL; // parsed
1530 fields[argp++] = TypeInt::INT; // parsedLength
1531
1532 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1533 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1534
1535 // result type needed
1536 fields = TypeTuple::fields(1);
1537 fields[TypeFunc::Parms + 0] = TypeInt::INT;
1538 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1539 return TypeFunc::make(domain, range);
1540 }
1541
1542 // Kyber Barrett reduce function
1543 static const TypeFunc* make_kyberBarrettReduce_Type() {
1544 int argcnt = 1;
1545
1546 const Type** fields = TypeTuple::fields(argcnt);
1547 int argp = TypeFunc::Parms;
1548 fields[argp++] = TypePtr::NOTNULL; // coeffs
1549
1550 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1551 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1552
1553 // result type needed
1554 fields = TypeTuple::fields(1);
1555 fields[TypeFunc::Parms + 0] = TypeInt::INT;
1556 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1557 return TypeFunc::make(domain, range);
1558 }
1559
1560 // Dilithium NTT function except for the final "normalization" to |coeff| < Q
1561 static const TypeFunc* make_dilithiumAlmostNtt_Type() {
1562 int argcnt = 2;
1563
1564 const Type** fields = TypeTuple::fields(argcnt);
1565 int argp = TypeFunc::Parms;
1566 fields[argp++] = TypePtr::NOTNULL; // coeffs
1567 fields[argp++] = TypePtr::NOTNULL; // NTT zetas
1568
1569 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1570 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1571
1572 // result type needed
1573 fields = TypeTuple::fields(1);
1574 fields[TypeFunc::Parms + 0] = TypeInt::INT;
1575 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1576 return TypeFunc::make(domain, range);
1577 }
1578
1579 // Dilithium inverse NTT function except the final mod Q division by 2^256
1580 static const TypeFunc* make_dilithiumAlmostInverseNtt_Type() {
1581 int argcnt = 2;
1582
1583 const Type** fields = TypeTuple::fields(argcnt);
1584 int argp = TypeFunc::Parms;
1585 fields[argp++] = TypePtr::NOTNULL; // coeffs
1586 fields[argp++] = TypePtr::NOTNULL; // inverse NTT zetas
1587
1588 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1589 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1590
1591 // result type needed
1592 fields = TypeTuple::fields(1);
1593 fields[TypeFunc::Parms + 0] = TypeInt::INT;
1594 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1595 return TypeFunc::make(domain, range);
1596 }
1597
1598 // Dilithium NTT multiply function
1599 static const TypeFunc* make_dilithiumNttMult_Type() {
1600 int argcnt = 3;
1601
1602 const Type** fields = TypeTuple::fields(argcnt);
1603 int argp = TypeFunc::Parms;
1604 fields[argp++] = TypePtr::NOTNULL; // result
1605 fields[argp++] = TypePtr::NOTNULL; // ntta
1606 fields[argp++] = TypePtr::NOTNULL; // nttb
1607
1608 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1609 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1610
1611 // result type needed
1612 fields = TypeTuple::fields(1);
1613 fields[TypeFunc::Parms + 0] = TypeInt::INT;
1614 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1615 return TypeFunc::make(domain, range);
1616 }
1617
1618 // Dilithium Montgomery multiply a polynome coefficient array by a constant
1619 static const TypeFunc* make_dilithiumMontMulByConstant_Type() {
1620 int argcnt = 2;
1621
1622 const Type** fields = TypeTuple::fields(argcnt);
1623 int argp = TypeFunc::Parms;
1624 fields[argp++] = TypePtr::NOTNULL; // coeffs
1625 fields[argp++] = TypeInt::INT; // constant multiplier
1626
1627 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1628 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1629
1630 // result type needed
1631 fields = TypeTuple::fields(1);
1632 fields[TypeFunc::Parms + 0] = TypeInt::INT;
1633 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1634 return TypeFunc::make(domain, range);
1635 }
1636
1637 // Dilithium decompose polynomial
1638 static const TypeFunc* make_dilithiumDecomposePoly_Type() {
1639 int argcnt = 5;
1640
1641 const Type** fields = TypeTuple::fields(argcnt);
1642 int argp = TypeFunc::Parms;
1643 fields[argp++] = TypePtr::NOTNULL; // input
1644 fields[argp++] = TypePtr::NOTNULL; // lowPart
1645 fields[argp++] = TypePtr::NOTNULL; // highPart
1646 fields[argp++] = TypeInt::INT; // 2 * gamma2
1647 fields[argp++] = TypeInt::INT; // multiplier
1648
1649 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1650 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields);
1651
1652 // result type needed
1653 fields = TypeTuple::fields(1);
1654 fields[TypeFunc::Parms + 0] = TypeInt::INT;
1655 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1656 return TypeFunc::make(domain, range);
1657 }
1658
1659 static const TypeFunc* make_base64_encodeBlock_Type() {
1660 int argcnt = 6;
1661
1662 const Type** fields = TypeTuple::fields(argcnt);
1663 int argp = TypeFunc::Parms;
1664 fields[argp++] = TypePtr::NOTNULL; // src array
1665 fields[argp++] = TypeInt::INT; // offset
1666 fields[argp++] = TypeInt::INT; // length
1667 fields[argp++] = TypePtr::NOTNULL; // dest array
1668 fields[argp++] = TypeInt::INT; // dp
1669 fields[argp++] = TypeInt::BOOL; // isURL
1670 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1671 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1672
1673 // result type needed
1674 fields = TypeTuple::fields(1);
1675 fields[TypeFunc::Parms + 0] = nullptr; // void
1676 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1677 return TypeFunc::make(domain, range);
1678 }
1679
1680 static const TypeFunc* make_string_IndexOf_Type() {
1681 int argcnt = 4;
1682
1683 const Type** fields = TypeTuple::fields(argcnt);
1684 int argp = TypeFunc::Parms;
1685 fields[argp++] = TypePtr::NOTNULL; // haystack array
1686 fields[argp++] = TypeInt::INT; // haystack length
1687 fields[argp++] = TypePtr::NOTNULL; // needle array
1688 fields[argp++] = TypeInt::INT; // needle length
1689 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1690 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1691
1692 // result type needed
1693 fields = TypeTuple::fields(1);
1694 fields[TypeFunc::Parms + 0] = TypeInt::INT; // Index of needle in haystack
1695 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1696 return TypeFunc::make(domain, range);
1697 }
1698
1699 static const TypeFunc* make_base64_decodeBlock_Type() {
1700 int argcnt = 7;
1701
1702 const Type** fields = TypeTuple::fields(argcnt);
1703 int argp = TypeFunc::Parms;
1704 fields[argp++] = TypePtr::NOTNULL; // src array
1705 fields[argp++] = TypeInt::INT; // src offset
1706 fields[argp++] = TypeInt::INT; // src length
1707 fields[argp++] = TypePtr::NOTNULL; // dest array
1708 fields[argp++] = TypeInt::INT; // dest offset
1709 fields[argp++] = TypeInt::BOOL; // isURL
1710 fields[argp++] = TypeInt::BOOL; // isMIME
1711 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1712 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1713
1714 // result type needed
1715 fields = TypeTuple::fields(1);
1716 fields[TypeFunc::Parms + 0] = TypeInt::INT; // count of bytes written to dst
1717 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields);
1718 return TypeFunc::make(domain, range);
1719 }
1720
1721 static const TypeFunc* make_poly1305_processBlocks_Type() {
1722 int argcnt = 4;
1723
1724 const Type** fields = TypeTuple::fields(argcnt);
1725 int argp = TypeFunc::Parms;
1726 fields[argp++] = TypePtr::NOTNULL; // input array
1727 fields[argp++] = TypeInt::INT; // input length
1728 fields[argp++] = TypePtr::NOTNULL; // accumulator array
1729 fields[argp++] = TypePtr::NOTNULL; // r array
1730 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1731 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1732
1733 // result type needed
1734 fields = TypeTuple::fields(1);
1735 fields[TypeFunc::Parms + 0] = nullptr; // void
1736 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1737 return TypeFunc::make(domain, range);
1738 }
1739
1740 static const TypeFunc* make_intpoly_montgomeryMult_P256_Type() {
1741 int argcnt = 3;
1742
1743 const Type** fields = TypeTuple::fields(argcnt);
1744 int argp = TypeFunc::Parms;
1745 fields[argp++] = TypePtr::NOTNULL; // a array
1746 fields[argp++] = TypePtr::NOTNULL; // b array
1747 fields[argp++] = TypePtr::NOTNULL; // r(esult) array
1748 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1749 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1750
1751 // result type needed
1752 fields = TypeTuple::fields(1);
1753 fields[TypeFunc::Parms + 0] = nullptr; // void
1754 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1755 return TypeFunc::make(domain, range);
1756 }
1757
1758 static const TypeFunc* make_intpoly_assign_Type() {
1759 int argcnt = 4;
1760
1761 const Type** fields = TypeTuple::fields(argcnt);
1762 int argp = TypeFunc::Parms;
1763 fields[argp++] = TypeInt::INT; // set flag
1764 fields[argp++] = TypePtr::NOTNULL; // a array (result)
1765 fields[argp++] = TypePtr::NOTNULL; // b array (if set is set)
1766 fields[argp++] = TypeInt::INT; // array length
1767 assert(argp == TypeFunc::Parms + argcnt, "correct decoding");
1768 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1769
1770 // result type needed
1771 fields = TypeTuple::fields(1);
1772 fields[TypeFunc::Parms + 0] = nullptr; // void
1773 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1774 return TypeFunc::make(domain, range);
1775 }
1776
1777 //------------- Interpreter state for on stack replacement
1778 static const TypeFunc* make_osr_end_Type() {
1779 // create input type (domain)
1780 const Type **fields = TypeTuple::fields(1);
1781 fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // OSR temp buf
1782 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
1783
1784 // create result type
1785 fields = TypeTuple::fields(1);
1786 // fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // locked oop
1787 fields[TypeFunc::Parms+0] = nullptr; // void
1788 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
1789 return TypeFunc::make(domain, range);
1790 }
1791
1792 #ifndef PRODUCT
1793 static void debug_print_convert_type(const Type** fields, int* argp, Node *parm) {
1794 const BasicType bt = parm->bottom_type()->basic_type();
1795 fields[(*argp)++] = Type::get_const_basic_type(bt);
1796 if (bt == T_LONG || bt == T_DOUBLE) {
1797 fields[(*argp)++] = Type::HALF;
1798 }
1799 }
1800
1801 static void update_arg_cnt(const Node* parm, int* arg_cnt) {
1802 (*arg_cnt)++;
1803 const BasicType bt = parm->bottom_type()->basic_type();
1804 if (bt == T_LONG || bt == T_DOUBLE) {
1805 (*arg_cnt)++;
1806 }
1807 }
1808
1809 const TypeFunc* OptoRuntime::debug_print_Type(Node* parm0, Node* parm1,
1810 Node* parm2, Node* parm3,
1811 Node* parm4, Node* parm5,
1812 Node* parm6) {
1813 int argcnt = 1;
1814 if (parm0 != nullptr) { update_arg_cnt(parm0, &argcnt);
1815 if (parm1 != nullptr) { update_arg_cnt(parm1, &argcnt);
1816 if (parm2 != nullptr) { update_arg_cnt(parm2, &argcnt);
1817 if (parm3 != nullptr) { update_arg_cnt(parm3, &argcnt);
1818 if (parm4 != nullptr) { update_arg_cnt(parm4, &argcnt);
1819 if (parm5 != nullptr) { update_arg_cnt(parm5, &argcnt);
1820 if (parm6 != nullptr) { update_arg_cnt(parm6, &argcnt);
1821 /* close each nested if ===> */ } } } } } } }
1822
1823 // create input type (domain)
1824 const Type** fields = TypeTuple::fields(argcnt);
1825 int argp = TypeFunc::Parms;
1826 fields[argp++] = TypePtr::NOTNULL; // static string pointer
1827
1828 if (parm0 != nullptr) { debug_print_convert_type(fields, &argp, parm0);
1829 if (parm1 != nullptr) { debug_print_convert_type(fields, &argp, parm1);
1830 if (parm2 != nullptr) { debug_print_convert_type(fields, &argp, parm2);
1831 if (parm3 != nullptr) { debug_print_convert_type(fields, &argp, parm3);
1832 if (parm4 != nullptr) { debug_print_convert_type(fields, &argp, parm4);
1833 if (parm5 != nullptr) { debug_print_convert_type(fields, &argp, parm5);
1834 if (parm6 != nullptr) { debug_print_convert_type(fields, &argp, parm6);
1835 /* close each nested if ===> */ } } } } } } }
1836
1837 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1838 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1839
1840 // no result type needed
1841 fields = TypeTuple::fields(1);
1842 fields[TypeFunc::Parms+0] = nullptr; // void
1843 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1844 return TypeFunc::make(domain, range);
1845 }
1846 #endif // PRODUCT
1847
1848 //-------------------------------------------------------------------------------------
1849 // register policy
1850
1851 bool OptoRuntime::is_callee_saved_register(MachRegisterNumbers reg) {
1852 assert(reg >= 0 && reg < _last_Mach_Reg, "must be a machine register");
1853 switch (register_save_policy[reg]) {
1854 case 'C': return false; //SOC
1855 case 'E': return true ; //SOE
1856 case 'N': return false; //NS
1857 case 'A': return false; //AS
1858 }
1859 ShouldNotReachHere();
1860 return false;
1861 }
1862
1863 //-----------------------------------------------------------------------
1864 // Exceptions
1865 //
1866
1867 static void trace_exception(outputStream* st, oop exception_oop, address exception_pc, const char* msg);
1868
1869 // The method is an entry that is always called by a C++ method not
1870 // directly from compiled code. Compiled code will call the C++ method following.
1871 // We can't allow async exception to be installed during exception processing.
1872 JRT_ENTRY_NO_ASYNC_PROF(address, OptoRuntime, handle_exception_C_helper, OptoRuntime::handle_exception_C_helper(JavaThread* current, nmethod* &nm))
1873 // The frame we rethrow the exception to might not have been processed by the GC yet.
1874 // The stack watermark barrier takes care of detecting that and ensuring the frame
1875 // has updated oops.
1876 StackWatermarkSet::after_unwind(current);
1877
1878 // Do not confuse exception_oop with pending_exception. The exception_oop
1879 // is only used to pass arguments into the method. Not for general
1880 // exception handling. DO NOT CHANGE IT to use pending_exception, since
1881 // the runtime stubs checks this on exit.
1882 assert(current->exception_oop() != nullptr, "exception oop is found");
1883 address handler_address = nullptr;
1884
1885 Handle exception(current, current->exception_oop());
1886 address pc = current->exception_pc();
1887
1888 // Clear out the exception oop and pc since looking up an
1889 // exception handler can cause class loading, which might throw an
1890 // exception and those fields are expected to be clear during
1891 // normal bytecode execution.
1892 current->clear_exception_oop_and_pc();
1893
1894 LogTarget(Info, exceptions) lt;
1895 if (lt.is_enabled()) {
1896 LogStream ls(lt);
1897 trace_exception(&ls, exception(), pc, "");
1898 }
1899
1900 // for AbortVMOnException flag
1901 Exceptions::debug_check_abort(exception);
1902
1903 #ifdef ASSERT
1904 if (!(exception->is_a(vmClasses::Throwable_klass()))) {
1905 // should throw an exception here
1906 ShouldNotReachHere();
1907 }
1908 #endif
1909
1910 // new exception handling: this method is entered only from adapters
1911 // exceptions from compiled java methods are handled in compiled code
1912 // using rethrow node
1913
1914 nm = CodeCache::find_nmethod(pc);
1915 assert(nm != nullptr, "No NMethod found");
1916 if (nm->is_native_method()) {
1917 fatal("Native method should not have path to exception handling");
1918 } else {
1919 // we are switching to old paradigm: search for exception handler in caller_frame
1920 // instead in exception handler of caller_frame.sender()
1921
1922 if (JvmtiExport::can_post_on_exceptions()) {
1923 // "Full-speed catching" is not necessary here,
1924 // since we're notifying the VM on every catch.
1925 // Force deoptimization and the rest of the lookup
1926 // will be fine.
1927 deoptimize_caller_frame(current);
1928 }
1929
1930 // Check the stack guard pages. If enabled, look for handler in this frame;
1931 // otherwise, forcibly unwind the frame.
1932 //
1933 // 4826555: use default current sp for reguard_stack instead of &nm: it's more accurate.
1934 bool force_unwind = !current->stack_overflow_state()->reguard_stack();
1935 bool deopting = false;
1936 if (nm->is_deopt_pc(pc)) {
1937 deopting = true;
1938 RegisterMap map(current,
1939 RegisterMap::UpdateMap::skip,
1940 RegisterMap::ProcessFrames::include,
1941 RegisterMap::WalkContinuation::skip);
1942 frame deoptee = current->last_frame().sender(&map);
1943 assert(deoptee.is_deoptimized_frame(), "must be deopted");
1944 // Adjust the pc back to the original throwing pc
1945 pc = deoptee.pc();
1946 }
1947
1948 // If we are forcing an unwind because of stack overflow then deopt is
1949 // irrelevant since we are throwing the frame away anyway.
1950
1951 if (deopting && !force_unwind) {
1952 handler_address = SharedRuntime::deopt_blob()->unpack_with_exception();
1953 } else {
1954
1955 handler_address =
1956 force_unwind ? nullptr : nm->handler_for_exception_and_pc(exception, pc);
1957
1958 if (handler_address == nullptr) {
1959 bool recursive_exception = false;
1960 handler_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception);
1961 assert (handler_address != nullptr, "must have compiled handler");
1962 // Update the exception cache only when the unwind was not forced
1963 // and there didn't happen another exception during the computation of the
1964 // compiled exception handler. Checking for exception oop equality is not
1965 // sufficient because some exceptions are pre-allocated and reused.
1966 if (!force_unwind && !recursive_exception) {
1967 nm->add_handler_for_exception_and_pc(exception,pc,handler_address);
1968 }
1969 } else {
1970 #ifdef ASSERT
1971 bool recursive_exception = false;
1972 address computed_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception);
1973 vmassert(recursive_exception || (handler_address == computed_address), "Handler address inconsistency: " PTR_FORMAT " != " PTR_FORMAT,
1974 p2i(handler_address), p2i(computed_address));
1975 #endif
1976 }
1977 }
1978
1979 current->set_exception_pc(pc);
1980 current->set_exception_handler_pc(handler_address);
1981 }
1982
1983 // Restore correct return pc. Was saved above.
1984 current->set_exception_oop(exception());
1985 return handler_address;
1986
1987 JRT_END
1988
1989 // We are entering here from exception_blob
1990 // If there is a compiled exception handler in this method, we will continue there;
1991 // otherwise we will unwind the stack and continue at the caller of top frame method
1992 // Note we enter without the usual JRT wrapper. We will call a helper routine that
1993 // will do the normal VM entry. We do it this way so that we can see if the nmethod
1994 // we looked up the handler for has been deoptimized in the meantime. If it has been
1995 // we must not use the handler and instead return the deopt blob.
1996 address OptoRuntime::handle_exception_C(JavaThread* current) {
1997 //
1998 // We are in Java not VM and in debug mode we have a NoHandleMark
1999 //
2000 #ifndef PRODUCT
2001 SharedRuntime::_find_handler_ctr++; // find exception handler
2002 #endif
2003 DEBUG_ONLY(NoHandleMark __hm;)
2004 nmethod* nm = nullptr;
2005 address handler_address = nullptr;
2006 {
2007 // Enter the VM
2008
2009 ResetNoHandleMark rnhm;
2010 handler_address = handle_exception_C_helper(current, nm);
2011 }
2012
2013 // Back in java: Use no oops, DON'T safepoint
2014
2015 // Now check to see if the handler we are returning is in a now
2016 // deoptimized frame
2017
2018 if (nm != nullptr) {
2019 RegisterMap map(current,
2020 RegisterMap::UpdateMap::skip,
2021 RegisterMap::ProcessFrames::skip,
2022 RegisterMap::WalkContinuation::skip);
2023 frame caller = current->last_frame().sender(&map);
2024 #ifdef ASSERT
2025 assert(caller.is_compiled_frame(), "must be");
2026 #endif // ASSERT
2027 if (caller.is_deoptimized_frame()) {
2028 handler_address = SharedRuntime::deopt_blob()->unpack_with_exception();
2029 }
2030 }
2031 return handler_address;
2032 }
2033
2034 //------------------------------rethrow----------------------------------------
2035 // We get here after compiled code has executed a 'RethrowNode'. The callee
2036 // is either throwing or rethrowing an exception. The callee-save registers
2037 // have been restored, synchronized objects have been unlocked and the callee
2038 // stack frame has been removed. The return address was passed in.
2039 // Exception oop is passed as the 1st argument. This routine is then called
2040 // from the stub. On exit, we know where to jump in the caller's code.
2041 // After this C code exits, the stub will pop his frame and end in a jump
2042 // (instead of a return). We enter the caller's default handler.
2043 //
2044 // This must be JRT_LEAF:
2045 // - caller will not change its state as we cannot block on exit,
2046 // therefore raw_exception_handler_for_return_address is all it takes
2047 // to handle deoptimized blobs
2048 //
2049 // However, there needs to be a safepoint check in the middle! So compiled
2050 // safepoints are completely watertight.
2051 //
2052 // Thus, it cannot be a leaf since it contains the NoSafepointVerifier.
2053 //
2054 // *THIS IS NOT RECOMMENDED PROGRAMMING STYLE*
2055 //
2056 address OptoRuntime::rethrow_C(oopDesc* exception, JavaThread* thread, address ret_pc) {
2057 // ret_pc will have been loaded from the stack, so for AArch64 will be signed.
2058 AARCH64_PORT_ONLY(ret_pc = pauth_strip_verifiable(ret_pc));
2059
2060 #ifndef PRODUCT
2061 SharedRuntime::_rethrow_ctr++; // count rethrows
2062 #endif
2063 assert (exception != nullptr, "should have thrown a NullPointerException");
2064 #ifdef ASSERT
2065 if (!(exception->is_a(vmClasses::Throwable_klass()))) {
2066 // should throw an exception here
2067 ShouldNotReachHere();
2068 }
2069 #endif
2070
2071 thread->set_vm_result_oop(exception);
2072 // Frame not compiled (handles deoptimization blob)
2073 return SharedRuntime::raw_exception_handler_for_return_address(thread, ret_pc);
2074 }
2075
2076 static const TypeFunc* make_rethrow_Type() {
2077 // create input type (domain)
2078 const Type **fields = TypeTuple::fields(1);
2079 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Exception oop
2080 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields);
2081
2082 // create result type (range)
2083 fields = TypeTuple::fields(1);
2084 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Exception oop
2085 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
2086
2087 return TypeFunc::make(domain, range);
2088 }
2089
2090
2091 void OptoRuntime::deoptimize_caller_frame(JavaThread *thread, bool doit) {
2092 // Deoptimize the caller before continuing, as the compiled
2093 // exception handler table may not be valid.
2094 if (DeoptimizeOnAllocationException && doit) {
2095 deoptimize_caller_frame(thread);
2096 }
2097 }
2098
2099 void OptoRuntime::deoptimize_caller_frame(JavaThread *thread) {
2100 // Called from within the owner thread, so no need for safepoint
2101 RegisterMap reg_map(thread,
2102 RegisterMap::UpdateMap::include,
2103 RegisterMap::ProcessFrames::include,
2104 RegisterMap::WalkContinuation::skip);
2105 frame stub_frame = thread->last_frame();
2106 assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
2107 frame caller_frame = stub_frame.sender(®_map);
2108
2109 // Deoptimize the caller frame.
2110 Deoptimization::deoptimize_frame(thread, caller_frame.id());
2111 }
2112
2113
2114 bool OptoRuntime::is_deoptimized_caller_frame(JavaThread *thread) {
2115 // Called from within the owner thread, so no need for safepoint
2116 RegisterMap reg_map(thread,
2117 RegisterMap::UpdateMap::include,
2118 RegisterMap::ProcessFrames::include,
2119 RegisterMap::WalkContinuation::skip);
2120 frame stub_frame = thread->last_frame();
2121 assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
2122 frame caller_frame = stub_frame.sender(®_map);
2123 return caller_frame.is_deoptimized_frame();
2124 }
2125
2126 static const TypeFunc* make_register_finalizer_Type() {
2127 // create input type (domain)
2128 const Type **fields = TypeTuple::fields(1);
2129 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // oop; Receiver
2130 // // The JavaThread* is passed to each routine as the last argument
2131 // fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // JavaThread *; Executing thread
2132 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields);
2133
2134 // create result type (range)
2135 fields = TypeTuple::fields(0);
2136
2137 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
2138
2139 return TypeFunc::make(domain,range);
2140 }
2141
2142 const TypeFunc *OptoRuntime::class_init_barrier_Type() {
2143 // create input type (domain)
2144 const Type** fields = TypeTuple::fields(1);
2145 fields[TypeFunc::Parms+0] = TypeKlassPtr::NOTNULL;
2146 // // The JavaThread* is passed to each routine as the last argument
2147 // fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // JavaThread *; Executing thread
2148 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+1, fields);
2149
2150 // create result type (range)
2151 fields = TypeTuple::fields(0);
2152 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
2153 return TypeFunc::make(domain,range);
2154 }
2155
2156 #if INCLUDE_JFR
2157 static const TypeFunc* make_class_id_load_barrier_Type() {
2158 // create input type (domain)
2159 const Type **fields = TypeTuple::fields(1);
2160 fields[TypeFunc::Parms+0] = TypeInstPtr::KLASS;
2161 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms + 1, fields);
2162
2163 // create result type (range)
2164 fields = TypeTuple::fields(0);
2165
2166 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms + 0, fields);
2167
2168 return TypeFunc::make(domain,range);
2169 }
2170 #endif // INCLUDE_JFR
2171
2172 //-----------------------------------------------------------------------------
2173 // runtime upcall support
2174 const TypeFunc *OptoRuntime::runtime_up_call_Type() {
2175 // create input type (domain)
2176 const Type **fields = TypeTuple::fields(1);
2177 fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
2178 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields);
2179
2180 // create result type (range)
2181 fields = TypeTuple::fields(0);
2182
2183 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
2184
2185 return TypeFunc::make(domain,range);
2186 }
2187
2188 //-----------------------------------------------------------------------------
2189 static const TypeFunc* make_dtrace_method_entry_exit_Type() {
2190 // create input type (domain)
2191 const Type **fields = TypeTuple::fields(2);
2192 fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
2193 fields[TypeFunc::Parms+1] = TypeMetadataPtr::BOTTOM; // Method*; Method we are entering
2194 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
2195
2196 // create result type (range)
2197 fields = TypeTuple::fields(0);
2198
2199 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
2200
2201 return TypeFunc::make(domain,range);
2202 }
2203
2204 static const TypeFunc* make_dtrace_object_alloc_Type() {
2205 // create input type (domain)
2206 const Type **fields = TypeTuple::fields(2);
2207 fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
2208 fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL; // oop; newly allocated object
2209
2210 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
2211
2212 // create result type (range)
2213 fields = TypeTuple::fields(0);
2214
2215 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
2216
2217 return TypeFunc::make(domain,range);
2218 }
2219
2220 JRT_ENTRY_NO_ASYNC_PROF(void, OptoRuntime, register_finalizer_C, OptoRuntime::register_finalizer_C(oopDesc* obj, JavaThread* current))
2221 assert(oopDesc::is_oop(obj), "must be a valid oop");
2222 assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
2223 InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
2224 JRT_END
2225
2226 JRT_ENTRY_NO_ASYNC_PROF(void, OptoRuntime, class_init_barrier_C, OptoRuntime::class_init_barrier_C(Klass* k, JavaThread* current))
2227 InstanceKlass* ik = InstanceKlass::cast(k);
2228 if (ik->should_be_initialized()) {
2229 ik->initialize(CHECK);
2230 } else if (UsePerfData) {
2231 _perf_OptoRuntime_class_init_barrier_redundant_count->inc();
2232 }
2233 JRT_END
2234
2235 //-----------------------------------------------------------------------------
2236
2237 NamedCounter * volatile OptoRuntime::_named_counters = nullptr;
2238
2239 //
2240 // dump the collected NamedCounters.
2241 //
2242 void OptoRuntime::print_named_counters() {
2243 int total_lock_count = 0;
2244 int eliminated_lock_count = 0;
2245
2246 NamedCounter* c = _named_counters;
2247 while (c) {
2248 if (c->tag() == NamedCounter::LockCounter || c->tag() == NamedCounter::EliminatedLockCounter) {
2249 int count = c->count();
2250 if (count > 0) {
2251 bool eliminated = c->tag() == NamedCounter::EliminatedLockCounter;
2252 if (Verbose) {
2253 tty->print_cr("%d %s%s", count, c->name(), eliminated ? " (eliminated)" : "");
2254 }
2255 total_lock_count += count;
2256 if (eliminated) {
2257 eliminated_lock_count += count;
2258 }
2259 }
2260 }
2261 c = c->next();
2262 }
2263 if (total_lock_count > 0) {
2264 tty->print_cr("dynamic locks: %d", total_lock_count);
2265 if (eliminated_lock_count) {
2266 tty->print_cr("eliminated locks: %d (%d%%)", eliminated_lock_count,
2267 (int)(eliminated_lock_count * 100.0 / total_lock_count));
2268 }
2269 }
2270 }
2271
2272 //
2273 // Allocate a new NamedCounter. The JVMState is used to generate the
2274 // name which consists of method@line for the inlining tree.
2275 //
2276
2277 NamedCounter* OptoRuntime::new_named_counter(JVMState* youngest_jvms, NamedCounter::CounterTag tag) {
2278 int max_depth = youngest_jvms->depth();
2279
2280 // Visit scopes from youngest to oldest.
2281 bool first = true;
2282 stringStream st;
2283 for (int depth = max_depth; depth >= 1; depth--) {
2284 JVMState* jvms = youngest_jvms->of_depth(depth);
2285 ciMethod* m = jvms->has_method() ? jvms->method() : nullptr;
2286 if (!first) {
2287 st.print(" ");
2288 } else {
2289 first = false;
2290 }
2291 int bci = jvms->bci();
2292 if (bci < 0) bci = 0;
2293 if (m != nullptr) {
2294 st.print("%s.%s", m->holder()->name()->as_utf8(), m->name()->as_utf8());
2295 } else {
2296 st.print("no method");
2297 }
2298 st.print("@%d", bci);
2299 // To print linenumbers instead of bci use: m->line_number_from_bci(bci)
2300 }
2301 NamedCounter* c = new NamedCounter(st.freeze(), tag);
2302
2303 // atomically add the new counter to the head of the list. We only
2304 // add counters so this is safe.
2305 NamedCounter* head;
2306 do {
2307 c->set_next(nullptr);
2308 head = _named_counters;
2309 c->set_next(head);
2310 } while (AtomicAccess::cmpxchg(&_named_counters, head, c) != head);
2311 return c;
2312 }
2313
2314 void OptoRuntime::initialize_types() {
2315 _new_instance_Type = make_new_instance_Type();
2316 _new_array_Type = make_new_array_Type();
2317 _multianewarray2_Type = multianewarray_Type(2);
2318 _multianewarray3_Type = multianewarray_Type(3);
2319 _multianewarray4_Type = multianewarray_Type(4);
2320 _multianewarray5_Type = multianewarray_Type(5);
2321 _multianewarrayN_Type = make_multianewarrayN_Type();
2322 _complete_monitor_enter_Type = make_complete_monitor_enter_Type();
2323 _complete_monitor_exit_Type = make_complete_monitor_exit_Type();
2324 _monitor_notify_Type = make_monitor_notify_Type();
2325 _uncommon_trap_Type = make_uncommon_trap_Type();
2326 _athrow_Type = make_athrow_Type();
2327 _rethrow_Type = make_rethrow_Type();
2328 _Math_D_D_Type = make_Math_D_D_Type();
2329 _Math_DD_D_Type = make_Math_DD_D_Type();
2330 _modf_Type = make_modf_Type();
2331 _l2f_Type = make_l2f_Type();
2332 _void_long_Type = make_void_long_Type();
2333 _void_void_Type = make_void_void_Type();
2334 _jfr_write_checkpoint_Type = make_jfr_write_checkpoint_Type();
2335 _flush_windows_Type = make_flush_windows_Type();
2336 _fast_arraycopy_Type = make_arraycopy_Type(ac_fast);
2337 _checkcast_arraycopy_Type = make_arraycopy_Type(ac_checkcast);
2338 _generic_arraycopy_Type = make_arraycopy_Type(ac_generic);
2339 _slow_arraycopy_Type = make_arraycopy_Type(ac_slow);
2340 _unsafe_setmemory_Type = make_setmemory_Type();
2341 _array_fill_Type = make_array_fill_Type();
2342 _array_sort_Type = make_array_sort_Type();
2343 _array_partition_Type = make_array_partition_Type();
2344 _aescrypt_block_Type = make_aescrypt_block_Type();
2345 _cipherBlockChaining_aescrypt_Type = make_cipherBlockChaining_aescrypt_Type();
2346 _electronicCodeBook_aescrypt_Type = make_electronicCodeBook_aescrypt_Type();
2347 _counterMode_aescrypt_Type = make_counterMode_aescrypt_Type();
2348 _galoisCounterMode_aescrypt_Type = make_galoisCounterMode_aescrypt_Type();
2349 _digestBase_implCompress_with_sha3_Type = make_digestBase_implCompress_Type( /* is_sha3= */ true);
2350 _digestBase_implCompress_without_sha3_Type = make_digestBase_implCompress_Type( /* is_sha3= */ false);;
2351 _digestBase_implCompressMB_with_sha3_Type = make_digestBase_implCompressMB_Type(/* is_sha3= */ true);
2352 _digestBase_implCompressMB_without_sha3_Type = make_digestBase_implCompressMB_Type(/* is_sha3= */ false);
2353 _double_keccak_Type = make_double_keccak_Type();
2354 _multiplyToLen_Type = make_multiplyToLen_Type();
2355 _montgomeryMultiply_Type = make_montgomeryMultiply_Type();
2356 _montgomerySquare_Type = make_montgomerySquare_Type();
2357 _squareToLen_Type = make_squareToLen_Type();
2358 _mulAdd_Type = make_mulAdd_Type();
2359 _bigIntegerShift_Type = make_bigIntegerShift_Type();
2360 _vectorizedMismatch_Type = make_vectorizedMismatch_Type();
2361 _ghash_processBlocks_Type = make_ghash_processBlocks_Type();
2362 _chacha20Block_Type = make_chacha20Block_Type();
2363 _kyberNtt_Type = make_kyberNtt_Type();
2364 _kyberInverseNtt_Type = make_kyberInverseNtt_Type();
2365 _kyberNttMult_Type = make_kyberNttMult_Type();
2366 _kyberAddPoly_2_Type = make_kyberAddPoly_2_Type();
2367 _kyberAddPoly_3_Type = make_kyberAddPoly_3_Type();
2368 _kyber12To16_Type = make_kyber12To16_Type();
2369 _kyberBarrettReduce_Type = make_kyberBarrettReduce_Type();
2370 _dilithiumAlmostNtt_Type = make_dilithiumAlmostNtt_Type();
2371 _dilithiumAlmostInverseNtt_Type = make_dilithiumAlmostInverseNtt_Type();
2372 _dilithiumNttMult_Type = make_dilithiumNttMult_Type();
2373 _dilithiumMontMulByConstant_Type = make_dilithiumMontMulByConstant_Type();
2374 _dilithiumDecomposePoly_Type = make_dilithiumDecomposePoly_Type();
2375 _base64_encodeBlock_Type = make_base64_encodeBlock_Type();
2376 _base64_decodeBlock_Type = make_base64_decodeBlock_Type();
2377 _string_IndexOf_Type = make_string_IndexOf_Type();
2378 _poly1305_processBlocks_Type = make_poly1305_processBlocks_Type();
2379 _intpoly_montgomeryMult_P256_Type = make_intpoly_montgomeryMult_P256_Type();
2380 _intpoly_assign_Type = make_intpoly_assign_Type();
2381 _updateBytesCRC32_Type = make_updateBytesCRC32_Type();
2382 _updateBytesCRC32C_Type = make_updateBytesCRC32C_Type();
2383 _updateBytesAdler32_Type = make_updateBytesAdler32_Type();
2384 _osr_end_Type = make_osr_end_Type();
2385 _register_finalizer_Type = make_register_finalizer_Type();
2386 JFR_ONLY(
2387 _class_id_load_barrier_Type = make_class_id_load_barrier_Type();
2388 )
2389 #if INCLUDE_JVMTI
2390 _notify_jvmti_vthread_Type = make_notify_jvmti_vthread_Type();
2391 #endif // INCLUDE_JVMTI
2392 _dtrace_method_entry_exit_Type = make_dtrace_method_entry_exit_Type();
2393 _dtrace_object_alloc_Type = make_dtrace_object_alloc_Type();
2394 }
2395
2396 int trace_exception_counter = 0;
2397 static void trace_exception(outputStream* st, oop exception_oop, address exception_pc, const char* msg) {
2398 trace_exception_counter++;
2399 stringStream tempst;
2400
2401 tempst.print("%d [Exception (%s): ", trace_exception_counter, msg);
2402 exception_oop->print_value_on(&tempst);
2403 tempst.print(" in ");
2404 CodeBlob* blob = CodeCache::find_blob(exception_pc);
2405 if (blob->is_nmethod()) {
2406 blob->as_nmethod()->method()->print_value_on(&tempst);
2407 } else if (blob->is_runtime_stub()) {
2408 tempst.print("<runtime-stub>");
2409 } else {
2410 tempst.print("<unknown>");
2411 }
2412 tempst.print(" at " INTPTR_FORMAT, p2i(exception_pc));
2413 tempst.print("]");
2414
2415 st->print_raw_cr(tempst.freeze());
2416 }
2417
2418 #define DO_COUNTERS2(macro2, macro1) \
2419 macro2(OptoRuntime, new_instance_C) \
2420 macro2(OptoRuntime, new_array_C) \
2421 macro2(OptoRuntime, new_array_nozero_C) \
2422 macro2(OptoRuntime, multianewarray2_C) \
2423 macro2(OptoRuntime, multianewarray3_C) \
2424 macro2(OptoRuntime, multianewarray4_C) \
2425 macro2(OptoRuntime, multianewarrayN_C) \
2426 macro2(OptoRuntime, monitor_notify_C) \
2427 macro2(OptoRuntime, monitor_notifyAll_C) \
2428 macro2(OptoRuntime, handle_exception_C_helper) \
2429 macro2(OptoRuntime, register_finalizer_C) \
2430 macro2(OptoRuntime, class_init_barrier_C) \
2431 macro1(OptoRuntime, class_init_barrier_redundant)
2432
2433 #define INIT_COUNTER_TIME_AND_CNT(sub, name) \
2434 NEWPERFTICKCOUNTERS(_perf_##sub##_##name##_timer, SUN_CI, #sub "::" #name); \
2435 NEWPERFEVENTCOUNTER(_perf_##sub##_##name##_count, SUN_CI, #sub "::" #name "_count");
2436
2437 #define INIT_COUNTER_CNT(sub, name) \
2438 NEWPERFEVENTCOUNTER(_perf_##sub##_##name##_count, SUN_CI, #sub "::" #name "_count");
2439
2440 void OptoRuntime::init_counters() {
2441 assert(CompilerConfig::is_c2_enabled(), "");
2442
2443 if (UsePerfData) {
2444 EXCEPTION_MARK;
2445
2446 DO_COUNTERS2(INIT_COUNTER_TIME_AND_CNT, INIT_COUNTER_CNT)
2447
2448 if (HAS_PENDING_EXCEPTION) {
2449 vm_exit_during_initialization("jvm_perf_init failed unexpectedly");
2450 }
2451 }
2452 }
2453 #undef INIT_COUNTER_TIME_AND_CNT
2454 #undef INIT_COUNTER_CNT
2455
2456 #define PRINT_COUNTER_TIME_AND_CNT(sub, name) { \
2457 jlong count = _perf_##sub##_##name##_count->get_value(); \
2458 if (count > 0) { \
2459 st->print_cr(" %-50s = " JLONG_FORMAT_W(6) "us (elapsed) " JLONG_FORMAT_W(6) "us (thread) (" JLONG_FORMAT_W(5) " events)", #sub "::" #name, \
2460 _perf_##sub##_##name##_timer->elapsed_counter_value_us(), \
2461 _perf_##sub##_##name##_timer->thread_counter_value_us(), \
2462 count); \
2463 }}
2464
2465 #define PRINT_COUNTER_CNT(sub, name) { \
2466 jlong count = _perf_##sub##_##name##_count->get_value(); \
2467 if (count > 0) { \
2468 st->print_cr(" %-30s = " JLONG_FORMAT_W(5) " events", #name, count); \
2469 }}
2470
2471 void OptoRuntime::print_counters_on(outputStream* st) {
2472 if (UsePerfData && ProfileRuntimeCalls && CompilerConfig::is_c2_enabled()) {
2473 DO_COUNTERS2(PRINT_COUNTER_TIME_AND_CNT, PRINT_COUNTER_CNT)
2474 } else {
2475 st->print_cr(" OptoRuntime: no info (%s is disabled)",
2476 (!CompilerConfig::is_c2_enabled() ? "C2" : (UsePerfData ? "ProfileRuntimeCalls" : "UsePerfData")));
2477 }
2478 }
2479
2480 #undef PRINT_COUNTER_TIME_AND_CNT
2481 #undef PRINT_COUNTER_CNT
2482 #undef DO_COUNTERS2