Bug 950513 - Remove JS_WORKER_THREADS typedef. r=luke, a=lsblakk
☠☠ backed out by fefdc280c829 ☠ ☠
authorBrian Hackett <bhackett1024@gmail.com>
Fri, 03 Jan 2014 16:16:38 -0500
changeset 175526 d56d13a32786145b46ebe846c88d1b55193fc618
parent 175525 13ab06f8339ca38ae8889e8f058290ee9c0eba23
child 175527 8c10d0e5d85dbc80f3182e16a2c0327c8b1e176a
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke, lsblakk
bugs950513
milestone28.0a2
Bug 950513 - Remove JS_WORKER_THREADS typedef. r=luke, a=lsblakk
js/src/builtin/TestingFunctions.cpp
js/src/jit/AsmJS.cpp
js/src/jsapi.cpp
js/src/jscntxt.cpp
js/src/jscntxt.h
js/src/jsgc.cpp
js/src/jsworkers.cpp
js/src/jsworkers.h
js/src/vm/Runtime.cpp
js/src/vm/Runtime.h
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -110,24 +110,16 @@ GetBuildConfiguration(JSContext *cx, uns
 #ifdef JS_THREADSAFE
     value = BooleanValue(true);
 #else
     value = BooleanValue(false);
 #endif
     if (!JS_SetProperty(cx, info, "threadsafe", value))
         return false;
 
-#ifdef JS_WORKER_THREADS
-    value = BooleanValue(true);
-#else
-    value = BooleanValue(false);
-#endif
-    if (!JS_SetProperty(cx, info, "worker-threads", value))
-        return false;
-
 #ifdef JS_MORE_DETERMINISTIC
     value = BooleanValue(true);
 #else
     value = BooleanValue(false);
 #endif
     if (!JS_SetProperty(cx, info, "more-deterministic", value))
         return false;
 
--- a/js/src/jit/AsmJS.cpp
+++ b/js/src/jit/AsmJS.cpp
@@ -5081,17 +5081,17 @@ CheckFunctionsSequential(ModuleCompiler 
     }
 
     if (!CheckAllFunctionsDefined(m))
         return false;
 
     return true;
 }
 
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
 
 // Currently, only one asm.js parallel compilation is allowed at a time.
 // This RAII class attempts to claim this parallel compilation using atomic ops
 // on rt->workerThreadState->asmJSCompilationInProgress.
 class ParallelCompilationGuard
 {
     WorkerThreadState *parallelState_;
   public:
@@ -5321,17 +5321,17 @@ CheckFunctionsParallel(ModuleCompiler &m
             return m.failOffset(func->srcOffset(), "allocation failure during compilation");
         }
 
         // Otherwise, the error occurred on the main thread and was already reported.
         return false;
     }
     return true;
 }
