From: Jinoh Kang jinoh.kang.kr@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 */