зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1207232: Let lockOwner be Atomic; r=terrence
--HG-- extra : commitid : FFrGdIRgTdY extra : rebase_source : c04b2c8ed994fd3d74f3a4467015199d03e130ee
This commit is contained in:
Родитель
d64ac7ea6b
Коммит
b34e6f5815
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче