8337657: AArch64: No need for acquire fence in safepoint poll during JNI calls

Reviewed-by: phh
This commit is contained in:
Dmitry Chuyko 2024-08-09 17:56:37 +00:00
parent 60fa08fcfe
commit 358d77dafb
2 changed files with 4 additions and 19 deletions

View file

@ -1883,16 +1883,8 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
// Check for safepoint operation in progress and/or pending suspend requests. // Check for safepoint operation in progress and/or pending suspend requests.
{ {
// We need an acquire here to ensure that any subsequent load of the // No need for acquire as Java threads always disarm themselves.
// global SafepointSynchronize::_state flag is ordered after this load __ safepoint_poll(safepoint_in_progress, true /* at_return */, false /* acquire */, false /* in_nmethod */);
// of the thread-local polling word. We don't want this poll to
// return false (i.e. not safepointing) and a later poll of the global
// SafepointSynchronize::_state spuriously to return true.
//
// This is to avoid a race when we're in a native->Java transition
// racing the code which wakes up from a safepoint.
__ safepoint_poll(safepoint_in_progress, true /* at_return */, true /* acquire */, false /* in_nmethod */);
__ ldrw(rscratch1, Address(rthread, JavaThread::suspend_flags_offset())); __ ldrw(rscratch1, Address(rthread, JavaThread::suspend_flags_offset()));
__ cbnzw(rscratch1, safepoint_in_progress); __ cbnzw(rscratch1, safepoint_in_progress);
__ bind(safepoint_in_progress_done); __ bind(safepoint_in_progress_done);

View file

@ -1413,15 +1413,8 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
{ {
Label L, Continue; Label L, Continue;
// We need an acquire here to ensure that any subsequent load of the // No need for acquire as Java threads always disarm themselves.
// global SafepointSynchronize::_state flag is ordered after this load __ safepoint_poll(L, true /* at_return */, false /* acquire */, false /* in_nmethod */);
// of the thread-local polling word. We don't want this poll to
// return false (i.e. not safepointing) and a later poll of the global
// SafepointSynchronize::_state spuriously to return true.
//
// This is to avoid a race when we're in a native->Java transition
// racing the code which wakes up from a safepoint.
__ safepoint_poll(L, true /* at_return */, true /* acquire */, false /* in_nmethod */);
__ ldrw(rscratch2, Address(rthread, JavaThread::suspend_flags_offset())); __ ldrw(rscratch2, Address(rthread, JavaThread::suspend_flags_offset()));
__ cbz(rscratch2, Continue); __ cbz(rscratch2, Continue);
__ bind(L); __ bind(L);