Bug 1295741 - jslock.h is dead, long live jsnspr.h; r=terrence
authorNick Fitzgerald <fitzgen@gmail.com>
Mon, 22 Aug 2016 10:15:53 -0700
changeset 354212 4b6f61ea7594ae263945c95fc652d1aaad01042b
parent 354211 82b764f1a1b11ceae82fc3e9bdd2c3a4296da6a0
child 354213 e07157e29deedd1b2bda60c62f307503c558844f
push id1324
push usermtabara@mozilla.com
push dateMon, 16 Jan 2017 13:07:44 +0000
treeherdermozilla-release@a01c49833940 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs1295741
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1295741 - jslock.h is dead, long live jsnspr.h; r=terrence This commit makes the following changes: * Removed unnecessary includes of jslock.h from files that are using js/src/thread/* primitives now. * Removed includes of prcvar.h, prlock.h, and prthread.h in jslock.h. * Renamed jslock.h to jsnspr.h since its only remaining utility is to either wrap the few NSPR headers we still use, or alternatively include the vm/PosixNSPR.h shim instead if JS_POSIX_NSPR is defined.
js/src/asmjs/WasmSignalHandlers.h
js/src/jit/PerfSpewer.cpp
js/src/jit/arm/Simulator-arm.h
js/src/jit/mips32/Simulator-mips32.h
js/src/jit/mips64/Simulator-mips64.h
js/src/jsapi.cpp
js/src/jsgc.h
js/src/jslock.h
js/src/jsnspr.h
js/src/jsscript.h
js/src/shell/js.cpp
js/src/vm/HelperThreads.h
js/src/vm/PosixNSPR.cpp
js/src/vm/PosixNSPR.h
js/src/vm/TraceLogging.h
js/src/vm/TraceLoggingGraph.h
--- a/js/src/asmjs/WasmSignalHandlers.h
+++ b/js/src/asmjs/WasmSignalHandlers.h
@@ -18,17 +18,16 @@
 
 #ifndef wasm_signal_handlers_h
 #define wasm_signal_handlers_h
 
 #include "mozilla/Attributes.h"
 
 #if defined(XP_DARWIN) && defined(ASMJS_MAY_USE_SIGNAL_HANDLERS)
 # include <mach/mach.h>
-# include "jslock.h"
 #endif
 #include "threading/Thread.h"
 
 struct JSRuntime;
 
 namespace js {
 
 // Force any currently-executing asm.js/ion code to call HandleExecutionInterrupt.
--- a/js/src/jit/PerfSpewer.cpp
+++ b/js/src/jit/PerfSpewer.cpp
@@ -15,18 +15,16 @@
 
 #ifdef JS_ION_PERF
 # include "jit/JitSpewer.h"
 # include "jit/LIR.h"
 # include "jit/MIR.h"
 # include "jit/MIRGraph.h"
 #endif
 
-#include "jslock.h"
-
 // perf expects its data to be in a file /tmp/perf-PID.map, but for Android
 // and B2G the map files are written to /data/local/tmp/perf-PID.map
 //
 // Except that Android 4.3 no longer allows the browser to write to /data/local/tmp/
 // so also try /sdcard/.
 
 #ifndef PERF_SPEW_DIR
 # if defined(__ANDROID__)
--- a/js/src/jit/arm/Simulator-arm.h
+++ b/js/src/jit/arm/Simulator-arm.h
@@ -26,18 +26,16 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #ifndef jit_arm_Simulator_arm_h
 #define jit_arm_Simulator_arm_h
 
 #ifdef JS_SIMULATOR_ARM
 
-#include "jslock.h"
-
 #include "jit/arm/Architecture-arm.h"
 #include "jit/arm/disasm/Disasm-arm.h"
 #include "jit/IonTypes.h"
 #include "threading/Mutex.h"
 #include "threading/Thread.h"
 
 namespace js {
 namespace jit {
--- a/js/src/jit/mips32/Simulator-mips32.h
+++ b/js/src/jit/mips32/Simulator-mips32.h
@@ -26,18 +26,16 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #ifndef jit_mips32_Simulator_mips32_h
 #define jit_mips32_Simulator_mips32_h
 
 #ifdef JS_SIMULATOR_MIPS32
 
-#include "jslock.h"
-
 #include "jit/IonTypes.h"
 #include "threading/Mutex.h"
 #include "threading/Thread.h"
 
 namespace js {
 namespace jit {
 
 class Simulator;
--- a/js/src/jit/mips64/Simulator-mips64.h
+++ b/js/src/jit/mips64/Simulator-mips64.h
@@ -27,18 +27,16 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #ifndef jit_mips64_Simulator_mips64_h
 #define jit_mips64_Simulator_mips64_h
 
 #ifdef JS_SIMULATOR_MIPS64
 
-#include "jslock.h"
-
 #include "jit/IonTypes.h"
 #include "threading/Mutex.h"
 #include "threading/Thread.h"
 
 namespace js {
 namespace jit {
 
 class Simulator;
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -23,18 +23,18 @@
 #include "jsbool.h"
 #include "jscntxt.h"
 #include "jsdate.h"
 #include "jsexn.h"
 #include "jsfriendapi.h"
 #include "jsfun.h"
 #include "jsgc.h"
 #include "jsiter.h"
-#include "jslock.h"
 #include "jsmath.h"
+#include "jsnspr.h"
 #include "jsnum.h"
 #include "jsobj.h"
 #include "json.h"
 #include "jsprf.h"
 #include "jsscript.h"
 #include "jsstr.h"
 #include "jstypes.h"
 #include "jsutil.h"
--- a/js/src/jsgc.h
+++ b/js/src/jsgc.h
@@ -9,18 +9,16 @@
 #ifndef jsgc_h
 #define jsgc_h
 
 #include "mozilla/Atomics.h"
 #include "mozilla/EnumeratedArray.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/TypeTraits.h"
 
-#include "jslock.h"
-
 #include "js/GCAPI.h"
 #include "js/SliceBudget.h"
 #include "js/Vector.h"
 #include "threading/ConditionVariable.h"
 #include "threading/Thread.h"
 #include "vm/NativeObject.h"
 
 namespace js {
rename from js/src/jslock.h
rename to js/src/jsnspr.h
--- a/js/src/jslock.h
+++ b/js/src/jsnspr.h
@@ -1,36 +1,22 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef jslock_h
-#define jslock_h
-
-#include "mozilla/TimeStamp.h"
+#ifndef jsnspr_h
+#define jsnspr_h
 
 #ifdef JS_POSIX_NSPR
 
-#include "vm/PosixNSPR.h"
+# include "vm/PosixNSPR.h"
 
 #else /* JS_POSIX_NSPR */
 
