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