1 /*
   2  * Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2025, Red Hat, Inc. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #ifndef SHARE_RUNTIME_STUBDECLARATIONS_HPP
  27 #define SHARE_RUNTIME_STUBDECLARATIONS_HPP
  28 
  29 #include "code/codeBlob.hpp"
  30 #include "oops/klass.hpp"
  31 #include "utilities/macros.hpp"
  32 
  33 // Macros for generating definitions and declarations for shared, c1,
  34 // opto and stubgen blobs and associated stub and entry ids.
  35 //
  36 // The template macros that follow define blobs, stubs and entries in
  37 // each stub group. Invocations of the macros with different macro
  38 // arguments can be used to generate definitions and declarations of
  39 // types, data and methods/functions which support blob, stub and
  40 // entry management.
  41 //
  42 // In particular, they are used to generate 3 global enums that list
  43 // all blobs, stubs and entries across stub groups. They are also used
  44 // to generate local (per-stub group) enums listing every stub in the
  45 // group. The former are provided ot allow systematic management of
  46 // blobs, stubs and entries by generic code. The latter are used by
  47 // code which generates and consumes stubs in a specific group. An API
  48 // is provided to convert between global and local ids where needed
  49 // (see class StubInfo).
  50 
  51 // Shared stub declarations
  52 //
  53 // Every shared stub has a unique associated blob whose type must be
  54 // defined as part of the stub declaration. The blob type determines
  55 // how many entries are associated with the stub, normally 1. A build
  56 // may optionally include some JFR stubs.
  57 //
  58 // n.b resolve, handler and throw stubs must remain grouped
  59 // contiguously and in the same order so that id values can be range
  60 // checked
  61 //
  62 // Alongside the global and local enums, shared declations are used to
  63 // generate the following code elements in class SharedRuntime:
  64 //
  65 // Shared Stub blob fields
  66 //
  67 // Static field declarations/definitons for fields of class
  68 // SharedRuntime are generated to store shared blobs
  69 //
  70 // static <blobtype>* _<stubname>;
  71 //
  72 // Shared stub field names
  73 //
  74 // Stubs are provided with names in the format "Shared Runtime
  75 // <stubname> _blob".
  76 //
  77 
  78 #if INCLUDE_JFR
  79 // do_blob(name, type)
  80 #define SHARED_JFR_STUBS_DO(do_blob)                                   \
  81   do_blob(jfr_write_checkpoint, RuntimeStub)                           \
  82   do_blob(jfr_return_lease, RuntimeStub)                               \
  83 
  84 #else
  85 #define SHARED_JFR_STUBS_DO(do_blob)
  86 #endif
  87 
  88 // client macro to operate on shared stubs
  89 //
  90 // do_blob(name, type)
  91 #define SHARED_STUBS_DO(do_blob)                                       \
  92   do_blob(deopt, DeoptimizationBlob)                                   \
  93   /* resolve stubs */                                                  \
  94   do_blob(wrong_method, RuntimeStub)                                   \
  95   do_blob(wrong_method_abstract, RuntimeStub)                          \
  96   do_blob(ic_miss, RuntimeStub)                                        \
  97   do_blob(resolve_opt_virtual_call, RuntimeStub)                       \
  98   do_blob(resolve_virtual_call, RuntimeStub)                           \
  99   do_blob(resolve_static_call, RuntimeStub)                            \
 100   /* handler stubs */                                                  \
 101   do_blob(polling_page_vectors_safepoint_handler, SafepointBlob)       \
 102   do_blob(polling_page_safepoint_handler, SafepointBlob)               \
 103   do_blob(polling_page_return_handler, SafepointBlob)                  \
 104   /* throw stubs */                                                    \
 105   do_blob(throw_AbstractMethodError, RuntimeStub)                      \
 106   do_blob(throw_IncompatibleClassChangeError, RuntimeStub)             \
 107   do_blob(throw_NullPointerException_at_call, RuntimeStub)             \
 108   do_blob(throw_StackOverflowError, RuntimeStub)                       \
 109   do_blob(throw_delayed_StackOverflowError, RuntimeStub)               \
 110   /* shenandoah stubs */                                               \
 111   do_blob(shenandoah_keepalive_none, RuntimeStub)                      \
 112   do_blob(shenandoah_lrb_strong_narrow_none, RuntimeStub)              \
 113   do_blob(shenandoah_lrb_weak_narrow_none, RuntimeStub)                \
 114   do_blob(shenandoah_lrb_phantom_narrow_none, RuntimeStub)             \
 115   do_blob(shenandoah_lrb_strong_none, RuntimeStub)                     \
 116   do_blob(shenandoah_lrb_weak_none, RuntimeStub)                       \
 117   do_blob(shenandoah_lrb_phantom_none, RuntimeStub)                    \
 118   do_blob(shenandoah_keepalive_gp, RuntimeStub)                        \
 119   do_blob(shenandoah_lrb_strong_narrow_gp, RuntimeStub)                \
 120   do_blob(shenandoah_lrb_weak_narrow_gp, RuntimeStub)                  \
 121   do_blob(shenandoah_lrb_phantom_narrow_gp, RuntimeStub)               \
 122   do_blob(shenandoah_lrb_strong_gp, RuntimeStub)                       \
 123   do_blob(shenandoah_lrb_weak_gp, RuntimeStub)                         \
 124   do_blob(shenandoah_lrb_phantom_gp, RuntimeStub)                      \
 125   do_blob(shenandoah_keepalive_all, RuntimeStub)                       \
 126   do_blob(shenandoah_lrb_strong_narrow_all, RuntimeStub)               \
 127   do_blob(shenandoah_lrb_weak_narrow_all, RuntimeStub)                 \
 128   do_blob(shenandoah_lrb_phantom_narrow_all, RuntimeStub)              \
 129   do_blob(shenandoah_lrb_strong_all, RuntimeStub)                      \
 130   do_blob(shenandoah_lrb_weak_all, RuntimeStub)                        \
 131   do_blob(shenandoah_lrb_phantom_all, RuntimeStub)                     \
 132   /* other stubs */                                                    \
 133   SHARED_JFR_STUBS_DO(do_blob)                                         \
 134 
 135 // C1 stub declarations
 136 //
 137 // C1 stubs are always generated in a unique associated generic
 138 // CodeBlob with a single entry. C1 stubs are stored in an array
 139 // indexed by local enum. So, no other code elements need to be
 140 // generated via this macro.
 141 
 142 #ifdef COMPILER1
 143 // client macro to operate on c1 stubs
 144 //
 145 // do_blob(name)
 146 #define C1_STUBS_DO(do_blob)                                           \
 147   do_blob(dtrace_object_alloc)                                         \
 148   do_blob(unwind_exception)                                            \
 149   do_blob(forward_exception)                                           \
 150   do_blob(throw_range_check_failed)       /* throws ArrayIndexOutOfBoundsException */ \
 151   do_blob(throw_index_exception)          /* throws IndexOutOfBoundsException */ \
 152   do_blob(throw_div0_exception)                                        \
 153   do_blob(throw_null_pointer_exception)                                \
 154   do_blob(register_finalizer)                                          \
 155   do_blob(new_instance)                                                \
 156   do_blob(fast_new_instance)                                           \
 157   do_blob(fast_new_instance_init_check)                                \
 158   do_blob(new_type_array)                                              \
 159   do_blob(new_object_array)                                            \
 160   do_blob(new_multi_array)                                             \
 161   do_blob(handle_exception_nofpu)         /* optimized version that does not preserve fpu registers */ \
 162   do_blob(handle_exception)                                            \
 163   do_blob(handle_exception_from_callee)                                \
 164   do_blob(throw_array_store_exception)                                 \
 165   do_blob(throw_class_cast_exception)                                  \
 166   do_blob(throw_incompatible_class_change_error)                       \
 167   do_blob(slow_subtype_check)                                          \
 168   do_blob(is_instance_of)                                              \
 169   do_blob(monitorenter)                                                \
 170   do_blob(monitorenter_nofpu)             /* optimized version that does not preserve fpu registers */ \
 171   do_blob(monitorexit)                                                 \
 172   do_blob(monitorexit_nofpu)              /* optimized version that does not preserve fpu registers */ \
 173   do_blob(deoptimize)                                                  \
 174   do_blob(access_field_patching)                                       \
 175   do_blob(load_klass_patching)                                         \
 176   do_blob(load_mirror_patching)                                        \
 177   do_blob(load_appendix_patching)                                      \
 178   do_blob(fpu2long_stub)                                               \
 179   do_blob(counter_overflow)                                            \
 180   do_blob(predicate_failed_trap)                                       \
 181 
 182 #else
 183 #define C1_STUBS_DO(do_blob)
 184 #endif
 185 
 186 // C2 stub declarations
 187 //
 188 // C2 stubs are always generated in a unique associated generic
 189 // CodeBlob and have a single entry. In some cases, including JVMTI
 190 // stubs, a standard code blob is employed and only the stub entry
 191 // address is retained. In others a specialized code blob with
 192 // stub-specific properties (e.g. frame size) is required so the blob
 193 // address needs to be stored. In these latter cases the declaration
 194 // includes the relevant storage type.
 195 //
 196 // n.b. blob and stub enum tags are generated in the order defined by
 197 // C2_STUBS_DO, allowing dependencies from any givem stub on its
 198 // predecessors to be guaranteed. That explains the initial placement
 199 // of the blob declarations and intermediate placement of the jvmti
 200 // stubs.
 201 //
 202 // Alongside the local and global enums, C2 declarations are used to
 203 // generate several elements of class OptoRuntime.
 204 //
 205 // C2 Stub blob/address fields
 206 //
 207 // Static field declarations/definitions for fields of class
 208 // OptoRuntime are generated to store either C2 blob or C2 blob entry
 209 // addresses:
 210 //
 211 // static <blobtype>* _<stubname>_Java;
 212 // static address _<stubname>;
 213 //
 214 // C2 stub blob/field names
 215 //
 216 // C2 stubs are provided with names in the format "<stubname>_blob (C2 runtime)".
 217 //
 218 // A stub creation method OptoRuntime::generate(ciEnv* env) is
 219 // generated which invokes the C2 compiler to generate each stub in
 220 // declaration order.
 221 
 222 #ifdef COMPILER2
 223 // client macro to operate on c2 stubs
 224 //
 225 // do_blob(name, type)
 226 // do_stub(name, fancy_jump, pass_tls, return_pc)
 227 //
 228 // do_blob is used for stubs that are generated via direct invocation
 229 // of the assembler to write into a blob of the appropriate type
 230 //
 231 // do_stub is used for stubs that are generated as C2 compiler IR
 232 // intrinsics, using the supplied arguments to determine wheher nodes
 233 // in the IR graph employ a special type of jump (0, 1 or 2) or
 234 // provide access to TLS and the return pc.
 235 //
 236 
 237 #define C2_STUBS_DO(do_blob, do_stub)                                  \
 238   do_blob(uncommon_trap, UncommonTrapBlob)                             \
 239   do_blob(exception, ExceptionBlob)                                    \
 240   do_stub(new_instance, 0, true, false)                                \
 241   do_stub(new_array, 0, true, false)                                   \
 242   do_stub(new_array_nozero, 0, true, false)                            \
 243   do_stub(multianewarray2, 0, true, false)                             \
 244   do_stub(multianewarray3, 0, true, false)                             \
 245   do_stub(multianewarray4, 0, true, false)                             \
 246   do_stub(multianewarray5, 0, true, false)                             \
 247   do_stub(multianewarrayN, 0, true, false)                             \
 248   do_stub(complete_monitor_locking, 0, false, false)                   \
 249   do_stub(monitor_notify, 0, false, false)                             \
 250   do_stub(monitor_notifyAll, 0, false, false)                          \
 251   do_stub(rethrow, 2, true, true)                                      \
 252   do_stub(slow_arraycopy, 0, false, false)                             \
 253   do_stub(register_finalizer, 0, false, false)                         \
 254   do_stub(vthread_end_first_transition, 0, false, false)               \
 255   do_stub(vthread_start_final_transition, 0, false, false)             \
 256   do_stub(vthread_start_transition, 0, false, false)                   \
 257   do_stub(vthread_end_transition, 0, false, false)                     \
 258 
 259 #else
 260 #define C2_STUBS_DO(do_blob, do_stub)
 261 #endif
 262 
 263 // Stubgen stub declarations
 264 //
 265 // Stub Generator Blobs, Stubs and Entries Overview
 266 //
 267 // StubGenerator stubs do not require their own individual blob. They
 268 // are generated in batches into one of five distinct BufferBlobs:
 269 //
 270 // 1) PreUniverse stubs
 271 // 2) Initial stubs
 272 // 3) Continuation stubs
 273 // 4) Compiler stubs
 274 // 5) Final stubs
 275 //
 276 // Most StubGen stubs have a single entry point. However, in some
 277 // cases there are additional entry points.
 278 //
 279 // Creation of each successive BufferBlob is staged to ensure that
 280 // specific VM subsystems required by those stubs are suitably
 281 // initialized before generated code attempts to reference data or
 282 // addresses exported by those subsystems. The sequencing of
 283 // initialization must be taken into account when adding a new stub
 284 // declaration.
 285 //
 286 // StubGen blobs, stubs and entries are declared using template
 287 // macros, grouped hierarchically by blob and stub, with arch-specific
 288 // stubs for any given blob declared after generic stubs for that
 289 // blob. Stub declarations must follow the blob start (do_blob)
 290 // declaration for their containing blob. Entry declarations must
 291 // follow the the stub start (do_stub) declaration for their
 292 // containing stub.
 293 //
 294 // Blob and stub declarations are used to generate a variety of C++
 295 // code elements needed to manage stubs, including the global and
 296 // local blob, stub and entry enum types mentioned above. The blob
 297 // declaration order must reflect the order in which blob create
 298 // operations are invoked during startup. Stubs within a blob are
 299 // currently generated in an order determined by the arch-specific
 300 // generator code which may not always reflect the order of stub
 301 // declarations (it is not straightforward to enforce a strict
 302 // ordering, not least because arch-specific stub creation may need to
 303 // be interleaved with generic stub creation).
 304 //
 305 // Alongside the global enums, the stubgen declarations are used to
 306 // define the following elements of class StubRoutines:
 307 //
 308 // Stub names and associated getters:
 309 //
 310 // Name strings are generated for each blob where a blob declared with
 311 // name argument <blob_name> will be named using string "<blob_name>".
 312 //
 313 // Name strings are also generated for each stub where a stub declared
 314 // with name argument <stub_name> will be named using string
 315 // "<stub_name>".
 316 //
 317 // Corresponding public static lookup methods are generated to allow
 318 // names to be looked up by blob or global stub id.
 319 //
 320 //  const char* StubRoutines::get_blob_name(BlobId id)
 321 //  const char* StubRoutines::get_stub_name(StubId id)
 322 //
 323 // These name lookup methods should be used by generic and
 324 // cpu-specific client code to ensure that blobs and stubs are
 325 // identified consistently.
 326 //
 327 // Blob code buffer sizes:
 328 //
 329 // An enumeration enum platform_dependent_constants is generated in
 330 // the architecture specific StubRoutines header. For each blob named
 331 // <nnn> an associated enum tag is generated which defines the
 332 // relevant size
 333 //
 334 //  _<nnn>_stubs_code_size      = <size>,
 335 //
 336 // For example,
 337 //
 338 // enum platform_dependent_constants {
 339 //   _preuniverse_stubs_code_size  =   500,
 340 //   _initial_stubs_code_size      = 10000,
 341 //   _continuation_stubs_code_size =  2000,
 342 //   . . .
 343 //
 344 // Blob fields and associated getters:
 345 //
 346 // For each blob named <nnn> a private field declaration will be
 347 // generated: static field address StubRoutines::_<nnn>_stubs_code and
 348 // a declaration provided to initialise it to nullptr. A corresponding
 349 // public getter method address StubRoutines::_<nnn>_stubs_code() will
 350 // be generated.
 351 //
 352 // Blob initialization routines:
 353 //
 354 // For each blob named <nnn> an initalization function is defined
 355 // which allows clients to schedule blob and stub generation during
 356 // JVM bootstrap:
 357 //
 358 // void <nnn>_stubs_init() { StubRoutines::initialize_<nnn>_stubs(); }
 359 //
 360 // A declaration and definition of each underlying implementation
 361 // method StubRoutines::initialize_<nnn>_stubs() is also generated.
 362 //
 363 // Stub entry points and associated getters:
 364 //
 365 // Some generated stubs require their main entry point and, possibly,
 366 // auxiliary entry points to be stored in fields declared either as
 367 // members of class SharedRuntime. For stubs that are specific to a
 368 // given cpu, the field needs to be declared in an arch-specific inner
 369 // class of SharedRuntime.
 370 //
 371 // For a generic stub named <nnn> the corresponding main entry usually
 372 // has the same name: static field address StubRoutines::_<nnn> modulo
 373 // an _ prefix.  An associated getter method is also generated, again
 374 // normally using the same name: address StubRoutines::<nnn>() e.g.
 375 //
 376 //  class StubRoutines {
 377 //    . . .
 378 //    static address _aescrypt_encryptBlock;
 379 //    . . .
 380 //    address aescrypt_encryptBlock() { return _aescrypt_encryptBlock; }
 381 //
 382 // Multiple fields and getters may be generated where a stub has more
 383 // than one entry point, each provided with their own unique field and
 384 // getter name e.g.
 385 //
 386 //    . . .
 387 //    static address _call_stub;
 388 //    static address _call_stub_return_address;
 389 //    . . .
 390 //    static address call_stub_entry() { return _call_stub; }
 391 //    static address call_stub_return_address() { return _call_stub_return_address; }
 392 //
 393 // In special cases a stub may declare a (compile-time) fixed size
 394 // array of entries, in which case an address array field is
 395 // generated,along with a getter that accepts an index as argument:
 396 //
 397 //    . . .
 398 //   static address _lookup_secondary_supers_table[Klass::SECONDARY_SUPERS_TABLE_SIZE];
 399 //   . . .
 400 //   static address lookup_secondary_supers_table(int i);
 401 //
 402 // CPU-specific stub entry points and associated getters:
 403 //
 404 // For an arch-specific stub with name <nnn> belonging to architecture
 405 // <arch> private field address StubRoutines::<arch>::_<nnn> is
 406 // generated to hold the entry address. An associated public getter
 407 // method address StubRoutines::<arch>::<nnn>() is also generated e.g.
 408 //
 409 //  class StubRoutines {
 410 //    . . .
 411 //    class x86 {
 412 //      . . .
 413 //      static address _f2i_fixup;
 414 //      . . .
 415 //      static address f2i_fixup() { return _f2i_fixup; }
 416 //      static void set_f2i_fixup(address a) { _f2i_fixup = a; }
 417 //
 418 
 419 //--------------------------------------------------
 420 // Stub Generator Blob, Stub and Entry Declarations
 421 // -------------------------------------------------
 422 //
 423 // The formal declarations of blobs, stubs and entries provided below
 424 // are used to schedule application of template macros that either
 425 // declare or define the C++ code we need to manage those blobs, stubs
 426 // and entries.
 427 //
 428 // All ports employ the same blobs. However, the organization of the
 429 // stubs and entry points in a blob can vary from one port to the
 430 // next. A template macro is provided to specify the details of each
 431 // blob, including generic and arch-specific variations.
 432 //
 433 // If you want to define a new stub or entry then you can do so by
 434 // adding suitable declarations within the scope of the relevant blob.
 435 // For the blob with name BLOB_NAME add your declarations to macro
 436 // STUBGEN_<BLOB_NAME>_STUBS_DO. Generic stubs and entries are
 437 // declared using the do_stub, do_entry and do_entry_init and
 438 // array_entry templates (see below for full details). The do_blob
 439 // and end_blob templates should never need to be modified.
 440 //
 441 // Some stubs and their associated entries are architecture-specific.
 442 // They need to be declared in the architecture-specific header file
 443 // src/cpu/<arch>stubDecolaration_<arch>.cpp. For the blob with name
 444 // BLOB_NAME the correspnding declarations macro are provided by macro
 445 // STUBGEN_<BLOB_NAME>_STUBS_ARCH_DO. Arch-specific stubs and entries
 446 // are declared using the do_stub, do_arch_entry and
 447 // do_arch_entry_init templates (see below for details). An
 448 // architecure also needs to specify architecture parameters used when
 449 // creating each blob. These are defined using the do_arch_blob
 450 // template (see below).
 451 //
 452 // Note, the client macro STUBGEN_ALL_DO is provided to allow client
 453 // code to iterate over all blob, stub or entry declarations. It has
 454 // only been split into separate per-blob generic submacros,
 455 // STUBGEN_<BLOB_NAME>_BLOBS_DO and arch-specific per-blob submacros
 456 // STUBGEN_<BLOB_NAME>_BLOBS_ARCH_DO for convenience, to make it
 457 // easier to manage definitions. The blob_specific sub-macros should
 458 // not be called directly by client code (in class StubRoutines and
 459 // StubGenerator),
 460 //
 461 // A client wishing to generate blob, stub or entry code elements is
 462 // expected to pass template macros as arguments to STUBGEN_ALL_DO.
 463 // This will schedule code generation code for whatever C++ code
 464 // elements are required to implement a declaration or definition
 465 // relevant to each blob, stub or entry. Alternatively, a client can
 466 // operate on a subset of the declarations by calling macros
 467 // STUBGEN_BLOBS_DO, STUBGEN_STUBS_DO, STUBGEN_BLOBS_STUBS_DO,
 468 // STUBGEN_ENTRIES_DO and STUBGEN_ARCH_ENTRIES_DO.
 469 //
 470 // The do_blob and end_blob templates receive a blob name as argument.
 471 //
 472 // do_blob(blob_name)
 473 // end_blob(blob_name)
 474 //
 475 // do_blob is primarily used to define a global enum tag for a blob
 476 // and an associated constant string name, both for use by client
 477 // code.
 478 //
 479 // end_blob is provided for use in combination with do_blob to to open
 480 // and close a blob-local enum type identifying all stubs within a
 481 // given blob. This enum is private to the stub management code and
 482 // used to validate correct use of stubs within a given blob.
 483 //
 484 // The do_stub template receives a blob name and stub name as
 485 // argument.
 486 //
 487 // do_stub(blob_name, stub_name)
 488 //
 489 // do_stub is primarily used to define values associated with the stub
 490 // wiht name stub_name, a global enum tag for it and a constant string
 491 // name, both for use by client code. It is also used to declare a tag
 492 // within the blob-local enum type used to validate correct use of
 493 // stubs within their declared blob. Finally, it is also used to
 494 // declare a name string for the stub.
 495 //
 496 // The do_entry and do_entry_array templates receive 4 or 5 arguments
 497 //
 498 // do_entry(blob_name, stub_name, field_name, getter_name)
 499 //
 500 // do_entry_init(blob_name, stub_name, field_name, getter_name, init_function)
 501 //
 502 // do_entry_array(blob_name, stub_name, field_name, getter_name, count)
 503 //
 504 // do_entry is used to declare or define a static field of class
 505 // StubRoutines with type address that stores a specific entry point
 506 // for a given stub. n.b. the number of entries associated with a stub
 507 // is often one but it can be more than one and, in a few special
 508 // cases, it is zero. do_entry is also used to declare and define an
 509 // associated getter method for the field. do_entry is used to declare
 510 // fields that should be initialized to nullptr.
 511 //
 512 // do_entry_init is used when the field needs to be initialized a
 513 // specific function or method .
 514 //
 515 // do_entry_array is used for the special case where a stub employs an
 516 // array to store multiple entries which are stored at generate time
 517 // and subsequently accessed using an associated index (e.g. the
 518 // secondary supers table stub which has 63 qassociated entries).
 519 // Note that this distinct from the case where a stub generates
 520 // multiple entries each of them stored in its own named field with
 521 // its own named getter. In the latter case multiple do_entry or
 522 // do_entry_init declarations are associated with the stub.
 523 //
 524 // All the above entry macros are used to declare enum tages that
 525 // identify the entry. Three different enums are generated via these
 526 // macros: a per-stub enum that indexes and provides a count for the
 527 // entries associated with the owning stub; a per-blob enume that
 528 // indexes and provides a count for the entries associated with the
 529 // owning blob; and a global enum that indexes and provides a count
 530 // for all entries associated with generated stubs.
 531 //
 532 // blob_name and stub_name are the names of the blob and stub to which
 533 // the entry belongs.
 534 //
 535 // field_name is prefixed with a leading '_' to produce the name of
 536 // the field used to store an entry address for the stub. For stubs
 537 // with one entry field_name is normally, but not always, the same as
 538 // stub_name.  Obviously when a stub has multiple entries secondary
 539 // names must be different to stub_name. For normal entry declarations
 540 // the field type is address. For do_entry_array declarations the field
 541 // type is an address[] whose size is defined by then parameter.
 542 //
 543 // getter_name is the name of a getter that is generated to allow
 544 // access to the field. It is normally, but not always, the same as
 545 // stub_name. For normal entry declarations the getter signature is
 546 // (void).  For do_entry_array declarations the getter signature is
 547 // (int).
 548 //
 549 // init_function is the name of an function or method which should be
 550 // assigned to the field as a default value (n.b. fields declared
 551 // using do_entry are intialised to nullptr, array fields declared
 552 // using do_entry_array have their elements initalized to nullptr).
 553 //
 554 // Architecture-specific blob details need to be specified using the
 555 // do_arch_blob template
 556 //
 557 // do_arch_blob(blob_name, size)
 558 //
 559 // Currently, the do_arch_blob macro is only used to define the size
 560 // of the code buffer into which blob-specific stub code is to be
 561 // generated.
 562 //
 563 // Architecture-specific entries need to be declared using the
 564 // do_arch_entry template
 565 //
 566 // do_arch_entry(arch, blob_name, stub_name, field_name, getter_name)
 567 //
 568 // do_arch_entry_init(arch, blob_name, stub_name, field_name,
 569 //                    getter_name, init_function)
 570 //
 571 // The only difference between these templates and the generic ones is
 572 // that they receive an extra argument which identifies the current
 573 // architecture e.g. x86, aarch64 etc.
 574 //
 575 // Currently there is no support for a do_arch_array_entry template.
 576 
 577 // Include arch-specific stub and entry declarations and make sure the
 578 // relevant template macros have been defined
 579 
 580 #include CPU_HEADER(stubDeclarations)
 581 
 582 #ifndef STUBGEN_PREUNIVERSE_BLOBS_ARCH_DO
 583 #error "Arch-specific directory failed to declare required initial stubs and entries"
 584 #endif
 585 
 586 #ifndef STUBGEN_INITIAL_BLOBS_ARCH_DO
 587 #error "Arch-specific directory failed to declare required initial stubs and entries"
 588 #endif
 589 
 590 #ifndef STUBGEN_CONTINUATION_BLOBS_ARCH_DO
 591 #error "Arch-specific directory failed to declare required continuation stubs and entries"
 592 #endif
 593 
 594 #ifndef STUBGEN_COMPILER_BLOBS_ARCH_DO
 595 #error "Arch-specific directory failed to declare required compiler stubs and entries"
 596 #endif
 597 
 598 #ifndef STUBGEN_FINAL_BLOBS_ARCH_DO
 599 #error "Arch-specific directory failed to declare required final stubs and entries"
 600 #endif
 601 
 602 // Iterator macros to apply templates to all relevant blobs, stubs and
 603 // entries. Clients should use STUBGEN_ALL_DO, STUBGEN_BLOBS_DO,
 604 // STUBGEN_STUBS_DO, STUBGEN_BLOBS_STUBS_DO, STUBGEN_ENTRIES_DO,
 605 // STUBGEN_ARCH_BLOBS_DO and STUBGEN_ARCH_ENTRIES_DO.
 606 //
 607 // n.b. Client macros appear after the STUBGEN_<BLOB_NAME>_BLOBS_DO
 608 // submacros which follow next. These submacros are not intended to be
 609 // called directly. They serve to define the main client macro
 610 // STUBGEN_ALL_DO and, from there, the other more specific client
 611 // macros. n.b. multiple, 'per-blob' submacros are used to declare
 612 // each group of stubs and entries, because that makes it simpler to
 613 // lookup and update related elements. If you need to update these
 614 // submacros to change the list of stubs or entries be sure to locate
 615 // stubs within the correct blob and locate entry declarations
 616 // immediately after their associated stub declaration.
 617 
 618 #define STUBGEN_PREUNIVERSE_BLOBS_DO(do_blob, end_blob,                 \
 619                                      do_stub,                           \
 620                                      do_entry, do_entry_init,           \
 621                                      do_entry_array,                    \
 622                                      do_arch_blob,                      \
 623                                      do_arch_entry, do_arch_entry_init) \
 624   do_blob(preuniverse)                                                  \
 625   do_stub(preuniverse, fence)                                           \
 626   do_entry(preuniverse, fence, fence_entry, fence_entry)                \
 627   do_stub(preuniverse, atomic_add)                                      \
 628   do_entry(preuniverse, atomic_add, atomic_add_entry, atomic_add_entry) \
 629   do_stub(preuniverse, atomic_xchg)                                     \
 630   do_entry(preuniverse, atomic_xchg, atomic_xchg_entry,                 \
 631            atomic_xchg_entry)                                           \
 632   do_stub(preuniverse, atomic_cmpxchg)                                  \
 633   do_entry(preuniverse, atomic_cmpxchg, atomic_cmpxchg_entry,           \
 634            atomic_cmpxchg_entry)                                        \
 635   do_stub(preuniverse, atomic_cmpxchg_long)                             \
 636   do_entry(preuniverse, atomic_cmpxchg_long, atomic_cmpxchg_long_entry, \
 637            atomic_cmpxchg_long_entry)                                   \
 638   /* merge in stubs and entries declared in arch header */              \
 639   STUBGEN_PREUNIVERSE_BLOBS_ARCH_DO(do_stub, do_arch_blob,              \
 640                                     do_arch_entry, do_arch_entry_init)  \
 641   end_blob(preuniverse)                                                 \
 642 
 643 #define STUBGEN_INITIAL_BLOBS_DO(do_blob, end_blob,                     \
 644                                  do_stub,                               \
 645                                  do_entry, do_entry_init,               \
 646                                  do_entry_array,                        \
 647                                  do_arch_blob,                          \
 648                                  do_arch_entry, do_arch_entry_init)     \
 649   do_blob(initial)                                                      \
 650   do_stub(initial, call_stub)                                           \
 651   do_entry(initial, call_stub, call_stub_entry, call_stub_entry)        \
 652   do_entry(initial, call_stub, call_stub_return_address,                \
 653            call_stub_return_address)                                    \
 654   do_stub(initial, forward_exception)                                   \
 655   do_entry(initial, forward_exception, forward_exception_entry,         \
 656            forward_exception_entry)                                     \
 657   do_stub(initial, catch_exception)                                     \
 658   do_entry(initial, catch_exception, catch_exception_entry,             \
 659            catch_exception_entry)                                       \
 660   do_stub(initial, updateBytesCRC32)                                    \
 661   do_entry(initial, updateBytesCRC32, updateBytesCRC32,                 \
 662            updateBytesCRC32)                                            \
 663   do_stub(initial, updateBytesCRC32C)                                   \
 664   do_entry(initial, updateBytesCRC32C, updateBytesCRC32C,               \
 665            updateBytesCRC32C)                                           \
 666   do_stub(initial, f2hf)                                                \
 667   do_entry(initial, f2hf, f2hf, f2hf_adr)                               \
 668   do_stub(initial, hf2f)                                                \
 669   do_entry(initial, hf2f, hf2f, hf2f_adr)                               \
 670   do_stub(initial, dexp)                                                \
 671   do_entry(initial, dexp, dexp, dexp)                                   \
 672   do_stub(initial, dlog)                                                \
 673   do_entry(initial, dlog, dlog, dlog)                                   \
 674   do_stub(initial, dlog10)                                              \
 675   do_entry(initial, dlog10, dlog10, dlog10)                             \
 676   do_stub(initial, dpow)                                                \
 677   do_entry(initial, dpow, dpow, dpow)                                   \
 678   do_stub(initial, dsin)                                                \
 679   do_entry(initial, dsin, dsin, dsin)                                   \
 680   do_stub(initial, dcos)                                                \
 681   do_entry(initial, dcos, dcos, dcos)                                   \
 682   do_stub(initial, dtan)                                                \
 683   do_entry(initial, dtan, dtan, dtan)                                   \
 684   do_stub(initial, dsinh)                                               \
 685   do_entry(initial, dsinh, dsinh, dsinh)                                \
 686   do_stub(initial, dtanh)                                               \
 687   do_entry(initial, dtanh, dtanh, dtanh)                                \
 688   do_stub(initial, dcbrt)                                               \
 689   do_entry(initial, dcbrt, dcbrt, dcbrt)                                \
 690   do_stub(initial, fmod)                                                \
 691   do_entry(initial, fmod, fmod, fmod)                                   \
 692   /* merge in stubs and entries declared in arch header */              \
 693   STUBGEN_INITIAL_BLOBS_ARCH_DO(do_stub, do_arch_blob,                  \
 694                                 do_arch_entry, do_arch_entry_init)      \
 695   end_blob(initial)                                                     \
 696 
 697 
 698 #define STUBGEN_CONTINUATION_BLOBS_DO(do_blob, end_blob,                \
 699                                       do_stub,                          \
 700                                       do_entry, do_entry_init,          \
 701                                       do_entry_array,                   \
 702                                       do_arch_blob,                     \
 703                                       do_arch_entry,                    \
 704                                       do_arch_entry_init)               \
 705   do_blob(continuation)                                                 \
 706   do_stub(continuation, cont_thaw)                                      \
 707   do_entry(continuation, cont_thaw, cont_thaw, cont_thaw)               \
 708   do_stub(continuation, cont_preempt)                                   \
 709   do_entry(continuation, cont_preempt, cont_preempt_stub,               \
 710            cont_preempt_stub)                                           \
 711   do_stub(continuation, cont_returnBarrier)                             \
 712   do_entry(continuation, cont_returnBarrier, cont_returnBarrier,        \
 713            cont_returnBarrier)                                          \
 714   do_stub(continuation, cont_returnBarrierExc)                          \
 715   do_entry(continuation, cont_returnBarrierExc, cont_returnBarrierExc,  \
 716            cont_returnBarrierExc)                                       \
 717   /* merge in stubs and entries declared in arch header */              \
 718   STUBGEN_CONTINUATION_BLOBS_ARCH_DO(do_stub, do_arch_blob,             \
 719                                      do_arch_entry, do_arch_entry_init) \
 720   end_blob(continuation)                                                \
 721 
 722 
 723 #define STUBGEN_COMPILER_BLOBS_DO(do_blob, end_blob,                    \
 724                                   do_stub,                              \
 725                                   do_entry, do_entry_init,              \
 726                                   do_entry_array,                       \
 727                                   do_arch_blob,                         \
 728                                   do_arch_entry, do_arch_entry_init)    \
 729   do_blob(compiler)                                                     \
 730   do_stub(compiler, array_sort)                                         \
 731   do_entry(compiler, array_sort, array_sort, select_arraysort_function) \
 732   do_stub(compiler, array_partition)                                    \
 733   do_entry(compiler, array_partition, array_partition,                  \
 734            select_array_partition_function)                             \
 735   do_stub(compiler, aescrypt_encryptBlock)                              \
 736   do_entry(compiler, aescrypt_encryptBlock, aescrypt_encryptBlock,      \
 737            aescrypt_encryptBlock)                                       \
 738   do_stub(compiler, aescrypt_decryptBlock)                              \
 739   do_entry(compiler, aescrypt_decryptBlock, aescrypt_decryptBlock,      \
 740            aescrypt_decryptBlock)                                       \
 741   do_stub(compiler, cipherBlockChaining_encryptAESCrypt)                \
 742   do_entry(compiler, cipherBlockChaining_encryptAESCrypt,               \
 743            cipherBlockChaining_encryptAESCrypt,                         \
 744            cipherBlockChaining_encryptAESCrypt)                         \
 745   do_stub(compiler, cipherBlockChaining_decryptAESCrypt)                \
 746   do_entry(compiler, cipherBlockChaining_decryptAESCrypt,               \
 747            cipherBlockChaining_decryptAESCrypt,                         \
 748            cipherBlockChaining_decryptAESCrypt)                         \
 749   do_stub(compiler, electronicCodeBook_encryptAESCrypt)                 \
 750   do_entry(compiler, electronicCodeBook_encryptAESCrypt,                \
 751            electronicCodeBook_encryptAESCrypt,                          \
 752            electronicCodeBook_encryptAESCrypt)                          \
 753   do_stub(compiler, electronicCodeBook_decryptAESCrypt)                 \
 754   do_entry(compiler, electronicCodeBook_decryptAESCrypt,                \
 755            electronicCodeBook_decryptAESCrypt,                          \
 756            electronicCodeBook_decryptAESCrypt)                          \
 757   do_stub(compiler, counterMode_AESCrypt)                               \
 758   do_entry(compiler, counterMode_AESCrypt, counterMode_AESCrypt,        \
 759            counterMode_AESCrypt)                                        \
 760   do_stub(compiler, galoisCounterMode_AESCrypt)                         \
 761   do_entry(compiler, galoisCounterMode_AESCrypt,                        \
 762            galoisCounterMode_AESCrypt, galoisCounterMode_AESCrypt)      \
 763   do_stub(compiler, ghash_processBlocks)                                \
 764   do_entry(compiler, ghash_processBlocks, ghash_processBlocks,          \
 765            ghash_processBlocks)                                         \
 766   do_stub(compiler, chacha20Block)                                      \
 767   do_entry(compiler, chacha20Block, chacha20Block, chacha20Block)       \
 768   do_stub(compiler, kyberNtt)                                           \
 769   do_entry(compiler, kyberNtt, kyberNtt, kyberNtt)                      \
 770   do_stub(compiler, kyberInverseNtt)                                    \
 771   do_entry(compiler, kyberInverseNtt, kyberInverseNtt, kyberInverseNtt) \
 772   do_stub(compiler, kyberNttMult)                                       \
 773   do_entry(compiler, kyberNttMult, kyberNttMult, kyberNttMult)          \
 774   do_stub(compiler, kyberAddPoly_2)                                     \
 775   do_entry(compiler, kyberAddPoly_2, kyberAddPoly_2, kyberAddPoly_2)    \
 776   do_stub(compiler, kyberAddPoly_3)                                     \
 777   do_entry(compiler, kyberAddPoly_3, kyberAddPoly_3, kyberAddPoly_3)    \
 778   do_stub(compiler, kyber12To16)                                        \
 779   do_entry(compiler, kyber12To16, kyber12To16, kyber12To16)             \
 780   do_stub(compiler, kyberBarrettReduce)                                 \
 781   do_entry(compiler, kyberBarrettReduce, kyberBarrettReduce,            \
 782            kyberBarrettReduce)                                          \
 783   do_stub(compiler, dilithiumAlmostNtt)                                 \
 784   do_entry(compiler, dilithiumAlmostNtt,                                \
 785            dilithiumAlmostNtt, dilithiumAlmostNtt)                      \
 786   do_stub(compiler, dilithiumAlmostInverseNtt)                          \
 787   do_entry(compiler, dilithiumAlmostInverseNtt,                         \
 788            dilithiumAlmostInverseNtt, dilithiumAlmostInverseNtt)        \
 789   do_stub(compiler, dilithiumNttMult)                                   \
 790   do_entry(compiler, dilithiumNttMult,                                  \
 791            dilithiumNttMult, dilithiumNttMult)                          \
 792   do_stub(compiler, dilithiumMontMulByConstant)                         \
 793   do_entry(compiler, dilithiumMontMulByConstant,                        \
 794            dilithiumMontMulByConstant, dilithiumMontMulByConstant)      \
 795   do_stub(compiler, dilithiumDecomposePoly)                             \
 796   do_entry(compiler, dilithiumDecomposePoly,                            \
 797            dilithiumDecomposePoly, dilithiumDecomposePoly)              \
 798   do_stub(compiler, data_cache_writeback)                               \
 799   do_entry(compiler, data_cache_writeback, data_cache_writeback,        \
 800            data_cache_writeback)                                        \
 801   do_stub(compiler, data_cache_writeback_sync)                          \
 802   do_entry(compiler, data_cache_writeback_sync,                         \
 803            data_cache_writeback_sync, data_cache_writeback_sync)        \
 804   do_stub(compiler, base64_encodeBlock)                                 \
 805   do_entry(compiler, base64_encodeBlock, base64_encodeBlock,            \
 806            base64_encodeBlock)                                          \
 807   do_stub(compiler, base64_decodeBlock)                                 \
 808   do_entry(compiler, base64_decodeBlock, base64_decodeBlock,            \
 809            base64_decodeBlock)                                          \
 810   do_stub(compiler, poly1305_processBlocks)                             \
 811   do_entry(compiler, poly1305_processBlocks, poly1305_processBlocks,    \
 812            poly1305_processBlocks)                                      \
 813   do_stub(compiler, intpoly_montgomeryMult_P256)                        \
 814   do_entry(compiler, intpoly_montgomeryMult_P256,                       \
 815            intpoly_montgomeryMult_P256, intpoly_montgomeryMult_P256)    \
 816   do_stub(compiler, intpoly_assign)                                     \
 817   do_entry(compiler, intpoly_assign, intpoly_assign, intpoly_assign)    \
 818   do_stub(compiler, md5_implCompress)                                   \
 819   do_entry(compiler, md5_implCompress, md5_implCompress,                \
 820            md5_implCompress)                                            \
 821   do_stub(compiler, md5_implCompressMB)                                 \
 822   do_entry(compiler, md5_implCompressMB, md5_implCompressMB,            \
 823            md5_implCompressMB)                                          \
 824   do_stub(compiler, sha1_implCompress)                                  \
 825   do_entry(compiler, sha1_implCompress, sha1_implCompress,              \
 826            sha1_implCompress)                                           \
 827   do_stub(compiler, sha1_implCompressMB)                                \
 828   do_entry(compiler, sha1_implCompressMB, sha1_implCompressMB,          \
 829            sha1_implCompressMB)                                         \
 830   do_stub(compiler, sha256_implCompress)                                \
 831   do_entry(compiler, sha256_implCompress, sha256_implCompress,          \
 832            sha256_implCompress)                                         \
 833   do_stub(compiler, sha256_implCompressMB)                              \
 834   do_entry(compiler, sha256_implCompressMB, sha256_implCompressMB,      \
 835            sha256_implCompressMB)                                       \
 836   do_stub(compiler, sha512_implCompress)                                \
 837   do_entry(compiler, sha512_implCompress, sha512_implCompress,          \
 838            sha512_implCompress)                                         \
 839   do_stub(compiler, sha512_implCompressMB)                              \
 840   do_entry(compiler, sha512_implCompressMB, sha512_implCompressMB,      \
 841            sha512_implCompressMB)                                       \
 842   do_stub(compiler, sha3_implCompress)                                  \
 843   do_entry(compiler, sha3_implCompress, sha3_implCompress,              \
 844            sha3_implCompress)                                           \
 845   do_stub(compiler, double_keccak)                                      \
 846   do_entry(compiler, double_keccak, double_keccak, double_keccak)       \
 847   do_stub(compiler, sha3_implCompressMB)                                \
 848   do_entry(compiler, sha3_implCompressMB, sha3_implCompressMB,          \
 849            sha3_implCompressMB)                                         \
 850   do_stub(compiler, updateBytesAdler32)                                 \
 851   do_entry(compiler, updateBytesAdler32, updateBytesAdler32,            \
 852            updateBytesAdler32)                                          \
 853   do_stub(compiler, multiplyToLen)                                      \
 854   do_entry(compiler, multiplyToLen, multiplyToLen, multiplyToLen)       \
 855   do_stub(compiler, squareToLen)                                        \
 856   do_entry(compiler, squareToLen, squareToLen, squareToLen)             \
 857   do_stub(compiler, mulAdd)                                             \
 858   do_entry(compiler, mulAdd, mulAdd, mulAdd)                            \
 859   do_stub(compiler, montgomeryMultiply)                                 \
 860   do_entry(compiler, montgomeryMultiply, montgomeryMultiply,            \
 861            montgomeryMultiply)                                          \
 862   do_stub(compiler, montgomerySquare)                                   \
 863   do_entry(compiler, montgomerySquare, montgomerySquare,                \
 864            montgomerySquare)                                            \
 865   do_stub(compiler, bigIntegerRightShiftWorker)                         \
 866   do_entry(compiler, bigIntegerRightShiftWorker,                        \
 867            bigIntegerRightShiftWorker, bigIntegerRightShift)            \
 868   do_stub(compiler, bigIntegerLeftShiftWorker)                          \
 869   do_entry(compiler, bigIntegerLeftShiftWorker,                         \
 870            bigIntegerLeftShiftWorker, bigIntegerLeftShift)              \
 871   /* merge in stubs and entries declared in arch header */              \
 872   STUBGEN_COMPILER_BLOBS_ARCH_DO(do_stub, do_arch_blob,                 \
 873                                      do_arch_entry, do_arch_entry_init) \
 874   end_blob(compiler)                                                    \
 875 
 876 
 877 #define STUBGEN_FINAL_BLOBS_DO(do_blob, end_blob,                       \
 878                                do_stub,                                 \
 879                                do_entry, do_entry_init,                 \
 880                                do_entry_array,                          \
 881                                do_arch_blob,                            \
 882                                do_arch_entry, do_arch_entry_init)       \
 883   do_blob(final)                                                        \
 884   do_stub(final, verify_oop)                                            \
 885   do_entry(final, verify_oop, verify_oop_subroutine_entry,              \
 886            verify_oop_subroutine_entry)                                 \
 887   do_stub(final, unsafecopy_common)                                     \
 888   do_entry(final, unsafecopy_common, unsafecopy_common_exit,            \
 889            unsafecopy_common_exit)                                      \
 890   do_stub(final, jbyte_arraycopy)                                       \
 891   do_entry_init(final, jbyte_arraycopy, jbyte_arraycopy,                \
 892                 jbyte_arraycopy, StubRoutines::jbyte_copy)              \
 893   do_entry(final, jbyte_arraycopy, jbyte_arraycopy_nopush,              \
 894             jbyte_arraycopy_nopush)                                     \
 895   do_stub(final, jshort_arraycopy)                                      \
 896   do_entry_init(final, jshort_arraycopy, jshort_arraycopy,              \
 897                 jshort_arraycopy, StubRoutines::jshort_copy)            \
 898   do_entry(final, jshort_arraycopy, jshort_arraycopy_nopush,            \
 899             jshort_arraycopy_nopush)                                    \
 900   do_stub(final, jint_arraycopy)                                        \
 901   do_entry_init(final, jint_arraycopy, jint_arraycopy,                  \
 902                 jint_arraycopy, StubRoutines::jint_copy)                \
 903   do_entry(final, jint_arraycopy, jint_arraycopy_nopush,                \
 904             jint_arraycopy_nopush)                                      \
 905   do_stub(final, jlong_arraycopy)                                       \
 906   do_entry_init(final, jlong_arraycopy, jlong_arraycopy,                \
 907                 jlong_arraycopy, StubRoutines::jlong_copy)              \
 908   do_entry(final, jlong_arraycopy, jlong_arraycopy_nopush,              \
 909             jlong_arraycopy_nopush)                                     \
 910   do_stub(final, oop_arraycopy)                                         \
 911   do_entry_init(final, oop_arraycopy, oop_arraycopy,                    \
 912                 oop_arraycopy_entry, StubRoutines::oop_copy)            \
 913   do_entry(final, oop_arraycopy, oop_arraycopy_nopush,                  \
 914             oop_arraycopy_nopush)                                       \
 915   do_stub(final, oop_arraycopy_uninit)                                  \
 916   do_entry_init(final, oop_arraycopy_uninit, oop_arraycopy_uninit,      \
 917                 oop_arraycopy_uninit_entry,                             \
 918                 StubRoutines::oop_copy_uninit)                          \
 919   do_stub(final, jbyte_disjoint_arraycopy)                              \
 920   do_entry_init(final, jbyte_disjoint_arraycopy,                        \
 921                 jbyte_disjoint_arraycopy, jbyte_disjoint_arraycopy,     \
 922                 StubRoutines::jbyte_copy)                               \
 923   do_entry(final, jbyte_disjoint_arraycopy,                             \
 924            jbyte_disjoint_arraycopy_nopush,                             \
 925            jbyte_disjoint_arraycopy_nopush)                             \
 926   do_stub(final, jshort_disjoint_arraycopy)                             \
 927   do_entry_init(final, jshort_disjoint_arraycopy,                       \
 928                 jshort_disjoint_arraycopy, jshort_disjoint_arraycopy,   \
 929                 StubRoutines::jshort_copy)                              \
 930   do_entry(final, jshort_disjoint_arraycopy,                            \
 931            jshort_disjoint_arraycopy_nopush,                            \
 932            jshort_disjoint_arraycopy_nopush)                            \
 933   do_stub(final, jint_disjoint_arraycopy)                               \
 934   do_entry_init(final, jint_disjoint_arraycopy,                         \
 935                 jint_disjoint_arraycopy, jint_disjoint_arraycopy,       \
 936                 StubRoutines::jint_copy)                                \
 937   do_entry(final, jint_disjoint_arraycopy,                              \
 938            jint_disjoint_arraycopy_nopush,                              \
 939            jint_disjoint_arraycopy_nopush)                              \
 940   do_stub(final, jlong_disjoint_arraycopy)                              \
 941   do_entry_init(final, jlong_disjoint_arraycopy,                        \
 942                 jlong_disjoint_arraycopy, jlong_disjoint_arraycopy,     \
 943                 StubRoutines::jlong_copy)                               \
 944   do_entry(final, jlong_disjoint_arraycopy,                             \
 945            jlong_disjoint_arraycopy_nopush,                             \
 946            jlong_disjoint_arraycopy_nopush)                             \
 947   do_stub(final, oop_disjoint_arraycopy)                                \
 948   do_entry_init(final, oop_disjoint_arraycopy, oop_disjoint_arraycopy,  \
 949                 oop_disjoint_arraycopy_entry, StubRoutines::oop_copy)   \
 950   do_entry(final, oop_disjoint_arraycopy,                               \
 951            oop_disjoint_arraycopy_nopush,                               \
 952            oop_disjoint_arraycopy_nopush)                               \
 953   do_stub(final, oop_disjoint_arraycopy_uninit)                         \
 954   do_entry_init(final, oop_disjoint_arraycopy_uninit,                   \
 955                 oop_disjoint_arraycopy_uninit,                          \
 956                 oop_disjoint_arraycopy_uninit_entry,                    \
 957                 StubRoutines::oop_copy_uninit)                          \
 958   do_entry(final, oop_disjoint_arraycopy_uninit,                        \
 959            oop_disjoint_arraycopy_uninit_nopush,                        \
 960            oop_disjoint_arraycopy_uninit_nopush)                        \
 961   do_stub(final, arrayof_jbyte_arraycopy)                               \
 962   do_entry_init(final, arrayof_jbyte_arraycopy,                         \
 963                 arrayof_jbyte_arraycopy, arrayof_jbyte_arraycopy,       \
 964                 StubRoutines::arrayof_jbyte_copy)                       \
 965   do_stub(final, arrayof_jshort_arraycopy)                              \
 966   do_entry_init(final, arrayof_jshort_arraycopy,                        \
 967                 arrayof_jshort_arraycopy, arrayof_jshort_arraycopy,     \
 968                 StubRoutines::arrayof_jshort_copy)                      \
 969   do_stub(final, arrayof_jint_arraycopy)                                \
 970   do_entry_init(final, arrayof_jint_arraycopy, arrayof_jint_arraycopy,  \
 971                 arrayof_jint_arraycopy,                                 \
 972                 StubRoutines::arrayof_jint_copy)                        \
 973   do_stub(final, arrayof_jlong_arraycopy)                               \
 974   do_entry_init(final, arrayof_jlong_arraycopy,                         \
 975                 arrayof_jlong_arraycopy, arrayof_jlong_arraycopy,       \
 976                 StubRoutines::arrayof_jlong_copy)                       \
 977   do_stub(final, arrayof_oop_arraycopy)                                 \
 978   do_entry_init(final, arrayof_oop_arraycopy, arrayof_oop_arraycopy,    \
 979                 arrayof_oop_arraycopy, StubRoutines::arrayof_oop_copy)  \
 980   do_stub(final, arrayof_oop_arraycopy_uninit)                          \
 981   do_entry_init(final, arrayof_oop_arraycopy_uninit,                    \
 982                 arrayof_oop_arraycopy_uninit,                           \
 983                 arrayof_oop_arraycopy_uninit,                           \
 984                 StubRoutines::arrayof_oop_copy_uninit)                  \
 985   do_stub(final, arrayof_jbyte_disjoint_arraycopy)                      \
 986   do_entry_init(final, arrayof_jbyte_disjoint_arraycopy,                \
 987                 arrayof_jbyte_disjoint_arraycopy,                       \
 988                 arrayof_jbyte_disjoint_arraycopy,                       \
 989                 StubRoutines::arrayof_jbyte_copy)                       \
 990   do_entry(final, arrayof_jbyte_disjoint_arraycopy,                     \
 991            arrayof_jbyte_disjoint_arraycopy_nopush,                     \
 992            arrayof_jbyte_disjoint_arraycopy_nopush)                     \
 993   do_stub(final, arrayof_jshort_disjoint_arraycopy)                     \
 994   do_entry_init(final, arrayof_jshort_disjoint_arraycopy,               \
 995                 arrayof_jshort_disjoint_arraycopy,                      \
 996                 arrayof_jshort_disjoint_arraycopy,                      \
 997                 StubRoutines::arrayof_jshort_copy)                      \
 998   do_entry(final, arrayof_jshort_disjoint_arraycopy,                    \
 999            arrayof_jshort_disjoint_arraycopy_nopush,                    \
1000            arrayof_jshort_disjoint_arraycopy_nopush)                    \
1001   do_stub(final, arrayof_jint_disjoint_arraycopy)                       \
1002   do_entry_init(final, arrayof_jint_disjoint_arraycopy,                 \
1003                 arrayof_jint_disjoint_arraycopy,                        \
1004                 arrayof_jint_disjoint_arraycopy,                        \
1005                 StubRoutines::arrayof_jint_copy)                        \
1006   do_entry(final, arrayof_jint_disjoint_arraycopy,                      \
1007            arrayof_jint_disjoint_arraycopy_nopush,                      \
1008            arrayof_jint_disjoint_arraycopy_nopush)                      \
1009   do_stub(final, arrayof_jlong_disjoint_arraycopy)                      \
1010   do_entry_init(final, arrayof_jlong_disjoint_arraycopy,                \
1011                 arrayof_jlong_disjoint_arraycopy,                       \
1012                 arrayof_jlong_disjoint_arraycopy,                       \
1013                 StubRoutines::arrayof_jlong_copy)                       \
1014   do_entry(final, arrayof_jlong_disjoint_arraycopy,                     \
1015            arrayof_jlong_disjoint_arraycopy_nopush,                     \
1016            arrayof_jlong_disjoint_arraycopy_nopush)                     \
1017   do_stub(final, arrayof_oop_disjoint_arraycopy)                        \
1018   do_entry_init(final, arrayof_oop_disjoint_arraycopy,                  \
1019                 arrayof_oop_disjoint_arraycopy,                         \
1020                 arrayof_oop_disjoint_arraycopy_entry,                   \
1021                 StubRoutines::arrayof_oop_copy)                         \
1022   do_entry(final, arrayof_oop_disjoint_arraycopy,                       \
1023            arrayof_oop_disjoint_arraycopy_nopush,                       \
1024            arrayof_oop_disjoint_arraycopy_nopush)                       \
1025   do_stub(final, arrayof_oop_disjoint_arraycopy_uninit)                 \
1026   do_entry_init(final, arrayof_oop_disjoint_arraycopy_uninit,           \
1027                 arrayof_oop_disjoint_arraycopy_uninit,                  \
1028                 arrayof_oop_disjoint_arraycopy_uninit_entry,            \
1029                 StubRoutines::arrayof_oop_copy_uninit)                  \
1030   do_entry(final, arrayof_oop_disjoint_arraycopy_uninit,                \
1031            arrayof_oop_disjoint_arraycopy_uninit_nopush,                \
1032            arrayof_oop_disjoint_arraycopy_uninit_nopush)                \
1033   do_stub(final, checkcast_arraycopy)                                   \
1034   do_entry(final, checkcast_arraycopy, checkcast_arraycopy,             \
1035            checkcast_arraycopy_entry)                                   \
1036   do_entry(final, checkcast_arraycopy, checkcast_arraycopy_nopush,      \
1037             checkcast_arraycopy_nopush)                                 \
1038   do_stub(final, checkcast_arraycopy_uninit)                            \
1039   do_entry(final, checkcast_arraycopy_uninit,                           \
1040            checkcast_arraycopy_uninit,                                  \
1041            checkcast_arraycopy_uninit_entry)                            \
1042   do_stub(final, unsafe_arraycopy)                                      \
1043   do_entry(final, unsafe_arraycopy, unsafe_arraycopy, unsafe_arraycopy) \
1044   do_stub(final, generic_arraycopy)                                     \
1045   do_entry(final, generic_arraycopy, generic_arraycopy,                 \
1046            generic_arraycopy)                                           \
1047   do_stub(final, unsafe_setmemory)                                      \
1048   do_entry(final, unsafe_setmemory, unsafe_setmemory, unsafe_setmemory) \
1049   do_stub(final, jbyte_fill)                                            \
1050   do_entry(final, jbyte_fill, jbyte_fill, jbyte_fill)                   \
1051   do_stub(final, jshort_fill)                                           \
1052   do_entry(final, jshort_fill, jshort_fill, jshort_fill)                \
1053   do_stub(final, jint_fill)                                             \
1054   do_entry(final, jint_fill, jint_fill, jint_fill)                      \
1055   do_stub(final, arrayof_jbyte_fill)                                    \
1056   do_entry(final, arrayof_jbyte_fill, arrayof_jbyte_fill,               \
1057            arrayof_jbyte_fill)                                          \
1058   do_stub(final, arrayof_jshort_fill)                                   \
1059   do_entry(final, arrayof_jshort_fill, arrayof_jshort_fill,             \
1060            arrayof_jshort_fill)                                         \
1061   do_stub(final, arrayof_jint_fill)                                     \
1062   do_entry(final, arrayof_jint_fill, arrayof_jint_fill,                 \
1063            arrayof_jint_fill)                                           \
1064   do_stub(final, method_entry_barrier)                                  \
1065   do_entry(final, method_entry_barrier, method_entry_barrier,           \
1066            method_entry_barrier)                                        \
1067   do_stub(final, vectorizedMismatch) /* only used by x86! */            \
1068   do_entry(final, vectorizedMismatch, vectorizedMismatch,               \
1069            vectorizedMismatch)                                          \
1070   do_stub(final, upcall_stub_exception_handler)                         \
1071   do_entry(final, upcall_stub_exception_handler,                        \
1072            upcall_stub_exception_handler,                               \
1073            upcall_stub_exception_handler)                               \
1074   do_stub(final, upcall_stub_load_target)                               \
1075   do_entry(final, upcall_stub_load_target, upcall_stub_load_target,     \
1076            upcall_stub_load_target)                                     \
1077   do_stub(final, lookup_secondary_supers_table)                         \
1078   do_entry_array(final, lookup_secondary_supers_table,                  \
1079                  lookup_secondary_supers_table_stubs,                   \
1080                  lookup_secondary_supers_table_stub,                    \
1081                  Klass::SECONDARY_SUPERS_TABLE_SIZE)                    \
1082   do_stub(final, lookup_secondary_supers_table_slow_path)               \
1083   do_entry(final, lookup_secondary_supers_table_slow_path,              \
1084            lookup_secondary_supers_table_slow_path_stub,                \
1085            lookup_secondary_supers_table_slow_path_stub)                \
1086   /* merge in stubs and entries declared in arch header */              \
1087   STUBGEN_FINAL_BLOBS_ARCH_DO(do_stub,  do_arch_blob,                   \
1088                               do_arch_entry, do_arch_entry_init)        \
1089   end_blob(final)                                                       \
1090 
1091 
1092 // The whole shebang!
1093 //
1094 // client macro for emitting StubGenerator blobs, stubs and entries
1095 
1096 #define STUBGEN_ALL_DO(do_blob, end_blob,                               \
1097                        do_stub,                                         \
1098                        do_entry, do_entry_init,                         \
1099                        do_entry_array,                                  \
1100                        do_arch_blob,                                    \
1101                        do_arch_entry, do_arch_entry_init)               \
1102   STUBGEN_PREUNIVERSE_BLOBS_DO(do_blob, end_blob,                       \
1103                                do_stub,                                 \
1104                                do_entry, do_entry_init,                 \
1105                                do_entry_array,                          \
1106                                do_arch_blob,                            \
1107                                do_arch_entry, do_arch_entry_init)       \
1108   STUBGEN_INITIAL_BLOBS_DO(do_blob, end_blob,                           \
1109                            do_stub,                                     \
1110                            do_entry, do_entry_init,                     \
1111                            do_entry_array,                              \
1112                            do_arch_blob,                                \
1113                            do_arch_entry, do_arch_entry_init)           \
1114   STUBGEN_CONTINUATION_BLOBS_DO(do_blob, end_blob,                      \
1115                                 do_stub,                                \
1116                                 do_entry, do_entry_init,                \
1117                                 do_entry_array,                         \
1118                                 do_arch_blob,                           \
1119                                 do_arch_entry, do_arch_entry_init)      \
1120   STUBGEN_COMPILER_BLOBS_DO(do_blob, end_blob,                          \
1121                             do_stub,                                    \
1122                             do_entry, do_entry_init,                    \
1123                             do_entry_array,                             \
1124                             do_arch_blob,                               \
1125                             do_arch_entry, do_arch_entry_init)          \
1126   STUBGEN_FINAL_BLOBS_DO(do_blob, end_blob,                             \
1127                          do_stub,                                       \
1128                          do_entry, do_entry_init,                       \
1129                          do_entry_array,                                \
1130                          do_arch_blob,                                  \
1131                          do_arch_entry, do_arch_entry_init)             \
1132 
1133 // Convenience macros for use by template implementations
1134 
1135 #define JOIN2(name, suffix)                     \
1136   name ## _ ## suffix
1137 
1138 #define JOIN3(prefix, name, suffix)             \
1139   prefix ## _ ## name ## _ ## suffix
1140 
1141 #define JOIN4(prefix, prefix2, name, suffix)            \
1142   prefix ## _ ## prefix2 ## _ ## name ## _ ## suffix
1143 
1144 #define STUB_ID_NAME(base) JOIN2(base, id)
1145 
1146 // emit a runtime or stubgen stub field name
1147 
1148 #define STUB_FIELD_NAME(base) _##base
1149 
1150 // emit a runtime blob field name
1151 
1152 #define BLOB_FIELD_NAME(base) _## base ## _blob
1153 
1154 // emit a stubgen blob field name
1155 
1156 #define STUBGEN_BLOB_FIELD_NAME(base) _ ## base ## _stubs_code
1157 
1158 // first some macros that add an increment
1159 
1160 #define COUNT1(_1)                              \
1161   + 1
1162 
1163 #define COUNT2(_1, _2)                          \
1164   + 1
1165 
1166 #define COUNT4(_1, _2, _3, _4)                  \
1167   + 1
1168 
1169 #define COUNT5(_1, _2, _3, _4, _5)              \
1170   + 1
1171 
1172 #define COUNT6(_1, _2, _3, _4, _5, _6)          \
1173   + 1
1174 
1175 #define SHARED_COUNT2(_1, type)                 \
1176   + type :: ENTRY_COUNT
1177 
1178 #define STUBGEN_COUNT5(_1, _2, _3, _4, count)   \
1179   + count
1180 
1181 // Convenience templates that emit nothing
1182 
1183 // ignore do_blob(blob_name, type) declarations
1184 #define DO_BLOB_EMPTY2(blob_name, type)
1185 
1186 // ignore do_blob(blob_name) and end_blob(blob_name) declarations
1187 #define DO_BLOB_EMPTY1(blob_name)
1188 
1189 // ignore do_stub(name, fancy_jump, pass_tls, return_pc) declarations
1190 #define DO_STUB_EMPTY4(name, fancy_jump, pass_tls, return_pc)
1191 
1192 // ignore do_stub(blob_name, stub_name) declarations
1193 #define DO_STUB_EMPTY2(blob_name, stub_name)
1194 
1195 // ignore do_entry(blob_name, stub_name, fieldname, getter_name) declarations
1196 #define DO_ENTRY_EMPTY4(blob_name, stub_name, fieldname, getter_name)
1197 
1198 // ignore do_entry(blob_name, stub_name, fieldname, getter_name, init_function) and
1199 // do_entry_array(blob_name, stub_name, fieldname, getter_name, count) declarations
1200 #define DO_ENTRY_EMPTY5(blob_name, stub_name, fieldname, getter_name, init_function)
1201 
1202 // ignore do_arch_blob(blob_name, size) declarations
1203 #define DO_ARCH_BLOB_EMPTY2(arch, size)
1204 
1205 // ignore do_arch_entry(arch, blob_name, stub_name, fieldname, getter_name) declarations
1206 #define DO_ARCH_ENTRY_EMPTY5(arch, blob_name, stub_name, field_name, getter_name)
1207 
1208 // ignore do_arch_entry(arch, blob_name, stub_name, fieldname, getter_name, init_function) declarations
1209 #define DO_ARCH_ENTRY_EMPTY6(arch, blob_name, stub_name, field_name, getter_name, init_function)
1210 
1211 // client macro to operate only on StubGenerator blobs
1212 
1213 #define STUBGEN_BLOBS_DO(do_blob)                                       \
1214   STUBGEN_ALL_DO(do_blob, DO_BLOB_EMPTY1,                               \
1215                  DO_STUB_EMPTY2,                                        \
1216                  DO_ENTRY_EMPTY4, DO_ENTRY_EMPTY5,                      \
1217                  DO_ENTRY_EMPTY5,                                       \
1218                  DO_ARCH_BLOB_EMPTY2,                                   \
1219                  DO_ARCH_ENTRY_EMPTY5, DO_ARCH_ENTRY_EMPTY6)            \
1220 
1221 // client macro to operate only on StubGenerator stubs
1222 
1223 #define STUBGEN_STUBS_DO(do_stub)                                       \
1224   STUBGEN_ALL_DO(DO_BLOB_EMPTY1, DO_BLOB_EMPTY1,                        \
1225                  do_stub,                                               \
1226                  DO_ENTRY_EMPTY4, DO_ENTRY_EMPTY5,                      \
1227                  DO_ENTRY_EMPTY5,                                       \
1228                  DO_ARCH_BLOB_EMPTY2,                                   \
1229                  DO_ARCH_ENTRY_EMPTY5, DO_ARCH_ENTRY_EMPTY6)            \
1230 
1231 // client macros to operate only on StubGenerator blobs and stubs
1232 
1233 #define STUBGEN_BLOBS_STUBS_DO(do_blob, end_blob, do_stub)              \
1234   STUBGEN_ALL_DO(do_blob, end_blob,                                     \
1235                  do_stub,                                               \
1236                  DO_ENTRY_EMPTY4, DO_ENTRY_EMPTY5,                      \
1237                  DO_ENTRY_EMPTY5,                                       \
1238                  DO_ARCH_BLOB_EMPTY2,                                   \
1239                  DO_ARCH_ENTRY_EMPTY5,DO_ARCH_ENTRY_EMPTY6)             \
1240 
1241 // client macro to operate only on StubGenerator generci and arch entries
1242 
1243 #define STUBGEN_ALL_ENTRIES_DO(do_entry, do_entry_init, do_entry_array, \
1244                                do_arch_entry, do_arch_entry_init)       \
1245   STUBGEN_ALL_DO(DO_BLOB_EMPTY1, DO_BLOB_EMPTY1,                        \
1246                  DO_STUB_EMPTY2,                                        \
1247                  do_entry, do_entry_init,                               \
1248                  do_entry_array,                                        \
1249                  DO_ARCH_BLOB_EMPTY2,                                   \
1250                  do_arch_entry, do_arch_entry_init)                     \
1251 
1252 // client macro to operate only on StubGenerator entries
1253 
1254 #define STUBGEN_ENTRIES_DO(do_entry, do_entry_init, do_entry_array)     \
1255   STUBGEN_ALL_DO(DO_BLOB_EMPTY1, DO_BLOB_EMPTY1,                        \
1256                  DO_STUB_EMPTY2,                                        \
1257                  do_entry, do_entry_init,                               \
1258                  do_entry_array,                                        \
1259                  DO_ARCH_BLOB_EMPTY2,                                   \
1260                  DO_ARCH_ENTRY_EMPTY5, DO_ARCH_ENTRY_EMPTY6)            \
1261 
1262 // client macro to operate only on StubGenerator arch blobs
1263 
1264 #define STUBGEN_ARCH_BLOBS_DO(do_arch_blob)                             \
1265   STUBGEN_ALL_DO(DO_BLOB_EMPTY1, DO_BLOB_EMPTY1,                        \
1266                  DO_STUB_EMPTY2,                                        \
1267                  DO_ENTRY_EMPTY4, DO_ENTRY_EMPTY5,                      \
1268                  DO_ENTRY_EMPTY5,                                       \
1269                  do_arch_blob,                                          \
1270                  DO_ARCH_ENTRY_EMPTY5, DO_ARCH_ENTRY_EMPTY6)            \
1271 
1272 // client macro to operate only on StubGenerator arch entries
1273 
1274 #define STUBGEN_ARCH_ENTRIES_DO(do_arch_entry, do_arch_entry_init)      \
1275   STUBGEN_ALL_DO(DO_BLOB_EMPTY1, DO_BLOB_EMPTY1,                        \
1276                  DO_STUB_EMPTY2,                                        \
1277                  DO_ENTRY_EMPTY4, DO_ENTRY_EMPTY5,                      \
1278                  DO_ENTRY_EMPTY5,                                       \
1279                  DO_ARCH_BLOB_EMPTY2,                                   \
1280                  do_arch_entry, do_arch_entry_init)                     \
1281 
1282 #endif // SHARE_RUNTIME_STUBDECLARATIONS_HPP