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