Skip to content

Commit 358d77d

Browse files
author
Dmitry Chuyko
committedAug 9, 2024
8337657: AArch64: No need for acquire fence in safepoint poll during JNI calls
Reviewed-by: phh
1 parent 60fa08f commit 358d77d

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed
 

‎src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp

+2-10
Original file line numberDiff line numberDiff line change
@@ -1883,16 +1883,8 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
18831883

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

‎src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp

+2-9
Original file line numberDiff line numberDiff line change
@@ -1413,15 +1413,8 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
14131413
{
14141414
Label L, Continue;
14151415

1416-
// We need an acquire here to ensure that any subsequent load of the
1417-
// global SafepointSynchronize::_state flag is ordered after this load
1418-
// of the thread-local polling word. We don't want this poll to
1419-
// return false (i.e. not safepointing) and a later poll of the global
1420-
// SafepointSynchronize::_state spuriously to return true.
1421-
//
1422-
// This is to avoid a race when we're in a native->Java transition
1423-
// racing the code which wakes up from a safepoint.
1424-
__ safepoint_poll(L, true /* at_return */, true /* acquire */, false /* in_nmethod */);
1416+
// No need for acquire as Java threads always disarm themselves.
1417+
__ safepoint_poll(L, true /* at_return */, false /* acquire */, false /* in_nmethod */);
14251418
__ ldrw(rscratch2, Address(rthread, JavaThread::suspend_flags_offset()));
14261419
__ cbz(rscratch2, Continue);
14271420
__ bind(L);

0 commit comments

Comments
 (0)
Failed to load comments.