Bug 1436400 - Part 8: Add code path for bytecode encoding module scripts. r=nbp

The module scripts are scanned immediately before executing, and if the
module script is not yet executed, and it matches the requirement for encoding
(size, fetch count, etc), it's marked as encode,
and they're scanned again immediately after executing, and marked scripts are
queued for bytecode encoding.

This patch doesn't actually enable the encoding, given ShouldCacheBytecode
returns false because the caching is not enabled for the channel and
GetCacheTokenFetchCount fails.

Differential Revision: https://phabricator.services.mozilla.com/D140296
This commit is contained in:
Tooru Fujisawa
2022-03-15 19:05:56 +00:00
parent d83ea3db0b
commit 8a92b769e9
5 changed files with 92 additions and 8 deletions

View File

@@ -460,6 +460,12 @@ nsresult ModuleLoader::CompileOrFinishModuleScript(
return NS_ERROR_FAILURE;
}
if (ScriptLoader::ShouldCacheBytecode(aRequest)) {
if (!JS::StartIncrementalEncoding(aCx, std::move(stencil))) {
return NS_ERROR_FAILURE;
}
}
return NS_OK;
}
@@ -487,6 +493,12 @@ nsresult ModuleLoader::CompileOrFinishModuleScript(
return NS_ERROR_FAILURE;
}
if (ScriptLoader::ShouldCacheBytecode(aRequest)) {
if (!JS::StartIncrementalEncoding(aCx, std::move(stencil))) {
return NS_ERROR_FAILURE;
}
}
return NS_OK;
}