Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/coreclr/gc/handletable.inl
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ inline void HndAssignHandle(OBJECTHANDLE handle, OBJECTREF objref)
if (value)
HndWriteBarrier(handle, objref);

// store the pointer
*(_UNCHECKED_OBJECTREF *)handle = value;
// Store the pointer with release semantics so object field writes are visible
// before the handle can publish the object to another thread.
VolatileStore((_UNCHECKED_OBJECTREF *)handle, value);
}

// This is used by the GC before we actually construct the object so we cannot
Expand All @@ -69,8 +70,9 @@ inline void HndAssignHandleGC(OBJECTHANDLE handle, uint8_t* objref)
if (value)
HndWriteBarrierWorker(handle, value);

// store the pointer
*(_UNCHECKED_OBJECTREF *)handle = value;
// Store the pointer with release semantics so object field writes are visible
// before the handle can publish the object to another thread.
VolatileStore((_UNCHECKED_OBJECTREF *)handle, value);
}

inline void* HndInterlockedCompareExchangeHandle(OBJECTHANDLE handle, OBJECTREF objref, OBJECTREF oldObjref)
Expand Down
Loading