[PATCH v2 0/2] 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... -- v2: kernel32/tests: Don't use _ReadWriteBarrier() on clang. 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
From: Jinoh Kang <jinoh.kang.kr(a)gmail.com> Some clang versions do not support _ReadWriteBarrier() when targeting armv7-windows (MSVC mode). --- dlls/kernel32/tests/virtual.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index 1c84acfc215..f35fbdee8dc 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -4467,7 +4467,7 @@ static DWORD CALLBACK sbtest_thread_proc( void *arg ) return 0; } -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) #pragma intrinsic(_ReadWriteBarrier) void _ReadWriteBarrier(void); @@ -4478,14 +4478,14 @@ static void WINAPI compiler_barrier(void) _ReadWriteBarrier(); } -#else /* _MSC_VER */ +#else /* defined(_MSC_VER) && !defined(__clang__) */ static void WINAPI compiler_barrier(void) { __asm__ __volatile__("" ::: "memory"); } -#endif /* _MSC_VER */ +#endif /* defined(_MSC_VER) && !defined(__clang__) */ static LONG store_buffer_litmus_test( void (*WINAPI barrier0)(void), void (*WINAPI barrier1)(void) ) { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7895
v2: Fix build on clang MSVC mode for arm(v7)-windows. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7895#note_101920
participants (2)
-
Jinoh Kang -
Jinoh Kang (@iamahuman)