Bug 1726498 - Add JS::DecodeOptions. r=tcampbell

Differential Revision: https://phabricator.services.mozilla.com/D128345
This commit is contained in:
Tooru Fujisawa
2021-10-21 21:48:48 +00:00
parent 2823cd9c99
commit b2e1a62bf0
20 changed files with 187 additions and 104 deletions

View File

@@ -1271,14 +1271,12 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
}
JSContext* cx = jsapi.cx();
JS::CompileOptions options(cx);
FillCompileOptionsForCachedStencil(options);
options.setFileAndLine(url.get(), 1);
RefPtr<JS::Stencil> stencil;
if (useScriptPreloader) {
stencil =
ScriptPreloader::GetChildSingleton().GetCachedStencil(cx, options, url);
JS::DecodeOptions decodeOptions;
ScriptPreloader::FillDecodeOptionsForCachedStencil(decodeOptions);
stencil = ScriptPreloader::GetChildSingleton().GetCachedStencil(
cx, decodeOptions, url);
}
if (!stencil) {
@@ -1315,6 +1313,10 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
return nullptr;
}
JS::CompileOptions options(cx);
FillCompileOptionsForCachedStencil(options);
options.setFileAndLine(url.get(), 1);
// If we are not encoding to the ScriptPreloader cache, we can now relax the
// compile options and use the JS syntax-parser for lower latency.
if (!useScriptPreloader || !ScriptPreloader::GetChildSingleton().Active()) {
@@ -1338,6 +1340,12 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
auto* holder = new nsMessageManagerScriptHolder(stencil);
sCachedScripts->InsertOrUpdate(aURL, holder);
}
#ifdef DEBUG
// The above shouldn't touch any options for instantiation.
JS::InstantiateOptions instantiateOptions(options);
instantiateOptions.assertDefault();
#endif
}
MOZ_ASSERT(stencil);