#include "PalRedhawkCommon.h"
#include "CommonMacros.inl"
-#include "GCMemoryHelpers.h"
#include "GCMemoryHelpers.inl"
// This function clears a piece of memory in a GC safe way.
return mem;
}
+#if defined(TARGET_X86) || defined(TARGET_AMD64)
+ //
+ // Memory writes are already ordered
+ //
+ #define GCHeapMemoryBarrier()
+#else
+ #define GCHeapMemoryBarrier() MemoryBarrier()
+#endif
+
// Move memory, in a way that is compatible with a move onto the heap, but
// does not require the destination pointer to be on the heap.
COOP_PINVOKE_HELPER(void, RhBulkMoveWithWriteBarrier, (uint8_t* pDest, uint8_t* pSrc, size_t cbDest))
{
+ // It is possible that the bulk write is publishing object references accessible so far only
+ // by the current thread to shared memory.
+ // The memory model requires that writes performed by current thread are observable no later
+ // than the writes that will actually publish the references.
+ GCHeapMemoryBarrier();
+
if (pDest <= pSrc || pSrc + cbDest <= pDest)
InlineForwardGCSafeCopy(pDest, pSrc, cbDest);
else
InlinedBulkWriteBarrier(pDest, cbDest);
}
-
-void REDHAWK_CALLCONV RhpBulkWriteBarrier(void* pMemStart, uint32_t cbMemSize)
-{
- InlinedBulkWriteBarrier(pMemStart, cbMemSize);
-}
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-//
-// Unmanaged GC memory helpers
-//
-
-EXTERN_C void REDHAWK_CALLCONV RhpBulkWriteBarrier(void* pMemStart, uint32_t cbMemSize);