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