diff --git a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp index 5d57505ddc5..0495f766bab 100644 --- a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp @@ -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. diff --git a/src/hotspot/cpu/arm/templateTable_arm.cpp b/src/hotspot/cpu/arm/templateTable_arm.cpp index 263ff4f9e8b..b8f1fdeebda 100644 --- a/src/hotspot/cpu/arm/templateTable_arm.cpp +++ b/src/hotspot/cpu/arm/templateTable_arm.cpp @@ -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. diff --git a/src/hotspot/cpu/riscv/templateTable_riscv.cpp b/src/hotspot/cpu/riscv/templateTable_riscv.cpp index 87efd3522d9..c85f2b97b1a 100644 --- a/src/hotspot/cpu/riscv/templateTable_riscv.cpp +++ b/src/hotspot/cpu/riscv/templateTable_riscv.cpp @@ -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.