Skip to content

Commit 8221c67

Browse files
authored
Merge pull request swiftlang#25960 from compnerd/nuclear-atomic-hammer
Runtime: add a workaround for Windows ARM64
2 parents 930699c + c0fb003 commit 8221c67

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

stdlib/public/SwiftShims/RefCount.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,4 +1495,15 @@ _Static_assert(_Alignof(InlineRefCounts) == _Alignof(__swift_uintptr_t),
14951495
"InlineRefCounts must be pointer-aligned");
14961496
#endif
14971497

1498+
#if defined(_WIN32) && defined(_M_ARM64)
1499+
namespace std {
1500+
template <>
1501+
inline void _Atomic_storage<swift::SideTableRefCountBits, 16>::_Unlock() const noexcept {
1502+
__dmb(0x8);
1503+
__iso_volatile_store32(&reinterpret_cast<volatile int &>(_Spinlock), 0);
1504+
__dmb(0x8);
1505+
}
1506+
}
1507+
#endif
1508+
14981509
#endif

stdlib/public/runtime/Metadata.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5168,3 +5168,14 @@ const HeapObject *swift_getKeyPathImpl(const void *pattern,
51685168
#define OVERRIDE_KEYPATH COMPATIBILITY_OVERRIDE
51695169
#define OVERRIDE_WITNESSTABLE COMPATIBILITY_OVERRIDE
51705170
#include "CompatibilityOverride.def"
5171+
5172+
#if defined(_WIN32) && defined(_M_ARM64)
5173+
namespace std {
5174+
template <>
5175+
inline void _Atomic_storage<::PoolRange, 16>::_Unlock() const noexcept {
5176+
__dmb(0x8);
5177+
__iso_volatile_store32(&reinterpret_cast<volatile int &>(_Spinlock), 0);
5178+
__dmb(0x8);
5179+
}
5180+
}
5181+
#endif

0 commit comments

Comments
 (0)