1 /*
  2  * Copyright (c) 1998, 2026, 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 #ifndef SHARE_OPTO_RUNTIME_HPP
 26 #define SHARE_OPTO_RUNTIME_HPP
 27 
 28 #include "code/codeBlob.hpp"
 29 #include "opto/machnode.hpp"
 30 #include "opto/optoreg.hpp"
 31 #include "runtime/stubDeclarations.hpp"
 32 #include "runtime/stubInfo.hpp"
 33 #include "runtime/vframe.hpp"
 34 
 35 //------------------------------OptoRuntime------------------------------------
 36 // Opto compiler runtime routines
 37 //
 38 // These are all generated from Ideal graphs.  They are called with the
 39 // Java calling convention.  Internally they call C++.  They are made once at
 40 // startup time and Opto compiles calls to them later.
 41 // Things are broken up into quads: the signature they will be called with,
 42 // the address of the generated code, the corresponding C++ code and an
 43 // nmethod.
 44 
 45 // The signature (returned by "xxx_Type()") is used at startup time by the
 46 // Generator to make the generated code "xxx_Java".  Opto compiles calls
 47 // to the generated code "xxx_Java".  When the compiled code gets executed,
 48 // it calls the C++ code "xxx_C".  The generated nmethod is saved in the
 49 // CodeCache.  Exception handlers use the nmethod to get the callee-save
 50 // register OopMaps.
 51 //
 52 // Please ensure the return type of the runtime call matches its signature,
 53 // even if the return value is unused. This is crucial for correct handling
 54 // of runtime calls that return an oop and may trigger deoptimization
 55 // on return. See rematerialize_objects() in deoptimization.cpp.
 56 
 57 class CallInfo;
 58 
 59 //
 60 // NamedCounters are tagged counters which can be used for profiling
 61 // code in various ways.  Currently they are used by the lock coarsening code
 62 //
 63 
 64 class NamedCounter : public CHeapObj<mtCompiler> {
 65 public:
 66     enum CounterTag {
 67     NoTag,
 68     LockCounter,
 69     EliminatedLockCounter
 70   };
 71 
 72 private:
 73   const char *  _name;
 74   int           _count;
 75   CounterTag    _tag;
 76   NamedCounter* _next;
 77 
 78  public:
 79   NamedCounter(const char *n, CounterTag tag = NoTag):
 80     _name(n == nullptr ? nullptr : os::strdup(n)),
 81     _count(0),
 82     _tag(tag),
 83     _next(nullptr) {}
 84 
 85   ~NamedCounter() {
 86     if (_name != nullptr) {
 87       os::free((void*)_name);
 88     }
 89   }
 90 
 91   const char * name() const     { return _name; }
 92   int count() const             { return _count; }
 93   address addr()                { return (address)&_count; }
 94   CounterTag tag() const        { return _tag; }
 95   void set_tag(CounterTag tag)  { _tag = tag; }
 96 
 97   NamedCounter* next() const    { return _next; }
 98   void set_next(NamedCounter* next) {
 99     assert(_next == nullptr || next == nullptr, "already set");
100     _next = next;
101   }
102 
103 };
104 
105 typedef const TypeFunc*(*TypeFunc_generator)();
106 
107 class OptoRuntime : public AllStatic {
108   friend class Matcher;  // allow access to stub names
109   friend class AOTCodeAddressTable;
110 
111  private:
112   // declare opto stub address/blob holder static fields
113 #define C2_BLOB_FIELD_DECLARE(name, type) \
114   static type*       BLOB_FIELD_NAME(name);
115 #define C2_STUB_FIELD_NAME(name) _ ## name ## _Java
116 #define C2_STUB_FIELD_DECLARE(name, f, t, r) \
117   static address     C2_STUB_FIELD_NAME(name) ;
118 
119   C2_STUBS_DO(C2_BLOB_FIELD_DECLARE, C2_STUB_FIELD_DECLARE)
120 
121 #undef C2_BLOB_FIELD_DECLARE
122 #undef C2_STUB_FIELD_NAME
123 #undef C2_STUB_FIELD_DECLARE
124 
125   // static TypeFunc* data members
126   static const TypeFunc* _new_instance_Type;
127   static const TypeFunc* _new_array_Type;
128   static const TypeFunc* _multianewarray2_Type;
129   static const TypeFunc* _multianewarray3_Type;
130   static const TypeFunc* _multianewarray4_Type;
131   static const TypeFunc* _multianewarray5_Type;
132   static const TypeFunc* _multianewarrayN_Type;
133   static const TypeFunc* _complete_monitor_enter_Type;
134   static const TypeFunc* _complete_monitor_exit_Type;
135   static const TypeFunc* _monitor_notify_Type;
136   static const TypeFunc* _uncommon_trap_Type;
137   static const TypeFunc* _athrow_Type;
138   static const TypeFunc* _rethrow_Type;
139   static const TypeFunc* _Math_D_D_Type;
140   static const TypeFunc* _Math_DD_D_Type;
141   static const TypeFunc* _modf_Type;
142   static const TypeFunc* _l2f_Type;
143   static const TypeFunc* _void_long_Type;
144   static const TypeFunc* _void_void_Type;
145   static const TypeFunc* _jfr_write_checkpoint_Type;
146   static const TypeFunc* _flush_windows_Type;
147   static const TypeFunc* _fast_arraycopy_Type;
148   static const TypeFunc* _checkcast_arraycopy_Type;
149   static const TypeFunc* _generic_arraycopy_Type;
150   static const TypeFunc* _slow_arraycopy_Type;
151   static const TypeFunc* _unsafe_setmemory_Type;
152   static const TypeFunc* _array_fill_Type;
153   static const TypeFunc* _array_sort_Type;
154   static const TypeFunc* _array_partition_Type;
155   static const TypeFunc* _aescrypt_block_Type;
156   static const TypeFunc* _cipherBlockChaining_aescrypt_Type;
157   static const TypeFunc* _electronicCodeBook_aescrypt_Type;
158   static const TypeFunc* _counterMode_aescrypt_Type;
159   static const TypeFunc* _galoisCounterMode_aescrypt_Type;
160   static const TypeFunc* _digestBase_implCompress_with_sha3_Type;
161   static const TypeFunc* _digestBase_implCompress_without_sha3_Type;
162   static const TypeFunc* _digestBase_implCompressMB_with_sha3_Type;
163   static const TypeFunc* _digestBase_implCompressMB_without_sha3_Type;
164   static const TypeFunc* _double_keccak_Type;
165   static const TypeFunc* _quad_keccak_Type;
166   static const TypeFunc* _multiplyToLen_Type;
167   static const TypeFunc* _montgomeryMultiply_Type;
168   static const TypeFunc* _montgomerySquare_Type;
169   static const TypeFunc* _squareToLen_Type;
170   static const TypeFunc* _mulAdd_Type;
171   static const TypeFunc* _bigIntegerShift_Type;
172   static const TypeFunc* _vectorizedMismatch_Type;
173   static const TypeFunc* _ghash_processBlocks_Type;
174   static const TypeFunc* _chacha20Block_Type;
175   static const TypeFunc* _kyberNtt_Type;
176   static const TypeFunc* _kyberInverseNtt_Type;
177   static const TypeFunc* _kyberNttMult_Type;
178   static const TypeFunc* _kyberAddPoly_2_Type;
179   static const TypeFunc* _kyberAddPoly_3_Type;
180   static const TypeFunc* _kyber12To16_Type;
181   static const TypeFunc* _kyberBarrettReduce_Type;
182   static const TypeFunc* _dilithiumAlmostNtt_Type;
183   static const TypeFunc* _dilithiumAlmostInverseNtt_Type;
184   static const TypeFunc* _dilithiumNttMult_Type;
185   static const TypeFunc* _dilithiumMontMulByConstant_Type;
186   static const TypeFunc* _dilithiumDecomposePoly_Type;
187   static const TypeFunc* _base64_encodeBlock_Type;
188   static const TypeFunc* _base64_decodeBlock_Type;
189   static const TypeFunc* _string_IndexOf_Type;
190   static const TypeFunc* _poly1305_processBlocks_Type;
191   static const TypeFunc* _intpoly_montgomeryMult_P256_Type;
192   static const TypeFunc* _intpoly_assign_Type;
193   static const TypeFunc* _intpoly_mult_25519_Type;
194   static const TypeFunc* _intpoly_square_25519_Type;
195   static const TypeFunc* _updateBytesCRC32_Type;
196   static const TypeFunc* _updateBytesCRC32C_Type;
197   static const TypeFunc* _updateBytesAdler32_Type;
198   static const TypeFunc* _osr_end_Type;
199   static const TypeFunc* _register_finalizer_Type;
200   static const TypeFunc* _vthread_transition_Type;
201 #if INCLUDE_JFR
202   static const TypeFunc* _class_id_load_barrier_Type;
203 #endif // INCLUDE_JFR
204   static const TypeFunc* _dtrace_method_entry_exit_Type;
205   static const TypeFunc* _dtrace_object_alloc_Type;
206 
207   // define stubs
208   static address generate_stub(ciEnv* ci_env, TypeFunc_generator gen, address C_function, const char* name, StubId stub_id, int is_fancy_jump, bool pass_tls, bool return_pc);
209 
210   //
211   // Implementation of runtime methods
212   // =================================
213 
214   // Allocate storage for a Java instance.
215   static void new_instance_C(Klass* instance_klass, JavaThread* current);
216 
217   // Allocate storage for a objArray or typeArray
218   static void new_array_C(Klass* array_klass, int len, JavaThread* current);
219   static void new_array_nozero_C(Klass* array_klass, int len, JavaThread* current);
220 
221   // Allocate storage for a multi-dimensional arrays
222   // Note: needs to be fixed for arbitrary number of dimensions
223   static void multianewarray2_C(Klass* klass, int len1, int len2, JavaThread* current);
224   static void multianewarray3_C(Klass* klass, int len1, int len2, int len3, JavaThread* current);
225   static void multianewarray4_C(Klass* klass, int len1, int len2, int len3, int len4, JavaThread* current);
226   static void multianewarray5_C(Klass* klass, int len1, int len2, int len3, int len4, int len5, JavaThread* current);
227   static void multianewarrayN_C(Klass* klass, arrayOopDesc* dims, JavaThread* current);
228 
229   // local methods passed as arguments to stub generator that forward
230   // control to corresponding JRT methods of SharedRuntime
231   static void slow_arraycopy_C(oopDesc* src,  jint src_pos,
232                                oopDesc* dest, jint dest_pos,
233                                jint length, JavaThread* thread);
234   static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* current);
235 
236 public:
237   static void monitor_notify_C(oopDesc* obj, JavaThread* current);
238   static void monitor_notifyAll_C(oopDesc* obj, JavaThread* current);
239 
240   static void vthread_end_first_transition_C(oopDesc* vt, jboolean hide, JavaThread* current);
241   static void vthread_start_final_transition_C(oopDesc* vt, jboolean hide, JavaThread* current);
242   static void vthread_start_transition_C(oopDesc* vt, jboolean hide, JavaThread* current);
243   static void vthread_end_transition_C(oopDesc* vt, jboolean hide, JavaThread* current);
244 
245 private:
246 
247   // Implicit exception support
248   static void throw_null_exception_C(JavaThread* thread);
249 
250   // Exception handling
251   static address handle_exception_C       (JavaThread* current);
252   static address handle_exception_C_helper(JavaThread* current, nmethod*& nm);
253   static address rethrow_C                (oopDesc* exception, JavaThread *thread, address return_pc );
254   static void deoptimize_caller_frame     (JavaThread *thread);
255   static void deoptimize_caller_frame     (JavaThread *thread, bool doit);
256   static bool is_deoptimized_caller_frame (JavaThread *thread);
257 
258   // CodeBlob support
259   // ===================================================================
260 
261   static UncommonTrapBlob* generate_uncommon_trap_blob(void);
262   static ExceptionBlob* generate_exception_blob();
263 
264   static void register_finalizer_C(oopDesc* obj, JavaThread* current);
265 
266  public:
267 
268   static bool is_callee_saved_register(MachRegisterNumbers reg);
269 
270   // One time only generate runtime code stubs. Returns true
271   // when runtime stubs have been generated successfully and
272   // false otherwise.
273   static bool generate(ciEnv* env);
274 
275   // Returns the name of a stub
276   static const char* stub_name(address entry);
277 
278   // Returns the name associated with a given stub id
279   static const char* stub_name(StubId id) {
280     assert(StubInfo::is_c2(id), "not a C2 stub %s", StubInfo::name(id));
281     return StubInfo::name(id);
282   }
283 
284   // access to runtime stubs entry points for java code
285   static address new_instance_Java()                     { return _new_instance_Java; }
286   static address new_array_Java()                        { return _new_array_Java; }
287   static address new_array_nozero_Java()                 { return _new_array_nozero_Java; }
288   static address multianewarray2_Java()                  { return _multianewarray2_Java; }
289   static address multianewarray3_Java()                  { return _multianewarray3_Java; }
290   static address multianewarray4_Java()                  { return _multianewarray4_Java; }
291   static address multianewarray5_Java()                  { return _multianewarray5_Java; }
292   static address multianewarrayN_Java()                  { return _multianewarrayN_Java; }
293   static address complete_monitor_locking_Java()         { return _complete_monitor_locking_Java; }
294   static address monitor_notify_Java()                   { return _monitor_notify_Java; }
295   static address monitor_notifyAll_Java()                { return _monitor_notifyAll_Java; }
296 
297   static address slow_arraycopy_Java()                   { return _slow_arraycopy_Java; }
298   static address register_finalizer_Java()               { return _register_finalizer_Java; }
299 
300   static address vthread_end_first_transition_Java()     { return _vthread_end_first_transition_Java; }
301   static address vthread_start_final_transition_Java()   { return _vthread_start_final_transition_Java; }
302   static address vthread_start_transition_Java()         { return _vthread_start_transition_Java; }
303   static address vthread_end_transition_Java()           { return _vthread_end_transition_Java; }
304 
305   static UncommonTrapBlob* uncommon_trap_blob()                  { return _uncommon_trap_blob; }
306   static ExceptionBlob*    exception_blob()                      { return _exception_blob; }
307 
308   // Implicit exception support
309   static void throw_div0_exception_C      (JavaThread* thread);
310   static void throw_stack_overflow_error_C(JavaThread* thread);
311 
312   // Exception handling
313   static address rethrow_stub()             { return _rethrow_Java; }
314 
315 
316   // Type functions
317   // ======================================================
318 
319   static inline const TypeFunc* new_instance_Type() {
320     assert(_new_instance_Type != nullptr, "should be initialized");
321     return _new_instance_Type;
322   }
323 
324   static inline const TypeFunc* new_array_Type() {
325     assert(_new_array_Type != nullptr, "should be initialized");
326     return _new_array_Type;
327   }
328 
329   static inline const TypeFunc* new_array_nozero_Type() {
330     return new_array_Type();
331   }
332 
333   static const TypeFunc* multianewarray_Type(int ndim); // multianewarray
334 
335   static inline const TypeFunc* multianewarray2_Type() {
336     assert(_multianewarray2_Type != nullptr, "should be initialized");
337     return _multianewarray2_Type;
338   }
339 
340   static inline const TypeFunc* multianewarray3_Type() {
341     assert(_multianewarray3_Type != nullptr, "should be initialized");
342     return _multianewarray3_Type;
343   }
344 
345   static inline const TypeFunc* multianewarray4_Type() {
346     assert(_multianewarray4_Type != nullptr, "should be initialized");
347     return _multianewarray4_Type;
348   }
349 
350   static inline const TypeFunc* multianewarray5_Type() {
351     assert(_multianewarray5_Type != nullptr, "should be initialized");
352     return _multianewarray5_Type;
353   }
354 
355   static inline const TypeFunc* multianewarrayN_Type() {
356     assert(_multianewarrayN_Type != nullptr, "should be initialized");
357     return _multianewarrayN_Type;
358   }
359 
360   static inline const TypeFunc* complete_monitor_enter_Type() {
361     assert(_complete_monitor_enter_Type != nullptr, "should be initialized");
362     return _complete_monitor_enter_Type;
363   }
364 
365   static inline const TypeFunc* complete_monitor_locking_Type() {
366     return complete_monitor_enter_Type();
367   }
368 
369   static inline const TypeFunc* complete_monitor_exit_Type() {
370     assert(_complete_monitor_exit_Type != nullptr, "should be initialized");
371     return _complete_monitor_exit_Type;
372   }
373 
374   static inline const TypeFunc* monitor_notify_Type() {
375     assert(_monitor_notify_Type != nullptr, "should be initialized");
376     return _monitor_notify_Type;
377   }
378 
379   static inline const TypeFunc* monitor_notifyAll_Type() {
380     return monitor_notify_Type();
381   }
382 
383   static inline const TypeFunc* uncommon_trap_Type() {
384     assert(_uncommon_trap_Type != nullptr, "should be initialized");
385     return _uncommon_trap_Type;
386   }
387 
388   static inline const TypeFunc* athrow_Type() {
389     assert(_athrow_Type != nullptr, "should be initialized");
390     return _athrow_Type;
391   }
392 
393   static inline const TypeFunc* rethrow_Type() {
394     assert(_rethrow_Type != nullptr, "should be initialized");
395     return _rethrow_Type;
396   }
397 
398   static inline const TypeFunc* Math_D_D_Type() {
399     assert(_Math_D_D_Type != nullptr, "should be initialized");
400     return _Math_D_D_Type;
401   }
402 
403   static inline const TypeFunc* Math_DD_D_Type() {
404     assert(_Math_DD_D_Type != nullptr, "should be initialized");
405     return _Math_DD_D_Type;
406   }
407 
408   static const TypeFunc* Math_Vector_Vector_Type(uint num_arg, const TypeVect* in_type, const TypeVect* out_type);
409 
410   static inline const TypeFunc* modf_Type() {
411     assert(_modf_Type != nullptr, "should be initialized");
412     return _modf_Type;
413   }
414 
415   static inline const TypeFunc* l2f_Type() {
416     assert(_l2f_Type != nullptr, "should be initialized");
417     return _l2f_Type;
418   }
419 
420   static inline const TypeFunc* void_long_Type() {
421     assert(_void_long_Type != nullptr, "should be initialized");
422     return _void_long_Type;
423   }
424 
425   static inline const TypeFunc* void_void_Type() {
426     assert(_void_void_Type != nullptr, "should be initialized");
427     return _void_void_Type;
428   }
429 
430   static const TypeFunc* jfr_write_checkpoint_Type() {
431     assert(_jfr_write_checkpoint_Type != nullptr, "should be initialized");
432     return _jfr_write_checkpoint_Type;
433   }
434 
435   static const TypeFunc* flush_windows_Type() {
436     assert(_flush_windows_Type != nullptr, "should be initialized");
437     return _flush_windows_Type;
438   }
439 
440   // arraycopy routine types
441   static inline const TypeFunc* fast_arraycopy_Type() {
442     assert(_fast_arraycopy_Type != nullptr, "should be initialized");
443     // This signature is simple:  Two base pointers and a size_t.
444     return _fast_arraycopy_Type;
445   }
446 
447   static inline const TypeFunc* checkcast_arraycopy_Type() {
448     assert(_checkcast_arraycopy_Type != nullptr, "should be initialized");
449     // An extension of fast_arraycopy_Type which adds type checking.
450     return _checkcast_arraycopy_Type;
451   }
452 
453   static inline const TypeFunc* generic_arraycopy_Type() {
454     assert(_generic_arraycopy_Type != nullptr, "should be initialized");
455     // This signature is like System.arraycopy, except that it returns status.
456     return _generic_arraycopy_Type;
457   }
458 
459   static inline const TypeFunc* slow_arraycopy_Type() {
460     assert(_slow_arraycopy_Type != nullptr, "should be initialized");
461     // This signature is exactly the same as System.arraycopy.
462     // There are no intptr_t (int/long) arguments.
463     return _slow_arraycopy_Type;
464   }   // the full routine
465 
466   static inline const TypeFunc* unsafe_setmemory_Type() {
467     assert(_unsafe_setmemory_Type != nullptr, "should be initialized");
468     return _unsafe_setmemory_Type;
469   }
470 
471 //  static const TypeFunc* digestBase_implCompress_Type(bool is_sha3);
472 //  static const TypeFunc* digestBase_implCompressMB_Type(bool is_sha3);
473 //  static const TypeFunc* double_keccak_Type();
474 
475   static inline const TypeFunc* array_fill_Type() {
476     assert(_array_fill_Type != nullptr, "should be initialized");
477     return _array_fill_Type;
478   }
479 
480   static inline const TypeFunc* array_sort_Type() {
481     assert(_array_sort_Type != nullptr, "should be initialized");
482     return _array_sort_Type;
483   }
484 
485   static inline const TypeFunc* array_partition_Type() {
486     assert(_array_partition_Type != nullptr, "should be initialized");
487     return _array_partition_Type;
488   }
489 
490   // for aescrypt encrypt/decrypt operations, just three pointers returning void (length is constant)
491   static inline const TypeFunc* aescrypt_block_Type() {
492     assert(_aescrypt_block_Type != nullptr, "should be initialized");
493     return _aescrypt_block_Type;
494   }
495 
496   // for cipherBlockChaining calls of aescrypt encrypt/decrypt, four pointers and a length, returning int
497   static inline const TypeFunc* cipherBlockChaining_aescrypt_Type() {
498     assert(_cipherBlockChaining_aescrypt_Type != nullptr, "should be initialized");
499     return _cipherBlockChaining_aescrypt_Type;
500   }
501 
502   // for electronicCodeBook calls of aescrypt encrypt/decrypt, three pointers and a length, returning int
503   static inline const TypeFunc* electronicCodeBook_aescrypt_Type() {
504     assert(_electronicCodeBook_aescrypt_Type != nullptr, "should be initialized");
505     return _electronicCodeBook_aescrypt_Type;
506   }
507 
508   //for counterMode calls of aescrypt encrypt/decrypt, four pointers and a length, returning int
509   static inline const TypeFunc* counterMode_aescrypt_Type() {
510     assert(_counterMode_aescrypt_Type != nullptr, "should be initialized");
511     return _counterMode_aescrypt_Type;
512   }
513 
514   //for counterMode calls of aescrypt encrypt/decrypt, four pointers and a length, returning int
515   static inline const TypeFunc* galoisCounterMode_aescrypt_Type() {
516     assert(_galoisCounterMode_aescrypt_Type != nullptr, "should be initialized");
517     return _galoisCounterMode_aescrypt_Type;
518   }
519 
520   /*
521    * void implCompress(byte[] buf, int ofs)
522    */
523   static inline const TypeFunc* digestBase_implCompress_Type(bool is_sha3) {
524     assert((_digestBase_implCompress_with_sha3_Type != nullptr) &&
525            (_digestBase_implCompress_without_sha3_Type != nullptr), "should be initialized");
526     return is_sha3 ? _digestBase_implCompress_with_sha3_Type : _digestBase_implCompress_without_sha3_Type;
527   }
528 
529   /*
530    * int implCompressMultiBlock(byte[] b, int ofs, int limit)
531    */
532   static inline const TypeFunc* digestBase_implCompressMB_Type(bool is_sha3) {
533     assert((_digestBase_implCompressMB_with_sha3_Type != nullptr) &&
534            (_digestBase_implCompressMB_without_sha3_Type != nullptr), "should be initialized");
535     return is_sha3 ? _digestBase_implCompressMB_with_sha3_Type : _digestBase_implCompressMB_without_sha3_Type;
536   }
537 
538   static inline const TypeFunc* double_keccak_Type() {
539     assert(_double_keccak_Type != nullptr, "should be initialized");
540     return _double_keccak_Type;
541   }
542 
543   static inline const TypeFunc* quad_keccak_Type() {
544     assert(_quad_keccak_Type != nullptr, "should be initialized");
545     return _quad_keccak_Type;
546   }
547 
548   static inline const TypeFunc* multiplyToLen_Type() {
549     assert(_multiplyToLen_Type != nullptr, "should be initialized");
550     return _multiplyToLen_Type;
551   }
552 
553   static inline const TypeFunc* montgomeryMultiply_Type() {
554     assert(_montgomeryMultiply_Type != nullptr, "should be initialized");
555     return _montgomeryMultiply_Type;
556   }
557 
558   static inline const TypeFunc* montgomerySquare_Type() {
559     assert(_montgomerySquare_Type != nullptr, "should be initialized");
560     return _montgomerySquare_Type;
561   }
562 
563   static inline const TypeFunc* squareToLen_Type() {
564     assert(_squareToLen_Type != nullptr, "should be initialized");
565     return _squareToLen_Type;
566   }
567 
568   // for mulAdd calls, 2 pointers and 3 ints, returning int
569   static inline const TypeFunc* mulAdd_Type() {
570     assert(_mulAdd_Type != nullptr, "should be initialized");
571     return _mulAdd_Type;
572   }
573 
574   static inline const TypeFunc* bigIntegerShift_Type() {
575     assert(_bigIntegerShift_Type != nullptr, "should be initialized");
576     return _bigIntegerShift_Type;
577   }
578 
579   static inline const TypeFunc* vectorizedMismatch_Type() {
580     assert(_vectorizedMismatch_Type != nullptr, "should be initialized");
581     return _vectorizedMismatch_Type;
582   }
583 
584   // GHASH block processing
585   static inline const TypeFunc* ghash_processBlocks_Type() {
586     assert(_ghash_processBlocks_Type != nullptr, "should be initialized");
587     return _ghash_processBlocks_Type;
588   }
589 
590   // ChaCha20 Block function
591   static inline const TypeFunc* chacha20Block_Type() {
592     assert(_chacha20Block_Type != nullptr, "should be initialized");
593     return _chacha20Block_Type;
594   }
595 
596   static inline const TypeFunc* kyberNtt_Type() {
597     assert(_kyberNtt_Type != nullptr, "should be initialized");
598     return _kyberNtt_Type;
599   }
600 
601   static inline const TypeFunc* kyberInverseNtt_Type() {
602     assert(_kyberInverseNtt_Type != nullptr, "should be initialized");
603     return _kyberInverseNtt_Type;
604   }
605 
606   static inline const TypeFunc* kyberNttMult_Type() {
607     assert(_kyberNttMult_Type != nullptr, "should be initialized");
608     return _kyberNttMult_Type;
609   }
610 
611   static inline const TypeFunc* kyberAddPoly_2_Type() {
612     assert(_kyberAddPoly_2_Type != nullptr, "should be initialized");
613     return _kyberAddPoly_2_Type;
614   }
615 
616   static inline const TypeFunc* kyberAddPoly_3_Type() {
617     assert(_kyberAddPoly_3_Type != nullptr, "should be initialized");
618     return _kyberAddPoly_3_Type;
619   }
620 
621   static inline const TypeFunc* kyber12To16_Type() {
622     assert(_kyber12To16_Type != nullptr, "should be initialized");
623     return _kyber12To16_Type;
624   }
625 
626   static inline const TypeFunc* kyberBarrettReduce_Type() {
627     assert(_kyberBarrettReduce_Type != nullptr, "should be initialized");
628     return _kyberBarrettReduce_Type;
629   }
630 
631   static inline const TypeFunc* dilithiumAlmostNtt_Type() {
632     assert(_dilithiumAlmostNtt_Type != nullptr, "should be initialized");
633     return _dilithiumAlmostNtt_Type;
634   }
635 
636   static inline const TypeFunc* dilithiumAlmostInverseNtt_Type() {
637     assert(_dilithiumAlmostInverseNtt_Type != nullptr, "should be initialized");
638     return _dilithiumAlmostInverseNtt_Type;
639   }
640 
641   static inline const TypeFunc* dilithiumNttMult_Type() {
642     assert(_dilithiumNttMult_Type != nullptr, "should be initialized");
643     return _dilithiumNttMult_Type;
644   }
645 
646   static inline const TypeFunc* dilithiumMontMulByConstant_Type() {
647     assert(_dilithiumMontMulByConstant_Type != nullptr, "should be initialized");
648     return _dilithiumMontMulByConstant_Type;
649   }
650 
651   static inline const TypeFunc* dilithiumDecomposePoly_Type() {
652     assert(_dilithiumDecomposePoly_Type != nullptr, "should be initialized");
653     return _dilithiumDecomposePoly_Type;
654   }
655 
656   // Base64 encode function
657   static inline const TypeFunc* base64_encodeBlock_Type() {
658     assert(_base64_encodeBlock_Type != nullptr, "should be initialized");
659     return _base64_encodeBlock_Type;
660   }
661 
662   // Base64 decode function
663   static inline const TypeFunc* base64_decodeBlock_Type() {
664     assert(_base64_decodeBlock_Type != nullptr, "should be initialized");
665     return _base64_decodeBlock_Type;
666   }
667 
668   // String IndexOf function
669   static inline const TypeFunc* string_IndexOf_Type() {
670     assert(_string_IndexOf_Type != nullptr, "should be initialized");
671     return _string_IndexOf_Type;
672   }
673 
674   // Poly1305 processMultipleBlocks function
675   static inline const TypeFunc* poly1305_processBlocks_Type() {
676     assert(_poly1305_processBlocks_Type != nullptr, "should be initialized");
677     return _poly1305_processBlocks_Type;
678   }
679 
680   // MontgomeryIntegerPolynomialP256 multiply function
681   static inline const TypeFunc* intpoly_montgomeryMult_P256_Type() {
682     assert(_intpoly_montgomeryMult_P256_Type != nullptr, "should be initialized");
683     return _intpoly_montgomeryMult_P256_Type;
684   }
685 
686   // IntegerPolynomial constant time assignment function
687   static inline const TypeFunc* intpoly_assign_Type() {
688     assert(_intpoly_assign_Type != nullptr, "should be initialized");
689     return _intpoly_assign_Type;
690   }
691 
692   // IntegerPolynomial25519 multiply function
693   static inline const TypeFunc* intpoly_mult_25519_Type() {
694     assert(_intpoly_mult_25519_Type != nullptr, "should be initialized");
695     return _intpoly_mult_25519_Type;
696   }
697 
698   // IntegerPolynomial25519 square function
699   static inline const TypeFunc* intpoly_square_25519_Type() {
700     assert(_intpoly_square_25519_Type != nullptr, "should be initialized");
701     return _intpoly_square_25519_Type;
702   }
703 
704   /**
705    * int updateBytesCRC32(int crc, byte* b, int len)
706    */
707   static inline const TypeFunc* updateBytesCRC32_Type() {
708     assert(_updateBytesCRC32_Type != nullptr, "should be initialized");
709     return _updateBytesCRC32_Type;
710   }
711 
712   /**
713    * int updateBytesCRC32C(int crc, byte* buf, int len, int* table)
714    */
715   static inline const TypeFunc* updateBytesCRC32C_Type() {
716     assert(_updateBytesCRC32C_Type != nullptr, "should be initialized");
717     return _updateBytesCRC32C_Type;
718   }
719 
720   /**
721    *  int updateBytesAdler32(int adler, bytes* b, int off, int len)
722    */
723   static inline const TypeFunc* updateBytesAdler32_Type() {
724     assert(_updateBytesAdler32_Type != nullptr, "should be initialized");
725     return _updateBytesAdler32_Type;
726   }
727 
728 
729   // leaf on stack replacement interpreter accessor types
730   static inline const TypeFunc* osr_end_Type() {
731     assert(_osr_end_Type != nullptr, "should be initialized");
732     return _osr_end_Type;
733   }
734 
735   static inline const TypeFunc* register_finalizer_Type() {
736     assert(_register_finalizer_Type != nullptr, "should be initialized");
737     return _register_finalizer_Type;
738   }
739 
740   static inline const TypeFunc* vthread_transition_Type() {
741     assert(_vthread_transition_Type != nullptr, "should be initialized");
742     return _vthread_transition_Type;
743   }
744 
745   static inline const TypeFunc* vthread_end_first_transition_Type() {
746     return vthread_transition_Type();
747   }
748 
749   static inline const TypeFunc* vthread_start_final_transition_Type() {
750     return vthread_transition_Type();
751   }
752 
753   static inline const TypeFunc* vthread_start_transition_Type() {
754     return vthread_transition_Type();
755   }
756 
757   static inline const TypeFunc* vthread_end_transition_Type() {
758     return vthread_transition_Type();
759   }
760 
761 #if INCLUDE_JFR
762   static inline const TypeFunc* class_id_load_barrier_Type() {
763     assert(_class_id_load_barrier_Type != nullptr, "should be initialized");
764     return _class_id_load_barrier_Type;
765   }
766 #endif // INCLUDE_JFR
767 
768   // Dtrace support. entry and exit probes have the same signature
769   static inline const TypeFunc* dtrace_method_entry_exit_Type() {
770     assert(_dtrace_method_entry_exit_Type != nullptr, "should be initialized");
771     return _dtrace_method_entry_exit_Type;
772   }
773 
774   static inline const TypeFunc* dtrace_object_alloc_Type() {
775     assert(_dtrace_object_alloc_Type != nullptr, "should be initialized");
776     return _dtrace_object_alloc_Type;
777   }
778 
779 #ifndef PRODUCT
780   // Signature for runtime calls in debug printing nodes, which depends on which nodes are actually passed
781   // Note: we do not allow more than 7 node arguments as GraphKit::make_runtime_call only allows 8, and we need
782   // one for the static string
783   static const TypeFunc* debug_print_Type(Node* parm0 = nullptr, Node* parm1 = nullptr,
784                                           Node* parm2 = nullptr, Node* parm3 = nullptr,
785                                           Node* parm4 = nullptr, Node* parm5 = nullptr,
786                                           Node* parm6 = nullptr);
787 #endif // PRODUCT
788 
789  private:
790  static NamedCounter * volatile _named_counters;
791 
792  public:
793  // helper function which creates a named counter labeled with the
794  // if they are available
795  static NamedCounter* new_named_counter(JVMState* jvms, NamedCounter::CounterTag tag);
796 
797  // dumps all the named counters
798  static void          print_named_counters();
799 
800  static void          initialize_types();
801 };
802 
803 #endif // SHARE_OPTO_RUNTIME_HPP