Bug 1207232: Let lockOwner be Atomic; r=terrence

--HG--
extra : commitid : FFrGdIRgTdY
extra : rebase_source : c04b2c8ed994fd3d74f3a4467015199d03e130ee
This commit is contained in:
Benjamin Bouvier 2015-09-22 19:26:21 +02:00
Родитель d64ac7ea6b
Коммит b34e6f5815
4 изменённых файлов: 16 добавлений и 20 удалений

Просмотреть файл

@ -673,7 +673,7 @@ class GCRuntime
bool onBackgroundThread() { return helperState.onBackgroundThread(); }
bool currentThreadOwnsGCLock() {
return lockOwner == PR_GetCurrentThread();
return lockOwner.value == PR_GetCurrentThread();
}
#endif // DEBUG
@ -684,15 +684,17 @@ class GCRuntime
void lockGC() {
PR_Lock(lock);
MOZ_ASSERT(!lockOwner);
#ifdef DEBUG
lockOwner = PR_GetCurrentThread();
MOZ_ASSERT(!lockOwner.value);
lockOwner.value = PR_GetCurrentThread();
#endif
}
void unlockGC() {
MOZ_ASSERT(lockOwner == PR_GetCurrentThread());
lockOwner = nullptr;
#ifdef DEBUG
MOZ_ASSERT(lockOwner.value == PR_GetCurrentThread());
lockOwner.value = nullptr;
#endif
PR_Unlock(lock);
}
@ -1298,7 +1300,7 @@ class GCRuntime
/* Synchronize GC heap access between main thread and GCHelperState. */
PRLock* lock;
mozilla::DebugOnly<PRThread*> lockOwner;
mozilla::DebugOnly<mozilla::Atomic<PRThread*>> lockOwner;
BackgroundAllocTask allocTask;
GCHelperState helperState;

Просмотреть файл

@ -1176,7 +1176,6 @@ GCRuntime::GCRuntime(JSRuntime* rt) :
noGCOrAllocationCheck(0),
#endif
lock(nullptr),
lockOwner(nullptr),
allocTask(rt, emptyChunks_),
helperState(rt)
{
@ -3409,11 +3408,11 @@ GCHelperState::waitForBackgroundThread()
MOZ_ASSERT(CurrentThreadCanAccessRuntime(rt));
#ifdef DEBUG
rt->gc.lockOwner = nullptr;
rt->gc.lockOwner.value = nullptr;
#endif
PR_WaitCondVar(done, PR_INTERVAL_NO_TIMEOUT);
#ifdef DEBUG
rt->gc.lockOwner = PR_GetCurrentThread();
rt->gc.lockOwner.value = PR_GetCurrentThread();
#endif
}

Просмотреть файл

@ -492,9 +492,6 @@ GlobalHelperThreadState::GlobalHelperThreadState()
threads(nullptr),
asmJSCompilationInProgress(false),
helperLock(nullptr),
#ifdef DEBUG
lockOwner(nullptr),
#endif
consumerWakeup(nullptr),
producerWakeup(nullptr),
pauseWakeup(nullptr),
@ -545,7 +542,7 @@ GlobalHelperThreadState::lock()
AssertCurrentThreadCanLock(HelperThreadStateLock);
PR_Lock(helperLock);
#ifdef DEBUG
lockOwner = PR_GetCurrentThread();
lockOwner.value = PR_GetCurrentThread();
#endif
}
@ -554,7 +551,7 @@ GlobalHelperThreadState::unlock()
{
MOZ_ASSERT(isLocked());
#ifdef DEBUG
lockOwner = nullptr;
lockOwner.value = nullptr;
#endif
PR_Unlock(helperLock);
}
@ -563,7 +560,7 @@ GlobalHelperThreadState::unlock()
bool
GlobalHelperThreadState::isLocked()
{
return lockOwner == PR_GetCurrentThread();
return lockOwner.value == PR_GetCurrentThread();
}
#endif
@ -572,14 +569,14 @@ GlobalHelperThreadState::wait(CondVar which, uint32_t millis)
{
MOZ_ASSERT(isLocked());
#ifdef DEBUG
lockOwner = nullptr;
lockOwner.value = nullptr;
#endif
DebugOnly<PRStatus> status =
PR_WaitCondVar(whichWakeup(which),
millis ? PR_MillisecondsToInterval(millis) : PR_INTERVAL_NO_TIMEOUT);
MOZ_ASSERT(status == PR_SUCCESS);
#ifdef DEBUG
lockOwner = PR_GetCurrentThread();
lockOwner.value = PR_GetCurrentThread();
#endif
}

Просмотреть файл

@ -242,9 +242,7 @@ class GlobalHelperThreadState
* used by all condition variables.
*/
PRLock* helperLock;
#ifdef DEBUG
PRThread* lockOwner;
#endif
mozilla::DebugOnly<mozilla::Atomic<PRThread*>> lockOwner;
/* Condvars for threads waiting/notifying each other. */
PRCondVar* consumerWakeup;