Bug 1787529 - Align the conditions in ScriptLoadContext::MaybeCancelOffThreadScript to ScriptLoader::AttemptAsyncScriptCompile. r=jonco

Differential Revision: https://phabricator.services.mozilla.com/D155740
This commit is contained in:
Tooru Fujisawa 2022-08-31 22:38:21 +00:00
parent 998208305e
commit a927c643ec
2 changed files with 9 additions and 7 deletions

View File

@ -105,14 +105,15 @@ void ScriptLoadContext::MaybeCancelOffThreadScript() {
}
JSContext* cx = danger::GetJSContext();
// Follow the same conditions as ScriptLoader::AttemptAsyncScriptCompile
if (mRequest->IsModuleRequest()) {
JS::CancelCompileModuleToStencilOffThread(cx, mOffThreadToken);
} else if (mRequest->IsSource()) {
JS::CancelCompileToStencilOffThread(cx, mOffThreadToken);
} else {
MOZ_ASSERT(mRequest->IsBytecode());
// The conditions should match ScriptLoader::AttemptAsyncScriptCompile.
if (mRequest->IsBytecode()) {
JS::CancelDecodeStencilOffThread(cx, mOffThreadToken);
} else if (mRequest->IsModuleRequest()) {
MOZ_ASSERT(mRequest->IsTextSource());
JS::CancelCompileModuleToStencilOffThread(cx, mOffThreadToken);
} else {
MOZ_ASSERT(mRequest->IsTextSource());
JS::CancelCompileToStencilOffThread(cx, mOffThreadToken);
}
// Cancellation request above should guarantee removal of the parse task, so

View File

@ -1646,6 +1646,7 @@ nsresult ScriptLoader::AttemptAsyncScriptCompile(ScriptLoadRequest* aRequest,
auto signalOOM = mozilla::MakeScopeExit(
[&aRequest]() { aRequest->GetScriptLoadContext()->mRunnable = nullptr; });
// The conditions should match ScriptLoadContext::MaybeCancelOffThreadScript.
if (aRequest->IsBytecode()) {
JS::DecodeOptions decodeOptions(options);
aRequest->GetScriptLoadContext()->mOffThreadToken =