Skip to content
8 changes: 7 additions & 1 deletion src/coreclr/vm/ceeload.inl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ SIZE_T LookupMap<SIZE_T>::GetValueAt(PTR_TADDR pValue, TADDR* pFlags, TADDR supp
{
WRAPPER_NO_CONTRACT;

TADDR value = VolatileLoadWithoutBarrier(pValue); // LookupMap's hold pointers, so we can use a data dependency instead of an explicit barrier here.
// LookupMap's hold pointers to data which is immutable, so normally we could use a data
// dependency instead of an explicit barrier here. However, the access pattern between
// m_TypeDefToMethodTableMap and m_MethodDefToDescMap/m_FieldDefToDescMap is such that a
// data dependency is not sufficient to ensure that the MethodTable is visible when we
// access the MethodDesc/FieldDesc. Since those loads are independent. So we use
// VolatileLoad here to ensure proper ordering.
TADDR value = VolatileLoad(pValue);

if (pFlags)
*pFlags = value & supportedFlags;
Expand Down
Loading