Bug 1221385 - Handle OOM during JitRuntime initialization a bit better. r=bhackett a=abillings
--- a/js/src/jscompartment.cpp
+++ b/js/src/jscompartment.cpp
@@ -162,29 +162,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::AutoMutateBackedges amb(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)
{