-# include "prcvar.h"
 # include "prinit.h"
 # include "prio.h"
-# include "prlock.h"
-# include "prthread.h"
 # include "private/pprio.h"
 
-#endif
+#endif /* JS_POSIX_NSPR */
 
-inline PRIntervalTime
-DurationToPRInterval(mozilla::TimeDuration duration)
-{
-    double millis = duration.ToMilliseconds();
-    return millis < double(UINT32_MAX)
-           ? PR_MillisecondsToInterval(millis)
-           : PR_INTERVAL_NO_TIMEOUT;
-}
-
-#endif /* jslock_h */
+#endif /* jsnspr_h */
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -10,17 +10,16 @@
 #define jsscript_h
 
 #include "mozilla/Atomics.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/PodOperations.h"
 #include "mozilla/Variant.h"
 
 #include "jsatom.h"
-#include "jslock.h"
 #include "jsopcode.h"
 #include "jstypes.h"
 
 #include "gc/Barrier.h"
 #include "gc/Rooting.h"
 #include "jit/IonCode.h"
 #include "js/UbiNode.h"
 #include "js/UniquePtr.h"
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -44,17 +44,16 @@
 # include <unistd.h>
 #endif
 
 #include "jsapi.h"
 #include "jsarray.h"
 #include "jsatom.h"
 #include "jscntxt.h"
 #include "jsfun.h"
-#include "jslock.h"
 #include "jsobj.h"
 #include "jsprf.h"
 #include "jsscript.h"
 #include "jstypes.h"
 #include "jsutil.h"
 #ifdef XP_WIN
 # include "jswin.h"
 #endif
