Commit graph

555 commits

Author SHA1 Message Date
Jon Coppeard
1aeb55dd59 Bug 1766276 - Give MaybeOneOf a map method r=jandem
There are a few places where we call one of two overloads of a fuction based on
the contents of a MaybeOneOf. We can simplify this code by giving the class a
map method.

Differential Revision: https://phabricator.services.mozilla.com/D144595
2022-04-26 12:29:24 +00:00
Yulia Startsev
a996a1aca2 Bug 1763372 - Rename GetLoadContext to GetScriptLoadContext; r=jonco
Depends on D143068

Differential Revision: https://phabricator.services.mozilla.com/D143037
2022-04-22 13:24:10 +00:00
Yulia Startsev
7b6ada3766 Bug 1763586 - Remove Element from LoadScript and child classes; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D143139
2022-04-21 09:53:34 +00:00
Yulia Startsev
9c4d96a57d Bug 1763586 - Adjust ScriptFetchOptions to be more accurate; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D143137
2022-04-21 09:53:33 +00:00
criss
1a5e600ac1 Backed out 4 changesets (bug 1763586) for causing mochitest failures on test_Debugger.Source.prototype.elementAttribute.html. CLOSED TREE
Backed out changeset 8da9574159d3 (bug 1763586)
Backed out changeset 8f964a9e2f31 (bug 1763586)
Backed out changeset 420105516ec3 (bug 1763586)
Backed out changeset 68cd444d018e (bug 1763586)
2022-04-19 16:28:30 +03:00
Yulia Startsev
0190773604 Bug 1763586 - Remove Element from LoadScript and child classes; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D143139
2022-04-19 12:28:49 +00:00
Yulia Startsev
edce198b19 Bug 1763586 - Adjust ScriptFetchOptions to be more accurate; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D143137
2022-04-19 12:28:48 +00:00
Iulian Moraru
2844dc6b1f Backed out 3 changesets (bug 1763586) for causing mochitest-chrome failures on test_Debugger.Source.prototype.element.html.
Backed out changeset f6b6ccfce3d1 (bug 1763586)
Backed out changeset ca0157c919a9 (bug 1763586)
Backed out changeset e0294a6f9f9f (bug 1763586)
2022-04-13 21:53:34 +03:00
Yulia Startsev
2b9e84ae6c Bug 1763586 - Remove Element from LoadScript and child classes; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D143139
2022-04-13 16:29:36 +00:00
Yulia Startsev
dce170ffad Bug 1763586 - Adjust ScriptFetchOptions to be more accurate; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D143137
2022-04-13 16:29:36 +00:00
Marian-Vasile Laza
05a897ed46 Backed out 3 changesets (bug 1763586) foar causing sm bustages. CLOSED TREE
Backed out changeset 02a961432a49 (bug 1763586)
Backed out changeset 3fc84237decb (bug 1763586)
Backed out changeset 365eff56ce0f (bug 1763586)
2022-04-12 09:49:21 -07:00
Yulia Startsev
ea5e3cbf1d Bug 1763586 - Remove Element from LoadScript and child classes; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D143139
2022-04-12 16:16:32 +00:00
Yulia Startsev
37530c6fda Bug 1763586 - Adjust ScriptFetchOptions to be more accurate; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D143137
2022-04-12 16:16:31 +00:00
Jon Coppeard
8907766025 Bug 1761938 - Part 6: Remove global from script load context r=smaug,yulia
This removes the global object field from the script load context and gets the
global from the script loader / module loader where necessary.

Differential Revision: https://phabricator.services.mozilla.com/D142833
2022-04-11 15:35:30 +00:00
Jon Coppeard
3b308851b4 Bug 1761938 - Part 5: Use module loader's global where possible and remove GetGlobalForRequest from script loader interface r=yulia
Differential Revision: https://phabricator.services.mozilla.com/D142832
2022-04-11 15:35:30 +00:00
Jon Coppeard
d4aae71cf3 Bug 1761938 - Part 4: Give module loaders a global object field r=smaug,yulia
This gives the module loader a field for the current global, since a module map
is only associated with a single global.

