Skip to content

Commit 84ef917

Browse files
committed
Introduced a GCHeapMemoryBarrier helper.
1 parent b82531e commit 84ef917

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/coreclr/nativeaot/Runtime/GCMemoryHelpers.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,25 @@ COOP_PINVOKE_CDECL_HELPER(void *, RhpGcSafeZeroMemory, (void * mem, size_t size)
3030
return mem;
3131
}
3232

33+
#if defined(TARGET_X86) || defined(TARGET_AMD64)
34+
//
35+
// Memory writes are already ordered
36+
//
37+
#define GCHeapMemoryBarrier()
38+
#else
39+
#define GCHeapMemoryBarrier() MemoryBarrier()
40+
#endif
41+
3342
// Move memory, in a way that is compatible with a move onto the heap, but
3443
// does not require the destination pointer to be on the heap.
3544

3645
COOP_PINVOKE_HELPER(void, RhBulkMoveWithWriteBarrier, (uint8_t* pDest, uint8_t* pSrc, size_t cbDest))
3746
{
38-
#if TARGET_ARM64
3947
// It is possible that the bulk write is publishing object references accessible so far only
4048
// by the current thread to shared memory.
4149
// The memory model requires that writes performed by current thread are observable no later
4250
// than the writes that will actually publish the references.
43-
MemoryBarrier();
44-
#endif
51+
GCHeapMemoryBarrier();
4552

4653
if (pDest <= pSrc || pSrc + cbDest <= pDest)
4754
InlineForwardGCSafeCopy(pDest, pSrc, cbDest);

0 commit comments

Comments
 (0)