From 395b1382d70933158ec6a9c7c994b7615eb8a5e4 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Mon, 1 Aug 2016 18:39:44 -0700 Subject: [PATCH] Bug 1290220 - Switch the simulators over to js::Thread instead of PRThread; r=terrence --- js/src/jit/arm/Simulator-arm.cpp | 11 ++++------- js/src/jit/arm/Simulator-arm.h | 9 +++++---- js/src/jit/mips32/Simulator-mips32.cpp | 11 ++++------- js/src/jit/mips32/Simulator-mips32.h | 9 +++++---- js/src/jit/mips64/Simulator-mips64.cpp | 11 ++++------- js/src/jit/mips64/Simulator-mips64.h | 9 +++++---- 6 files changed, 27 insertions(+), 33 deletions(-) diff --git a/js/src/jit/arm/Simulator-arm.cpp b/js/src/jit/arm/Simulator-arm.cpp index 00577a63de5b..58197b51a674 100644 --- a/js/src/jit/arm/Simulator-arm.cpp +++ b/js/src/jit/arm/Simulator-arm.cpp @@ -368,16 +368,16 @@ class AutoLockSimulatorCache : public LockGuard : Base(sim->cacheLock_) , sim_(sim) { - MOZ_ASSERT(!sim_->cacheLockHolder_); + MOZ_ASSERT(sim_->cacheLockHolder_.isNothing()); #ifdef DEBUG - sim_->cacheLockHolder_ = PR_GetCurrentThread(); + sim_->cacheLockHolder_ = mozilla::Some(ThisThread::GetId()); #endif } ~AutoLockSimulatorCache() { - MOZ_ASSERT(sim_->cacheLockHolder_); + MOZ_ASSERT(sim_->cacheLockHolder_.isSome()); #ifdef DEBUG - sim_->cacheLockHolder_ = nullptr; + sim_->cacheLockHolder_.reset(); #endif } @@ -1128,9 +1128,6 @@ Simulator::Simulator() lastDebuggerInput_ = nullptr; -#ifdef DEBUG - cacheLockHolder_ = nullptr; -#endif redirection_ = nullptr; exclusiveMonitorHeld_ = false; exclusiveMonitor_ = 0; diff --git a/js/src/jit/arm/Simulator-arm.h b/js/src/jit/arm/Simulator-arm.h index 4bbd46602552..a58d2de74dc0 100644 --- a/js/src/jit/arm/Simulator-arm.h +++ b/js/src/jit/arm/Simulator-arm.h @@ -37,6 +37,7 @@ #include "jit/arm/disasm/Disasm-arm.h" #include "jit/IonTypes.h" #include "threading/Mutex.h" +#include "threading/Thread.h" namespace js { namespace jit { @@ -435,7 +436,7 @@ class Simulator // and by the off-thread compiler (see Redirection::Get in the cpp file). Mutex cacheLock_; #ifdef DEBUG - PRThread* cacheLockHolder_; + mozilla::Maybe cacheLockHolder_; #endif Redirection* redirection_; @@ -446,17 +447,17 @@ class Simulator // Technically we need the lock to access the innards of the // icache, not to take its address, but the latter condition // serves as a useful complement to the former. - MOZ_ASSERT(cacheLockHolder_); + MOZ_ASSERT(cacheLockHolder_.isSome()); return icache_; } Redirection* redirection() const { - MOZ_ASSERT(cacheLockHolder_); + MOZ_ASSERT(cacheLockHolder_.isSome()); return redirection_; } void setRedirection(js::jit::Redirection* redirection) { - MOZ_ASSERT(cacheLockHolder_); + MOZ_ASSERT(cacheLockHolder_.isSome()); redirection_ = redirection; } diff --git a/js/src/jit/mips32/Simulator-mips32.cpp b/js/src/jit/mips32/Simulator-mips32.cpp index ad0bb4058abf..1113a57e7011 100644 --- a/js/src/jit/mips32/Simulator-mips32.cpp +++ b/js/src/jit/mips32/Simulator-mips32.cpp @@ -496,16 +496,16 @@ class AutoLockSimulatorCache : public LockGuard : Base(sim->cacheLock_) , sim_(sim) { - MOZ_ASSERT(!sim_->cacheLockHolder_); + MOZ_ASSERT(sim_->cacheLockHolder_.isNothing()); #ifdef DEBUG - sim_->cacheLockHolder_ = PR_GetCurrentThread(); + sim_->cacheLockHolder_ = mozilla::Some(ThisThread::GetId()); #endif } ~AutoLockSimulatorCache() { - MOZ_ASSERT(sim_->cacheLockHolder_); + MOZ_ASSERT(sim_->cacheLockHolder_.isSome()); #ifdef DEBUG - sim_->cacheLockHolder_ = nullptr; + sim_->cacheLockHolder_.reset(); #endif } @@ -1277,9 +1277,6 @@ Simulator::Simulator() lastDebuggerInput_ = nullptr; -#ifdef DEBUG - cacheLockHolder_ = nullptr; -#endif redirection_ = nullptr; } diff --git a/js/src/jit/mips32/Simulator-mips32.h b/js/src/jit/mips32/Simulator-mips32.h index dc139e80246a..58ac2dcb63c6 100644 --- a/js/src/jit/mips32/Simulator-mips32.h +++ b/js/src/jit/mips32/Simulator-mips32.h @@ -35,6 +35,7 @@ #include "jit/IonTypes.h" #include "threading/Mutex.h" +#include "threading/Thread.h" namespace js { namespace jit { @@ -383,7 +384,7 @@ class Simulator { // and by the off-thread compiler (see Redirection::Get in the cpp file). Mutex cacheLock_; #ifdef DEBUG - PRThread* cacheLockHolder_; + mozilla::Maybe cacheLockHolder_; #endif Redirection* redirection_; @@ -394,17 +395,17 @@ class Simulator { // Technically we need the lock to access the innards of the // icache, not to take its address, but the latter condition // serves as a useful complement to the former. - MOZ_ASSERT(cacheLockHolder_); + MOZ_ASSERT(cacheLockHolder_.isSome()); return icache_; } Redirection* redirection() const { - MOZ_ASSERT(cacheLockHolder_); + MOZ_ASSERT(cacheLockHolder_.isSome()); return redirection_; } void setRedirection(js::jit::Redirection* redirection) { - MOZ_ASSERT(cacheLockHolder_); + MOZ_ASSERT(cacheLockHolder_.isSome()); redirection_ = redirection; } }; diff --git a/js/src/jit/mips64/Simulator-mips64.cpp b/js/src/jit/mips64/Simulator-mips64.cpp index bf0878b57737..a1e492bbc40e 100644 --- a/js/src/jit/mips64/Simulator-mips64.cpp +++ b/js/src/jit/mips64/Simulator-mips64.cpp @@ -534,16 +534,16 @@ class AutoLockSimulatorCache : public LockGuard : Base(sim->cacheLock_) , sim_(sim) { - MOZ_ASSERT(!sim_->cacheLockHolder_); + MOZ_ASSERT(sim_->cacheLockHolder_.isNothing()); #ifdef DEBUG - sim_->cacheLockHolder_ = PR_GetCurrentThread(); + sim_->cacheLockHolder_ = mozilla::Some(ThisThread::GetId()); #endif } ~AutoLockSimulatorCache() { - MOZ_ASSERT(sim_->cacheLockHolder_); + MOZ_ASSERT(sim_->cacheLockHolder_.isSome()); #ifdef DEBUG - sim_->cacheLockHolder_ = nullptr; + sim_->cacheLockHolder_.reset(); #endif } @@ -1291,9 +1291,6 @@ Simulator::Simulator() lastDebuggerInput_ = nullptr; -#ifdef DEBUG - cacheLockHolder_ = nullptr; -#endif redirection_ = nullptr; } diff --git a/js/src/jit/mips64/Simulator-mips64.h b/js/src/jit/mips64/Simulator-mips64.h index d921a4b50891..9d73f37f7c98 100644 --- a/js/src/jit/mips64/Simulator-mips64.h +++ b/js/src/jit/mips64/Simulator-mips64.h @@ -36,6 +36,7 @@ #include "jit/IonTypes.h" #include "threading/Mutex.h" +#include "threading/Thread.h" namespace js { namespace jit { @@ -399,7 +400,7 @@ class Simulator { // and by the off-thread compiler (see Redirection::Get in the cpp file). Mutex cacheLock_; #ifdef DEBUG - PRThread* cacheLockHolder_; + mozilla::Maybe cacheLockHolder_; #endif Redirection* redirection_; @@ -410,17 +411,17 @@ class Simulator { // Technically we need the lock to access the innards of the // icache, not to take its address, but the latter condition // serves as a useful complement to the former. - MOZ_ASSERT(cacheLockHolder_); + MOZ_ASSERT(cacheLockHolder_.isSome()); return icache_; } Redirection* redirection() const { - MOZ_ASSERT(cacheLockHolder_); + MOZ_ASSERT(cacheLockHolder_.isSome()); return redirection_; } void setRedirection(js::jit::Redirection* redirection) { - MOZ_ASSERT(cacheLockHolder_); + MOZ_ASSERT(cacheLockHolder_.isSome()); redirection_ = redirection; } };