Bug 974739 - Fix non-threadsafe build errors in the SpiderMonkey shell, r=bhackett
authorTerrence Cole <terrence@mozilla.com>
Wed, 19 Feb 2014 18:54:43 -0800
changeset 169988 abfaf0ccae19a0702be8a8d3427cb15cee5f4add
parent 169987 36335b77688ed8517f88196bbf8d49f72f4fae5f
child 169989 b1d92f0829531ee34cfe5d14f6b276023f52911d
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersbhackett
bugs974739
milestone30.0a1
Bug 974739 - Fix non-threadsafe build errors in the SpiderMonkey shell, r=bhackett
js/src/jit-test/tests/basic/evaluate-worker.js
js/src/shell/js.cpp
--- a/js/src/jit-test/tests/basic/evaluate-worker.js
+++ b/js/src/jit-test/tests/basic/evaluate-worker.js
@@ -1,10 +1,13 @@
 // |jit-test| slow
 
+if (typeof evalInWorker == "undefined")
+    quit();
+
 gcslice(10);
 evalInWorker("print('helo world');");
 for (i = 0; i < 100000; i++) {}
 
 evalInWorker("\
   for (var i = 0; i < 10; i++) { \
     var o = {}; \
     for (var j = 0; j < 100; j++) \
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -2603,16 +2603,17 @@ EvalInFrame(JSContext *cx, unsigned argc
     bool ok = !!frame.evaluateUCInStackFrame(cx, chars, length,
                                              fpscript->filename(),
                                              JS_PCToLineNumber(cx, fpscript,
                                                                fi.pc()),
                                              MutableHandleValue::fromMarkedLocation(vp));
     return ok;
 }
 
+#ifdef JS_THREADSAFE
 struct WorkerInput
 {
     JSRuntime *runtime;
     jschar *chars;
     size_t length;
 
     WorkerInput(JSRuntime *runtime, jschar *chars, size_t length)
       : runtime(runtime), chars(chars), length(length)
@@ -2699,16 +2700,17 @@ EvalInWorker(JSContext *cx, unsigned arg
 
     PRThread *thread = PR_CreateThread(PR_USER_THREAD, WorkerMain, input,
                                        PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);
     if (!thread || !workerThreads.append(thread))
         return false;
 
     return true;
 }
+#endif
 
 static bool
 ShapeOf(JSContext *cx, unsigned argc, JS::Value *vp)
 {
     JS::Value v;
     if (argc < 1 || !((v = JS_ARGV(cx, vp)[0]).isObject())) {
         JS_ReportError(cx, "shapeOf: object expected");
         return false;
@@ -4264,41 +4266,43 @@ static const JSFunctionSpecWithHelp shel
 "  if (s == '' && !o) return new o with eager standard classes\n"
 "  if (s == 'lazy' && !o) return new o with lazy standard classes"),
 
     JS_FN_HELP("evalInFrame", EvalInFrame, 2, 0,
 "evalInFrame(n,str,save)",
 "  Evaluate 'str' in the nth up frame.\n"
 "  If 'save' (default false), save the frame chain."),
 
+#ifdef JS_THREADSAFE
     JS_FN_HELP("evalInWorker", EvalInWorker, 1, 0,
 "evalInWorker(str)",
 "  Evaluate 'str' in a separate thread with its own runtime.\n"),
+#endif
 
     JS_FN_HELP("shapeOf", ShapeOf, 1, 0,
 "shapeOf(obj)",
 "  Get the shape of obj (an implementation detail)."),
 
     JS_FN_HELP("resolver", Resolver, 1, 0,
 "resolver(src[, proto])",
 "  Create object with resolve hook that copies properties\n"
 "  from src. If proto is omitted, use Object.prototype."),
 
 #ifdef DEBUG
     JS_FN_HELP("arrayInfo", js_ArrayInfo, 1, 0,
 "arrayInfo(a1, a2, ...)",
 "  Report statistics about arrays."),
-
 #endif
+
 #ifdef JS_THREADSAFE
     JS_FN_HELP("sleep", Sleep_fn, 1, 0,
 "sleep(dt)",
 "  Sleep for dt seconds."),
-
 #endif
+
     JS_FN_HELP("snarf", Snarf, 1, 0,
 "snarf(filename, [\"binary\"])",
 "  Read filename into returned string. Filename is relative to the current\n"
                "  working directory."),
 
     JS_FN_HELP("read", Snarf, 1, 0,
 "read(filename, [\"binary\"])",
 "  Synonym for snarf."),
@@ -6048,15 +6052,17 @@ main(int argc, char **argv, char **envp)
 
     gTimeoutFunc = NullValue();
     JS_RemoveValueRootRT(rt, &gTimeoutFunc);
 
     DestroyContext(cx, true);
 
     KillWatchdog();
 
+#ifdef JS_THREADSAFE
     for (size_t i = 0; i < workerThreads.length(); i++)
         PR_JoinThread(workerThreads[i]);
+#endif
 
     JS_DestroyRuntime(rt);
     JS_ShutDown();
     return result;
 }