Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
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: 0 additions & 2 deletions src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

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: 0 additions & 2 deletions src/hotspot/cpu/ppc/stubGenerator_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

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: 0 additions & 2 deletions src/hotspot/cpu/riscv/stubGenerator_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

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: 0 additions & 2 deletions src/hotspot/cpu/s390/stubGenerator_s390.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

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_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);
}


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
4 changes: 0 additions & 4 deletions src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

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
4 changes: 2 additions & 2 deletions src/hotspot/cpu/zero/stubDeclarations_zero.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
do_arch_blob, \
do_arch_entry, \
do_arch_entry_init) \
do_arch_blob(initial, 0) \
do_arch_blob(initial, 32) \
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this any more?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, to call generate_initial_stubs() where _call_stub_entry is set.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, yes, how annoying.



#define STUBGEN_CONTINUATION_BLOBS_ARCH_DO(do_stub, \
Expand All @@ -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
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_adr, address) \
static_field(StubRoutines, _crc32c_table_addr, address) \
static_field(StubRoutines, _updateBytesCRC32C, address) \
static_field(StubRoutines, _updateBytesAdler32, address) \
static_field(StubRoutines, _multiplyToLen, address) \
Expand Down
5 changes: 1 addition & 4 deletions src/hotspot/share/runtime/stubDeclarations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand All @@ -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) \
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/stubRoutines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
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