@@ -3315,17 +3314,17 @@ KillWorkerThreads()
 
     if (!workerThreadsLock) {
         MOZ_ASSERT(workerThreads.empty());
         return;
     }
 
     while (true) {
         // We need to leave the AutoLockWorkerThreads scope before we call
-        // PR_JoinThread, to avoid deadlocks when AutoLockWorkerThreads is
+        // js::Thread::join, to avoid deadlocks when AutoLockWorkerThreads is
         // used by the worker thread.
         Thread* thread;
         {
             AutoLockWorkerThreads alwt;
             if (workerThreads.empty())
                 break;
             thread = workerThreads.popCopy();
         }
--- a/js/src/vm/HelperThreads.h
+++ b/js/src/vm/HelperThreads.h
@@ -14,17 +14,16 @@
 #define vm_HelperThreads_h
 
 #include "mozilla/GuardObjects.h"
 #include "mozilla/PodOperations.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Variant.h"
 
 #include "jscntxt.h"
-#include "jslock.h"
 
 #include "frontend/TokenStream.h"
 #include "jit/Ion.h"
 #include "threading/ConditionVariable.h"
 #include "threading/Mutex.h"
 
 namespace js {
 
--- a/js/src/vm/PosixNSPR.cpp
+++ b/js/src/vm/PosixNSPR.cpp
@@ -9,372 +9,28 @@
 #include "js/Utility.h"
 
 #ifdef JS_POSIX_NSPR
 
 #include <errno.h>
 #include <sys/time.h>
 #include <time.h>
 
-#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
-#include <pthread_np.h>
-#endif
-
-class nspr::Thread
-{
-    pthread_t pthread_;
-    void (*start)(void* arg);
-    void* arg;
-    bool joinable;
-
-  public:
-    Thread(void (*start)(void* arg), void* arg, bool joinable)
-      : start(start), arg(arg), joinable(joinable) {}
-
-    static void* ThreadRoutine(void* arg);
-
-    pthread_t& pthread() { return pthread_; }
-};
-
-static pthread_key_t gSelfThreadIndex;
-static nspr::Thread gMainThread(nullptr, nullptr, false);
-
-void*
-nspr::Thread::ThreadRoutine(void* arg)
-{
-    Thread* self = static_cast<Thread*>(arg);
-    pthread_setspecific(gSelfThreadIndex, self);
-    self->start(self->arg);
-    if (!self->joinable)
-        js_delete(self);
-    return nullptr;
-}
-
-static bool gInitialized;
-
-void
-DummyDestructor(void*)
-{
-}
-
-/* Should be called from the main thread. */
-static void
-Initialize()
-{
-    gInitialized = true;
-
-    if (pthread_key_create(&gSelfThreadIndex, DummyDestructor)) {
-        MOZ_CRASH();
-        return;
-    }
-
-    pthread_setspecific(gSelfThreadIndex, &gMainThread);
-}
-
-PRThread*
-PR_CreateThread(PRThreadType type,
-                void (*start)(void* arg),
-                void* arg,
-                PRThreadPriority priority,
-                PRThreadScope scope,
-                PRThreadState state,
-                uint32_t stackSize)
-{
-    MOZ_ASSERT(type == PR_USER_THREAD);
-    MOZ_ASSERT(priority == PR_PRIORITY_NORMAL);
-
-    if (!gInitialized) {
-        /*
-         * We assume that the first call to PR_CreateThread happens on the main
-         * thread.
-         */
-        Initialize();
-    }
-
-    pthread_attr_t attr;
-    if (pthread_attr_init(&attr))
-        return nullptr;
-
-    if (stackSize && pthread_attr_setstacksize(&attr, stackSize)) {
-        pthread_attr_destroy(&attr);
-        return nullptr;
-    }
-
-    nspr::Thread* t = js_new<nspr::Thread>(start, arg,
-                                           state != PR_UNJOINABLE_THREAD);
-    if (!t) {
-        pthread_attr_destroy(&attr);
-        return nullptr;
-    }
-
-    if (pthread_create(&t->pthread(), &attr, &nspr::Thread::ThreadRoutine, t)) {
-        pthread_attr_destroy(&attr);
-        js_delete(t);
-        return nullptr;
-    }
-
-    if (state == PR_UNJOINABLE_THREAD) {
-        if (pthread_detach(t->pthread())) {
-            pthread_attr_destroy(&attr);
-            js_delete(t);
-            return nullptr;
-        }
-    }
-
-    pthread_attr_destroy(&attr);
-
-    return t;
-}
-
-PRStatus
-PR_JoinThread(PRThread* thread)
-{
-    if (pthread_join(thread->pthread(), nullptr))
-        return PR_FAILURE;
-
-    js_delete(thread);
-
-    return PR_SUCCESS;
-}
-
-PRThread*
-PR_GetCurrentThread()
-{
-    if (!gInitialized)
-        Initialize();
-
-    PRThread* thread = reinterpret_cast<PRThread*>(pthread_getspecific(gSelfThreadIndex));
-    if (!thread) {
-        thread = js_new<PRThread>(nullptr, nullptr, false);
-        if (!thread)
-            return nullptr;
-        pthread_setspecific(gSelfThreadIndex, thread);
-    }
-    return thread;
-}
-
-PRStatus
-PR_SetCurrentThreadName(const char* name)
-{
-    int result;
-#ifdef XP_DARWIN
-    result = pthread_setname_np(name);
-#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
-    pthread_set_name_np(pthread_self(), name);
-    result = 0;
-#elif defined(__NetBSD__)
-    result = pthread_setname_np(pthread_self(), "%s", (void*)name);
-#else
-    result = pthread_setname_np(pthread_self(), name);
-#endif
-    if (result)
-        return PR_FAILURE;
-    return PR_SUCCESS;
-}
-
-static const size_t MaxTLSKeyCount = 32;
-static size_t gTLSKeyCount;
-static pthread_key_t gTLSKeys[MaxTLSKeyCount];
-
-PRStatus
-PR_NewThreadPrivateIndex(unsigned* newIndex, PRThreadPrivateDTOR destructor)
-{
-    /*
-     * We only call PR_NewThreadPrivateIndex from the main thread, so there's no
-     * need to lock the table of TLS keys.
-     */
-    MOZ_ASSERT(PR_GetCurrentThread() == &gMainThread);
-
-    pthread_key_t key;
-    if (pthread_key_create(&key, destructor))
-        return PR_FAILURE;
-
-    MOZ_ASSERT(gTLSKeyCount + 1 < MaxTLSKeyCount);
-
-    gTLSKeys[gTLSKeyCount] = key;
-    *newIndex = gTLSKeyCount;
-    gTLSKeyCount++;
-
-    return PR_SUCCESS;
-}
-
-PRStatus
-PR_SetThreadPrivate(unsigned index, void* priv)
-{
-    if (index >= gTLSKeyCount)
-        return PR_FAILURE;
-    if (pthread_setspecific(gTLSKeys[index], priv))
-        return PR_FAILURE;
-    return PR_SUCCESS;
-}
-
-void*
-PR_GetThreadPrivate(unsigned index)
-{
-    if (index >= gTLSKeyCount)
-        return nullptr;
-    return pthread_getspecific(gTLSKeys[index]);
-}
-
 PRStatus
 PR_CallOnce(PRCallOnceType* once, PRCallOnceFN func)
 {
     MOZ_CRASH("PR_CallOnce unimplemented");
 }
 
 PRStatus
 PR_CallOnceWithArg(PRCallOnceType* once, PRCallOnceWithArgFN func, void* arg)
 {
     MOZ_CRASH("PR_CallOnceWithArg unimplemented");
 }
 
-class nspr::Lock
-{
-    pthread_mutex_t mutex_;
-
-  public:
-    Lock() {}
-    pthread_mutex_t& mutex() { return mutex_; }
-};
-
-PRLock*
-PR_NewLock()
-{
-    nspr::Lock* lock = js_new<nspr::Lock>();
-    if (!lock)
-        return nullptr;
-
-    if (pthread_mutex_init(&lock->mutex(), nullptr)) {
-        js_delete(lock);
-        return nullptr;
-    }
-
-    return lock;
-}
-
-void
-PR_DestroyLock(PRLock* lock)
-{
-    pthread_mutex_destroy(&lock->mutex());
-    js_delete(lock);
-}
-
-void
-PR_Lock(PRLock* lock)
-{
-    pthread_mutex_lock(&lock->mutex());
-}
-
-PRStatus
-PR_Unlock(PRLock* lock)
-{
-    if (pthread_mutex_unlock(&lock->mutex()))
-        return PR_FAILURE;
-    return PR_SUCCESS;
-}
-
-class nspr::CondVar
-{
-    pthread_cond_t cond_;
-    nspr::Lock* lock_;
-
-  public:
-    explicit CondVar(nspr::Lock* lock) : lock_(lock) {}
-    pthread_cond_t& cond() { return cond_; }
-    nspr::Lock* lock() { return lock_; }
-};
-
-PRCondVar*
-PR_NewCondVar(PRLock* lock)
-{
-    nspr::CondVar* cvar = js_new<nspr::CondVar>(lock);
-    if (!cvar)
-        return nullptr;
-
-    if (pthread_cond_init(&cvar->cond(), nullptr)) {
-        js_delete(cvar);
-        return nullptr;
-    }
-
-    return cvar;
-}
-
-void
-PR_DestroyCondVar(PRCondVar* cvar)
-{
-    pthread_cond_destroy(&cvar->cond());
-    js_delete(cvar);
-}
-
-PRStatus
-PR_NotifyCondVar(PRCondVar* cvar)
-{
-    if (pthread_cond_signal(&cvar->cond()))
-        return PR_FAILURE;
-    return PR_SUCCESS;
-}
-
-PRStatus
-PR_NotifyAllCondVar(PRCondVar* cvar)
-{
-    if (pthread_cond_broadcast(&cvar->cond()))
-        return PR_FAILURE;
-    return PR_SUCCESS;
-}
-
-uint32_t
-PR_MillisecondsToInterval(uint32_t milli)
-{
-    return milli;
-}
-
-uint32_t
-PR_MicrosecondsToInterval(uint32_t micro)
-{
-    return (micro + 999) / 1000;
-}
-
-static const uint64_t TicksPerSecond = 1000;
-static const uint64_t NanoSecondsInSeconds = 1000000000;
-static const uint64_t MicroSecondsInSeconds = 1000000;
-
-uint32_t
-PR_TicksPerSecond()
-{
-    return TicksPerSecond;
-}
-
-PRStatus
-PR_WaitCondVar(PRCondVar* cvar, PRIntervalTime timeout)
-{
-    if (timeout == PR_INTERVAL_NO_TIMEOUT) {
-        if (pthread_cond_wait(&cvar->cond(), &cvar->lock()->mutex()))
-            return PR_FAILURE;
-        return PR_SUCCESS;
-    } else {
-        struct timespec ts;
-        struct timeval tv;
-
-        gettimeofday(&tv, nullptr);
-        ts.tv_sec = tv.tv_sec;
-        ts.tv_nsec = tv.tv_usec * (NanoSecondsInSeconds / MicroSecondsInSeconds);
-
-        ts.tv_nsec += timeout * (NanoSecondsInSeconds / TicksPerSecond);
-        while (uint64_t(ts.tv_nsec) >= NanoSecondsInSeconds) {
-            ts.tv_nsec -= NanoSecondsInSeconds;
-            ts.tv_sec++;
-        }
-
-        int result = pthread_cond_timedwait(&cvar->cond(), &cvar->lock()->mutex(), &ts);
-        if (result == 0 || result == ETIMEDOUT)
-            return PR_SUCCESS;
-        return PR_FAILURE;
-    }
-}
-
 int32_t
 PR_FileDesc2NativeHandle(PRFileDesc* fd)
 {
     MOZ_CRASH("PR_FileDesc2NativeHandle");
 }
 
 PRStatus
 PR_GetOpenFileInfo(PRFileDesc *fd, PRFileInfo *info)
--- a/js/src/vm/PosixNSPR.h
+++ b/js/src/vm/PosixNSPR.h
@@ -4,146 +4,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef vm_PosixNSPR_h
 #define vm_PosixNSPR_h
 
 #ifdef JS_POSIX_NSPR
 
-#include <pthread.h>
-
 #include "jspubtd.h"
 
-namespace nspr {
-class Thread;
-class Lock;
-class CondVar;
-};
-
-typedef nspr::Thread PRThread;
-typedef nspr::Lock PRLock;
-typedef nspr::CondVar PRCondVar;
-using PRIntervalTime = uint32_t;
-
-enum PRThreadType {
-   PR_USER_THREAD,
-   PR_SYSTEM_THREAD
-};
-
-enum PRThreadPriority
-{
-   PR_PRIORITY_FIRST   = 0,
-   PR_PRIORITY_LOW     = 0,
-   PR_PRIORITY_NORMAL  = 1,
-   PR_PRIORITY_HIGH    = 2,
-   PR_PRIORITY_URGENT  = 3,
-   PR_PRIORITY_LAST    = 3
-};
-
-enum PRThreadScope {
-   PR_LOCAL_THREAD,
-   PR_GLOBAL_THREAD,
-   PR_GLOBAL_BOUND_THREAD
-};
-
-enum PRThreadState {
-   PR_JOINABLE_THREAD,
-   PR_UNJOINABLE_THREAD
-};
-
-PRThread*
-PR_CreateThread(PRThreadType type,
-                void (*start)(void* arg),
-                void* arg,
-                PRThreadPriority priority,
-                PRThreadScope scope,
-                PRThreadState state,
-                uint32_t stackSize);
-
-typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
-
-PRStatus
-PR_JoinThread(PRThread* thread);
-
-PRThread*
-PR_GetCurrentThread();
-
-PRStatus
-PR_SetCurrentThreadName(const char* name);
-
-typedef void (*PRThreadPrivateDTOR)(void* priv);
-
-PRStatus
-PR_NewThreadPrivateIndex(unsigned* newIndex, PRThreadPrivateDTOR destructor);
-
-PRStatus
-PR_SetThreadPrivate(unsigned index, void* priv);
-
-void*
-PR_GetThreadPrivate(unsigned index);
-
-struct PRCallOnceType {
-    int initialized;
-    int32_t inProgress;
-    PRStatus status;
-};
-
-typedef PRStatus (*PRCallOnceFN)();
-
-PRStatus
-PR_CallOnce(PRCallOnceType* once, PRCallOnceFN func);
-
-typedef PRStatus (*PRCallOnceWithArgFN)(void*);
-
-PRStatus
-PR_CallOnceWithArg(PRCallOnceType* once, PRCallOnceWithArgFN func, void* arg);
-
-PRLock*
-PR_NewLock();
-
-void
-PR_DestroyLock(PRLock* lock);
-
-void
-PR_Lock(PRLock* lock);
-
-PRStatus
-PR_Unlock(PRLock* lock);
-
-PRCondVar*
-PR_NewCondVar(PRLock* lock);
-
-void
-PR_DestroyCondVar(PRCondVar* cvar);
-
-PRStatus
-PR_NotifyCondVar(PRCondVar* cvar);
-
-PRStatus
-PR_NotifyAllCondVar(PRCondVar* cvar);
-
-#define PR_INTERVAL_MIN 1000UL
-#define PR_INTERVAL_MAX 100000UL
-
-#define PR_INTERVAL_NO_WAIT 0UL
-#define PR_INTERVAL_NO_TIMEOUT 0xffffffffUL
-
-uint32_t
-PR_MillisecondsToInterval(uint32_t milli);
-
-uint32_t
-PR_MicrosecondsToInterval(uint32_t micro);
-
-uint32_t
-PR_TicksPerSecond();
-
-PRStatus
-PR_WaitCondVar(PRCondVar* cvar, PRIntervalTime timeout);
-
 int32_t
 PR_FileDesc2NativeHandle(PRFileDesc* fd);
 
 enum PRFileType
 {
     PR_FILE_FILE = 1,
     PR_FILE_DIRECTORY = 2,
     PR_FILE_OTHER = 3
@@ -152,16 +24,28 @@ enum PRFileType
 struct PRFileInfo
 {
     PRFileType type;
     int32_t size;
     int64_t creationTime;
     int64_t modifyTime;
 };
 
+typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
+
+typedef PRStatus (*PRCallOnceFN)();
+
+PRStatus
+PR_CallOnce(PRCallOnceType* once, PRCallOnceFN func);
+
+typedef PRStatus (*PRCallOnceWithArgFN)(void*);
+
+PRStatus
+PR_CallOnceWithArg(PRCallOnceType* once, PRCallOnceWithArgFN func, void* arg);
+
 PRStatus
 PR_GetOpenFileInfo(PRFileDesc *fd, PRFileInfo *info);
 
 enum PRSeekWhence
 {
     PR_SEEK_SET = 0,
     PR_SEEK_CUR = 1,
     PR_SEEK_END = 2
--- a/js/src/vm/TraceLogging.h
+++ b/js/src/vm/TraceLogging.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef TraceLogging_h
 #define TraceLogging_h
 
 #include "mozilla/GuardObjects.h"
 
 #include "jsalloc.h"
-#include "jslock.h"
 
 #include "js/HashTable.h"
 #include "js/TypeDecls.h"
 #include "js/Vector.h"
 #include "threading/Mutex.h"
 #include "threading/Thread.h"
 #include "vm/TraceLoggingGraph.h"
 #include "vm/TraceLoggingTypes.h"
--- a/js/src/vm/TraceLoggingGraph.h
+++ b/js/src/vm/TraceLoggingGraph.h
@@ -2,18 +2,16 @@
  * vim: set ts=8 sts=4 et sw=4 tw=99:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef TraceLoggingGraph_h
 #define TraceLoggingGraph_h
 
-#include "jslock.h"
-
 #include "js/TypeDecls.h"
 #include "threading/Mutex.h"
 #include "vm/TraceLoggingTypes.h"
 
 /*
  * The output of a tracelogging session is saved in /tmp/tl-data.json.
  * The format of that file is a JS array per tracelogger (=thread), with a map
  * containing: