Skip to content

Commit

Permalink
Bug 1290589 - Make JSRuntime's exclusiveAccessOwner a js::Thread::Id …
Browse files Browse the repository at this point in the history
…instead of a PRThread*; r=terrence
  • Loading branch information
fitzgen committed Aug 8, 2016
1 parent 833a2eb commit 6673f3f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions js/src/jscntxt.h
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ class MOZ_RAII AutoLockForExclusiveAccess
runtime->assertCanLock(ExclusiveAccessLock);
runtime->exclusiveAccessLock.lock();
#ifdef DEBUG
runtime->exclusiveAccessOwner = PR_GetCurrentThread();
runtime->exclusiveAccessOwner = mozilla::Some(ThisThread::GetId());
#endif
} else {
MOZ_ASSERT(!runtime->mainThreadHasExclusiveAccess);
Expand All @@ -775,8 +775,8 @@ class MOZ_RAII AutoLockForExclusiveAccess
~AutoLockForExclusiveAccess() {
if (runtime->numExclusiveThreads) {
#ifdef DEBUG
MOZ_ASSERT(runtime->exclusiveAccessOwner == PR_GetCurrentThread());
runtime->exclusiveAccessOwner = nullptr;
MOZ_ASSERT(*runtime->exclusiveAccessOwner == ThisThread::GetId());
runtime->exclusiveAccessOwner.reset();
#endif
runtime->exclusiveAccessLock.unlock();
} else {
Expand Down
6 changes: 3 additions & 3 deletions js/src/vm/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ JSRuntime::JSRuntime(JSRuntime* parentRuntime)
promiseRejectionTrackerCallback(nullptr),
promiseRejectionTrackerCallbackData(nullptr),
#ifdef DEBUG
exclusiveAccessOwner(nullptr),
mainThreadHasExclusiveAccess(false),
#endif
numExclusiveThreads(0),
Expand Down Expand Up @@ -432,7 +431,7 @@ JSRuntime::destroyRuntime()
*/
finishSelfHosting();

MOZ_ASSERT(!exclusiveAccessOwner);
MOZ_ASSERT(exclusiveAccessOwner.isNothing());

MOZ_ASSERT(!numExclusiveThreads);
AutoLockForExclusiveAccess lock(this);
Expand Down Expand Up @@ -899,7 +898,8 @@ JSRuntime::assertCanLock(RuntimeLock which)
// it must be done in the order below.
switch (which) {
case ExclusiveAccessLock:
MOZ_ASSERT(exclusiveAccessOwner != PR_GetCurrentThread());
MOZ_ASSERT_IF(exclusiveAccessOwner.isSome(),
exclusiveAccessOwner.ref() != js::ThisThread::GetId());
MOZ_FALLTHROUGH;
case HelperThreadStateLock:
MOZ_FALLTHROUGH;
Expand Down
5 changes: 3 additions & 2 deletions js/src/vm/Runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#endif
#include "js/UniquePtr.h"
#include "js/Vector.h"
#include "threading/Thread.h"
#include "vm/CodeCoverage.h"
#include "vm/CommonPropertyNames.h"
#include "vm/DateTime.h"
Expand Down Expand Up @@ -694,7 +695,7 @@ struct JSRuntime : public JS::shadow::Runtime,
*/
js::Mutex exclusiveAccessLock;
#ifdef DEBUG
PRThread* exclusiveAccessOwner;
mozilla::Maybe<js::Thread::Id> exclusiveAccessOwner;
bool mainThreadHasExclusiveAccess;
#endif

Expand All @@ -710,7 +711,7 @@ struct JSRuntime : public JS::shadow::Runtime,
#ifdef DEBUG
bool currentThreadHasExclusiveAccess() {
return (!numExclusiveThreads && mainThreadHasExclusiveAccess) ||
exclusiveAccessOwner == PR_GetCurrentThread();
exclusiveAccessOwner == mozilla::Some(js::ThisThread::GetId());
}
#endif // DEBUG

Expand Down

0 comments on commit 6673f3f

Please sign in to comment.