Commit graph

143 commits

Author SHA1 Message Date
Jon Coppeard
f9febfda89 Bug 1871075 - Part 1: Store referencing private as a pointer to the underlying LoadedScript r=yulia
In Gecko we use a LoadedScript pointer as the referencing private for dynamic
imports. This is passed through the JS engine as a private value, which doesn't
care what it means. Currently we store this in the module loader as a JS::Value,
but we could just as well unpack it since we know what it is. That lets use a
RefPtr which also keeps it alive and will let use remove some manual reference
counting.

We also don't need to pass it to the CreateDynamicImport method twice.

This change makes it the responsibility of the module loader for keeping the
referencing private alive until FinishDynamicModuleImport is called.

Differential Revision: https://phabricator.services.mozilla.com/D196974
2023-12-21 13:30:34 +00:00
Jon Coppeard
9ec5953695 Bug 1865410 - Part 2: Removed unused module APIs following previous patch r=allstarschh
Differential Revision: https://phabricator.services.mozilla.com/D194767
2023-12-02 08:49:59 +00:00
Tooru Fujisawa
e1306f14b6 Bug 1861309 - Part 1: Use 1-origin column number in JS::GetRequestedModuleSourcePos and ModuleLoaderBase::HandleResolveFailure. r=jonco
Depends on D192781

Differential Revision: https://phabricator.services.mozilla.com/D192782
2023-11-08 02:01:37 +00:00
Yoshi Cheng-Hao Huang
cd69bc3c65 Bug 1841859 - Part 1: Move ReferrerPolicy to ScriptLoadRequest and LoadedScript. r=jonco,smaug
Suggested by jonco during review,
https://phabricator.services.mozilla.com/D186944#inline-1036982

Differential Revision: https://phabricator.services.mozilla.com/D187385
2023-09-20 17:32:15 +00:00
Tooru Fujisawa
ce72fea4a7 Bug 1846194 - Remove off-thread compilation and decode API. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D185125
2023-09-01 03:43:21 +00:00
Tooru Fujisawa
70c40a1658 Bug 1845638 - Part 1: Use JS::FrontendContext APIs and TaskController in compilation and decode in ScriptLoader. r=smaug,bthrall
Differential Revision: https://phabricator.services.mozilla.com/D184896
2023-08-29 12:07:18 +00:00
Tooru Fujisawa
b23c224e33 Bug 1847469 - Part 20: Use column number types in JSErrorBase. r=iain
Differential Revision: https://phabricator.services.mozilla.com/D185758
2023-08-16 17:31:40 +00:00
Tooru Fujisawa
41cb19fe2a Bug 1847469 - Part 6: Use column number types in Module API. r=iain
Differential Revision: https://phabricator.services.mozilla.com/D185744
2023-08-16 17:31:37 +00:00
Cristian Tuns
4fe9ed8f30 Backed out 27 changesets (bug 1847469) for causing spidermonkey bustages in Script.cpp CLOSED TREE
Backed out changeset 9d6e2651a013 (bug 1847469)
Backed out changeset 9b72d668efd2 (bug 1847469)
Backed out changeset 86abf5cf0a22 (bug 1847469)
Backed out changeset 46833087f8ac (bug 1847469)
Backed out changeset f3e2207fdeec (bug 1847469)
Backed out changeset aed75776cfff (bug 1847469)
Backed out changeset 8292a38bd99f (bug 1847469)
Backed out changeset 1320f83fb8c7 (bug 1847469)
Backed out changeset df9f925f9837 (bug 1847469)
Backed out changeset 69f32cf1862a (bug 1847469)
Backed out changeset b2ddddec8818 (bug 1847469)
Backed out changeset 056eed7abc97 (bug 1847469)
Backed out changeset 5df4f43ac0bf (bug 1847469)
Backed out changeset cb57923f6532 (bug 1847469)
Backed out changeset a0993f2a2195 (bug 1847469)
Backed out changeset 782499fbedf2 (bug 1847469)
Backed out changeset cf84fb98c5e1 (bug 1847469)
Backed out changeset 1fa5ab59814b (bug 1847469)
Backed out changeset f5f78944df81 (bug 1847469)
Backed out changeset aa14337bf5c6 (bug 1847469)
Backed out changeset 6757db4575d7 (bug 1847469)
Backed out changeset 236ff135701e (bug 1847469)
Backed out changeset 9b4d5b435020 (bug 1847469)
Backed out changeset a0f789621bc8 (bug 1847469)
Backed out changeset c19b81f48055 (bug 1847469)
Backed out changeset b4521e546d7e (bug 1847469)
Backed out changeset f26a10289316 (bug 1847469)
2023-08-16 07:08:01 -04:00
Tooru Fujisawa
ee81f946a2 Bug 1847469 - Part 20: Use column number types in JSErrorBase. r=iain
Differential Revision: https://phabricator.services.mozilla.com/D185758
2023-08-16 10:26:32 +00:00
Tooru Fujisawa
475220dbaa Bug 1847469 - Part 6: Use column number types in Module API. r=iain
Differential Revision: https://phabricator.services.mozilla.com/D185744
2023-08-16 10:26:28 +00:00
Tooru Fujisawa
441e14104a Bug 1846913 - Part 1: Use 1-origin column number for compile errors, compile wanring, and error notes. r=iain,devtools-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D185370
2023-08-11 08:11:48 +00:00
Jon Coppeard
970aa448a4 Bug 1847813 - Process loaded modules asynchronously in DOM module loader r=smaug
Based on the explanation on the bug, the solution would seem to be to call the
ModuleLoaderBase::OnModuleLoadComplete hook from a microtask. This causes a ton
of test failures.

Instead this patch changes the DOM script loader to implement this hook with a
runnable. This fixes the problem (verified manually) and all tests pass.

(Replacing the runnable with a microtask just in the DOM script loader also
does not work and results in many test failures. I'm still trying to understand
why.)

The changes to ContinueDynamicImport are removed because they are also on this
path and we don't need a microtask as well.

This takes us closer to the state before bug 1842798 landed when all the module
loader used MozPromise internally and completions like this happened via
runnables.

I was not able to immediately come up with a test for this.

Differential Revision: https://phabricator.services.mozilla.com/D185830
2023-08-09 22:49:46 +00:00
Jon Coppeard
80cac6bbb5 Bug 1843838 - Rename ScriptLoadRequest::IsReadyToRun to IsFinished since this returns true for cancelled requests r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D183740
2023-08-04 09:40:40 +00:00
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