summaryrefslogtreecommitdiff
path: root/src/gc/gc.cpp
diff options
context:
space:
mode:
authorSteve MacLean <sdmaclea.qdt@qualcommdatacenter.com>2017-07-06 23:59:49 +0000
committerMaoni Stephens <Maoni0@users.noreply.github.com>2017-08-01 15:44:12 -0700
commit59f2a57563b7488779a9b93220a9dfe5c6a45700 (patch)
tree084ddc416ff410ac8b6b6455db3c2e932ae42c85 /src/gc/gc.cpp
parent7eb6865565fbd3c45ca58e398a72750fa43c432e (diff)
downloadcoreclr-59f2a57563b7488779a9b93220a9dfe5c6a45700.tar.gz
coreclr-59f2a57563b7488779a9b93220a9dfe5c6a45700.tar.bz2
coreclr-59f2a57563b7488779a9b93220a9dfe5c6a45700.zip
GC Prefer CompareExchange
Diffstat (limited to 'src/gc/gc.cpp')
-rw-r--r--src/gc/gc.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp
index 4ba4b66c92..5afc024090 100644
--- a/src/gc/gc.cpp
+++ b/src/gc/gc.cpp
@@ -831,7 +831,7 @@ respin:
return TRUE;
}
- if (Interlocked::Decrement(&join_struct.r_join_lock) != (join_struct.n_threads - 1))
+ if (Interlocked::CompareExchange(&join_struct.r_join_lock, 0, join_struct.n_threads) == 0)
{
if (!join_struct.wait_done)
{
@@ -1083,7 +1083,7 @@ public:
{
dprintf (3, ("cm: probing %Ix", obj));
retry:
- if (Interlocked::Exchange (&needs_checking, 1) == 0)
+ if (Interlocked::CompareExchange(&needs_checking, 1, 0) == 0)
{
// If we spend too much time spending all the allocs,
// consider adding a high water mark and scan up
@@ -1122,7 +1122,7 @@ retry:
retry:
dprintf (3, ("loh alloc: probing %Ix", obj));
- if (Interlocked::Exchange (&needs_checking, 1) == 0)
+ if (Interlocked::CompareExchange(&needs_checking, 1, 0) == 0)
{
if (obj == rwp_object)
{
@@ -1581,7 +1581,7 @@ static void enter_spin_lock_noinstru (RAW_KEYWORD(volatile) int32_t* lock)
{
retry:
- if (Interlocked::Exchange (lock, 0) >= 0)
+ if (Interlocked::CompareExchange(lock, 0, -1) >= 0)
{
unsigned int i = 0;
while (VolatileLoad(lock) >= 0)
@@ -1623,7 +1623,7 @@ retry:
inline
static BOOL try_enter_spin_lock_noinstru(RAW_KEYWORD(volatile) int32_t* lock)
{
- return (Interlocked::Exchange (&*lock, 0) < 0);
+ return (Interlocked::CompareExchange(&*lock, 0, -1) < 0);
}
inline
@@ -1742,7 +1742,7 @@ static void enter_spin_lock (GCSpinLock* spin_lock)
{
retry:
- if (Interlocked::Exchange (&spin_lock->lock, 0) >= 0)
+ if (Interlocked::CompareExchange(&spin_lock->lock, 0, -1) >= 0)
{
unsigned int i = 0;
while (spin_lock->lock >= 0)
@@ -1793,7 +1793,7 @@ retry:
inline BOOL try_enter_spin_lock(GCSpinLock* spin_lock)
{
- return (Interlocked::Exchange (&spin_lock->lock, 0) < 0);
+ return (Interlocked::CompareExchange(&spin_lock->lock, 0, -1) < 0);
}
inline
@@ -10269,7 +10269,7 @@ gc_heap::enter_gc_done_event_lock()
uint32_t dwSwitchCount = 0;
retry:
- if (Interlocked::Exchange (&gc_done_event_lock, 0) >= 0)
+ if (Interlocked::CompareExchange(&gc_done_event_lock, 0, -1) >= 0)
{
while (gc_done_event_lock >= 0)
{
@@ -35717,7 +35717,7 @@ void CFinalize::EnterFinalizeLock()
GCToEEInterface::IsPreemptiveGCDisabled(GCToEEInterface::GetThread()));
retry:
- if (Interlocked::Exchange (&lock, 0) >= 0)
+ if (Interlocked::CompareExchange(&lock, 0, -1) >= 0)
{
unsigned int i = 0;
while (lock >= 0)