-#endif // JS_WORKER_THREADS
+#endif // JS_THREADSAFE
 
 static bool
 CheckFuncPtrTable(ModuleCompiler &m, ParseNode *var)
 {
     if (!IsDefinition(var))
         return m.fail(var, "function-pointer table name must be unique");
 
     ParseNode *arrayLiteral = MaybeDefinitionInitializer(var);
@@ -6416,17 +6416,17 @@ CheckModule(ExclusiveContext *cx, AsmJSP
         return false;
 
     if (!CheckPrecedingStatements(m, stmtList))
         return false;
 
     if (!CheckModuleGlobals(m))
         return false;
 
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
     if (!CheckFunctionsParallel(m))
         return false;
 #else
     if (!CheckFunctionsSequential(m))
         return false;
 #endif
 
     m.finishFunctionBodies();
@@ -6480,17 +6480,17 @@ EstablishPreconditions(ExclusiveContext 
         return Warn(parser, JSMSG_USE_ASM_TYPE_FAIL, "Temporarily disabled for event-handler and other cloneable scripts");
 
     if (cx->compartment()->debugMode())
         return Warn(parser, JSMSG_USE_ASM_TYPE_FAIL, "Disabled by debugger");
 
     if (parser.pc->isGenerator())
         return Warn(parser, JSMSG_USE_ASM_TYPE_FAIL, "Disabled by generator context");
 
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
     if (ParallelCompilationEnabled(cx)) {
         if (!EnsureWorkerThreadsInitialized(cx))
             return Warn(parser, JSMSG_USE_ASM_TYPE_FAIL, "Failed compilation thread initialization");
     }
 #endif
 
     return true;
 }
@@ -6532,16 +6532,17 @@ js::CompileAsmJS(ExclusiveContext *cx, A
 }
 
 bool
 js::IsAsmJSCompilationAvailable(JSContext *cx, unsigned argc, Value *vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 
     // See EstablishPreconditions.
-    bool available = JSC::MacroAssembler::supportsFloatingPoint() &&
+    bool available = cx->jitSupportsFloatingPoint() &&
+                     cx->signalHandlersInstalled() &&
                      cx->gcSystemPageSize() == AsmJSPageSize &&
                      !cx->compartment()->debugMode() &&
                      cx->compartment()->options().asmJS(cx);
 
     args.rval().set(BooleanValue(available));
     return true;
 }
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -4511,17 +4511,17 @@ JS::CompileOffThread(JSContext *cx, Hand
 {
     JS_ASSERT(CanCompileOffThread(cx, options));
     return StartOffThreadParseScript(cx, options, chars, length, obj, callback, callbackData);
 }
 
 JS_PUBLIC_API(JSScript *)
 JS::FinishOffThreadScript(JSContext *maybecx, JSRuntime *rt, void *token)
 {
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
     JS_ASSERT(CurrentThreadCanAccessRuntime(rt));
 
     Maybe<AutoLastFrameCheck> lfc;
     if (maybecx)
         lfc.construct(maybecx);
 
     return rt->workerThreadState->finishParseTask(maybecx, rt, token);
 #else
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -1049,17 +1049,17 @@ js_HandleExecutionInterrupt(JSContext *c
 }
 
 js::ThreadSafeContext::ThreadSafeContext(JSRuntime *rt, PerThreadData *pt, ContextKind kind)
   : ContextFriendFields(rt),
     contextKind_(kind),
     perThreadData(pt),
     allocator_(nullptr)
 {
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
     JS_ASSERT_IF(kind == Context_Exclusive, rt->workerThreadState != nullptr);
 #endif
 }
 
 bool
 ThreadSafeContext::isForkJoinSlice() const
 {
     return contextKind_ == Context_ForkJoin;
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -384,17 +384,17 @@ class ExclusiveContext : public ThreadSa
     }
     JSCompartment *atomsCompartment() {
         return runtime_->atomsCompartment();
     }
     ScriptDataTable &scriptDataTable() {
         return runtime_->scriptDataTable();
     }
 
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
     // Since JSRuntime::workerThreadState is necessarily initialized from the
     // main thread before the first worker thread can access it, there is no
     // possibility for a race read/writing it.
     WorkerThreadState *workerThreadState() {
         return runtime_->workerThreadState;
     }
 #endif
 
@@ -1027,17 +1027,17 @@ bool intrinsic_UnsafeGetReservedSlot(JSC
 bool intrinsic_HaveSameClass(JSContext *cx, unsigned argc, Value *vp);
 bool intrinsic_IsPackedArray(JSContext *cx, unsigned argc, Value *vp);
 
 bool intrinsic_ShouldForceSequential(JSContext *cx, unsigned argc, Value *vp);
 bool intrinsic_NewParallelArray(JSContext *cx, unsigned argc, Value *vp);
 
 class AutoLockForExclusiveAccess
 {
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
     JSRuntime *runtime;
 
     void init(JSRuntime *rt) {
         runtime = rt;
         if (runtime->numExclusiveThreads) {
             runtime->assertCanLock(JSRuntime::ExclusiveAccessLock);
             PR_Lock(runtime->exclusiveAccessLock);
             runtime->exclusiveAccessOwner = PR_GetCurrentThread();
@@ -1063,29 +1063,29 @@ class AutoLockForExclusiveAccess
             runtime->exclusiveAccessOwner = nullptr;
 #endif
             PR_Unlock(runtime->exclusiveAccessLock);
         } else {
             JS_ASSERT(runtime->mainThreadHasExclusiveAccess);
             runtime->mainThreadHasExclusiveAccess = false;
         }
     }
-#else // JS_WORKER_THREADS
+#else // JS_THREADSAFE
   public:
     AutoLockForExclusiveAccess(ExclusiveContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     }
     AutoLockForExclusiveAccess(JSRuntime *rt MOZ_GUARD_OBJECT_NOTIFIER_PARAM) {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     }
     ~AutoLockForExclusiveAccess() {
         // An empty destructor is needed to avoid warnings from clang about
         // unused local variables of this type.
     }
-#endif // JS_WORKER_THREADS
+#endif // JS_THREADSAFE
 
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 } /* namespace js */
 
 #ifdef _MSC_VER
 #pragma warning(pop)
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -1664,17 +1664,17 @@ ArenaLists::refillFreeList(ThreadSafeCon
     JS_ASSERT_IF(cx->isJSContext(), !cx->asJSContext()->runtime()->isHeapBusy());
 
     Zone *zone = cx->allocator()->zone_;
 
     bool runGC = cx->allowGC() && allowGC &&
                  cx->asJSContext()->runtime()->gcIncrementalState != NO_INCREMENTAL &&
                  zone->gcBytes > zone->gcTriggerBytes;
 
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
     JS_ASSERT_IF(cx->isJSContext() && allowGC,
                  !cx->asJSContext()->runtime()->currentThreadHasExclusiveAccess());
 #endif
 
     for (;;) {
         if (JS_UNLIKELY(runGC)) {
             if (void *thing = RunLastDitchGC(cx->asJSContext(), zone, thingKind))
                 return thing;
@@ -1694,17 +1694,17 @@ ArenaLists::refillFreeList(ThreadSafeCon
                 if (JS_LIKELY(!!thing))
                     return thing;
                 if (secondAttempt)
                     break;
 
                 cx->asJSContext()->runtime()->gcHelperThread.waitBackgroundSweepEnd();
             }
         } else {
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
             /*
              * If we're off the main thread, we try to allocate once and
              * return whatever value we get. If we aren't in a ForkJoin
              * session (i.e. we are in a worker thread async with the main
              * thread), we need to first ensure the main thread is not in a GC
              * session.
              */
             mozilla::Maybe<AutoLockWorkerThreadState> lock;
@@ -4299,33 +4299,33 @@ AutoTraceSession::AutoTraceSession(JSRun
     // the exclusive access lock. To avoid deadlocking when we try to acquire
     // this lock during GC and the other thread is waiting, make sure we hold
     // the exclusive access lock during GC sessions.
     JS_ASSERT(rt->currentThreadHasExclusiveAccess());
 
     if (rt->exclusiveThreadsPresent()) {
         // Lock the worker thread state when changing the heap state in the
         // presence of exclusive threads, to avoid racing with refillFreeList.
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
         AutoLockWorkerThreadState lock(*rt->workerThreadState);
         rt->heapState = heapState;
 #else
         MOZ_CRASH();
 #endif
     } else {
         rt->heapState = heapState;
     }
 }
 
 AutoTraceSession::~AutoTraceSession()
 {
     JS_ASSERT(runtime->isHeapBusy());
 
     if (runtime->exclusiveThreadsPresent()) {
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
         AutoLockWorkerThreadState lock(*runtime->workerThreadState);
         runtime->heapState = prevState;
 
         // Notify any worker threads waiting for the trace session to end.
         runtime->workerThreadState->notifyAll(WorkerThreadState::PRODUCER);
 #else
         MOZ_CRASH();
 #endif
@@ -4943,17 +4943,17 @@ Collect(JSRuntime *rt, bool incremental,
          * repeat GCs that happen during shutdown (the gcShouldCleanUpEverything
          * case) until we can be sure that no additional garbage is created
          * (which typically happens if roots are dropped during finalizers).
          */
         repeat = (rt->gcPoke && rt->gcShouldCleanUpEverything) || wasReset;
     } while (repeat);
 
     if (rt->gcIncrementalState == NO_INCREMENTAL) {
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
         EnqueuePendingParseTasksAfterGC(rt);
 #endif
     }
 }
 
 void
 js::GC(JSRuntime *rt, JSGCInvocationKind gckind, JS::gcreason::Reason reason)
 {
--- a/js/src/jsworkers.cpp
+++ b/js/src/jsworkers.cpp
@@ -1,17 +1,18 @@
 /* -*- 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/. */
 
 #include "jsworkers.h"
 
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
+
 #include "mozilla/DebugOnly.h"
 
 #include "jsnativestack.h"
 #include "prmjtime.h"
 
 #include "frontend/BytecodeCompiler.h"
 #include "jit/ExecutionModeInlines.h"
 #include "jit/IonBuilder.h"
@@ -48,16 +49,18 @@ js::EnsureWorkerThreadsInitialized(Exclu
         js_delete(rt->workerThreadState);
         rt->workerThreadState = nullptr;
         return false;
     }
 
     return true;
 }
 
+#ifdef JS_ION
+
 bool
 js::StartOffThreadAsmJSCompile(ExclusiveContext *cx, AsmJSParallelTask *asmData)
 {
     // Threads already initialized by the AsmJS compiler.
     JS_ASSERT(cx->workerThreadState() != nullptr);
     JS_ASSERT(asmData->mir);
     JS_ASSERT(asmData->lir == nullptr);
 
@@ -105,27 +108,30 @@ FinishOffThreadIonCompile(jit::IonBuilde
 {
     JSCompartment *compartment = builder->script()->compartment();
     JS_ASSERT(compartment->runtimeFromAnyThread()->workerThreadState);
     JS_ASSERT(compartment->runtimeFromAnyThread()->workerThreadState->isLocked());
 
     compartment->jitCompartment()->finishedOffThreadCompilations().append(builder);
 }
 
+#endif // JS_ION
+
 static inline bool
 CompiledScriptMatches(JSCompartment *compartment, JSScript *script, JSScript *target)
 {
     if (script)
         return target == script;
     return target->compartment() == compartment;
 }
 
 void
 js::CancelOffThreadIonCompile(JSCompartment *compartment, JSScript *script)
 {
+#ifdef JS_ION
     JSRuntime *rt = compartment->runtimeFromMainThread();
 
     if (!rt->workerThreadState)
         return;
 
     WorkerThreadState &state = *rt->workerThreadState;
 
     jit::JitCompartment *jitComp = compartment->jitCompartment();
@@ -161,16 +167,17 @@ js::CancelOffThreadIonCompile(JSCompartm
     for (size_t i = 0; i < compilations.length(); i++) {
         jit::IonBuilder *builder = compilations[i];
         if (CompiledScriptMatches(compartment, script, builder->script())) {
             jit::FinishOffThreadBuilder(builder);
             compilations[i--] = compilations.back();
             compilations.popBack();
         }
     }
+#endif // JS_ION
 }
 
 static const JSClass workerGlobalClass = {
     "internal-worker-global", JSCLASS_GLOBAL_FLAGS,
     JS_PropertyStub,  JS_DeletePropertyStub,
     JS_PropertyStub,  JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub,
     JS_ConvertStub,   nullptr
@@ -681,16 +688,17 @@ WorkerThread::ThreadMain(void *arg)
 {
     PR_SetCurrentThreadName("Analysis Helper");
     static_cast<WorkerThread *>(arg)->threadLoop();
 }
 
 void
 WorkerThread::handleAsmJSWorkload(WorkerThreadState &state)
 {
+#ifdef JS_ION
     JS_ASSERT(state.isLocked());
     JS_ASSERT(state.canStartAsmJSCompile());
     JS_ASSERT(idle());
 
     asmData = state.asmJSWorklist.popCopy();
     bool success = false;
 
     state.unlock();
@@ -722,21 +730,25 @@ WorkerThread::handleAsmJSWorkload(Worker
     }
 
     // On success, move work to the finished list.
     state.asmJSFinishedList.append(asmData);
     asmData = nullptr;
 
     // Notify the main thread in case it's blocked waiting for a LifoAlloc.
     state.notifyAll(WorkerThreadState::CONSUMER);
+#else
+    MOZ_CRASH();
+#endif // JS_ION
 }
 
 void
 WorkerThread::handleIonWorkload(WorkerThreadState &state)
 {
+#ifdef JS_ION
     JS_ASSERT(state.isLocked());
     JS_ASSERT(state.canStartIonCompile());
     JS_ASSERT(idle());
 
     ionBuilder = state.ionWorklist.popCopy();
 
     DebugOnly<ExecutionMode> executionMode = ionBuilder->info().executionMode();
     JS_ASSERT(jit::GetIonScript(ionBuilder->script(), executionMode) == ION_COMPILING_SCRIPT);
@@ -763,16 +775,19 @@ WorkerThread::handleIonWorkload(WorkerTh
     // Notify the main thread in case it is waiting for the compilation to finish.
     state.notifyAll(WorkerThreadState::CONSUMER);
 
     // Ping the main thread so that the compiled code can be incorporated
     // at the next operation callback. Don't interrupt Ion code for this, as
     // this incorporation can be delayed indefinitely without affecting
     // performance as long as the main thread is actually executing Ion code.
     runtime->triggerOperationCallback(JSRuntime::TriggerCallbackAnyThreadDontStopIon);
+#else
+    MOZ_CRASH();
+#endif // JS_ION
 }
 
 void
 ExclusiveContext::setWorkerThread(WorkerThread *workerThread)
 {
     workerThread_ = workerThread;
     perThreadData = workerThread->threadData.addr();
 }
@@ -993,32 +1008,36 @@ WorkerThread::threadLoop()
             handleParseWorkload(state);
         else if (state.canStartCompressionTask())
             handleCompressionWorkload(state);
         else
             MOZ_ASSUME_UNREACHABLE("No task to perform");
     }
 }
 
-#else /* JS_WORKER_THREADS */
+#else /* JS_THREADSAFE */
 
 using namespace js;
 
+#ifdef JS_ION
+
 bool
 js::StartOffThreadAsmJSCompile(ExclusiveContext *cx, AsmJSParallelTask *asmData)
 {
     MOZ_ASSUME_UNREACHABLE("Off thread compilation not available in non-THREADSAFE builds");
 }
 
 bool
 js::StartOffThreadIonCompile(JSContext *cx, jit::IonBuilder *builder)
 {
     MOZ_ASSUME_UNREACHABLE("Off thread compilation not available in non-THREADSAFE builds");
 }
 
+#endif // JS_ION
+
 void
 js::CancelOffThreadIonCompile(JSCompartment *compartment, JSScript *script)
 {
 }
 
 bool
 js::StartOffThreadParseScript(JSContext *cx, const ReadOnlyCompileOptions &options,
                               const jschar *chars, size_t length, HandleObject scopeChain,
@@ -1059,9 +1078,9 @@ ExclusiveContext::addPendingCompileError
 }
 
 void
 ExclusiveContext::addPendingOverRecursed()
 {
     MOZ_ASSUME_UNREACHABLE("Off thread compilation not available.");
 }
 
-#endif /* JS_WORKER_THREADS */
+#endif /* JS_THREADSAFE */
--- a/js/src/jsworkers.h
+++ b/js/src/jsworkers.h
@@ -26,17 +26,17 @@ namespace js {
 
 struct WorkerThread;
 struct AsmJSParallelTask;
 struct ParseTask;
 namespace jit {
   class IonBuilder;
 }
 
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
 
 /* Per-runtime state for off thread work items. */
 class WorkerThreadState
 {
   public:
     /* Available threads. */
     WorkerThread *threads;
     size_t numThreads;
@@ -193,35 +193,39 @@ struct WorkerThread
     void handleIonWorkload(WorkerThreadState &state);
     void handleParseWorkload(WorkerThreadState &state);
     void handleCompressionWorkload(WorkerThreadState &state);
 
     static void ThreadMain(void *arg);
     void threadLoop();
 };
 
-#endif /* JS_WORKER_THREADS */
+#endif /* JS_THREADSAFE */
 
 /* Methods for interacting with worker threads. */
 
 /* Initialize worker threads unless already initialized. */
 bool
 EnsureWorkerThreadsInitialized(ExclusiveContext *cx);
 
+#ifdef JS_ION
+
 /* Perform MIR optimization and LIR generation on a single function. */
 bool
 StartOffThreadAsmJSCompile(ExclusiveContext *cx, AsmJSParallelTask *asmData);
 
 /*
  * Schedule an Ion compilation for a script, given a builder which has been
  * generated and read everything needed from the VM state.
  */
 bool
 StartOffThreadIonCompile(JSContext *cx, jit::IonBuilder *builder);
 
+#endif // JS_ION
+
 /*
  * Cancel a scheduled or in progress Ion compilation for script. If script is
  * nullptr, all compilations for the compartment are cancelled.
  */
 void
 CancelOffThreadIonCompile(JSCompartment *compartment, JSScript *script);
 
 /*
@@ -247,17 +251,17 @@ WaitForOffThreadParsingToFinish(JSRuntim
 /* Start a compression job for the specified token. */
 bool
 StartOffThreadCompression(ExclusiveContext *cx, SourceCompressionTask *task);
 
 class AutoLockWorkerThreadState
 {
     MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
     WorkerThreadState &state;
 
   public:
     AutoLockWorkerThreadState(WorkerThreadState &state
                               MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : state(state)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
@@ -284,27 +288,27 @@ class AutoUnlockWorkerThreadState
 
   public:
 
     AutoUnlockWorkerThreadState(JSRuntime *rt
                                 MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : rt(rt)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
         JS_ASSERT(rt->workerThreadState);
         rt->workerThreadState->unlock();
 #else
         (void)this->rt;
 #endif
     }
 
     ~AutoUnlockWorkerThreadState()
     {
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
         rt->workerThreadState->lock();
 #endif
     }
 };
 
 #ifdef JS_ION
 struct AsmJSParallelTask
 {
@@ -368,17 +372,17 @@ struct ParseTask
 
 // Compression tasks are allocated on the stack by their triggering thread,
 // which will block on the compression completing as the task goes out of scope
 // to ensure it completes at the required time.
 struct SourceCompressionTask
 {
     friend class ScriptSource;
 
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
     // Thread performing the compression.
     WorkerThread *workerThread;
 #endif
 
   private:
     // Context from the triggering thread. Don't use this off thread!
     ExclusiveContext *cx;
 
@@ -393,17 +397,17 @@ struct SourceCompressionTask
 #else
     int32_t abort_;
 #endif
 
   public:
     explicit SourceCompressionTask(ExclusiveContext *cx)
       : cx(cx), ss(nullptr), chars(nullptr), oom(false), abort_(0)
     {
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
         workerThread = nullptr;
 #endif
     }
 
     ~SourceCompressionTask()
     {
         complete();
     }
--- a/js/src/vm/Runtime.cpp
+++ b/js/src/vm/Runtime.cpp
@@ -121,20 +121,16 @@ JSRuntime::JSRuntime(JSUseHelperThreads 
     ),
     mainThread(this),
     interrupt(0),
     handlingSignal(false),
     operationCallback(nullptr),
 #ifdef JS_THREADSAFE
     operationCallbackLock(nullptr),
     operationCallbackOwner(nullptr),
-#else
-    operationCallbackLockTaken(false),
-#endif
-#ifdef JS_WORKER_THREADS
     workerThreadState(nullptr),
     exclusiveAccessLock(nullptr),
     exclusiveAccessOwner(nullptr),
     mainThreadHasExclusiveAccess(false),
     numExclusiveThreads(0),
 #endif
     systemZone(nullptr),
     numCompartments(0),
@@ -351,19 +347,17 @@ JSRuntime::init(uint32_t maxbytes)
 
     operationCallbackLock = PR_NewLock();
     if (!operationCallbackLock)
         return false;
 
     gcLock = PR_NewLock();
     if (!gcLock)
         return false;
-#endif
 
-#ifdef JS_WORKER_THREADS
     exclusiveAccessLock = PR_NewLock();
     if (!exclusiveAccessLock)
         return false;
 #endif
 
     if (!mainThread.init())
         return false;
 
@@ -430,17 +424,17 @@ JSRuntime::~JSRuntime()
     /* Free source hook early, as its destructor may want to delete roots. */
     sourceHook = nullptr;
 
     /* Off thread compilation and parsing depend on atoms still existing. */
     for (CompartmentsIter comp(this, SkipAtoms); !comp.done(); comp.next())
         CancelOffThreadIonCompile(comp, nullptr);
     WaitForOffThreadParsingToFinish(this);
 
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
     if (workerThreadState)
         workerThreadState->cleanup();
 #endif
 
     /* Poison common names before final GC. */
     FinishCommonNames(this);
 
     /* Clear debugging state to remove GC roots. */
@@ -468,29 +462,27 @@ JSRuntime::~JSRuntime()
     /*
      * Clear the self-hosted global and delete self-hosted classes *after*
      * GC, as finalizers for objects check for clasp->finalize during GC.
      */
     finishSelfHosting();
 
     mainThread.removeFromThreadList();
 
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
     js_delete(workerThreadState);
 
     JS_ASSERT(!exclusiveAccessOwner);
     if (exclusiveAccessLock)
         PR_DestroyLock(exclusiveAccessLock);
 
     // Avoid bogus asserts during teardown.
     JS_ASSERT(!numExclusiveThreads);
     mainThreadHasExclusiveAccess = true;
-#endif
-
-#ifdef JS_THREADSAFE
+    
     JS_ASSERT(!operationCallbackOwner);
     if (operationCallbackLock)
         PR_DestroyLock(operationCallbackLock);
 #endif
 
     /*
      * Even though all objects in the compartment are dead, we may have keep
      * some filenames around because of gcKeepAtoms.
@@ -879,17 +871,17 @@ AutoThreadSafeAccess::~AutoThreadSafeAcc
         MOZ_CRASH();
 
     JS_ASSERT(arena == runtime->unprotectedArenas.back());
     runtime->unprotectedArenas.popBack();
 }
 
 #endif // DEBUG && !XP_WIN
 
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
 
 void
 JSRuntime::setUsedByExclusiveThread(Zone *zone)
 {
     JS_ASSERT(!zone->usedByExclusiveThread);
     zone->usedByExclusiveThread = true;
     numExclusiveThreads++;
 }
@@ -897,37 +889,33 @@ JSRuntime::setUsedByExclusiveThread(Zone
 void
 JSRuntime::clearUsedByExclusiveThread(Zone *zone)
 {
     JS_ASSERT(zone->usedByExclusiveThread);
     zone->usedByExclusiveThread = false;
     numExclusiveThreads--;
 }
 
-#endif // JS_WORKER_THREADS
-
-#ifdef JS_THREADSAFE
-
 bool
 js::CurrentThreadCanAccessRuntime(JSRuntime *rt)
 {
     DebugOnly<PerThreadData *> pt = js::TlsPerThreadData.get();
     JS_ASSERT(pt && pt->associatedWith(rt));
     return rt->ownerThread_ == PR_GetCurrentThread() || InExclusiveParallelSection();
 }
 
 bool
 js::CurrentThreadCanAccessZone(Zone *zone)
 {
     DebugOnly<PerThreadData *> pt = js::TlsPerThreadData.get();
     JS_ASSERT(pt && pt->associatedWith(zone->runtime_));
     return !InParallelSection() || InExclusiveParallelSection();
 }
 
-#else
+#else // JS_THREADSAFE
 
 bool
 js::CurrentThreadCanAccessRuntime(JSRuntime *rt)
 {
     return true;
 }
 
 bool
@@ -938,17 +926,17 @@ js::CurrentThreadCanAccessZone(Zone *zon
 
 #endif
 
 #ifdef DEBUG
 
 void
 JSRuntime::assertCanLock(RuntimeLock which)
 {
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
     // In the switch below, each case falls through to the one below it. None
     // of the runtime locks are reentrant, and when multiple locks are acquired
     // it must be done in the order below.
     switch (which) {
       case ExclusiveAccessLock:
         JS_ASSERT(exclusiveAccessOwner != PR_GetCurrentThread());
       case WorkerThreadStateLock:
         JS_ASSERT_IF(workerThreadState, !workerThreadState->isLocked());
--- a/js/src/vm/Runtime.h
+++ b/js/src/vm/Runtime.h
@@ -779,18 +779,17 @@ struct JSRuntime : public JS::shadow::Ru
     bool currentThreadOwnsOperationCallbackLock() {
 #if defined(JS_THREADSAFE)
         return operationCallbackOwner == PR_GetCurrentThread();
 #else
         return operationCallbackLockTaken;
 #endif
     }
 
-#if defined(JS_THREADSAFE) && defined(JS_ION)
-# define JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
 
     js::WorkerThreadState *workerThreadState;
 
   private:
     /*
      * Lock taken when using per-runtime or per-zone data that could otherwise
      * be accessed simultaneously by both the main thread and another thread
      * with an ExclusiveContext.
@@ -806,29 +805,29 @@ struct JSRuntime : public JS::shadow::Ru
     size_t numExclusiveThreads;
 
     friend class js::AutoLockForExclusiveAccess;
 
   public:
     void setUsedByExclusiveThread(JS::Zone *zone);
     void clearUsedByExclusiveThread(JS::Zone *zone);
 
-#endif // JS_THREADSAFE && JS_ION
+#endif // JS_THREADSAFE
 
     bool currentThreadHasExclusiveAccess() {
 #if defined(JS_WORKER_THREADS) && defined(DEBUG)
         return (!numExclusiveThreads && mainThreadHasExclusiveAccess) ||
             exclusiveAccessOwner == PR_GetCurrentThread();
 #else
         return true;
 #endif
     }
 
     bool exclusiveThreadsPresent() const {
-#ifdef JS_WORKER_THREADS
+#ifdef JS_THREADSAFE
         return numExclusiveThreads > 0;
 #else
         return false;
 #endif
     }
 
     /* Embedders can use this zone however they wish. */
     JS::Zone            *systemZone;