707 Commits

Author SHA1 Message Date
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
Butkovits Atila
c40fc96827 Merge mozilla-central to autoland. CLOSED TREE 2022-03-29 00:52:16 +03:00
Butkovits Atila
570f6e5c06 Merge autoland to mozilla-central. a=merge 2022-03-29 00:33:50 +03: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
7045acf305 Bug 1759881 - Part 9: Move module loading hooks into the generic module loader r=yulia
Now we can move the JS engine integration hooks into the generic module loader.

There is still some code there to deal with web extension globals. This will be
removed in a later patch.

Differential Revision: https://phabricator.services.mozilla.com/D141735
2022-03-28 12:38:28 +00:00
Jon Coppeard
eb0afeffa3 Bug 1759881 - Part 8: Add a virtual method to create a module load request for a dynamic import r=yulia
This adds a new virtual to the module loader base, along the same lines as the
one to create a load request for a static import. This makes the
HostImportModuleDynamically hook generic.

Differential Revision: https://phabricator.services.mozilla.com/D141734
2022-03-28 12:38:28 +00:00
Jon Coppeard
050bae2fd0 Bug 1759881 - Part 7: Add a virtual method to get the module loader to use for the current global r=yulia,smaug
This adds a virtual method to  nsIGlobalObject and implements it for
nsGlobalWindowInner and SandboxPrivate. This means we don't have to put the
logic for dealing with all the different kinds of globals in once place.

Differential Revision: https://phabricator.services.mozilla.com/D141733
2022-03-28 12:38:27 +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
c6920683db Bug 1436400 - Part 3: Remove nsJSUtils::CompileModule and directly use JSAPI with stencil. r=nbp
To add conditional JS::StartIncrementalEncoding, and also to add a bytecode
decoding branch, replace nsJSUtils::CompileModule with raw JSAPI calls with
Stencil.

Differential Revision: https://phabricator.services.mozilla.com/D140291
2022-03-15 19:05:54 +00:00
Tooru Fujisawa
6b3236dc9e Bug 1436400 - Part 2: Simplify ModuleLoader::CompileOrFinishModuleScript code flow. r=jonco
As a preparation to add bytecode case to CompileOrFinishModuleScript, removed
the shared nsresult variable and make each branch directly return, and also
do early return for error case.

Differential Revision: https://phabricator.services.mozilla.com/D140290
2022-03-15 19:05:54 +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
aaeb81d7b9 Bug 1436400 - Part 3: Remove nsJSUtils::CompileModule and directly use JSAPI with stencil. r=nbp
To add conditional JS::StartIncrementalEncoding, and also to add a bytecode
decoding branch, replace nsJSUtils::CompileModule with raw JSAPI calls with
Stencil.

Differential Revision: https://phabricator.services.mozilla.com/D140291
2022-03-15 04:24:49 +00:00
Tooru Fujisawa
518074add7 Bug 1436400 - Part 2: Simplify ModuleLoader::CompileOrFinishModuleScript code flow. r=jonco
As a preparation to add bytecode case to CompileOrFinishModuleScript, removed
the shared nsresult variable and make each branch directly return, and also
do early return for error case.

Differential Revision: https://phabricator.services.mozilla.com/D140290
2022-03-15 04:24:49 +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