Commit graph

129 commits

Author SHA1 Message Date
Jon Coppeard
19409077f2 Bug 1842798 - Part 3: Complete dynamic imports asynchronously with a microtask r=smaug
According to the spec this should happen as the result of resolving a promise
(see ContinueDynamicImport). If this happens synchronously it's possible for
the importing module to still be in the evaluating state when trying to
instantiate and evaluate the dynamically imported module which breaks the
module loader invariants.

Differential Revision: https://phabricator.services.mozilla.com/D183876
2023-08-03 08:15:29 +00:00
Jon Coppeard
85b88021df Bug 1842798 - Part 2: Remove use of MozPromise to wait for module imports to load r=smaug
This replaces the use of a promise to wait for all imports of a module to load
with a counter of reminaing imports in the parent and a pointer to the parent
that is waiting in the child. The parent request is updated immediately rather
than by dispatching a runnable.

Differential Revision: https://phabricator.services.mozilla.com/D183273
2023-08-03 08:15:29 +00:00
Jon Coppeard
baca1b8e1f Bug 1842798 - Part 1: Remove use of MozPromise to wait for module fetch r=smaug
This replaces the promise with a list of module requests that are waiting for a
resource to be fetched. When the fetch completes the waiting requests are
resumed appropriately. This now happens immediately rather tha via dispatching
a runnable.

Differential Revision: https://phabricator.services.mozilla.com/D183272
2023-08-03 08:15:29 +00:00
Narcis Beleuzu
cf92578c03 Backed out 4 changesets (bug 1842798) for wpt failures on module-tla-import.html . CLOSED TREE
Backed out changeset 879154594bb1 (bug 1842798)
Backed out changeset 2a6b3ff79a01 (bug 1842798)
Backed out changeset 507da9d36f91 (bug 1842798)
Backed out changeset 3528d70acb5f (bug 1842798)
2023-08-02 20:48:53 +03:00
Jon Coppeard
b74ed7afeb Bug 1842798 - Part 3: Complete dynamic imports asynchronously with a microtask r=smaug
According to the spec this should happen as the result of resolving a promise
(see ContinueDynamicImport). If this happens synchronously it's possible for
the importing module to still be in the evaluating state when trying to
instantiate and evaluate the dynamically imported module which breaks the
module loader invariants.

Differential Revision: https://phabricator.services.mozilla.com/D183876
2023-08-02 14:39:33 +00:00
Jon Coppeard
afcabcef11 Bug 1842798 - Part 2: Remove use of MozPromise to wait for module imports to load r=smaug
This replaces the use of a promise to wait for all imports of a module to load
with a counter of reminaing imports in the parent and a pointer to the parent
that is waiting in the child. The parent request is updated immediately rather
than by dispatching a runnable.

Differential Revision: https://phabricator.services.mozilla.com/D183273
2023-08-02 14:39:33 +00:00
Jon Coppeard
07468c5fe3 Bug 1842798 - Part 1: Remove use of MozPromise to wait for module fetch r=smaug
This replaces the promise with a list of module requests that are waiting for a
resource to be fetched. When the fetch completes the waiting requests are
resumed appropriately. This now happens immediately rather tha via dispatching
a runnable.

Differential Revision: https://phabricator.services.mozilla.com/D183272
2023-08-02 14:39:33 +00:00
Sandor Molnar
9de1620f3b Backed out 4 changesets (bug 1842798) for causing wpt failures in /html/webappapis/dynamic-markup-insertion/document-write/module-dynamic-import.html CLOSED TREE
Backed out changeset b153ebf104ef (bug 1842798)
Backed out changeset 05bcaff61b68 (bug 1842798)
Backed out changeset 0864a23409e6 (bug 1842798)
Backed out changeset 98a1aa86513d (bug 1842798)
2023-08-02 14:58:13 +03:00
Jon Coppeard
dc4791f4d9 Bug 1842798 - Part 3: Complete dynamic imports asynchronously with a microtask r=smaug
According to the spec this should happen as the result of resolving a promise
(see ContinueDynamicImport). If this happens synchronously it's possible for
the importing module to still be in the evaluating state when trying to
instantiate and evaluate the dynamically imported module which breaks the
module loader invariants.

