Skip to content

Commit

Permalink
8300247: Harden C1 xchg on AArch64 and PPC
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Doerr <mdoerr@openjdk.org>
Reviewed-by: aph, rcastanedalo
  • Loading branch information
fisk and TheRealMDoerr committed Jan 26, 2023
1 parent 3f63381 commit 28545dc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3185,7 +3185,8 @@ void LIR_Assembler::atomic_op(LIR_Code code, LIR_Opr src, LIR_Opr data, LIR_Opr
__ encode_heap_oop(rscratch2, obj);
obj = rscratch2;
}
assert_different_registers(obj, addr.base(), tmp, rscratch1, dst);
assert_different_registers(obj, addr.base(), tmp, rscratch1);
assert_different_registers(dst, addr.base(), tmp, rscratch1);
__ lea(tmp, addr);
(_masm->*xchg)(dst, obj, tmp);
if (is_oop && UseCompressedOops) {
Expand Down
9 changes: 7 additions & 2 deletions src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3019,8 +3019,13 @@ void LIR_Assembler::atomic_op(LIR_Code code, LIR_Opr src, LIR_Opr data, LIR_Opr
__ lwarx(Rold, Rptr, MacroAssembler::cmpxchgx_hint_atomic_update());
__ stwcx_(Rco, Rptr);
} else {
const Register Robj = data->as_register();
assert_different_registers(Rptr, Rold, Robj);
Register Robj = data->as_register();
assert_different_registers(Rptr, Rold, Rtmp);
assert_different_registers(Rptr, Robj, Rtmp);
if (Robj == Rold) { // May happen with ZGC.
__ mr(Rtmp, Robj);
Robj = Rtmp;
}
__ ldarx(Rold, Rptr, MacroAssembler::cmpxchgx_hint_atomic_update());
__ stdcx_(Robj, Rptr);
}
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1967,7 +1967,8 @@ void LIR_Assembler::atomic_op(LIR_Code code, LIR_Opr src, LIR_Opr data, LIR_Opr
__ encode_heap_oop(t0, obj);
obj = t0;
}
assert_different_registers(obj, addr.base(), tmp, dst);
assert_different_registers(obj, addr.base(), tmp);
assert_different_registers(dst, addr.base(), tmp);
__ la(tmp, addr);
(_masm->*xchg)(dst, obj, tmp);
if (is_oop && UseCompressedOops) {
Expand Down

1 comment on commit 28545dc

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.