Bug 1753709 - JavaScript: Add a preference to switch between delazification strategies. r=arai

This patch changes the way we parse JavaScript coming from Necko while loading
web pages, by adding an about:config flag named
javascript.options.delazification.strategy which is used to select between:

 0 - On Demand
 1 - Concurrent Depth First
 255 - Parse Everything Eagerly

Previously, we moved from On-demand delazification, to parsing everything
eagerly to improve responsiveness of the browser, but we knew that more room for
optimization exists.

This toogle is meant to explore the space of delazification strategies, such
that we can parse functions of JavaScript files on an helper thread, while the
JavaScript file is being executed on the main thread. The space of
delazification strategies goes from ordering the order in which functions are
processed, as well as filtering functions which are processed. Not all functions
have to be delazified, and if the main thread needs a function which is not
parsed yet, it will fallback to parsing it on-demand.

Differential Revision: https://phabricator.services.mozilla.com/D138034
This commit is contained in:
Nicolas B. Pierron
2022-02-21 17:26:03 +00:00
parent 10fbaad49e
commit f12cf15dc9
4 changed files with 76 additions and 18 deletions

View File

@@ -617,7 +617,9 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
void AddAsyncRequest(ScriptLoadRequest* aRequest);
bool MaybeRemovedDeferRequests();
bool ShouldFullParse(ScriptLoadRequest* aRequest);
bool ShouldApplyDelazifyStrategy(ScriptLoadRequest* aRequest);
void ApplyDelazifyStrategy(JS::CompileOptions* aOptions);
bool ShouldCompileOffThread(ScriptLoadRequest* aRequest);
void MaybeMoveToLoadedList(ScriptLoadRequest* aRequest);