8297763: Fix missing stub code expansion before align() in shared trampolines

Reviewed-by: fyang, luhenry
This commit is contained in:
Xiaolin Zheng 2022-12-05 12:43:57 +00:00 committed by Tobias Hartmann
parent 2300ed458d
commit f9e0f1d5b3
3 changed files with 19 additions and 2 deletions

@ -52,7 +52,14 @@ static bool emit_shared_trampolines(CodeBuffer* cb, CodeBuffer::SharedTrampoline
bool p_succeeded = true;
auto emit = [&](address dest, const CodeBuffer::Offsets &offsets) {
masm.set_code_section(cb->stubs());
masm.align(wordSize);
if (!is_aligned(masm.offset(), wordSize)) {
if (cb->stubs()->maybe_expand_to_ensure_remaining(NativeInstruction::instruction_size) && cb->blob() == NULL) {
ciEnv::current()->record_failure("CodeCache is full");
p_succeeded = false;
return p_succeeded;
}
masm.align(wordSize);
}
LinkedListIterator<int> it(offsets.head());
int offset = *it.next();

@ -53,7 +53,14 @@ static bool emit_shared_trampolines(CodeBuffer* cb, CodeBuffer::SharedTrampoline
bool p_succeeded = true;
auto emit = [&](address dest, const CodeBuffer::Offsets &offsets) {
masm.set_code_section(cb->stubs());
masm.align(wordSize, NativeCallTrampolineStub::data_offset);
if (!is_aligned(masm.offset() + NativeCallTrampolineStub::data_offset, wordSize)) {
if (cb->stubs()->maybe_expand_to_ensure_remaining(NativeInstruction::instruction_size) && cb->blob() == NULL) {
ciEnv::current()->record_failure("CodeCache is full");
p_succeeded = false;
return p_succeeded;
}
masm.align(wordSize, NativeCallTrampolineStub::data_offset);
}
LinkedListIterator<int> it(offsets.head());
int offset = *it.next();

@ -3128,6 +3128,9 @@ address MacroAssembler::emit_trampoline_stub(int insts_call_instruction_offset,
return NULL; // CodeBuffer::expand failed
}
// We are always 4-byte aligned here.
assert_alignment(pc());
// Create a trampoline stub relocation which relates this trampoline stub
// with the call instruction at insts_call_instruction_offset in the
// instructions code-section.