Bug 1221385 - Handle OOM during JitRuntime initialization a bit better. r=bhackett
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 30 Dec 2015 13:27:09 +0100
changeset 277888 350fbdbad784715d2e36a4dcb3eb7d89002033e2
parent 277887 fcd8d385410805aa3fadc7f027c478f65cda7dbc
child 277889 27b9d60e819cce5f20de8a0c48b1aa40522c7dd2
push id69631
push userjandemooij@gmail.com
push dateWed, 30 Dec 2015 12:31:30 +0000
treeherdermozilla-inbound@27b9d60e819c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs1221385
milestone46.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 1221385 - Handle OOM during JitRuntime initialization a bit better. r=bhackett
js/src/jscompartment.cpp
--- a/js/src/jscompartment.cpp
+++ b/js/src/jscompartment.cpp
@@ -163,29 +163,22 @@ JSRuntime::createJitRuntime(JSContext* c
         return nullptr;
 
     // Protect jitRuntime_ from being observed (by InterruptRunningJitCode)
     // while it is being initialized. Unfortunately, initialization depends on
     // jitRuntime_ being non-null, so we can't just wait to assign jitRuntime_.
     JitRuntime::AutoPreventBackedgePatching apbp(cx->runtime(), jrt);
     jitRuntime_ = jrt;
 
+    AutoEnterOOMUnsafeRegion noOOM;
     if (!jitRuntime_->initialize(cx)) {
-        ReportOutOfMemory(cx);
-
-        js_delete(jitRuntime_);
-        jitRuntime_ = nullptr;
-
-        JSCompartment* comp = cx->runtime()->atomsCompartment();
-        if (comp->jitCompartment_) {
-            js_delete(comp->jitCompartment_);
-            comp->jitCompartment_ = nullptr;
-        }
-
-        return nullptr;
+        // Handling OOM here is complicated: if we delete jitRuntime_ now, we
+        // will destroy the ExecutableAllocator, even though there may still be
+        // JitCode instances holding references to ExecutablePools.
+        noOOM.crash("OOM in createJitRuntime");
     }
 
     return jitRuntime_;
 }
 
 bool
 JSCompartment::ensureJitCompartmentExists(JSContext* cx)
 {