8293999: [JVMCI] need support for aligned constants in generated code larger than 8 bytes
Reviewed-by: dlong, dnsimon
This commit is contained in:
parent
8aa1526b44
commit
f3ca0cab75
@ -236,8 +236,9 @@ void MachConstantBaseNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const {
|
||||
|
||||
Register r = as_Register(ra_->get_encode(this));
|
||||
CodeSection* consts_section = __ code()->consts();
|
||||
CodeSection* insts_section = __ code()->insts();
|
||||
// constants section size is aligned according to the align_at_start settings of the next section
|
||||
int consts_size = CodeSection::align_at_start(consts_section->size(), CodeBuffer::SECT_INSTS);
|
||||
int consts_size = insts_section->align_at_start(consts_section->size());
|
||||
assert(constant_table.size() == consts_size, "must be: %d == %d", constant_table.size(), consts_size);
|
||||
|
||||
// Materialize the constant table base.
|
||||
|
@ -422,6 +422,21 @@ void CodeSection::expand_locs(int new_capacity) {
|
||||
}
|
||||
}
|
||||
|
||||
int CodeSection::alignment() const {
|
||||
if (_index == CodeBuffer::SECT_CONSTS) {
|
||||
// CodeBuffer controls the alignment of the constants section
|
||||
return _outer->_const_section_alignment;
|
||||
}
|
||||
if (_index == CodeBuffer::SECT_INSTS) {
|
||||
return (int) CodeEntryAlignment;
|
||||
}
|
||||
if (_index == CodeBuffer::SECT_STUBS) {
|
||||
// CodeBuffer installer expects sections to be HeapWordSize aligned
|
||||
return HeapWordSize;
|
||||
}
|
||||
ShouldNotReachHere();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Support for emitting the code to its final location.
|
||||
/// The pattern is the same for all functions.
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "code/oopRecorder.hpp"
|
||||
#include "code/relocInfo.hpp"
|
||||
#include "compiler/compiler_globals.hpp"
|
||||
#include "utilities/align.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
#include "utilities/growableArray.hpp"
|
||||
@ -256,18 +257,13 @@ class CodeSection {
|
||||
void relocate(address at, RelocationHolder const& rspec, int format = 0);
|
||||
void relocate(address at, relocInfo::relocType rtype, int format = 0, jint method_index = 0);
|
||||
|
||||
static int alignment(int section);
|
||||
int alignment() { return alignment(_index); }
|
||||
int alignment() const;
|
||||
|
||||
// Slop between sections, used only when allocating temporary BufferBlob buffers.
|
||||
static csize_t end_slop() { return MAX2((int)sizeof(jdouble), (int)CodeEntryAlignment); }
|
||||
|
||||
static csize_t align_at_start(csize_t off, int section) {
|
||||
return (csize_t) align_up(off, alignment(section));
|
||||
}
|
||||
|
||||
csize_t align_at_start(csize_t off) const {
|
||||
return align_at_start(off, _index);
|
||||
return (csize_t) align_up(off, alignment());
|
||||
}
|
||||
|
||||
// Ensure there's enough space left in the current section.
|
||||
@ -431,6 +427,8 @@ class CodeBuffer: public StackObj DEBUG_ONLY(COMMA private Scrubber) {
|
||||
SharedTrampolineRequests* _shared_trampoline_requests; // used to collect requests for shared trampolines
|
||||
bool _finalize_stubs; // Indicate if we need to finalize stubs to make CodeBuffer final.
|
||||
|
||||
int _const_section_alignment;
|
||||
|
||||
#ifndef PRODUCT
|
||||
AsmRemarks _asm_remarks;
|
||||
DbgStrings _dbg_strings;
|
||||
@ -456,6 +454,10 @@ class CodeBuffer: public StackObj DEBUG_ONLY(COMMA private Scrubber) {
|
||||
_insts.initialize_outer(this, SECT_INSTS);
|
||||
_stubs.initialize_outer(this, SECT_STUBS);
|
||||
|
||||
// Default is to align on 8 bytes. A compiler can change this
|
||||
// if larger alignment (e.g., 32-byte vector masks) is required.
|
||||
_const_section_alignment = (int) sizeof(jdouble);
|
||||
|
||||
#ifndef PRODUCT
|
||||
_decode_begin = NULL;
|
||||
// Collect block comments, but restrict collection to cases where a disassembly is output.
|
||||
@ -709,6 +711,10 @@ class CodeBuffer: public StackObj DEBUG_ONLY(COMMA private Scrubber) {
|
||||
// Request for a shared stub to the interpreter
|
||||
void shared_stub_to_interp_for(ciMethod* callee, csize_t call_offset);
|
||||
|
||||
void set_const_section_alignment(int align) {
|
||||
_const_section_alignment = align_up(align, HeapWordSize);
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
public:
|
||||
// Printing / Decoding
|
||||
@ -746,19 +752,4 @@ inline bool CodeSection::maybe_expand_to_ensure_remaining(csize_t amount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
inline int CodeSection::alignment(int section) {
|
||||
if (section == CodeBuffer::SECT_CONSTS) {
|
||||
return (int) sizeof(jdouble);
|
||||
}
|
||||
if (section == CodeBuffer::SECT_INSTS) {
|
||||
return (int) CodeEntryAlignment;
|
||||
}
|
||||
if (section == CodeBuffer::SECT_STUBS) {
|
||||
// CodeBuffer installer expects sections to be HeapWordSize aligned
|
||||
return HeapWordSize;
|
||||
}
|
||||
ShouldNotReachHere();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // SHARE_ASM_CODEBUFFER_HPP
|
||||
|
@ -687,7 +687,7 @@ JVMCI::CodeInstallResult CodeInstaller::install(JVMCICompiler* compiler,
|
||||
_instructions = buffer.insts();
|
||||
_constants = buffer.consts();
|
||||
|
||||
initialize_fields(stream, code_flags, method, JVMCI_CHECK_OK);
|
||||
initialize_fields(stream, code_flags, method, buffer, JVMCI_CHECK_OK);
|
||||
JVMCI::CodeInstallResult result = initialize_buffer(compiled_code, buffer, stream, code_flags, JVMCI_CHECK_OK);
|
||||
|
||||
u4 available = stream->available();
|
||||
@ -770,7 +770,7 @@ JVMCI::CodeInstallResult CodeInstaller::install(JVMCICompiler* compiler,
|
||||
return result;
|
||||
}
|
||||
|
||||
void CodeInstaller::initialize_fields(HotSpotCompiledCodeStream* stream, u1 code_flags, methodHandle& method, JVMCI_TRAPS) {
|
||||
void CodeInstaller::initialize_fields(HotSpotCompiledCodeStream* stream, u1 code_flags, methodHandle& method, CodeBuffer& buffer, JVMCI_TRAPS) {
|
||||
if (!method.is_null()) {
|
||||
_parameter_count = method->size_of_parameters();
|
||||
JVMCI_event_2("installing code for %s", method->name_and_sig_as_C_string());
|
||||
@ -797,6 +797,7 @@ void CodeInstaller::initialize_fields(HotSpotCompiledCodeStream* stream, u1 code
|
||||
// Pre-calculate the constants section size. This is required for PC-relative addressing.
|
||||
u4 data_section_size = stream->read_u4("dataSectionSize");
|
||||
u1 data_section_alignment = stream->read_u1("dataSectionAlignment");
|
||||
buffer.set_const_section_alignment(data_section_alignment);
|
||||
if ((_constants->alignment() % data_section_alignment) != 0) {
|
||||
JVMCI_ERROR("invalid data section alignment: %d [constants alignment: %d]%s",
|
||||
data_section_alignment, _constants->alignment(), stream->context());
|
||||
@ -851,8 +852,8 @@ JVMCI::CodeInstallResult CodeInstaller::initialize_buffer(JVMCIObject compiled_c
|
||||
assert((CodeBuffer::SECT_INSTS == CodeBuffer::SECT_STUBS - 1) &&
|
||||
(CodeBuffer::SECT_CONSTS == CodeBuffer::SECT_INSTS - 1), "sections order: consts, insts, stubs");
|
||||
// buffer content: [constants + code_align] + [code + stubs_align] + [stubs]
|
||||
int total_size = align_up(_constants_size, CodeSection::alignment(CodeBuffer::SECT_INSTS)) +
|
||||
align_up(_code_size, CodeSection::alignment(CodeBuffer::SECT_STUBS)) +
|
||||
int total_size = align_up(_constants_size, buffer.insts()->alignment()) +
|
||||
align_up(_code_size, buffer.stubs()->alignment()) +
|
||||
stubs_size;
|
||||
|
||||
if (total_size > JVMCINMethodSizeLimit) {
|
||||
|
@ -361,7 +361,7 @@ protected:
|
||||
GrowableArray<MonitorValue*>* read_monitor_values(HotSpotCompiledCodeStream* stream, u1 frame_flags, JVMCI_TRAPS);
|
||||
|
||||
// extract the fields of the HotSpotCompiledCode
|
||||
void initialize_fields(HotSpotCompiledCodeStream* stream, u1 code_flags, methodHandle& method, JVMCI_TRAPS);
|
||||
void initialize_fields(HotSpotCompiledCodeStream* stream, u1 code_flags, methodHandle& method, CodeBuffer& buffer, JVMCI_TRAPS);
|
||||
void initialize_dependencies(HotSpotCompiledCodeStream* stream, u1 code_flags, OopRecorder* oop_recorder, JVMCI_TRAPS);
|
||||
|
||||
int estimate_stubs_size(HotSpotCompiledCodeStream* stream, JVMCI_TRAPS);
|
||||
|
Loading…
Reference in New Issue
Block a user