JSContext* js::NewContext(uint32_t maxBytes, uint32_t maxNurseryBytes, JSRuntime* parentRuntime) { AutoNoteSingleThreadedRegion anstr; MOZ_RELEASE_ASSERT(!TlsContext.get()); JSRuntime* runtime = js_new<JSRuntime>(parentRuntime); if (!runtime) return nullptr; JSContext* cx = js_new<JSContext>(runtime, JS::ContextOptions()); if (!cx) { js_delete(runtime); return nullptr; } if (!runtime->init(cx, maxBytes, maxNurseryBytes)) { runtime->destroyRuntime(); js_delete(cx); js_delete(runtime); return nullptr; } if (!cx->init(ContextKind::Cooperative)) { runtime->destroyRuntime(); js_delete(cx); js_delete(runtime); return nullptr; } return cx; }
JSContext* js::NewContext(uint32_t maxBytes, uint32_t maxNurseryBytes, JSRuntime* parentRuntime) { AutoNoteSingleThreadedRegion anstr; MOZ_RELEASE_ASSERT(!TlsContext.get()); #if defined(DEBUG) || defined(JS_OOM_BREAKPOINT) js::oom::SetThreadType(!parentRuntime ? js::THREAD_TYPE_COOPERATING : js::THREAD_TYPE_WORKER); #endif JSRuntime* runtime = js_new<JSRuntime>(parentRuntime); if (!runtime) return nullptr; JSContext* cx = js_new<JSContext>(runtime, JS::ContextOptions()); if (!cx) { js_delete(runtime); return nullptr; } if (!runtime->init(cx, maxBytes, maxNurseryBytes)) { runtime->destroyRuntime(); js_delete(cx); js_delete(runtime); return nullptr; } if (!cx->init(ContextKind::Cooperative)) { runtime->destroyRuntime(); js_delete(cx); js_delete(runtime); return nullptr; } return cx; }