Bug 1414840 - Don't try to recover from OOM when creating cooperative threads in the shell, r=jandem.
authorBrian Hackett <bhackett1024@gmail.com>
Mon, 04 Dec 2017 07:53:04 -0700
changeset 399445 dccbf55508540c0459f36c286e3aff6975af722e
parent 399444 06dc5a5ea2238a6611c965bba2c46d1533524aa6
child 399446 47ef66d8992edf8ccb4b92ab4242e3385fb2dc1c
child 399563 b2cb61e83ac50115a28f04aaa8a32d4db90aad23
push id98955
push userbhackett@mozilla.com
push dateTue, 16 Jan 2018 16:50:03 +0000
treeherdermozilla-inbound@dccbf5550854 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1414840
milestone59.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 1414840 - Don't try to recover from OOM when creating cooperative threads in the shell, r=jandem.
js/src/shell/js.cpp
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -3750,25 +3750,22 @@ EvalInThread(JSContext* cx, unsigned arg
         return false;
     }
 
     if (cooperative) {
         cooperationState->numThreads++;
         CooperativeBeginWait(cx);
     }
 
-    auto thread = js_new<Thread>(Thread::Options().setStackSize(gMaxStackSize + 128 * 1024));
-    if (!thread || !thread->init(WorkerMain, input)) {
-        ReportOutOfMemory(cx);
-        if (cooperative) {
-            cooperationState->numThreads--;
-            CooperativeYield();
-            CooperativeEndWait(cx);
-        }
-        return false;
+    Thread* thread;
+    {
+        AutoEnterOOMUnsafeRegion oomUnsafe;
+        thread = js_new<Thread>(Thread::Options().setStackSize(gMaxStackSize + 128 * 1024));
+        if (!thread || !thread->init(WorkerMain, input))
+            oomUnsafe.crash("EvalInThread");
     }
 
     if (cooperative) {
         CooperativeEndWait(cx);
     } else {
         AutoLockWorkerThreads alwt;
         if (!workerThreads.append(thread)) {
             ReportOutOfMemory(cx);