Differential Revision: https://phabricator.services.mozilla.com/D183876
2023-08-02 09:34:39 +00:00
Jon Coppeard
7378829120 Bug 1842798 - Part 2: Remove use of MozPromise to wait for module imports to load r=smaug
This replaces the use of a promise to wait for all imports of a module to load
with a counter of reminaing imports in the parent and a pointer to the parent
that is waiting in the child. The parent request is updated immediately rather
than by dispatching a runnable.

Differential Revision: https://phabricator.services.mozilla.com/D183273
2023-08-02 09:34:39 +00:00
Jon Coppeard
a71d4dc77c Bug 1842798 - Part 1: Remove use of MozPromise to wait for module fetch r=smaug
This replaces the promise with a list of module requests that are waiting for a
resource to be fetched. When the fetch completes the waiting requests are
resumed appropriately. This now happens immediately rather tha via dispatching
a runnable.

Differential Revision: https://phabricator.services.mozilla.com/D183272
2023-08-02 09:34:39 +00:00
Natalia Csoregi
87dee095ca Backed out 6 changesets (bug 1842798) for causing failures on js/src/tests/test262/language/*. CLOSED TREE
Backed out changeset 38669a2ddad9 (bug 1842798)
Backed out changeset 5dad4aeacd53 (bug 1842798)
Backed out changeset 23d10eb8f853 (bug 1842798)
Backed out changeset 946e4dfe5452 (bug 1842798)
Backed out changeset 1b89736a463f (bug 1842798)
Backed out changeset b2e6bdd781ac (bug 1842798)
2023-07-17 20:52:18 +03:00
Jon Coppeard
3aab0ac6ba Bug 1842798 - Part 3: Remove unused event target from ModuleLoaderBase r=smaug
This was previously used by MozPromise but is no longer required.

Differential Revision: https://phabricator.services.mozilla.com/D183586
2023-07-17 12:44:19 +00:00
Jon Coppeard
3d87996a4b Bug 1842798 - Part 2: Remove use of MozPromise to wait for module imports to load r=smaug
This replaces the use of a promise to wait for all imports of a module to load
with a counter of reminaing imports in the parent and a pointer to the parent
that is waiting in the child. The parent request is updated immediately rather
than by dispatching a runnable.

Differential Revision: https://phabricator.services.mozilla.com/D183273
2023-07-17 12:44:18 +00:00
Jon Coppeard
9a911aa85b Bug 1842798 - Part 1: Remove use of MozPromise to wait for module fetch r=smaug
This replaces the promise with a list of module requests that are waiting for a
resource to be fetched. When the fetch completes the waiting requests are
resumed appropriately. This now happens immediately rather tha via dispatching
a runnable.

Differential Revision: https://phabricator.services.mozilla.com/D183272
2023-07-17 12:44:18 +00:00
Jon Coppeard
71cd073308 Bug 1803984 - Part 2: Add assertion that we only remove unlinked modules from the map r=allstarschh
It would not be correct to remove modules that were already linked or evaluated.



Depends on D178298

Differential Revision: https://phabricator.services.mozilla.com/D178787
2023-06-28 08:43:43 +00:00
Yoshi Cheng-Hao Huang
53e105ef77 Bug 1803984 - Part 1: Don't use the preloaded module request if there's an import map. r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D178298
2023-06-28 08:43:42 +00:00
Jon Coppeard
abb473b383 Bug 1835886 - Cancel outstanding load requests when a document is detached from a global r=smaug
Also cancel module load requests when cancelling requests generally.

What was happening here was that a previous load was completing and calling
into the wrong module loader, because the loader to use is determined via the
current global, and this was now associated with a different document / script
loader / module loader.

Differential Revision: https://phabricator.services.mozilla.com/D179787
2023-06-13 08:46:26 +00:00
Narcis Beleuzu
93735c7b73 Backed out changeset 57b6e6158949 (bug 1835886) for bc failure on browser_protectionsUI_categories.js . CLOSED TREE 2023-06-06 14:14:11 +03:00
Jon Coppeard
9163fab639 Bug 1835886 - Cancel outstanding load requests when a document is detached from a global r=smaug
Also cancel module load requests when cancelling requests generally.

What was happening here was that a previous load was completing and calling
into the wrong module loader, because the loader to use is determined via the
current global, and this was now associated with a different document / script
loader / module loader.

Differential Revision: https://phabricator.services.mozilla.com/D179787
2023-06-06 08:38:42 +00:00
Cristina Horotan
0c2945ad47 Backed out 3 changesets (bug 1803984)
Backed out changeset d6316cfb118d (bug 1803984)
Backed out changeset bcbcbdf4f449 (bug 1803984)
Backed out changeset 3bc8c30ecc25 (bug 1803984)
2023-05-29 12:36:25 +03:00
Jon Coppeard
c4161d1f6c Bug 1803984 - Add assertion that we only remove unlinked modules from the map r=allstarschh
It would not be correct to remove modules that were already linked or evaluated.



Depends on D178298

Differential Revision: https://phabricator.services.mozilla.com/D178787
2023-05-26 12:22:54 +00:00
Yoshi Cheng-Hao Huang
b32c496142 Bug 1803984 - Don't use the preloaded module request if there's an import map. r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D178298
2023-05-26 12:22:54 +00:00
Yoshi Cheng-Hao Huang
a30459a36b Bug 1826110 - Add the module's URL into the error message. r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D178627
2023-05-22 15:30:16 +00:00
Yulia
2e8899ceb2 Bug 1822452 - Reject any remaining requests; r=jonco
This patch allows us to reject any outstanding requests when terminating a worker. As this is
controlled by the module loader, the approach I took here was to reject the promises and allow the
moduleloader to
shutdown. I am open to alternatives however.

Differential Revision: https://phabricator.services.mozilla.com/D173290
2023-03-23 09:54:49 +00:00
Yoshi Cheng-Hao Huang
19e0568f4d Bug 1820119 - import() should throw a TypeError in a worklet script. r=jonco,yulia
Differential Revision: https://phabricator.services.mozilla.com/D171563
2023-03-19 20:39:02 +00:00
Sandor Molnar
b1ca540f9f Backed out changeset d341f6827d75 (bug 1820119) for causing xpc failures in js/xpconnect/tests/unit/test_import_es6_modules.js CLOSED TREE 2023-03-16 19:18:45 +02:00
Yoshi Cheng-Hao Huang
d73f5a0402 Bug 1820119 - import() should throw a TypeError in a worklet script. r=jonco,yulia
Differential Revision: https://phabricator.services.mozilla.com/D171563
2023-03-16 14:27:48 +00:00
Yulia
99088fb36f Bug 1540913 - Part 3: Exit early if worker module evaluation is aborted; r=jonco
This change addresses the second issue around worker shutdown with infinitely running dynamic
imports: As the event loop is prevented from running when the worker is dying, we do not want to
delegate to the event loop in this case. This case always has a failing promise. Since this is a
failure case related to the worker dying, we stop running code, rather
than waiting for a tick (that never comes) from the event loop.

Differential Revision: https://phabricator.services.mozilla.com/D171684
2023-03-14 18:16:31 +00:00
Yulia
5231b910c8 Bug 1540913 - Part 2: Clear and shutdown ModuleLoader at worker termination; r=asuth,jonco
When running an infinitely-looping dynamic import, it is possible for the module loader to still be
holding on to that module at shutdown. Shutdown on the worker means that we will no longer run the
event loop, which will execute the dynamic import promises necessary to clear the global. The result
is that the global is kept alive. By calling `Shutdown()` we prevent this partially. We additionally
need to address the failure in the module code (next patch).

Differential Revision: https://phabricator.services.mozilla.com/D171683
2023-03-14 18:16:31 +00:00
Yulia
4e6402f008 Bug 1540913 - Part 1: allow ModuleLoaders to return BaseURI without ScriptLoader;r=jonco
This is a required change for dynamic import on workers, as the ScriptLoader is not guaranteed to
live long enough. Once the initial script loading is finished, and the script has executed, the
scriptloader is cleared and the strong reference to the workerRef is cleared so that shutdown is
possible. The workerRef is required in order to access the worker private safely. In order to
address this, we move the GetBaseURI method to the module loader itself. In the future, we should
remove the script loader interface all together.

Differential Revision: https://phabricator.services.mozilla.com/D171682
2023-03-14 18:16:30 +00:00
Yoshi Cheng-Hao Huang
c01828aba9 Bug 1572644 - Part 11-1: Add a virtual method GetResolveFailureMessage in ModuleLoaderBase. r=jonco,yulia
The virtual method will be overrided by WorkletModuleLoader in the next
patch.



Depends on D166548

Differential Revision: https://phabricator.services.mozilla.com/D166549
2023-03-13 22:59:41 +00:00
Yulia
2e680f55e9 Bug 1821066 - Ensure that module error is correctly set when ResolveRequestedModules fails; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D172243
2023-03-10 17:30:04 +00:00
Jon Coppeard
e205425545 Bug 1813494 - Part 2: Add IsErrored() predicate for module load request r=smaug
This condition is checked in a few places.

Differential Revision: https://phabricator.services.mozilla.com/D168232
2023-02-07 11:55:51 +00:00
Peter Van der Beken
1f731ae6fe Bug 1811238 - Correct QueryInterface implementation of LoadedScript and ModuleLoaderBase. r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D167252
2023-01-24 09:55:27 +00:00
Yulia Startsev
87c8288cb8 Bug 1247687 - Handle cancellation of long running modules; r=jonco
This is a slightly annoying thing that can happen. When we abruptly cancel (such as an infinitely
running script being forcibly terminated) we will be in a state where the EvaluateModule call will
finish _after_ the loader is destroyed. So, instead we track if there has been a forcible
cancelation, and exit early.

Depends on D155690

Differential Revision: https://phabricator.services.mozilla.com/D155568
2023-01-18 13:46:32 +00:00
Yulia Startsev
56c6f79308 Bug 1247687 - Implement InitModuleLoader methods for WorkerScriptLoader and WorkerGlobalScope; r=jonco
This implements a method to initialize the moduleLoader for workers. This will initialize only once, for all worker types (module and classic).

Depends on D147324

Differential Revision: https://phabricator.services.mozilla.com/D147326
2023-01-18 13:46:29 +00:00
Jonatan Klemets
402679a7ad Bug 1810366 - Remove unused requestedModule variable in ModuleLoaderBase::ResolveRequestedModules r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D166879
2023-01-16 20:17:30 +00:00
Norisz Fay
8cf029b070 Backed out 15 changesets (bug 1247687) as requested by dev CLOSED TREE
Backed out changeset 81d052cabf84 (bug 1247687)
Backed out changeset d698041e5174 (bug 1247687)
Backed out changeset 2adf67f910e8 (bug 1247687)
Backed out changeset 0bc871906e97 (bug 1247687)
Backed out changeset 1700d5b79273 (bug 1247687)
Backed out changeset 31888ffde37a (bug 1247687)
Backed out changeset 9153182c650d (bug 1247687)
Backed out changeset 45de9ffeec19 (bug 1247687)
Backed out changeset 59207e959b7c (bug 1247687)
Backed out changeset 49f18430c465 (bug 1247687)
Backed out changeset 0ae1fd421d4f (bug 1247687)
Backed out changeset 7770ec4717fd (bug 1247687)
Backed out changeset 68b476066248 (bug 1247687)
Backed out changeset c94a9dc60dff (bug 1247687)
Backed out changeset 0ab366c6eaaf (bug 1247687)
2022-12-21 10:48:15 +02:00
Yulia Startsev
ef3c7012f8 Bug 1247687 - Handle cancellation of long running modules; r=jonco
This is a slightly annoying thing that can happen. When we abruptly cancel (such as an infinitely
running script being forcibly terminated) we will be in a state where the EvaluateModule call will
finish _after_ the loader is destroyed. So, instead we track if there has been a forcible
cancelation, and exit early.

Depends on D155690

Differential Revision: https://phabricator.services.mozilla.com/D155568
2022-12-20 20:56:14 +00:00
Yulia Startsev
e859be10b8 Bug 1247687 - Implement InitModuleLoader methods for WorkerScriptLoader and WorkerGlobalScope; r=jonco
This implements a method to initialize the moduleLoader for workers. This will initialize only once, for all worker types (module and classic).

Depends on D147324

Differential Revision: https://phabricator.services.mozilla.com/D147326
2022-12-20 20:56:12 +00:00
Jon Coppeard
50c149f6dc Bug 1806136 - Part 0: Change the API so that the supported assertions are set once on initialization r=arai
Not related to the rest of the bug. This is a simplification so that we set the
supported import assertions once rather than querying the host every time they
are needed.

Differential Revision: https://phabricator.services.mozilla.com/D164914
2022-12-19 11:56:34 +00:00
Csoregi Natalia
c382c6a7ca Backed out 16 changesets (bug 1247687) for frequent string bundle related crashes with PDF viewer (bug 1806064). a=backout
Backed out changeset 721f612fd09f (bug 1247687)
Backed out changeset c6c5750cf713 (bug 1247687)
Backed out changeset 5d05ab0c7cde (bug 1247687)
Backed out changeset 2429599729cb (bug 1247687)
Backed out changeset 55f13fb4ee3f (bug 1247687)
Backed out changeset 354711cf113a (bug 1247687)
Backed out changeset 40b8abaf1c0b (bug 1247687)
Backed out changeset 0c9650a1ac48 (bug 1247687)
Backed out changeset e7b103c79b1a (bug 1247687)
Backed out changeset 4dbd510fb042 (bug 1247687)
Backed out changeset 9276c7e1ddd9 (bug 1247687)
Backed out changeset 6ee318df6641 (bug 1247687)
Backed out changeset 6c129bd72b61 (bug 1247687)
Backed out changeset 4b0a4fcc6894 (bug 1247687)
Backed out changeset 34680059b9f0 (bug 1247687)
Backed out changeset 85b827971a48 (bug 1247687)
2022-12-17 11:27:32 +02:00
Yulia Startsev
51d7d18a24 Bug 1247687 - Handle cancellation of long running modules; r=jonco
This is a slightly annoying thing that can happen. When we abruptly cancel (such as an infinitely
running script being forcibly terminated) we will be in a state where the EvaluateModule call will
finish _after_ the loader is destroyed. So, instead we track if there has been a forcible
cancelation, and exit early.

Depends on D155690

Differential Revision: https://phabricator.services.mozilla.com/D155568
2022-12-14 14:55:37 +00:00
Yulia Startsev
a40b702d6e Bug 1247687 - Implement InitModuleLoader methods for WorkerScriptLoader and WorkerGlobalScope; r=jonco
This implements a method to initialize the moduleLoader for workers. This will initialize only once, for all worker types (module and classic).

Depends on D147324

Differential Revision: https://phabricator.services.mozilla.com/D147326
2022-12-14 14:55:35 +00:00
Jon Coppeard
7856ea877c Bug 1804254 - Part 3: Replace RequestedModuleObject with native RequestedModule r=arai
This is more complicated because it needed a change to the public API now we're
not longer returning an array object. The new API is less error prone since
it's no longer possible for the caller to mutate the object returned.

Depends on D163948

Differential Revision: https://phabricator.services.mozilla.com/D163949
2022-12-07 11:28:28 +00:00
Jon Coppeard
f3248398d8 Bug 1774111 - Check for already-completed request in ModuleLoaderBase::FinishDynamicImport r=yulia
I've looked at this for a while and still don't know how this can happen but it
does seem reasonable to add a check here that we haven't already completed the
request.

Depends on D162386

Differential Revision: https://phabricator.services.mozilla.com/D162387
2022-11-18 13:25:47 +00:00
Jon Coppeard
71d7de8c4d Bug 1774111 - Initialize AutoJAPI from the native global in the module loader r=yulia
We're getting a bunch of crashes related to initializing AutoJSAPI from a
JSObject pointer that turns out to be null. That overload of Init() gets the
native global from the JSObject and since we already have a native global in
the module loader we can use the overload that takes that instead. This
overload does a null check so we will catch the case where the global is null
(although that should also not happen).

This might just move crashes elsewhere but it's a reasonable tidyup.

Differential Revision: https://phabricator.services.mozilla.com/D162386
2022-11-18 13:25:46 +00:00
Jon Coppeard
f64d585ec0 Bug 1797166 - Don't assume an exception is always set if module compilation fails r=yulia
It would be nice to assume this but CompileFetchedModule can potentially fail for reasons that
are not JS-related.

Also check for the exception being |undefined| which would cause
ModuleScript::HasParseError to return false. Such an exception should never be
thrown by parsing but check for it just in case.

Add a diagnostic assert to check module script state is as we expect to
hopefully catch related problems sooner.

Differential Revision: https://phabricator.services.mozilla.com/D160788
2022-10-31 14:26:48 +00:00
Jon Coppeard
a8344b1f34 Bug 1712762 - Check if module load requests have already been cancelled in ModuleLoaderBase::CancelDynamicImport r=yulia
I don't know whether this is the problem, but if we try and cancel a request
that has already been cancelled it would produce this crash.

Differential Revision: https://phabricator.services.mozilla.com/D159167
2022-10-12 16:26:20 +00:00