Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/stubDeclarations_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
do_arch_blob, \
do_arch_entry, \
do_arch_entry_init) \
do_arch_blob(preuniverse, 32) \
do_arch_blob(preuniverse, 0) \


#define STUBGEN_INITIAL_BLOBS_ARCH_DO(do_stub, \
Expand Down
7 changes: 1 addition & 6 deletions src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11654,12 +11654,7 @@ class StubGenerator: public StubCodeGenerator {

// Initialization
void generate_preuniverse_stubs() {
// Initialize runtime addresses needed by AOTCodeAddressTable.
// Note, they are not stubs and not located in CodeCache.
if (UseCRC32Intrinsics || UseCRC32CIntrinsics) {
// set table address before stub generation which use it
StubRoutines::_crc_table_addr = (address)StubRoutines::aarch64::_crc_table;
}
// preuniverse stubs are not needed for aarch64
}

void generate_initial_stubs() {
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/cpu/aarch64/stubRoutines_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/cpu/aarch64/stubRoutines_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ enum platform_dependent_constants {

class aarch64 {
friend class StubGenerator;
friend class StubRoutines;
#if INCLUDE_JVMCI
friend class JVMCIVMStructs;
#endif
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/cpu/arm/stubRoutines_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
2 changes: 1 addition & 1 deletion src/hotspot/cpu/ppc/stubDeclarations_ppc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
do_arch_blob, \
do_arch_entry, \
do_arch_entry_init) \
do_arch_blob(preuniverse, 32) \
do_arch_blob(preuniverse, 0) \


#define STUBGEN_INITIAL_BLOBS_ARCH_DO(do_stub, \
Expand Down
9 changes: 1 addition & 8 deletions src/hotspot/cpu/ppc/stubGenerator_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4960,14 +4960,7 @@ void generate_lookup_secondary_supers_table_stub() {

// Initialization
void generate_preuniverse_stubs() {
// Initialize runtime addresses needed by AOTCodeAddressTable.
// Note, they are not stubs and not located in CodeCache.
if (UseCRC32Intrinsics) {
StubRoutines::_crc_table_addr = StubRoutines::ppc::generate_crc_constants(REVERSE_CRC32_POLY);
}
if (UseCRC32CIntrinsics) {
StubRoutines::_crc32c_table_addr = StubRoutines::ppc::generate_crc_constants(REVERSE_CRC32C_POLY);
}
// preuniverse stubs are not needed for ppc
}

void generate_initial_stubs() {
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/cpu/ppc/stubRoutines_ppc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ enum platform_dependent_constants {

class ppc {
friend class StubGenerator;
friend class StubRoutines;

private:
public:
Expand Down
16 changes: 16 additions & 0 deletions src/hotspot/cpu/ppc/stubRoutines_ppc_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/riscv/stubDeclarations_riscv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
do_arch_blob, \
do_arch_entry, \
do_arch_entry_init) \
do_arch_blob(preuniverse, 32) \
do_arch_blob(preuniverse, 0) \


#define STUBGEN_INITIAL_BLOBS_ARCH_DO(do_stub, \
Expand Down
7 changes: 1 addition & 6 deletions src/hotspot/cpu/riscv/stubGenerator_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6661,12 +6661,7 @@ static const int64_t right_3_bits = right_n_bits(3);

// Initialization
void generate_preuniverse_stubs() {
// Initialize runtime addresses needed by AOTCodeAddressTable.
// Note, they are not stubs and not located in CodeCache.
if (UseCRC32Intrinsics) {
// set table address before stub generation which use it
StubRoutines::_crc_table_addr = (address)StubRoutines::riscv::_crc_table;
}
// preuniverse stubs are not needed for riscv
}

void generate_initial_stubs() {
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/cpu/riscv/stubRoutines_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/cpu/riscv/stubRoutines_riscv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ enum platform_dependent_constants {

class riscv {
friend class StubGenerator;
friend class StubRoutines;
#if INCLUDE_JVMCI
friend class JVMCIVMStructs;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/s390/stubDeclarations_s390.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
do_arch_blob, \
do_arch_entry, \
do_arch_entry_init) \
do_arch_blob(preuniverse, 32) \
do_arch_blob(preuniverse, 0) \


#define STUBGEN_INITIAL_BLOBS_ARCH_DO(do_stub, \
Expand Down
9 changes: 1 addition & 8 deletions src/hotspot/cpu/s390/stubGenerator_s390.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3284,14 +3284,7 @@ class StubGenerator: public StubCodeGenerator {
}

void generate_preuniverse_stubs() {
// Initialize runtime addresses needed by AOTCodeAddressTable.
// Note, they are not stubs and not located in CodeCache.
if (UseCRC32Intrinsics) {
StubRoutines::_crc_table_addr = (address)StubRoutines::zarch::_crc_table;
}
if (UseCRC32CIntrinsics) {
StubRoutines::_crc32c_table_addr = (address)StubRoutines::zarch::_crc32c_table;
}
// preuniverse stubs are not needed for s390
}

void generate_initial_stubs() {
Expand Down
7 changes: 5 additions & 2 deletions src/hotspot/cpu/s390/stubRoutines_s390.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_addr, 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);
}


Expand Down
1 change: 1 addition & 0 deletions src/hotspot/cpu/s390/stubRoutines_s390.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ enum method_handles_platform_dependent_constants {

class zarch {
friend class StubGenerator;
friend class StubRoutines;

public:
enum { nof_instance_allocators = 10 };
Expand Down
14 changes: 1 addition & 13 deletions src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4051,19 +4051,7 @@ void StubGenerator::create_control_words() {
// Initialization
void StubGenerator::generate_preuniverse_stubs() {
// atomic calls
StubRoutines::_fence_entry = generate_orderaccess_fence();

// Initialize runtime addresses needed by AOTCodeAddressTable.
// Note, they are not stubs and not located in CodeCache.
if (UseCRC32Intrinsics) {
// set table address before stub generation which use it
StubRoutines::_crc_table_addr = (address)StubRoutines::x86::_crc_table;
}
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::_fence_entry = generate_orderaccess_fence();
}

void StubGenerator::generate_initial_stubs() {
Expand Down
13 changes: 12 additions & 1 deletion src/hotspot/cpu/x86/stubRoutines_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {

Expand Down
1 change: 1 addition & 0 deletions src/hotspot/cpu/x86/stubRoutines_x86.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/zero/stubDeclarations_zero.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
do_arch_blob, \
do_arch_entry, \
do_arch_entry_init) \
do_arch_blob(preuniverse, 32) \
do_arch_blob(preuniverse, 0) \


#define STUBGEN_INITIAL_BLOBS_ARCH_DO(do_stub, \
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/cpu/zero/stubRoutines_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
2 changes: 0 additions & 2 deletions src/hotspot/share/jvmci/vmStructs_jvmci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,6 @@
static_field(StubRoutines, _dilithiumMontMulByConstant, address) \
static_field(StubRoutines, _dilithiumDecomposePoly, address) \
static_field(StubRoutines, _updateBytesCRC32, address) \
static_field(StubRoutines, _crc_table_addr, address) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please export via CompilerToVM::Data?

diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp
index 41531b083fc..71331b578a5 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 b6d919fdfe9..8a1a02d62b3 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 1408cb09b0a..88d098468e9 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)                                      \

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mur47x111 sure. But do you need also crc32c_table_addr? And I don't see initialization. Can you prepare full patch for JVMCI which I can integrate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialization is done by SET_TRIGFUNC_OR_NULL(). I see.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I will add crc32c_table_addr myself then.

Copy link
Contributor Author

@vnkozlov vnkozlov Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that crc32c_table_addr() failed on Aarch64 because we should not call it.
I will go with your patch @mur47x111 then and let you solve crc32c.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I also ran across the ShouldNotCallThis on aarch64 and decided to drop that because anyway we don't use crc32c_table_addr. I think crc32c_table_addr is only used internally in HotSpot but not via intrinsification call. Let's only export crc_table_addr for now. I will examine the crc32c_table_addr later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @mur47x111

static_field(StubRoutines, _crc32c_table_addr, address) \
static_field(StubRoutines, _updateBytesCRC32C, address) \
static_field(StubRoutines, _updateBytesAdler32, address) \
static_field(StubRoutines, _multiplyToLen, address) \
Expand Down
3 changes: 0 additions & 3 deletions src/hotspot/share/runtime/stubDeclarations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,12 +651,9 @@
do_stub(initial, updateBytesCRC32) \
do_entry(initial, updateBytesCRC32, updateBytesCRC32, \
updateBytesCRC32) \
do_entry(initial, updateBytesCRC32, crc_table_addr, 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) \
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/runtime/stubRoutines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ class StubRoutines: AllStatic {
return dest_uninitialized ? _arrayof_oop_disjoint_arraycopy_uninit : _arrayof_oop_disjoint_arraycopy;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have a comment here to note that 1) this method is implemented in architecture-specific code 2) any table that is returned must be allocated once-only in foreign memory rather generated in the code cache.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

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);
Expand Down