Bug 1724236 - Move InstantiateStencil out of Compile and Decode r=arai

Differential Revision: https://phabricator.services.mozilla.com/D218449
This commit is contained in:
Bryan Thrall
2024-10-30 13:41:42 +00:00
parent ffd49dfc27
commit e6436b95c3
5 changed files with 54 additions and 47 deletions

View File

@@ -2740,7 +2740,13 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
MarkerInnerWindowIdFromJSContext(aCx),
profilerLabelString);
aExec.Decode(aCx, aCompileOptions, aRequest->Bytecode(), aScript, aRv);
RefPtr<JS::Stencil> stencil;
aExec.Decode(aCx, aCompileOptions, aRequest->Bytecode(), stencil, aRv);
if (stencil) {
bool unused;
aExec.InstantiateStencil(aCx, aCompileOptions, std::move(stencil),
aScript, unused, aRv);
}
}
// We do not expect to be saving anything when we already have some
@@ -2774,14 +2780,20 @@ void ScriptLoader::InstantiateClassicScriptFromMaybeEncodedSource(
MarkerInnerWindowIdFromJSContext(aCx),
profilerLabelString);
RefPtr<JS::Stencil> stencil;
auto compile = [&](auto& source) {
aExec.Compile(aCx, aCompileOptions, source, aScript, aRv,
encodeBytecode);
aExec.Compile(aCx, aCompileOptions, source, stencil, aRv);
};
MOZ_ASSERT(!maybeSource.empty());
TimeStamp startTime = TimeStamp::Now();
maybeSource.mapNonEmpty(compile);
if (stencil) {
bool unused;
aExec.InstantiateStencil(aCx, aCompileOptions, std::move(stencil),
aScript, unused, aRv);
}
mMainThreadParseTime += TimeStamp::Now() - startTime;
}
}