1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

aarch64: Fix swap_atomic retry

* lightening/aarch64-cpu.c (swap_atomic): If the swap fails, and the dst
register was the same as the val, we would stomple val during the retry.
Fixes https://github.com/wingo/fibers/issues/83#issuecomment-2068847127.
This commit is contained in:
Tony Garnock-Jones 2024-04-22 13:24:17 +02:00 committed by Andy Wingo
parent d759faa27a
commit 2c0126e3ef

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013-2017, 2019 Free Software Foundation, Inc.
* Copyright (C) 2013-2017, 2019, 2024 Free Software Foundation, Inc.
*
* This file is part of GNU lightning.
*
@ -2532,10 +2532,10 @@ str_atomic(jit_state_t *_jit, int32_t loc, int32_t val)
static void
swap_atomic(jit_state_t *_jit, int32_t dst, int32_t loc, int32_t val)
{
void *retry = jit_address(_jit);
int32_t result = jit_gpr_regno(get_temp_gpr(_jit));
int32_t val_or_tmp = dst == val ? jit_gpr_regno(get_temp_gpr(_jit)) : val;
movr(_jit, val_or_tmp, val);
void *retry = jit_address(_jit);
LDAXR(_jit, dst, loc);
STLXR(_jit, val_or_tmp, loc, result);
jit_patch_there(_jit, bnei(_jit, result, 0), retry);