Skip to content

Commit 869879b

Browse files
DingliZhangRealFYang
authored andcommitted
8359105: RISC-V: No need for acquire fence in safepoint poll during JNI calls
Backport-of: 1a01839f8c0522a90710e101cce6ecc479a77529
1 parent cc08a51 commit 869879b

8 files changed

+9
-28
lines changed

src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ void LIR_Assembler::return_op(LIR_Opr result, C1SafepointPollStub* code_stub) {
401401

402402
code_stub->set_safepoint_offset(__ offset());
403403
__ relocate(relocInfo::poll_return_type);
404-
__ safepoint_poll(*code_stub->entry(), true /* at_return */, false /* acquire */, true /* in_nmethod */);
404+
__ safepoint_poll(*code_stub->entry(), true /* at_return */, true /* in_nmethod */);
405405
__ ret();
406406
}
407407

src/hotspot/cpu/riscv/downcallLinker_riscv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ void DowncallLinker::StubGenerator::generate() {
287287
__ membar(MacroAssembler::AnyAny);
288288
}
289289

290-
__ safepoint_poll(L_safepoint_poll_slow_path, true /* at_return */, true /* acquire */, false /* in_nmethod */);
290+
__ safepoint_poll(L_safepoint_poll_slow_path, true /* at_return */, false /* in_nmethod */);
291291
__ lwu(t0, Address(xthread, JavaThread::suspend_flags_offset()));
292292
__ bnez(t0, L_safepoint_poll_slow_path);
293293

src/hotspot/cpu/riscv/interp_masm_riscv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ void InterpreterMacroAssembler::remove_activation(TosState state,
645645
// the stack, will call InterpreterRuntime::at_unwind.
646646
Label slow_path;
647647
Label fast_path;
648-
safepoint_poll(slow_path, true /* at_return */, false /* acquire */, false /* in_nmethod */);
648+
safepoint_poll(slow_path, true /* at_return */, false /* in_nmethod */);
649649
j(fast_path);
650650

651651
bind(slow_path);

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3773,11 +3773,8 @@ void MacroAssembler::check_klass_subtype(Register sub_klass,
37733773
bind(L_failure);
37743774
}
37753775

3776-
void MacroAssembler::safepoint_poll(Label& slow_path, bool at_return, bool acquire, bool in_nmethod, Register tmp_reg) {
3776+
void MacroAssembler::safepoint_poll(Label& slow_path, bool at_return, bool in_nmethod, Register tmp_reg) {
37773777
ld(tmp_reg, Address(xthread, JavaThread::polling_word_offset()));
3778-
if (acquire) {
3779-
membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore);
3780-
}
37813778
if (at_return) {
37823779
bgtu(in_nmethod ? sp : fp, tmp_reg, slow_path, /* is_far */ true);
37833780
} else {

src/hotspot/cpu/riscv/macroAssembler_riscv.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class MacroAssembler: public Assembler {
4444

4545
MacroAssembler(CodeBuffer* code) : Assembler(code) {}
4646

47-
void safepoint_poll(Label& slow_path, bool at_return, bool acquire, bool in_nmethod, Register tmp_reg = t0);
47+
void safepoint_poll(Label& slow_path, bool at_return, bool in_nmethod, Register tmp_reg = t0);
4848

4949
// Alignment
5050
int align(int modulus, int extra_offset = 0);

src/hotspot/cpu/riscv/riscv.ad

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,7 @@ void MachEpilogNode::emit(C2_MacroAssembler *masm, PhaseRegAlloc *ra_) const {
14931493
code_stub = &stub->entry();
14941494
}
14951495
__ relocate(relocInfo::poll_return_type);
1496-
__ safepoint_poll(*code_stub, true /* at_return */, false /* acquire */, true /* in_nmethod */);
1496+
__ safepoint_poll(*code_stub, true /* at_return */, true /* in_nmethod */);
14971497
}
14981498
}
14991499

src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,15 +1777,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
17771777

17781778
// check for safepoint operation in progress and/or pending suspend requests
17791779
{
1780-
// We need an acquire here to ensure that any subsequent load of the
1781-
// global SafepointSynchronize::_state flag is ordered after this load
1782-
// of the thread-local polling word. We don't want this poll to
1783-
// return false (i.e. not safepointing) and a later poll of the global
1784-
// SafepointSynchronize::_state spuriously to return true.
1785-
// This is to avoid a race when we're in a native->Java transition
1786-
// racing the code which wakes up from a safepoint.
1787-
1788-
__ safepoint_poll(safepoint_in_progress, true /* at_return */, true /* acquire */, false /* in_nmethod */);
1780+
__ safepoint_poll(safepoint_in_progress, true /* at_return */, false /* in_nmethod */);
17891781
__ lwu(t0, Address(xthread, JavaThread::suspend_flags_offset()));
17901782
__ bnez(t0, safepoint_in_progress);
17911783
__ bind(safepoint_in_progress_done);

src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,15 +1229,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
12291229
{
12301230
Label L, Continue;
12311231

1232-
// We need an acquire here to ensure that any subsequent load of the
1233-
// global SafepointSynchronize::_state flag is ordered after this load
1234-
// of the thread-local polling word. We don't want this poll to
1235-
// return false (i.e. not safepointing) and a later poll of the global
1236-
// SafepointSynchronize::_state spuriously to return true.
1237-
//
1238-
// This is to avoid a race when we're in a native->Java transition
1239-
// racing the code which wakes up from a safepoint.
1240-
__ safepoint_poll(L, true /* at_return */, true /* acquire */, false /* in_nmethod */);
1232+
__ safepoint_poll(L, true /* at_return */, false /* in_nmethod */);
12411233
__ lwu(t1, Address(xthread, JavaThread::suspend_flags_offset()));
12421234
__ beqz(t1, Continue);
12431235
__ bind(L);
@@ -1388,7 +1380,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
13881380

13891381
Label slow_path;
13901382
Label fast_path;
1391-
__ safepoint_poll(slow_path, true /* at_return */, false /* acquire */, false /* in_nmethod */);
1383+
__ safepoint_poll(slow_path, true /* at_return */, false /* in_nmethod */);
13921384
__ j(fast_path);
13931385

13941386
__ bind(slow_path);

0 commit comments

Comments
 (0)