[PATCH 0/1] MR7895: Revert "kernel32/tests: Don't use _ReadWriteBarrier on ARM platforms."
This reverts commit 504a305a60849704f2d83b55e9aabb26d89edf11. The choice of weak barrier was by design. The stronger barrier broke the positive half of the litmus test for FlushProcessWriteBuffers():
virtual.c:4568: Test failed: expected write-read reordering with compiler barrier only (got 0 reorderings)
FlushProcessWriteBuffers() is used in tandem with a compiler-only barrier to implement fast synchronization, where only one side is executed frequently and the other side only occassionally (e.g., garbage collection). Prominent applications include .NET and HotSpot JVM. Although _ReadWriteBarrier() is "marked deprecated," it is in fact used by Microsoft's own STL library (with explicit suppression of warning) to implement a compiler-only memory barrier[^1]. The deprecation notice suggests C++11 atomics as the (only?) alternative. [^1]: https://github.com/microsoft/STL/blob/b5df16a98934319e2e6864d6036cbe9cd9c74f... -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7895
From: Jinoh Kang <jinoh.kang.kr(a)gmail.com> This reverts commit 504a305a60849704f2d83b55e9aabb26d89edf11. The choice of weak barrier was by design. The stronger barrier broke the positive half of the litmus test for FlushProcessWriteBuffers():
virtual.c:4568: Test failed: expected write-read reordering with compiler barrier only (got 0 reorderings)
FlushProcessWriteBuffers() is used in tandem with a compiler-only barrier to implement fast synchronization, where only one side is executed frequently and the other side only occassionally (e.g., garbage collection). Prominent applications include .NET and HotSpot JVM. Although _ReadWriteBarrier() is "marked deprecated," it is in fact used by Microsoft's own STL library (with explicit suppression of warning) to implement a compiler-only memory barrier [1]. The deprecation notice suggests C++11 atomics as the (only?) alternative. [1]: https://github.com/microsoft/STL/blob/b5df16a98934319e2e6864d6036cbe9cd9c74f... --- dlls/kernel32/tests/virtual.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index b83b32dc88c..1c84acfc215 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -4469,16 +4469,13 @@ static DWORD CALLBACK sbtest_thread_proc( void *arg ) #ifdef _MSC_VER +#pragma intrinsic(_ReadWriteBarrier) +void _ReadWriteBarrier(void); + static void WINAPI compiler_barrier(void) { -#if defined(__i386__) || defined(__x86_64__) #pragma warning(suppress:4996) _ReadWriteBarrier(); -#elif defined(__arm__) - __dmb(_ARM_BARRIER_ISH); -#elif defined(__aarch64__) - __dmb(_ARM64_BARRIER_ISH); -#endif } #else /* _MSC_VER */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7895
Although _ReadWriteBarrier() is "marked deprecated," it is in fact used by Microsoft's own STL library (with explicit suppression of warning) to implement a compiler-only memory barrier 1. The deprecation notice suggests C++11 atomics as the (only?) alternative.
It breaks the build in MSVC mode on ARM, so that would need to be fixed some other way. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7895#note_101866
On Sat Apr 26 00:51:02 2025 +0000, Alexandre Julliard wrote:
Although _ReadWriteBarrier() is "marked deprecated," it is in fact used by Microsoft's own STL library (with explicit suppression of warning) to implement a compiler-only memory barrier 1. The deprecation notice suggests C++11 atomics as the (only?) alternative. It breaks the build in MSVC mode on ARM, so that would need to be fixed some other way. Sorry. I cannot reproduce this error on my side using this MSVC on wine:
``` Microsoft (R) C/C++ Optimizing Compiler Version 19.43.34810 for ARM Copyright (C) Microsoft Corporation. All rights reserved. ``` Do you have an error log for this? Thanks. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7895#note_101897
On Sat Apr 26 00:51:02 2025 +0000, Jinoh Kang wrote:
Sorry. I cannot reproduce this error on my side using this MSVC on wine: ``` Microsoft (R) C/C++ Optimizing Compiler Version 19.43.34810 for ARM Copyright (C) Microsoft Corporation. All rights reserved. ``` Do you have an error log for this? Thanks. It's about Clang's MSVC mode, try `configure --with-mingw=clang`.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/7895#note_101918
participants (4)
-
Alexandre Julliard (@julliard) -
Jacek Caban (@jacek) -
Jinoh Kang -
Jinoh Kang (@iamahuman)