Skip to content

Commit 880afbc

Browse files
committed
Remove extraneous barriers
1 parent fefa82b commit 880afbc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/coreclr/vm/syncblk.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,7 +1428,7 @@ namespace
14281428
LIMITED_METHOD_CONTRACT;
14291429
ReleaseSpinLock(m_pLock);
14301430
}
1431-
}
1431+
};
14321432
}
14331433
#endif //!DACCESS_COMPILE
14341434

@@ -1773,9 +1773,10 @@ OBJECTHANDLE SyncBlock::GetOrCreateLock(OBJECTREF lockObj)
17731773
}
17741774
CONTRACTL_END;
17751775

1776-
if (m_Lock != (OBJECTHANDLE)NULL)
1776+
OBJECTHANDLE existingLock = VolatileLoad(&m_Lock);
1777+
if (existingLock != (OBJECTHANDLE)NULL)
17771778
{
1778-
return m_Lock;
1779+
return existingLock;
17791780
}
17801781

17811782
SetPrecious();
@@ -1794,7 +1795,7 @@ OBJECTHANDLE SyncBlock::GetOrCreateLock(OBJECTREF lockObj)
17941795
GCX_PREEMP_NO_DTOR_END();
17951796

17961797
// Check again now that we hold the spin-lock
1797-
OBJECTHANDLE existingLock = VolatileLoad(&m_Lock);
1798+
existingLock = m_Lock;
17981799
if (existingLock != (OBJECTHANDLE)NULL)
17991800
{
18001801
return existingLock;
@@ -1804,7 +1805,7 @@ OBJECTHANDLE SyncBlock::GetOrCreateLock(OBJECTREF lockObj)
18041805
// Grab the bits that are interesting for thin-lock info.
18051806
// This way we only call back into managed code
18061807
// to initialize the lock when necessary.
1807-
DWORD thinLock = (m_thinLock & ((SBLK_MASK_LOCK_THREADID) | (SBLK_MASK_LOCK_RECLEVEL)));
1808+
DWORD thinLock = (m_thinLock.LoadWithoutBarrier() & ((SBLK_MASK_LOCK_THREADID) | (SBLK_MASK_LOCK_RECLEVEL)));
18081809

18091810
if (thinLock != 0)
18101811
{
@@ -1831,7 +1832,7 @@ OBJECTHANDLE SyncBlock::GetOrCreateLock(OBJECTREF lockObj)
18311832
// It won't be used any more, but it will look out of date.
18321833
// Only clear the relevant bits, as the spin-lock bit is used to lock this method.
18331834
// That bit will be reset upon return.
1834-
m_thinLock &= ~((SBLK_MASK_LOCK_THREADID) | (SBLK_MASK_LOCK_RECLEVEL));
1835+
m_thinLock.StoreWithoutBarrier(m_thinLock.LoadWithoutBarrier() & ~((SBLK_MASK_LOCK_THREADID) | (SBLK_MASK_LOCK_RECLEVEL)));
18351836

18361837
return lockHandle;
18371838
}

0 commit comments

Comments
 (0)