Bug 1286795 part 6 - Replace JS_NewRuntime/JS_DestroyRuntime with JS_NewContext/JS_DestroyContext. r=luke,bz

This commit is contained in:
Jan de Mooij
2016-07-23 19:54:19 +02:00
parent 7745591aa5
commit 7ff36899cf
26 changed files with 230 additions and 250 deletions

View File

@@ -478,7 +478,7 @@ CycleCollectedJSRuntime::~CycleCollectedJSRuntime()
mConsumedRejections.reset();
#endif // SPIDERMONKEY_PROMISE
JS_DestroyRuntime(mJSRuntime);
JS_DestroyContext(mJSContext);
mJSRuntime = nullptr;
mJSContext = nullptr;
nsCycleCollector_forgetJSRuntime();
@@ -496,22 +496,22 @@ MozCrashWarningReporter(JSContext*, const char*, JSErrorReport*)
}
nsresult
CycleCollectedJSRuntime::Initialize(JSRuntime* aParentRuntime,
CycleCollectedJSRuntime::Initialize(JSContext* aParentContext,
uint32_t aMaxBytes,
uint32_t aMaxNurseryBytes)
{
MOZ_ASSERT(!mJSRuntime);
MOZ_ASSERT(!mJSContext);
mOwningThread->SetScriptObserver(this);
// The main thread has a base recursion depth of 0, workers of 1.
mBaseRecursionDepth = RecursionDepth();
mozilla::dom::InitScriptSettings();
mJSRuntime = JS_NewRuntime(aMaxBytes, aMaxNurseryBytes, aParentRuntime);
if (!mJSRuntime) {
mJSContext = JS_NewContext(aMaxBytes, aMaxNurseryBytes, aParentContext);
if (!mJSContext) {
return NS_ERROR_OUT_OF_MEMORY;
}
mJSContext = JS_GetContext(mJSRuntime);
mJSRuntime = JS_GetRuntime(mJSContext);
if (!JS_AddExtraGCRootsTracer(mJSContext, TraceBlackJS, this)) {
MOZ_CRASH("JS_AddExtraGCRootsTracer failed");