Bug 1734098 - Part 11: Add JS::DecodeStencilOffThread. r=tcampbell

Also make JS::CanDecodeOffThread to receive JS::DecodeOptions.

Differential Revision: https://phabricator.services.mozilla.com/D133052
This commit is contained in:
Tooru Fujisawa
2021-12-10 04:28:29 +00:00
parent df2429f5cd
commit 69c348d423
12 changed files with 536 additions and 18 deletions

View File

@@ -1840,7 +1840,8 @@ nsresult ScriptLoader::AttemptAsyncScriptCompile(ScriptLoadRequest* aRequest,
size_t length =
aRequest->mScriptBytecode.length() - aRequest->mBytecodeOffset;
if (!JS::CanDecodeOffThread(cx, options, length)) {
JS::DecodeOptions decodeOptions(options);
if (!JS::CanDecodeOffThread(cx, decodeOptions, length)) {
return NS_OK;
}
}
@@ -1865,8 +1866,6 @@ nsresult ScriptLoader::AttemptAsyncScriptCompile(ScriptLoadRequest* aRequest,
nsresult rv = aRequest->GetScriptSource(cx, &maybeSource);
NS_ENSURE_SUCCESS(rv, rv);
options.allocateInstantiationStorage = true;
aRequest->mOffThreadToken =
maybeSource.constructed<SourceText<char16_t>>()
? JS::CompileModuleToStencilOffThread(
@@ -1879,8 +1878,9 @@ nsresult ScriptLoader::AttemptAsyncScriptCompile(ScriptLoadRequest* aRequest,
return NS_ERROR_OUT_OF_MEMORY;
}
} else if (aRequest->IsBytecode()) {
aRequest->mOffThreadToken = JS::DecodeOffThreadScript(
cx, options, aRequest->mScriptBytecode, aRequest->mBytecodeOffset,
JS::DecodeOptions decodeOptions(options);
aRequest->mOffThreadToken = JS::DecodeStencilOffThread(
cx, decodeOptions, aRequest->mScriptBytecode, aRequest->mBytecodeOffset,
OffThreadScriptLoaderCallback, static_cast<void*>(runnable));
if (!aRequest->mOffThreadToken) {
return NS_ERROR_OUT_OF_MEMORY;
@@ -1906,8 +1906,6 @@ nsresult ScriptLoader::AttemptAsyncScriptCompile(ScriptLoadRequest* aRequest,
nsresult rv = aRequest->GetScriptSource(cx, &maybeSource);
NS_ENSURE_SUCCESS(rv, rv);
options.allocateInstantiationStorage = true;
aRequest->mOffThreadToken =
maybeSource.constructed<SourceText<char16_t>>()
? JS::CompileToStencilOffThread(
@@ -2184,6 +2182,8 @@ nsresult ScriptLoader::FillCompileOptionsForRequest(
aOptions->borrowBuffer = true;
aOptions->allocateInstantiationStorage = true;
return NS_OK;
}