Bug 1018533 - Fix js shell's --thread-count assertion. (r=bhackett)
authorShu-yu Guo <shu@rfrn.org>
Mon, 02 Jun 2014 18:25:18 -0700
changeset 205447 143ce643d1b3c7908a91065e551793573aa4d4f3
parent 205446 eb3703f6d892c20e9ca9bcebd0dc7127eeabf78a
child 205448 1cd1d27985e99f9c2ddd79907c29745f1be6e584
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs1018533
milestone32.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 1018533 - Fix js shell's --thread-count assertion. (r=bhackett)
js/src/shell/js.cpp
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -6015,22 +6015,16 @@ SetRuntimeOptions(JSRuntime *rt, const O
 
     jsCacheDir = op.getStringOption("js-cache");
     if (jsCacheDir) {
         if (op.getBoolOption("js-cache-per-process"))
             jsCacheDir = JS_smprintf("%s/%u", jsCacheDir, (unsigned)getpid());
         jsCacheAsmJSPath = JS_smprintf("%s/asmjs.cache", jsCacheDir);
     }
 
-#ifdef JS_THREADSAFE
-    int32_t threadCount = op.getIntOption("thread-count");
-    if (threadCount >= 0)
-        SetFakeCPUCount(threadCount);
-#endif /* JS_THREADSAFE */
-
 #ifdef DEBUG
     dumpEntrainedVariables = op.getBoolOption("dump-entrained-variables");
 #endif
 
     return true;
 }
 
 static int
@@ -6272,16 +6266,24 @@ main(int argc, char **argv, char **envp)
     if (op.getBoolOption("no-sse4")) {
         JSC::MacroAssembler::SetSSE4Disabled();
         PropagateFlagToNestedShells("--no-sse4");
     }
 #endif
 
 #endif // DEBUG
 
+#ifdef JS_THREADSAFE
+    // The fake thread count must be set before initializing the Runtime,
+    // which spins up the thread pool.
+    int32_t threadCount = op.getIntOption("thread-count");
+    if (threadCount >= 0)
+        SetFakeCPUCount(threadCount);
+#endif /* JS_THREADSAFE */
+
     // Start the engine.
     if (!JS_Init())
         return 1;
 
     /* Use the same parameters as the browser in xpcjsruntime.cpp. */
     rt = JS_NewRuntime(32L * 1024L * 1024L);
     if (!rt)
         return 1;