8359373: Split stubgen initial blob into pre and post-universe blobs

This commit is contained in:
Andrew Dinn 2025-06-12 17:59:46 +01:00
parent 3c53057fa6
commit d7b5988915
17 changed files with 142 additions and 11 deletions

View File

@ -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, \

View File

@ -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;

View File

@ -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, \

View File

@ -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;

View File

@ -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, \

View File

@ -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;

View File

@ -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, \

View File

@ -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;

View File

@ -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, \

View File

@ -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;

View File

@ -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, \

View File

@ -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;

View File

@ -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, \

View File

@ -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;

View File

@ -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

View File

@ -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, \

View File

@ -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;