This adds a method to Document to tell the script loader when its global
changes. I'm not sure of when we do this exactly.

Differential Revision: https://phabricator.services.mozilla.com/D142831
2022-04-11 15:35:29 +00:00
Jon Coppeard
88d0d67d61 Bug 1761938 - Part 2: Give each web extension content script global its own module loader r=smaug,yulia
This gives the DOM module loader a kind and records content script module
loaders in an array on the script loader.

Differential Revision: https://phabricator.services.mozilla.com/D142829
2022-04-11 15:35:28 +00:00
Jon Coppeard
461cd542e9 Bug 1761938 - Part 1: Call into the module loader via the module load request object r=yulia
The script loader will need to deal with requests from more than one module
loader so this adds methods to the request which dispatch to the correct
loader.

Differential Revision: https://phabricator.services.mozilla.com/D142828
2022-04-11 15:35:28 +00:00
Jon Coppeard
9d8474b374 Bug 1759881 - Part 10: Move the generic parts of the StartLoad method to the module loader base r=yulia
StartModuleLoadImpl moves to the base class and uses to new virtual methods
CanStartLoad and StartFetch which are implemented by the derived class.

Differential Revision: https://phabricator.services.mozilla.com/D141736
2022-03-28 15:56:10 +00:00
Jon Coppeard
075e630cb9 Bug 1761432 - Part 4: Rename state accessor methods after the enum values r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D142044
2022-03-25 10:54:17 +00:00
Jon Coppeard
0d945e360c Bug 1761432 - Part 2: Split out script load request state for when we require loading from source r=smaug
This is used when we explicitly don't want to load cached bytecode. It is
better served by a separate flag in the request than a state.

Differential Revision: https://phabricator.services.mozilla.com/D142042
2022-03-25 10:54:16 +00:00
Jon Coppeard
880347ab90 Bug 1761432 - Part 1: Rename ScriptLoadRequest progress enum to 'State' r=smaug
This also renames 'loading' enum values to 'fetching' since this is more
specific. Loading covers the whole process of loading, which includes the other
states.

Enum values have the leading 'e' removed in line with the coding style for enum
classes.

Differential Revision: https://phabricator.services.mozilla.com/D142041
2022-03-25 10:54:16 +00:00
Tooru Fujisawa
887bb8ff86 Bug 1759206 - Part 2: Use ModuleObject instead of script for encoding module bytecode cache. r=nbp
Depends on D141743

Differential Revision: https://phabricator.services.mozilla.com/D141744
2022-03-23 12:51:39 +00:00
Jon Coppeard
54129e0662 Bug 1759881 - Part 5: Remove microtask checkpoints from the module loader in couple of places r=smaug
This removes the microtask checkpoint when instantiating modules and moves the
one when creating a module script to the the script loader.

Differential Revision: https://phabricator.services.mozilla.com/D141252
2022-03-17 15:22:18 +00:00
Jon Coppeard
3570cedee9 Bug 1759881 - Part 3: Don't pass a global to FillCompileOptionsForRequest r=yulia
This can work it out if it needs it by calling GetGlobalForRequest.

Depends on D141249

Differential Revision: https://phabricator.services.mozilla.com/D141250
2022-03-17 15:22:17 +00:00
Jon Coppeard
38f12fcc0d Bug 1759881 - Part 1: Make list of dynamic import requests private r=yulia
This restricts access to mDynamicImportRequests and adds the appropriate accessors.

Differential Revision: https://phabricator.services.mozilla.com/D141248
2022-03-17 15:22:16 +00:00
Tooru Fujisawa
141090b932 Bug 1436400 - Part 10: Support bytecode cache for module script. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D140297
2022-03-15 19:05:57 +00:00
Tooru Fujisawa
82b9ddf3a3 Bug 1436400 - Part 9: Support restarting module load request. r=jonco
After enabling bytecode cache for module script, we need to handle
the SRI mismatch on bytecode cache, that requires reloading the script source
again.

