From 1a42384e765bd070532869813fa9aa01592a6628 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 31 Jan 2024 09:20:52 +0100 Subject: [PATCH] Zero-extend comparand parameter of RhpLockCmpXchg16 to match the managed prototype which uses signed type argument and is thus sign extended. Conversely, sign extend the return value. --- src/coreclr/nativeaot/Runtime/arm/Interlocked.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreclr/nativeaot/Runtime/arm/Interlocked.S b/src/coreclr/nativeaot/Runtime/arm/Interlocked.S index ef32dbf3fabb0..67a079863d986 100644 --- a/src/coreclr/nativeaot/Runtime/arm/Interlocked.S +++ b/src/coreclr/nativeaot/Runtime/arm/Interlocked.S @@ -36,6 +36,7 @@ LEAF_END RhpLockCmpXchg8, _TEXT // r1 = value // r2 = comparand LEAF_ENTRY RhpLockCmpXchg16, _TEXT + uxth r2, r2 dmb ALTERNATE_ENTRY RhpLockCmpXchg16AVLocation LOCAL_LABEL(CmpXchg16Retry): @@ -46,7 +47,7 @@ LOCAL_LABEL(CmpXchg16Retry): cmp r12, #0 bne LOCAL_LABEL(CmpXchg16Retry) LOCAL_LABEL(CmpXchg16Exit): - mov r0, r3 + sxth r0, r3 dmb bx lr LEAF_END RhpLockCmpXchg16, _TEXT