Skip to content

8356556: AArch64: No need for acquire fence in safepoint poll in FFM #25211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/aarch64.ad
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,7 @@ void MachEpilogNode::emit(C2_MacroAssembler *masm, PhaseRegAlloc *ra_) const {
code_stub = &stub->entry();
}
__ relocate(relocInfo::poll_return_type);
__ safepoint_poll(*code_stub, true /* at_return */, false /* acquire */, true /* in_nmethod */);
__ safepoint_poll(*code_stub, true /* at_return */, true /* in_nmethod */);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ void LIR_Assembler::return_op(LIR_Opr result, C1SafepointPollStub* code_stub) {

code_stub->set_safepoint_offset(__ offset());
__ relocate(relocInfo::poll_return_type);
__ safepoint_poll(*code_stub->entry(), true /* at_return */, false /* acquire */, true /* in_nmethod */);
__ safepoint_poll(*code_stub->entry(), true /* at_return */, true /* in_nmethod */);
__ ret(lr);
}

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/aarch64/downcallLinker_aarch64.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, Arm Limited. All rights reserved.
* Copyright (c) 2019, 2025 Arm Limited. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -289,7 +289,7 @@ void DowncallLinker::StubGenerator::generate() {

__ verify_sve_vector_length(tmp1);

__ safepoint_poll(L_safepoint_poll_slow_path, true /* at_return */, true /* acquire */, false /* in_nmethod */, tmp1);
__ safepoint_poll(L_safepoint_poll_slow_path, true /* at_return */, false /* in_nmethod */, tmp1);

__ ldrw(tmp1, Address(rthread, JavaThread::suspend_flags_offset()));
__ cbnzw(tmp1, L_safepoint_poll_slow_path);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ void InterpreterMacroAssembler::remove_activation(
// the stack, will call InterpreterRuntime::at_unwind.
Label slow_path;
Label fast_path;
safepoint_poll(slow_path, true /* at_return */, false /* acquire */, false /* in_nmethod */);
safepoint_poll(slow_path, true /* at_return */, false /* in_nmethod */);
br(Assembler::AL, fast_path);
bind(slow_path);
push(state);
Expand Down
9 changes: 2 additions & 7 deletions src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,13 +553,8 @@ address MacroAssembler::target_addr_for_insn_or_null(address insn_addr, unsigned
return MacroAssembler::target_addr_for_insn(insn_addr, insn);
}

void MacroAssembler::safepoint_poll(Label& slow_path, bool at_return, bool acquire, bool in_nmethod, Register tmp) {
if (acquire) {
lea(tmp, Address(rthread, JavaThread::polling_word_offset()));
ldar(tmp, tmp);
} else {
ldr(tmp, Address(rthread, JavaThread::polling_word_offset()));
}
void MacroAssembler::safepoint_poll(Label& slow_path, bool at_return, bool in_nmethod, Register tmp) {
ldr(tmp, Address(rthread, JavaThread::polling_word_offset()));
if (at_return) {
// Note that when in_nmethod is set, the stack pointer is incremented before the poll. Therefore,
// we may safely use the sp instead to perform the stack watermark check.
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class MacroAssembler: public Assembler {
virtual void check_and_handle_popframe(Register java_thread);
virtual void check_and_handle_earlyret(Register java_thread);

void safepoint_poll(Label& slow_path, bool at_return, bool acquire, bool in_nmethod, Register tmp = rscratch1);
void safepoint_poll(Label& slow_path, bool at_return, bool in_nmethod, Register tmp = rscratch1);
void rt_call(address dest, Register tmp = rscratch1);

// Load Effective Address
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1875,8 +1875,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,

// Check for safepoint operation in progress and/or pending suspend requests.
{
// No need for acquire as Java threads always disarm themselves.
__ safepoint_poll(safepoint_in_progress, true /* at_return */, false /* acquire */, false /* in_nmethod */);
__ safepoint_poll(safepoint_in_progress, true /* at_return */, false /* in_nmethod */);
__ ldrw(rscratch1, Address(rthread, JavaThread::suspend_flags_offset()));
__ cbnzw(rscratch1, safepoint_in_progress);
__ bind(safepoint_in_progress_done);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ address TemplateInterpreterGenerator::generate_CRC32_update_entry() {

Label slow_path;
// If we need a safepoint check, generate full interpreter entry.
__ safepoint_poll(slow_path, false /* at_return */, false /* acquire */, false /* in_nmethod */);
__ safepoint_poll(slow_path, false /* at_return */, false /* in_nmethod */);

// We don't generate local frame and don't align stack because
// we call stub code and there is no safepoint on this path.
Expand Down Expand Up @@ -1060,7 +1060,7 @@ address TemplateInterpreterGenerator::generate_CRC32_updateBytes_entry(AbstractI

Label slow_path;
// If we need a safepoint check, generate full interpreter entry.
__ safepoint_poll(slow_path, false /* at_return */, false /* acquire */, false /* in_nmethod */);
__ safepoint_poll(slow_path, false /* at_return */, false /* in_nmethod */);

// We don't generate local frame and don't align stack because
// we call stub code and there is no safepoint on this path.
Expand Down Expand Up @@ -1449,8 +1449,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
{
Label L, Continue;

// No need for acquire as Java threads always disarm themselves.
__ safepoint_poll(L, true /* at_return */, false /* acquire */, false /* in_nmethod */);
__ safepoint_poll(L, true /* at_return */, false /* in_nmethod */);
__ ldrw(rscratch2, Address(rthread, JavaThread::suspend_flags_offset()));
__ cbz(rscratch2, Continue);
__ bind(L);
Expand Down