diff --git a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp index 4e07d0728a437..4f245ff28ea80 100644 --- a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp +++ b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp @@ -1212,6 +1212,9 @@ void CodeInstaller::site_DataPatch(CodeBuffer& buffer, jint pc_offset, HotSpotCo case PATCH_DATA_SECTION_REFERENCE: { int data_offset = stream->read_u4("data:offset"); if (0 <= data_offset && data_offset < _constants_size) { + if (!is_aligned(data_offset, CompilerToVM::Data::get_data_section_item_alignment())) { + JVMCI_ERROR("data offset 0x%x is not %d-byte aligned%s", data_offset, relocInfo::addr_unit(), stream->context()); + } pd_patch_DataSectionReference(pc_offset, data_offset, JVMCI_CHECK); } else { JVMCI_ERROR("data offset 0x%x points outside data section (size 0x%x)%s", data_offset, _constants_size, stream->context()); diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp index 1a0799566a97b..9b6dd072bbd25 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.hpp @@ -91,6 +91,9 @@ class CompilerToVM { static address symbol_init; static address symbol_clinit; + // Minimum alignment of an offset into CodeBuffer::SECT_CONSTS + static int data_section_item_alignment; + public: static void initialize(JVMCI_TRAPS); @@ -98,6 +101,10 @@ class CompilerToVM { assert(_max_oop_map_stack_offset > 0, "must be initialized"); return Data::_max_oop_map_stack_offset; } + + static int get_data_section_item_alignment() { + return data_section_item_alignment; + } }; static bool cstring_equals(const char* const& s0, const char* const& s1) { diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp index 04322c7b54e09..969aeaad8f432 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp @@ -95,6 +95,8 @@ address CompilerToVM::Data::dpow; address CompilerToVM::Data::symbol_init; address CompilerToVM::Data::symbol_clinit; +int CompilerToVM::Data::data_section_item_alignment; + void CompilerToVM::Data::initialize(JVMCI_TRAPS) { Klass_vtable_start_offset = in_bytes(Klass::vtable_start_offset()); Klass_vtable_length_offset = in_bytes(Klass::vtable_length_offset()); @@ -133,6 +135,8 @@ void CompilerToVM::Data::initialize(JVMCI_TRAPS) { _fields_annotations_base_offset = Array::base_offset_in_bytes(); + data_section_item_alignment = relocInfo::addr_unit(); + BarrierSet* bs = BarrierSet::barrier_set(); if (bs->is_a(BarrierSet::CardTableBarrierSet)) { CardTable::CardValue* base = ci_card_table_address(); diff --git a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp index 688686865d68e..08d65ef854693 100644 --- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp +++ b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp @@ -100,6 +100,8 @@ static_field(CompilerToVM::Data, symbol_init, address) \ static_field(CompilerToVM::Data, symbol_clinit, address) \ \ + static_field(CompilerToVM::Data, data_section_item_alignment, int) \ + \ static_field(Abstract_VM_Version, _features, uint64_t) \ \ nonstatic_field(Annotations, _fields_annotations, Array*) \