Differential Revision: https://phabricator.services.mozilla.com/D140551
2022-03-15 19:05:57 +00:00
Tooru Fujisawa
c963262d5c 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
2022-03-15 19:05:56 +00:00
Tooru Fujisawa
1f7d1985f5 Bug 1436400 - Part 7: Split ScriptLoader::MaybePrepareForBytecodeEncoding into 2 parts. r=nbp
As a preparation to use the bytecode encoding in the module evaluation code,
ScriptLoader::MaybePrepareForBytecodeEncoding is split into 2 parts:
  * one for performing preparation before executing script
  * one for queuing the request for bytecode encoding after executing script

In module's case, the bytecode encoding handling must be done on the entire
import tree, and also the module object's ScriptSlot is cleared on execution.
So, the script reference must be copied to the corresponding script load request
field before execution, and the script source must be queued for bytecode
encoding after executing the top-level script, so that incremental encoding
reflects functions called there.

Differential Revision: https://phabricator.services.mozilla.com/D140295
2022-03-15 19:05:56 +00:00
Tooru Fujisawa
227d00d1e1 Bug 1436400 - Part 5: Add bytecode MIME type for regular script and module. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D140293
2022-03-15 19:05:55 +00:00
Tooru Fujisawa
0aaa5686d0 Bug 1436400 - Part 4: Add ScriptLoader::BytecodeMimeTypeFor static method to get bytecode MIME type for given request. r=nbp
Module bytecode should use different MIME type, to avoid mixing up script/module
bytecodes for single JS file.

This patch adds a static method that simply returns the current bytecode MIME
type.
The later patch adds a new MIME type for module bytecode and modify the
ScriptLoader::BytecodeMimeTypeFor method to return corresponding MIME type.

Differential Revision: https://phabricator.services.mozilla.com/D140292
2022-03-15 19:05:55 +00:00
Tooru Fujisawa
ee8432f073 Bug 1436400 - Part 1: Remove Unused parameter from ExecuteCompiledScript. r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D140289
2022-03-15 19:05:54 +00:00
Tooru Fujisawa
45afe7d97e Bug 1757597 - Rename ScriptLoadRequest.mScript to mScriptForBytecodeEncoding. r=jonco
mScript field is used only for bytecode encoding, and this field is used as a
flag for whether the script load request has bytecode-encoding-related
references.

Differential Revision: https://phabricator.services.mozilla.com/D140288
2022-03-15 19:05:53 +00:00
Csoregi Natalia
6ae31a2e64 Backed out 15 changesets (bug 1757597, bug 1436400) for causing mochitest failures on test_bug1656248.html. CLOSED TREE
Backed out changeset 4be29c1eb5bc (bug 1436400)
Backed out changeset ffd9ddcef6b0 (bug 1436400)
Backed out changeset 5ac844508d8b (bug 1436400)
Backed out changeset 561aeb550892 (bug 1436400)
Backed out changeset 6f473bcf809a (bug 1436400)
Backed out changeset c33620854115 (bug 1436400)
Backed out changeset 8f894ea40eb2 (bug 1436400)
Backed out changeset cce080064d82 (bug 1436400)
Backed out changeset 001d8528ff96 (bug 1436400)
Backed out changeset dd2bb1b46f75 (bug 1436400)
Backed out changeset b1c2084042fa (bug 1436400)
Backed out changeset dd0fea93bcd7 (bug 1436400)
Backed out changeset e38a959648e1 (bug 1436400)
Backed out changeset 40b474d430e9 (bug 1436400)
Backed out changeset 5bef21ef1ba2 (bug 1757597)
2022-03-15 07:23:29 +02:00
Tooru Fujisawa
d09fb8acd5 Bug 1436400 - Part 10: Support bytecode cache for module script. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D140297
2022-03-15 04:24:52 +00:00
Tooru Fujisawa
4d4aa8001e Bug 1436400 - Part 9: Support restarting module load request. r=jonco
After enabling bytecode cache for module script, we need to handle
the SRI mismatch on bytecode cache, that requires reloading the script source
again.

