Skip to content

Commit

Permalink
8313419: Template interpreter produces no safepoint check for return …
Browse files Browse the repository at this point in the history
…bytecodes

Reviewed-by: pchilanomate
  • Loading branch information
Fredrik Bredberg authored and pchilano committed Aug 18, 2023
1 parent c36e009 commit bcba5e9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/hotspot/cpu/aarch64/templateTable_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2205,6 +2205,18 @@ void TemplateTable::_return(TosState state)
if (_desc->bytecode() == Bytecodes::_return)
__ membar(MacroAssembler::StoreStore);

if (_desc->bytecode() != Bytecodes::_return_register_finalizer) {
Label no_safepoint;
__ ldr(rscratch1, Address(rthread, JavaThread::polling_word_offset()));
__ tbz(rscratch1, log2i_exact(SafepointMechanism::poll_bit()), no_safepoint);
__ push(state);
__ push_cont_fastpath(rthread);
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint));
__ pop_cont_fastpath(rthread);
__ pop(state);
__ bind(no_safepoint);
}

// Narrow result if state is itos but result type is smaller.
// Need to narrow in the return bytecode rather than in generate_return_entry
// since compiled code callers expect the result to already be narrowed.
Expand Down
10 changes: 10 additions & 0 deletions src/hotspot/cpu/arm/templateTable_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2492,6 +2492,16 @@ void TemplateTable::_return(TosState state) {
__ bind(skip_register_finalizer);
}

if (_desc->bytecode() != Bytecodes::_return_register_finalizer) {
Label no_safepoint;
__ ldr(Rtemp, Address(Rthread, JavaThread::polling_word_offset()));
__ tbz(Rtemp, exact_log2(SafepointMechanism::poll_bit()), no_safepoint);
__ push(state);
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint));
__ pop(state);
__ bind(no_safepoint);
}

// Narrow result if state is itos but result type is smaller.
// Need to narrow in the return bytecode rather than in generate_return_entry
// since compiled code callers expect the result to already be narrowed.
Expand Down
13 changes: 13 additions & 0 deletions src/hotspot/cpu/riscv/templateTable_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2114,6 +2114,19 @@ void TemplateTable::_return(TosState state) {
__ membar(MacroAssembler::StoreStore);
}

if (_desc->bytecode() != Bytecodes::_return_register_finalizer) {
Label no_safepoint;
__ ld(t0, Address(xthread, JavaThread::polling_word_offset()));
__ test_bit(t0, t0, exact_log2(SafepointMechanism::poll_bit()));
__ beqz(t0, no_safepoint);
__ push(state);
__ push_cont_fastpath(xthread);
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint));
__ pop_cont_fastpath(xthread);
__ pop(state);
__ bind(no_safepoint);
}

// Narrow result if state is itos but result type is smaller.
// Need to narrow in the return bytecode rather than in generate_return_entry
// since compiled code callers expect the result to already be narrowed.
Expand Down

1 comment on commit bcba5e9

@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.