From d7b59889155e1c47bbbb2b8f37661479a8db1a05 Mon Sep 17 00:00:00 2001 From: Andrew Dinn Date: Thu, 12 Jun 2025 17:59:46 +0100 Subject: [PATCH] 8359373: Split stubgen initial blob into pre and post-universe blobs --- .../cpu/aarch64/stubDeclarations_aarch64.hpp | 7 ++++ .../cpu/aarch64/stubGenerator_aarch64.cpp | 7 ++++ src/hotspot/cpu/arm/stubDeclarations_arm.hpp | 7 ++++ src/hotspot/cpu/arm/stubGenerator_arm.cpp | 7 ++++ src/hotspot/cpu/ppc/stubDeclarations_ppc.hpp | 7 ++++ src/hotspot/cpu/ppc/stubGenerator_ppc.cpp | 7 ++++ .../cpu/riscv/stubDeclarations_riscv.hpp | 7 ++++ src/hotspot/cpu/riscv/stubGenerator_riscv.cpp | 7 ++++ .../cpu/s390/stubDeclarations_s390.hpp | 7 ++++ src/hotspot/cpu/s390/stubGenerator_s390.cpp | 7 ++++ src/hotspot/cpu/x86/stubDeclarations_x86.hpp | 7 ++++ src/hotspot/cpu/x86/stubGenerator_x86_64.cpp | 11 +++-- .../cpu/zero/stubDeclarations_zero.hpp | 7 ++++ src/hotspot/cpu/zero/stubGenerator_zero.cpp | 7 ++++ src/hotspot/share/runtime/init.cpp | 3 ++ .../share/runtime/stubDeclarations.hpp | 40 +++++++++++++++---- src/hotspot/share/runtime/stubRoutines.cpp | 8 ++++ 17 files changed, 142 insertions(+), 11 deletions(-) diff --git a/src/hotspot/cpu/aarch64/stubDeclarations_aarch64.hpp b/src/hotspot/cpu/aarch64/stubDeclarations_aarch64.hpp index e0ca01ba6ce..695534604b8 100644 --- a/src/hotspot/cpu/aarch64/stubDeclarations_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/stubDeclarations_aarch64.hpp @@ -26,6 +26,13 @@ #ifndef CPU_AARCH64_STUBDECLARATIONS_HPP #define CPU_AARCH64_STUBDECLARATIONS_HPP +#define STUBGEN_PREUNIVERSE_BLOBS_ARCH_DO(do_stub, \ + do_arch_blob, \ + do_arch_entry, \ + do_arch_entry_init) \ + do_arch_blob(preuniverse, 0) \ + + #define STUBGEN_INITIAL_BLOBS_ARCH_DO(do_stub, \ do_arch_blob, \ do_arch_entry, \ diff --git a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp index a0d1e22ff96..8241e94c108 100644 --- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp @@ -11653,6 +11653,10 @@ class StubGenerator: public StubCodeGenerator { }; // Initialization + void generate_preuniverse_stubs() { + // preuniverse stubs are not needed for aarch64 + } + void generate_initial_stubs() { // Generate initial stubs and initializes the entry points @@ -11898,6 +11902,9 @@ class StubGenerator: public StubCodeGenerator { public: StubGenerator(CodeBuffer* code, StubGenBlobId blob_id) : StubCodeGenerator(code, blob_id) { switch(blob_id) { + case preuniverse_id: + generate_preuniverse_stubs(); + break; case initial_id: generate_initial_stubs(); break; diff --git a/src/hotspot/cpu/arm/stubDeclarations_arm.hpp b/src/hotspot/cpu/arm/stubDeclarations_arm.hpp index 35df4b924d2..93ab16791b5 100644 --- a/src/hotspot/cpu/arm/stubDeclarations_arm.hpp +++ b/src/hotspot/cpu/arm/stubDeclarations_arm.hpp @@ -26,6 +26,13 @@ #ifndef CPU_ARM_STUBDECLARATIONS_HPP #define CPU_ARM_STUBDECLARATIONS_HPP +#define STUBGEN_PREUNIVERSE_BLOBS_ARCH_DO(do_stub, \ + do_arch_blob, \ + do_arch_entry, \ + do_arch_entry_init) \ + do_arch_blob(preuniverse, 0) \ + + #define STUBGEN_INITIAL_BLOBS_ARCH_DO(do_stub, \ do_arch_blob, \ do_arch_entry, \ diff --git a/src/hotspot/cpu/arm/stubGenerator_arm.cpp b/src/hotspot/cpu/arm/stubGenerator_arm.cpp index fc5bcb4e0e6..5f2fd2e3b6d 100644 --- a/src/hotspot/cpu/arm/stubGenerator_arm.cpp +++ b/src/hotspot/cpu/arm/stubGenerator_arm.cpp @@ -3126,6 +3126,10 @@ class StubGenerator: public StubCodeGenerator { //--------------------------------------------------------------------------- // Initialization + void generate_preuniverse_stubs() { + // preuniverse stubs are not needed for arm + } + void generate_initial_stubs() { // Generates all stubs and initializes the entry points @@ -3201,6 +3205,9 @@ class StubGenerator: public StubCodeGenerator { public: StubGenerator(CodeBuffer* code, StubGenBlobId blob_id) : StubCodeGenerator(code, blob_id) { switch(blob_id) { + case preuniverse_id: + generate_preuniverse_stubs(); + break; case initial_id: generate_initial_stubs(); break; diff --git a/src/hotspot/cpu/ppc/stubDeclarations_ppc.hpp b/src/hotspot/cpu/ppc/stubDeclarations_ppc.hpp index 1a19f1b8cf2..be51afe42a4 100644 --- a/src/hotspot/cpu/ppc/stubDeclarations_ppc.hpp +++ b/src/hotspot/cpu/ppc/stubDeclarations_ppc.hpp @@ -26,6 +26,13 @@ #ifndef CPU_PPC_STUBDECLARATIONS_HPP #define CPU_PPC_STUBDECLARATIONS_HPP +#define STUBGEN_PREUNIVERSE_BLOBS_ARCH_DO(do_stub, \ + do_arch_blob, \ + do_arch_entry, \ + do_arch_entry_init) \ + do_arch_blob(preuniverse, 0) \ + + #define STUBGEN_INITIAL_BLOBS_ARCH_DO(do_stub, \ do_arch_blob, \ do_arch_entry, \ diff --git a/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp b/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp index 2624131033c..ba4b00197fb 100644 --- a/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp +++ b/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp @@ -4938,6 +4938,10 @@ void generate_lookup_secondary_supers_table_stub() { } // Initialization + void generate_preuniverse_stubs() { + // preuniverse stubs are not needed for ppc + } + void generate_initial_stubs() { // Generates all stubs and initializes the entry points @@ -5067,6 +5071,9 @@ void generate_lookup_secondary_supers_table_stub() { public: StubGenerator(CodeBuffer* code, StubGenBlobId blob_id) : StubCodeGenerator(code, blob_id) { switch(blob_id) { + case preuniverse_id: + generate_preuniverse_stubs(); + break; case initial_id: generate_initial_stubs(); break; diff --git a/src/hotspot/cpu/riscv/stubDeclarations_riscv.hpp b/src/hotspot/cpu/riscv/stubDeclarations_riscv.hpp index 4905566c233..fe7f52884fa 100644 --- a/src/hotspot/cpu/riscv/stubDeclarations_riscv.hpp +++ b/src/hotspot/cpu/riscv/stubDeclarations_riscv.hpp @@ -26,6 +26,13 @@ #ifndef CPU_RISCV_STUBDECLARATIONS_HPP #define CPU_RISCV_STUBDECLARATIONS_HPP +#define STUBGEN_PREUNIVERSE_BLOBS_ARCH_DO(do_stub, \ + do_arch_blob, \ + do_arch_entry, \ + do_arch_entry_init) \ + do_arch_blob(preuniverse, 0) \ + + #define STUBGEN_INITIAL_BLOBS_ARCH_DO(do_stub, \ do_arch_blob, \ do_arch_entry, \ diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp index c58f6bc338d..f7d13578caf 100644 --- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -6660,6 +6660,10 @@ static const int64_t right_3_bits = right_n_bits(3); #undef __ // Initialization + void generate_preuniverse_stubs() { + // preuniverse stubs are not needed for riscv + } + void generate_initial_stubs() { // Generate initial stubs and initializes the entry points @@ -6815,6 +6819,9 @@ static const int64_t right_3_bits = right_n_bits(3); public: StubGenerator(CodeBuffer* code, StubGenBlobId blob_id) : StubCodeGenerator(code, blob_id) { switch(blob_id) { + case preuniverse_id: + generate_preuniverse_stubs(); + break; case initial_id: generate_initial_stubs(); break; diff --git a/src/hotspot/cpu/s390/stubDeclarations_s390.hpp b/src/hotspot/cpu/s390/stubDeclarations_s390.hpp index f382a319c48..c3ad3cefeb9 100644 --- a/src/hotspot/cpu/s390/stubDeclarations_s390.hpp +++ b/src/hotspot/cpu/s390/stubDeclarations_s390.hpp @@ -26,6 +26,13 @@ #ifndef CPU_S390_STUBDECLARATIONS_HPP #define CPU_S390_STUBDECLARATIONS_HPP +#define STUBGEN_PREUNIVERSE_BLOBS_ARCH_DO(do_stub, \ + do_arch_blob, \ + do_arch_entry, \ + do_arch_entry_init) \ + do_arch_blob(preuniverse, 0) \ + + #define STUBGEN_INITIAL_BLOBS_ARCH_DO(do_stub, \ do_arch_blob, \ do_arch_entry, \ diff --git a/src/hotspot/cpu/s390/stubGenerator_s390.cpp b/src/hotspot/cpu/s390/stubGenerator_s390.cpp index d3f6540a3ea..d1c794002e7 100644 --- a/src/hotspot/cpu/s390/stubGenerator_s390.cpp +++ b/src/hotspot/cpu/s390/stubGenerator_s390.cpp @@ -3283,6 +3283,10 @@ class StubGenerator: public StubCodeGenerator { return start; } + void generate_preuniverse_stubs() { + // preuniverse stubs are not needed for s390 + } + void generate_initial_stubs() { // Generates all stubs and initializes the entry points. @@ -3418,6 +3422,9 @@ class StubGenerator: public StubCodeGenerator { public: StubGenerator(CodeBuffer* code, StubGenBlobId blob_id) : StubCodeGenerator(code, blob_id) { switch(blob_id) { + case preuniverse_id: + generate_preuniverse_stubs(); + break; case initial_id: generate_initial_stubs(); break; diff --git a/src/hotspot/cpu/x86/stubDeclarations_x86.hpp b/src/hotspot/cpu/x86/stubDeclarations_x86.hpp index dcb919ddcd0..0bf4ba34b05 100644 --- a/src/hotspot/cpu/x86/stubDeclarations_x86.hpp +++ b/src/hotspot/cpu/x86/stubDeclarations_x86.hpp @@ -26,6 +26,13 @@ #ifndef CPU_X86_STUBDECLARATIONS_HPP #define CPU_X86_STUBDECLARATIONS_HPP +#define STUBGEN_PREUNIVERSE_BLOBS_ARCH_DO(do_stub, \ + do_arch_blob, \ + do_arch_entry, \ + do_arch_entry_init) \ + do_arch_blob(preuniverse, 500) \ + + #define STUBGEN_INITIAL_BLOBS_ARCH_DO(do_stub, \ do_arch_blob, \ do_arch_entry, \ diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp index 1014c1c376f..29c6b1b8d9f 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp @@ -4049,6 +4049,11 @@ void StubGenerator::create_control_words() { } // Initialization +void generate_preuniverse_stubs() { + // atomic calls + StubRoutines::_fence_entry = generate_orderaccess_fence(); +} + void StubGenerator::generate_initial_stubs() { // Generates all stubs and initializes the entry points @@ -4074,9 +4079,6 @@ void StubGenerator::generate_initial_stubs() { // is referenced by megamorphic call StubRoutines::_catch_exception_entry = generate_catch_exception(); - // atomic calls - StubRoutines::_fence_entry = generate_orderaccess_fence(); - // platform dependent StubRoutines::x86::_get_previous_sp_entry = generate_get_previous_sp(); @@ -4344,6 +4346,9 @@ void StubGenerator::generate_compiler_stubs() { StubGenerator::StubGenerator(CodeBuffer* code, StubGenBlobId blob_id) : StubCodeGenerator(code, blob_id) { switch(blob_id) { + case preuniverse_id: + generate_preuniverse_stubs(); + break; case initial_id: generate_initial_stubs(); break; diff --git a/src/hotspot/cpu/zero/stubDeclarations_zero.hpp b/src/hotspot/cpu/zero/stubDeclarations_zero.hpp index 5808ae3bd8f..2357bbb5169 100644 --- a/src/hotspot/cpu/zero/stubDeclarations_zero.hpp +++ b/src/hotspot/cpu/zero/stubDeclarations_zero.hpp @@ -26,6 +26,13 @@ #ifndef CPU_ZERO_STUBDECLARATIONS_HPP #define CPU_ZERO_STUBDECLARATIONS_HPP +#define STUBGEN_PREUNIVERSE_BLOBS_ARCH_DO(do_stub, \ + do_arch_blob, \ + do_arch_entry, \ + do_arch_entry_init) \ + do_arch_blob(preuniverse, 0) \ + + #define STUBGEN_INITIAL_BLOBS_ARCH_DO(do_stub, \ do_arch_blob, \ do_arch_entry, \ diff --git a/src/hotspot/cpu/zero/stubGenerator_zero.cpp b/src/hotspot/cpu/zero/stubGenerator_zero.cpp index 07b4e2a92af..0b8f4b08867 100644 --- a/src/hotspot/cpu/zero/stubGenerator_zero.cpp +++ b/src/hotspot/cpu/zero/stubGenerator_zero.cpp @@ -178,6 +178,10 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_oop_arraycopy; } + void generate_preuniverse_stubs() { + // preuniverse stubs are not needed for zero + } + void generate_initial_stubs() { // entry points that exist in all platforms Note: This is code // that could be shared among different platforms - however the @@ -214,6 +218,9 @@ class StubGenerator: public StubCodeGenerator { public: StubGenerator(CodeBuffer* code, StubGenBlobId blob_id) : StubCodeGenerator(code, blob_id) { switch(blob_id) { + case preuniverse_id: + generate_preuniverse_stubs(); + break; case initial_id: generate_initial_stubs(); break; diff --git a/src/hotspot/share/runtime/init.cpp b/src/hotspot/share/runtime/init.cpp index 22a2e302600..dbd0a355efe 100644 --- a/src/hotspot/share/runtime/init.cpp +++ b/src/hotspot/share/runtime/init.cpp @@ -68,6 +68,7 @@ void compilationPolicy_init(); void codeCache_init(); void VM_Version_init(); void icache_init2(); +void preuniverse_stubs_init(); void initial_stubs_init(); jint universe_init(); // depends on codeCache_init and initial_stubs_init @@ -129,6 +130,8 @@ jint init_globals() { codeCache_init(); VM_Version_init(); // depends on codeCache_init for emitting code icache_init2(); // depends on VM_Version for choosing the mechanism + // initialize stubs needed before we can init the universe + preuniverse_stubs_init(); // stub routines in initial blob are referenced by later generated code initial_stubs_init(); // stack overflow exception blob is referenced by the interpreter diff --git a/src/hotspot/share/runtime/stubDeclarations.hpp b/src/hotspot/share/runtime/stubDeclarations.hpp index 5dc7d293662..8c01434b73a 100644 --- a/src/hotspot/share/runtime/stubDeclarations.hpp +++ b/src/hotspot/share/runtime/stubDeclarations.hpp @@ -175,12 +175,13 @@ // Stub Generator Blobs and Stubs Overview // // StubGenerator stubs do not require their own individual blob. They -// are generated in batches into one of four distinct BufferBlobs: +// are generated in batches into one of five distinct BufferBlobs: // -// 1) Initial stubs -// 2) Continuation stubs -// 3) Compiler stubs -// 4) Final stubs +// 1) PreUniverse stubs +// 2) Initial stubs +// 3) Continuation stubs +// 4) Compiler stubs +// 5) Final stubs // // Creation of each successive BufferBlobs is staged to ensure that // specific VM subsystems required by those stubs are suitably @@ -268,6 +269,7 @@ // For example, // // enum platform_dependent_constants { +// _preuniverse_stubs_code_size = 500, // _initial_stubs_code_size = 10000, // _continuation_stubs_code_size = 2000, // . . . @@ -501,6 +503,10 @@ #include CPU_HEADER(stubDeclarations) +#ifndef STUBGEN_PREUNIVERSE_BLOBS_ARCH_DO +#error "Arch-specific directory failed to declare required initial stubs and entries" +#endif + #ifndef STUBGEN_INITIAL_BLOBS_ARCH_DO #error "Arch-specific directory failed to declare required initial stubs and entries" #endif @@ -533,7 +539,21 @@ // stubs within the correct blob and locate entry declarations // immediately after their associated stub declaration. -#define STUBGEN_INITIAL_BLOBS_DO(do_blob, end_blob, \ +#define STUBGEN_PREUNIVERSE_BLOBS_DO(do_blob, end_blob, \ + do_stub, \ + do_entry, do_entry_init, \ + do_entry_array, \ + do_arch_blob, \ + do_arch_entry, do_arch_entry_init) \ + do_blob(preuniverse) \ + do_stub(preuniverse, fence) \ + do_entry(preuniverse, fence, fence_entry, fence_entry) \ + /* merge in stubs and entries declared in arch header */ \ + STUBGEN_PREUNIVERSE_BLOBS_ARCH_DO(do_stub, do_arch_blob, \ + do_arch_entry, do_arch_entry_init) \ + end_blob(preuniverse) \ + +#define STUBGEN_INITIAL_BLOBS_DO(do_blob, end_blob, \ do_stub, \ do_entry, do_entry_init, \ do_entry_array, \ @@ -550,8 +570,6 @@ do_stub(initial, catch_exception) \ do_entry(initial, catch_exception, catch_exception_entry, \ catch_exception_entry) \ - do_stub(initial, fence) \ - do_entry(initial, fence, fence_entry, fence_entry) \ do_stub(initial, atomic_add) \ do_entry(initial, atomic_add, atomic_add_entry, atomic_add_entry) \ do_stub(initial, atomic_xchg) \ @@ -1012,6 +1030,12 @@ do_entry_array, \ do_arch_blob, \ do_arch_entry, do_arch_entry_init) \ + STUBGEN_PREUNIVERSE_BLOBS_DO(do_blob, end_blob, \ + do_stub, \ + do_entry, do_entry_init, \ + do_entry_array, \ + do_arch_blob, \ + do_arch_entry, do_arch_entry_init) \ STUBGEN_INITIAL_BLOBS_DO(do_blob, end_blob, \ do_stub, \ do_entry, do_entry_init, \ diff --git a/src/hotspot/share/runtime/stubRoutines.cpp b/src/hotspot/share/runtime/stubRoutines.cpp index 358434938f2..163ab4bfb6a 100644 --- a/src/hotspot/share/runtime/stubRoutines.cpp +++ b/src/hotspot/share/runtime/stubRoutines.cpp @@ -220,6 +220,14 @@ static BufferBlob* initialize_stubs(StubGenBlobId blob_id, const char* buffer_name, const char* assert_msg) { ResourceMark rm; + if (code_size == 0) { + LogTarget(Info, stubs) lt; + if (lt.is_enabled()) { + LogStream ls(lt); + ls.print_cr("%s\t not generated", buffer_name); + return nullptr; + } + } TraceTime timer(timer_msg, TRACETIME_LOG(Info, startuptime)); // Add extra space for large CodeEntryAlignment int size = code_size + CodeEntryAlignment * max_aligned_stubs;