Skip to content

Commit

Permalink
Bug 1275749 - Part 1: Remove the DEBUG-only js::FutexRuntime::lockHol…
Browse files Browse the repository at this point in the history
…der_ member, since we already get those checks by using js::Mutex; r=terrence
  • Loading branch information
fitzgen committed Aug 22, 2016
1 parent 8114267 commit 012adba
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 38 deletions.
33 changes: 0 additions & 33 deletions js/src/builtin/AtomicsObject.cpp
Expand Up @@ -733,19 +733,9 @@ class AutoLockFutexAPI
AutoLockFutexAPI() {
js::Mutex* lock = FutexRuntime::lock_;
unique_.emplace(*lock);

#ifdef DEBUG
MOZ_ASSERT(!FutexRuntime::lockHolder_);
FutexRuntime::lockHolder_ = PR_GetCurrentThread();
#endif
}

~AutoLockFutexAPI() {
#ifdef DEBUG
MOZ_ASSERT(FutexRuntime::lockHolder_ == PR_GetCurrentThread());
FutexRuntime::lockHolder_ = nullptr;
#endif

unique_.reset();
}

Expand Down Expand Up @@ -928,25 +918,13 @@ js::FutexRuntime::lock()
js::Mutex* lock = lock_;

lock->lock();
#ifdef DEBUG
MOZ_ASSERT(!lockHolder_);
lockHolder_ = PR_GetCurrentThread();
#endif
}

/* static */ mozilla::Atomic<js::Mutex*> FutexRuntime::lock_;

#ifdef DEBUG
/* static */ mozilla::Atomic<PRThread*> FutexRuntime::lockHolder_;
#endif

/* static */ void
js::FutexRuntime::unlock()
{
#ifdef DEBUG
MOZ_ASSERT(lockHolder_ == PR_GetCurrentThread());
lockHolder_ = nullptr;
#endif
// Load the atomic pointer.
js::Mutex* lock = lock_;

Expand Down Expand Up @@ -993,7 +971,6 @@ js::FutexRuntime::wait(JSContext* cx, js::UniqueLock<js::Mutex>& locked,
{
MOZ_ASSERT(&cx->runtime()->fx == this);
MOZ_ASSERT(cx->runtime()->fx.canWait());
MOZ_ASSERT(lockHolder_ == PR_GetCurrentThread());
MOZ_ASSERT(state_ == Idle || state_ == WaitingInterrupted);

// Disallow waiting when a runtime is processing an interrupt.
Expand Down Expand Up @@ -1029,21 +1006,12 @@ js::FutexRuntime::wait(JSContext* cx, js::UniqueLock<js::Mutex>& locked,

state_ = Waiting;

#ifdef DEBUG
PRThread* holder = lockHolder_;
lockHolder_ = nullptr;
#endif

if (isTimed) {
mozilla::Unused << cond_->wait_until(locked, *sliceEnd);
} else {
cond_->wait(locked);
}

#ifdef DEBUG
lockHolder_ = holder;
#endif

switch (state_) {
case FutexRuntime::Waiting:
// Timeout or spurious wakeup.
Expand Down Expand Up @@ -1115,7 +1083,6 @@ js::FutexRuntime::wait(JSContext* cx, js::UniqueLock<js::Mutex>& locked,
void
js::FutexRuntime::wake(WakeReason reason)
{
MOZ_ASSERT(lockHolder_ == PR_GetCurrentThread());
MOZ_ASSERT(isWaiting());

if ((state_ == WaitingInterrupted || state_ == WaitingNotifiedForInterrupt) && reason == WakeExplicit) {
Expand Down
5 changes: 0 additions & 5 deletions js/src/builtin/AtomicsObject.h
Expand Up @@ -144,11 +144,6 @@ class FutexRuntime
// or coarser.
static mozilla::Atomic<js::Mutex*> lock_;

#ifdef DEBUG
// Null or the thread holding the lock.
static mozilla::Atomic<PRThread*> lockHolder_;
#endif

// A flag that controls whether waiting is allowed.
bool canWait_;
};
Expand Down

0 comments on commit 012adba

Please sign in to comment.