diff --git a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp index 0a7d9af9bff4b..b3bd0b9220643 100644 --- a/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp @@ -11680,8 +11680,6 @@ class StubGenerator: public StubCodeGenerator { } if (UseCRC32Intrinsics) { - // set table address before stub generation which use it - StubRoutines::_crc_table_adr = (address)StubRoutines::aarch64::_crc_table; StubRoutines::_updateBytesCRC32 = generate_updateBytesCRC32(); } diff --git a/src/hotspot/cpu/aarch64/stubRoutines_aarch64.cpp b/src/hotspot/cpu/aarch64/stubRoutines_aarch64.cpp index fab76c41303c7..88993818b47ee 100644 --- a/src/hotspot/cpu/aarch64/stubRoutines_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/stubRoutines_aarch64.cpp @@ -71,6 +71,10 @@ ATTRIBUTE_ALIGNED(64) uint32_t StubRoutines::aarch64::_dilithiumConsts[] = /** * crc_table[] from jdk/src/share/native/java/util/zip/zlib-1.2.5/crc32.h */ + +address StubRoutines::crc_table_addr() { return (address)StubRoutines::aarch64::_crc_table; } +address StubRoutines::crc32c_table_addr() { ShouldNotCallThis(); return nullptr; } + ATTRIBUTE_ALIGNED(4096) juint StubRoutines::aarch64::_crc_table[] = { // Table 0 diff --git a/src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp b/src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp index 4c942b9f8d81d..c35371e10833d 100644 --- a/src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp @@ -47,6 +47,7 @@ enum platform_dependent_constants { class aarch64 { friend class StubGenerator; + friend class StubRoutines; #if INCLUDE_JVMCI friend class JVMCIVMStructs; #endif diff --git a/src/hotspot/cpu/arm/stubRoutines_arm.cpp b/src/hotspot/cpu/arm/stubRoutines_arm.cpp index d843d89186ea1..a4f2b5e1bd915 100644 --- a/src/hotspot/cpu/arm/stubRoutines_arm.cpp +++ b/src/hotspot/cpu/arm/stubRoutines_arm.cpp @@ -36,3 +36,6 @@ STUBGEN_ARCH_ENTRIES_DO(DEFINE_ARCH_ENTRY, DEFINE_ARCH_ENTRY_INIT) #undef DEFINE_ARCH_ENTRY_INIT #undef DEFINE_ARCH_ENTRY + +address StubRoutines::crc_table_addr() { ShouldNotCallThis(); return nullptr; } +address StubRoutines::crc32c_table_addr() { ShouldNotCallThis(); return nullptr; } diff --git a/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp b/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp index c2f290212bdf1..9b27441c75205 100644 --- a/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp +++ b/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp @@ -4982,13 +4982,11 @@ void generate_lookup_secondary_supers_table_stub() { // CRC32 Intrinsics. if (UseCRC32Intrinsics) { - StubRoutines::_crc_table_adr = StubRoutines::ppc::generate_crc_constants(REVERSE_CRC32_POLY); StubRoutines::_updateBytesCRC32 = generate_CRC32_updateBytes(StubId::stubgen_updateBytesCRC32_id); } // CRC32C Intrinsics. if (UseCRC32CIntrinsics) { - StubRoutines::_crc32c_table_addr = StubRoutines::ppc::generate_crc_constants(REVERSE_CRC32C_POLY); StubRoutines::_updateBytesCRC32C = generate_CRC32_updateBytes(StubId::stubgen_updateBytesCRC32C_id); } diff --git a/src/hotspot/cpu/ppc/stubRoutines_ppc.hpp b/src/hotspot/cpu/ppc/stubRoutines_ppc.hpp index a542d7947f85f..f8909ad5fa163 100644 --- a/src/hotspot/cpu/ppc/stubRoutines_ppc.hpp +++ b/src/hotspot/cpu/ppc/stubRoutines_ppc.hpp @@ -54,6 +54,7 @@ enum platform_dependent_constants { class ppc { friend class StubGenerator; + friend class StubRoutines; private: public: diff --git a/src/hotspot/cpu/ppc/stubRoutines_ppc_64.cpp b/src/hotspot/cpu/ppc/stubRoutines_ppc_64.cpp index fed3f208f0655..914c5a17a19b7 100644 --- a/src/hotspot/cpu/ppc/stubRoutines_ppc_64.cpp +++ b/src/hotspot/cpu/ppc/stubRoutines_ppc_64.cpp @@ -74,6 +74,22 @@ static julong compute_inverse_poly(julong long_poly) { return div; } +static address _crc_table_addr = nullptr; +static address _crc32c_table_addr = nullptr; + +address StubRoutines::crc_table_addr() { + if (_crc_table_addr == nullptr) { + _crc_table_addr = StubRoutines::ppc::generate_crc_constants(REVERSE_CRC32_POLY); + } + return _crc_table_addr; +} +address StubRoutines::crc32c_table_addr() { + if (_crc32c_table_addr == nullptr) { + _crc32c_table_addr = StubRoutines::ppc::generate_crc_constants(REVERSE_CRC32C_POLY); + } + return _crc32c_table_addr; +} + // Constants to fold n words as needed by macroAssembler. address StubRoutines::ppc::generate_crc_constants(juint reverse_poly) { // Layout of constant table: diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp index a44fe39917c50..a4f42104d35b5 100644 --- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -6686,8 +6686,6 @@ static const int64_t right_3_bits = right_n_bits(3); StubRoutines::_catch_exception_entry = generate_catch_exception(); if (UseCRC32Intrinsics) { - // set table address before stub generation which use it - StubRoutines::_crc_table_adr = (address)StubRoutines::riscv::_crc_table; StubRoutines::_updateBytesCRC32 = generate_updateBytesCRC32(); } diff --git a/src/hotspot/cpu/riscv/stubRoutines_riscv.cpp b/src/hotspot/cpu/riscv/stubRoutines_riscv.cpp index 2a1150276c1be..2aac95d71fa94 100644 --- a/src/hotspot/cpu/riscv/stubRoutines_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubRoutines_riscv.cpp @@ -52,6 +52,10 @@ bool StubRoutines::riscv::_completed = false; /** * crc_table[] from jdk/src/java.base/share/native/libzip/zlib/crc32.h */ + +address StubRoutines::crc_table_addr() { return (address)StubRoutines::riscv::_crc_table; } +address StubRoutines::crc32c_table_addr() { ShouldNotCallThis(); return nullptr; } + ATTRIBUTE_ALIGNED(4096) juint StubRoutines::riscv::_crc_table[] = { // Table 0 diff --git a/src/hotspot/cpu/riscv/stubRoutines_riscv.hpp b/src/hotspot/cpu/riscv/stubRoutines_riscv.hpp index 1cd10b996dbcf..0f90777ce6428 100644 --- a/src/hotspot/cpu/riscv/stubRoutines_riscv.hpp +++ b/src/hotspot/cpu/riscv/stubRoutines_riscv.hpp @@ -48,6 +48,7 @@ enum platform_dependent_constants { class riscv { friend class StubGenerator; + friend class StubRoutines; #if INCLUDE_JVMCI friend class JVMCIVMStructs; #endif diff --git a/src/hotspot/cpu/s390/stubGenerator_s390.cpp b/src/hotspot/cpu/s390/stubGenerator_s390.cpp index aaed67fd26987..32c15e56baf98 100644 --- a/src/hotspot/cpu/s390/stubGenerator_s390.cpp +++ b/src/hotspot/cpu/s390/stubGenerator_s390.cpp @@ -3308,12 +3308,10 @@ class StubGenerator: public StubCodeGenerator { } if (UseCRC32Intrinsics) { - StubRoutines::_crc_table_adr = (address)StubRoutines::zarch::_crc_table; StubRoutines::_updateBytesCRC32 = generate_CRC32_updateBytes(); } if (UseCRC32CIntrinsics) { - StubRoutines::_crc32c_table_addr = (address)StubRoutines::zarch::_crc32c_table; StubRoutines::_updateBytesCRC32C = generate_CRC32C_updateBytes(); } diff --git a/src/hotspot/cpu/s390/stubRoutines_s390.cpp b/src/hotspot/cpu/s390/stubRoutines_s390.cpp index e75928ad00e61..6feb20f960473 100644 --- a/src/hotspot/cpu/s390/stubRoutines_s390.cpp +++ b/src/hotspot/cpu/s390/stubRoutines_s390.cpp @@ -78,14 +78,17 @@ void StubRoutines::zarch::generate_load_absolute_address(MacroAssembler* masm, R #endif } +address StubRoutines::crc_table_addr() { return (address)StubRoutines::zarch::_crc_table; } +address StubRoutines::crc32c_table_addr() { return (address)StubRoutines::zarch::_crc32c_table; } + void StubRoutines::zarch::generate_load_crc_table_addr(MacroAssembler* masm, Register table) { const uint64_t table_contents = 0x77073096UL; // required contents of table[1] - generate_load_absolute_address(masm, table, StubRoutines::_crc_table_adr, table_contents); + generate_load_absolute_address(masm, table, StubRoutines::crc_table_addr(), table_contents); } void StubRoutines::zarch::generate_load_crc32c_table_addr(MacroAssembler* masm, Register table) { const uint64_t table_contents = 0xf26b8303UL; // required contents of table[1] - generate_load_absolute_address(masm, table, StubRoutines::_crc32c_table_addr, table_contents); + generate_load_absolute_address(masm, table, StubRoutines::crc32c_table_addr(), table_contents); } diff --git a/src/hotspot/cpu/s390/stubRoutines_s390.hpp b/src/hotspot/cpu/s390/stubRoutines_s390.hpp index 7a4bc18eb7d4c..494d90cd85aa8 100644 --- a/src/hotspot/cpu/s390/stubRoutines_s390.hpp +++ b/src/hotspot/cpu/s390/stubRoutines_s390.hpp @@ -62,6 +62,7 @@ enum method_handles_platform_dependent_constants { class zarch { friend class StubGenerator; + friend class StubRoutines; public: enum { nof_instance_allocators = 10 }; diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp index 30ce971837812..df321f63a4d32 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp @@ -4095,15 +4095,11 @@ void StubGenerator::generate_initial_stubs() { StubRoutines::x86::_double_sign_flip = generate_fp_mask(StubId::stubgen_double_sign_flip_id, 0x8000000000000000); if (UseCRC32Intrinsics) { - // set table address before stub generation which use it - StubRoutines::_crc_table_adr = (address)StubRoutines::x86::_crc_table; StubRoutines::_updateBytesCRC32 = generate_updateBytesCRC32(); } if (UseCRC32CIntrinsics) { bool supports_clmul = VM_Version::supports_clmul(); - StubRoutines::x86::generate_CRC32C_table(supports_clmul); - StubRoutines::_crc32c_table_addr = (address)StubRoutines::x86::_crc32c_table; StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C(supports_clmul); } diff --git a/src/hotspot/cpu/x86/stubRoutines_x86.cpp b/src/hotspot/cpu/x86/stubRoutines_x86.cpp index 9b524ae94cf45..ee9cea08e647c 100644 --- a/src/hotspot/cpu/x86/stubRoutines_x86.cpp +++ b/src/hotspot/cpu/x86/stubRoutines_x86.cpp @@ -45,6 +45,17 @@ STUBGEN_ARCH_ENTRIES_DO(DEFINE_ARCH_ENTRY, DEFINE_ARCH_ENTRY_INIT) #undef DEFINE_ARCH_ENTRY_INIT #undef DEFINE_ARCH_ENTRY +address StubRoutines::crc_table_addr() { + return (address)StubRoutines::x86::_crc_table; +} +address StubRoutines::crc32c_table_addr() { + if (StubRoutines::x86::_crc32c_table == nullptr) { + bool supports_clmul = VM_Version::supports_clmul(); + StubRoutines::x86::generate_CRC32C_table(supports_clmul); + } + return (address)StubRoutines::x86::_crc32c_table; +} + address StubRoutines::x86::_k256_adr = nullptr; address StubRoutines::x86::_k256_W_adr = nullptr; address StubRoutines::x86::_k512_W_addr = nullptr; @@ -291,7 +302,7 @@ static uint32_t crc32c_f_pow_n(uint32_t n) { return result; } -juint *StubRoutines::x86::_crc32c_table; +juint* StubRoutines::x86::_crc32c_table = nullptr; void StubRoutines::x86::generate_CRC32C_table(bool is_pclmulqdq_table_supported) { diff --git a/src/hotspot/cpu/x86/stubRoutines_x86.hpp b/src/hotspot/cpu/x86/stubRoutines_x86.hpp index c4930e1593c47..7d13c4f6e7ac9 100644 --- a/src/hotspot/cpu/x86/stubRoutines_x86.hpp +++ b/src/hotspot/cpu/x86/stubRoutines_x86.hpp @@ -44,6 +44,7 @@ enum platform_dependent_constants { class x86 { friend class StubGenerator; + friend class StubRoutines; friend class VMStructs; // declare fields for arch-specific entries diff --git a/src/hotspot/cpu/zero/stubDeclarations_zero.hpp b/src/hotspot/cpu/zero/stubDeclarations_zero.hpp index 2357bbb51699d..3126cf7146004 100644 --- a/src/hotspot/cpu/zero/stubDeclarations_zero.hpp +++ b/src/hotspot/cpu/zero/stubDeclarations_zero.hpp @@ -37,7 +37,7 @@ do_arch_blob, \ do_arch_entry, \ do_arch_entry_init) \ - do_arch_blob(initial, 0) \ + do_arch_blob(initial, 32) \ #define STUBGEN_CONTINUATION_BLOBS_ARCH_DO(do_stub, \ @@ -58,7 +58,7 @@ do_arch_blob, \ do_arch_entry, \ do_arch_entry_init) \ - do_arch_blob(final, 0) \ + do_arch_blob(final, 32) \ #endif // CPU_ZERO_STUBDECLARATIONS_HPP diff --git a/src/hotspot/cpu/zero/stubRoutines_zero.cpp b/src/hotspot/cpu/zero/stubRoutines_zero.cpp index 47d2c27eefdf1..9b53f09be5dc7 100644 --- a/src/hotspot/cpu/zero/stubRoutines_zero.cpp +++ b/src/hotspot/cpu/zero/stubRoutines_zero.cpp @@ -28,4 +28,5 @@ #include "runtime/javaThread.hpp" #include "runtime/stubRoutines.hpp" -// zero has no arch-specific stubs nor any associated entries +address StubRoutines::crc_table_addr() { ShouldNotCallThis(); return nullptr; } +address StubRoutines::crc32c_table_addr() { ShouldNotCallThis(); return nullptr; } diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp index 41531b083fc5a..71331b578a578 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp @@ -131,6 +131,8 @@ class CompilerToVM { static address dlog10; static address dpow; + static address crc_table_addr; + static address symbol_init; static address symbol_clinit; diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp index b6d919fdfe937..8a1a02d62b379 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp @@ -151,6 +151,8 @@ address CompilerToVM::Data::dlog; address CompilerToVM::Data::dlog10; address CompilerToVM::Data::dpow; +address CompilerToVM::Data::crc_table_addr; + address CompilerToVM::Data::symbol_init; address CompilerToVM::Data::symbol_clinit; @@ -289,6 +291,7 @@ void CompilerToVM::Data::initialize(JVMCI_TRAPS) { SET_TRIGFUNC_OR_NULL(dtanh); SET_TRIGFUNC_OR_NULL(dcbrt); + SET_TRIGFUNC_OR_NULL(crc_table_addr); #undef SET_TRIGFUNC_OR_NULL diff --git a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp index 32ef3eb3e1486..88d098468e9d7 100644 --- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp +++ b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp @@ -147,6 +147,7 @@ static_field(CompilerToVM::Data, dlog, address) \ static_field(CompilerToVM::Data, dlog10, address) \ static_field(CompilerToVM::Data, dpow, address) \ + static_field(CompilerToVM::Data, crc_table_addr, address) \ \ static_field(CompilerToVM::Data, symbol_init, address) \ static_field(CompilerToVM::Data, symbol_clinit, address) \ @@ -417,8 +418,6 @@ static_field(StubRoutines, _dilithiumMontMulByConstant, address) \ static_field(StubRoutines, _dilithiumDecomposePoly, address) \ static_field(StubRoutines, _updateBytesCRC32, address) \ - static_field(StubRoutines, _crc_table_adr, address) \ - static_field(StubRoutines, _crc32c_table_addr, address) \ static_field(StubRoutines, _updateBytesCRC32C, address) \ static_field(StubRoutines, _updateBytesAdler32, address) \ static_field(StubRoutines, _multiplyToLen, address) \ diff --git a/src/hotspot/share/runtime/stubDeclarations.hpp b/src/hotspot/share/runtime/stubDeclarations.hpp index 3574aeaf6369c..4af017687fa07 100644 --- a/src/hotspot/share/runtime/stubDeclarations.hpp +++ b/src/hotspot/share/runtime/stubDeclarations.hpp @@ -631,7 +631,7 @@ do_arch_entry, do_arch_entry_init) \ end_blob(preuniverse) \ -#define STUBGEN_INITIAL_BLOBS_DO(do_blob, end_blob, \ +#define STUBGEN_INITIAL_BLOBS_DO(do_blob, end_blob, \ do_stub, \ do_entry, do_entry_init, \ do_entry_array, \ @@ -651,12 +651,9 @@ do_stub(initial, updateBytesCRC32) \ do_entry(initial, updateBytesCRC32, updateBytesCRC32, \ updateBytesCRC32) \ - do_entry(initial, updateBytesCRC32, crc_table_adr, crc_table_addr) \ do_stub(initial, updateBytesCRC32C) \ do_entry(initial, updateBytesCRC32C, updateBytesCRC32C, \ updateBytesCRC32C) \ - do_entry(initial, updateBytesCRC32C, crc32c_table_addr, \ - crc32c_table_addr) \ do_stub(initial, f2hf) \ do_entry(initial, f2hf, f2hf, f2hf_adr) \ do_stub(initial, hf2f) \ diff --git a/src/hotspot/share/runtime/stubRoutines.cpp b/src/hotspot/share/runtime/stubRoutines.cpp index 2c50fe5091523..e365d744d2b91 100644 --- a/src/hotspot/share/runtime/stubRoutines.cpp +++ b/src/hotspot/share/runtime/stubRoutines.cpp @@ -144,8 +144,8 @@ static BufferBlob* initialize_stubs(BlobId blob_id, if (lt.is_enabled()) { LogStream ls(lt); ls.print_cr("%s\t not generated", buffer_name); - return nullptr; } + return nullptr; } TraceTime timer(timer_msg, TRACETIME_LOG(Info, startuptime)); // Add extra space for large CodeEntryAlignment diff --git a/src/hotspot/share/runtime/stubRoutines.hpp b/src/hotspot/share/runtime/stubRoutines.hpp index b333d6d74b91a..edd393549cdf2 100644 --- a/src/hotspot/share/runtime/stubRoutines.hpp +++ b/src/hotspot/share/runtime/stubRoutines.hpp @@ -304,6 +304,12 @@ class StubRoutines: AllStatic { return dest_uninitialized ? _arrayof_oop_disjoint_arraycopy_uninit : _arrayof_oop_disjoint_arraycopy; } + // These methods is implemented in architecture-specific code. + // Any table that is returned must be allocated once-only in + // foreign memory (or C heap) rather generated in the code cache. + static address crc_table_addr(); + static address crc32c_table_addr(); + typedef void (*DataCacheWritebackStub)(void *); static DataCacheWritebackStub DataCacheWriteback_stub() { return CAST_TO_FN_PTR(DataCacheWritebackStub, _data_cache_writeback); } typedef void (*DataCacheWritebackSyncStub)(bool);