Skip to content

Commit

Permalink
8297763: Fix missing stub code expansion before align() in shared tra…
Browse files Browse the repository at this point in the history
…mpolines

Reviewed-by: fyang, luhenry
  • Loading branch information
zhengxiaolinX authored and TobiHartmann committed Dec 5, 2022
1 parent 2300ed4 commit f9e0f1d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/hotspot/cpu/aarch64/codeBuffer_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
9 changes: 8 additions & 1 deletion src/hotspot/cpu/riscv/codeBuffer_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

1 comment on commit f9e0f1d

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.