Differential Revision: https://phabricator.services.mozilla.com/D140551
2022-03-15 04:24:52 +00:00
Tooru Fujisawa
bd3852013b 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
2022-03-15 04:24:51 +00:00
Tooru Fujisawa
5c2b6e6337 Bug 1436400 - Part 7: Split ScriptLoader::MaybePrepareForBytecodeEncoding into 2 parts. r=nbp
As a preparation to use the bytecode encoding in the module evaluation code,
ScriptLoader::MaybePrepareForBytecodeEncoding is split into 2 parts:
  * one for performing preparation before executing script
  * one for queuing the request for bytecode encoding after executing script

In module's case, the bytecode encoding handling must be done on the entire
import tree, and also the module object's ScriptSlot is cleared on execution.
So, the script reference must be copied to the corresponding script load request
field before execution, and the script source must be queued for bytecode
encoding after executing the top-level script, so that incremental encoding
reflects functions called there.

Differential Revision: https://phabricator.services.mozilla.com/D140295
2022-03-15 04:24:51 +00:00
Tooru Fujisawa
6aec9a0a75 Bug 1436400 - Part 5: Add bytecode MIME type for regular script and module. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D140293
2022-03-15 04:24:50 +00:00
Tooru Fujisawa
ea5bbd2533 Bug 1436400 - Part 4: Add ScriptLoader::BytecodeMimeTypeFor static method to get bytecode MIME type for given request. r=nbp
Module bytecode should use different MIME type, to avoid mixing up script/module
bytecodes for single JS file.

This patch adds a static method that simply returns the current bytecode MIME
type.
The later patch adds a new MIME type for module bytecode and modify the
ScriptLoader::BytecodeMimeTypeFor method to return corresponding MIME type.

Differential Revision: https://phabricator.services.mozilla.com/D140292
2022-03-15 04:24:50 +00:00
Tooru Fujisawa
d02a32e588 Bug 1436400 - Part 1: Remove Unused parameter from ExecuteCompiledScript. r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D140289
2022-03-15 04:24:49 +00:00
Tooru Fujisawa
bc93412a17 Bug 1757597 - Rename ScriptLoadRequest.mScript to mScriptForBytecodeEncoding. r=jonco
mScript field is used only for bytecode encoding, and this field is used as a
flag for whether the script load request has bytecode-encoding-related
references.

Differential Revision: https://phabricator.services.mozilla.com/D140288
2022-03-15 04:24:48 +00:00
Nicolas B. Pierron
c21376a6c8 Bug 1753709 - Add test case to verify delazification strategy is used. r=arai
Differential Revision: https://phabricator.services.mozilla.com/D138541
2022-03-01 15:00:04 +00:00
Nicolas B. Pierron
95eb456ef7 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
2022-03-01 15:00:03 +00:00
Cristian Tuns
c82feaecab Backed out 3 changesets (bug 1753709) for causing mochitest failures on test_delazification_strategy.html CLOSED TREE
Backed out changeset b908fc38d2d3 (bug 1753709)
Backed out changeset 56a169a692b9 (bug 1753709)
Backed out changeset 224f4cf66993 (bug 1753709)
2022-02-22 11:44:40 -05:00
Nicolas B. Pierron
fc8f1af2cf Bug 1753709 - Add test case to verify delazification strategy is used. r=arai
Differential Revision: https://phabricator.services.mozilla.com/D138541
2022-02-22 14:59:18 +00:00
Nicolas B. Pierron
01430ae030 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
2022-02-22 14:59:17 +00:00
Marian-Vasile Laza
3f7e0b2d4f Backed out 3 changesets (bug 1753709) for causing build bustages on ScriptLoader.cpp. CLOSED TREE
Backed out changeset eb7704e8a30c (bug 1753709)
Backed out changeset 193409767cf2 (bug 1753709)
Backed out changeset 891174ee20ee (bug 1753709)
2022-02-21 09:45:40 -08:00
Nicolas B. Pierron
a5888fac59 Bug 1753709 - Add test case to verify delazification strategy is used. r=arai
Differential Revision: https://phabricator.services.mozilla.com/D138541
2022-02-21 17:26:03 +00:00