This patch adds a module type parameter to
`ModuleLoaderBase::{CreateStaticImport,CreateDynamicImport},` and gets rid of a
bunch of hard-coded `JS::ModuleType::JavaScript.` However, the module type is
still hard-coded when we call `CreateDynamicImport` and `CreateStaticImport`.
Differential Revision: https://phabricator.services.mozilla.com/D218556
This patch is a small step towards the end goal, so we hardcoded the module
type to `JS::ModuleType::JavaScript`, but that will get changed in a later
patch.
Differential Revision: https://phabricator.services.mozilla.com/D218553
The module maps (`mFetchingModules` and `mFetchedModules`) in
`ModuleLoaderBase`, and `VisitedURLSet` were previously only keyed by the URL
and used the `nsURIHashKey` hashtable key class. This is no longer sufficient,
and the key should also contain the module type.
This patch introduces a new hashtable key class called `ModuleMapKey` and
changes `mFetchingModules`, `mFetchedModules`, and `VisitedURLSet` to use the
new key type.
To make this a bit easier to review, this first patch only introduces the new
key type and hard-codes the type to Javascript, where the key is constructed.
The hard-corded module types will be fixed in later patches.
Differential Revision: https://phabricator.services.mozilla.com/D155160
This patch adds a module type parameter to
`ModuleLoaderBase::{CreateStaticImport,CreateDynamicImport},` and gets rid of a
bunch of hard-coded `JS::ModuleType::JavaScript.` However, the module type is
still hard-coded when we call `CreateDynamicImport` and `CreateStaticImport`.
Differential Revision: https://phabricator.services.mozilla.com/D218556
This patch is a small step towards the end goal, so we hardcoded the module
type to `JS::ModuleType::JavaScript`, but that will get changed in a later
patch.
Differential Revision: https://phabricator.services.mozilla.com/D218553
The module maps (`mFetchingModules` and `mFetchedModules`) in
`ModuleLoaderBase`, and `VisitedURLSet` were previously only keyed by the URL
and used the `nsURIHashKey` hashtable key class. This is no longer sufficient,
and the key should also contain the module type.
This patch introduces a new hashtable key class called `ModuleMapKey` and
changes `mFetchingModules`, `mFetchedModules`, and `VisitedURLSet` to use the
new key type.
To make this a bit easier to review, this first patch only introduces the new
key type and hard-codes the type to Javascript, where the key is constructed.
The hard-corded module types will be fixed in later patches.
Differential Revision: https://phabricator.services.mozilla.com/D155160
In the following module graph:
0.html
+---- 1.mjs
+---- non_existing.mjs
+---- 3.mjs
+----- 2.mjs
+---- 3.mjs
Both 1.mjs and 2.mjs have a common submodule called 3.mjs
But 1.mjs also has a non-existing submodule, so we can't instantiate the
module graph of 1.mjs. which in turn will cancel 3.mjs
But 3.mjs is also a sub-module of 2.mjs, so in order to instantiate the
module graph of 2.mjs, we skip canceling 3.mjs when we processed 1.mjs
Differential Revision: https://phabricator.services.mozilla.com/D209210
Dynamic import is prevented by IsDynamicImportSupported, and now it now throws
TypeError instead of Error, and related wpt passes with it.
Differential Revision: https://phabricator.services.mozilla.com/D202494
Currently we record the URI of each fetching modules and any addtional requests
that are blocked waiting on that fetch. This adds the fetching module request
itself.
This is needed by the next patch.
Differential Revision: https://phabricator.services.mozilla.com/D204201
Currently we record the URI of each fetching modules and any addtional requests
that are blocked waiting on that fetch. This adds the fetching module request
itself.
This is needed by the next patch.
Differential Revision: https://phabricator.services.mozilla.com/D204201
Currently we record the URI of each fetching modules and any addtional requests
that are blocked waiting on that fetch. This adds the fetching module request
itself.
This is needed by the next patch.
Differential Revision: https://phabricator.services.mozilla.com/D204201
On the main thread, single mozJSModuleLoader instance is shared across all
loads in non-shared global, with resetting the internal state after importing
a module graph.
NonSharedGlobalSyncModuleLoaderScope manages the lifetime of each usage.
Import into the same non-shared global can be nested, but import into the
different non-shared gloobal is not allowed while other import for non-shared
global is ongoing.
Differential Revision: https://phabricator.services.mozilla.com/D199456
In non-shared global, the sync load is performed by separate SyncModuleLoader,
with the following algorithm:
1. copy all loaded modules from async module loader, so that they can be
used in the module graph in SyncModuleLoader
2. import a module graph
3. move all modules to async module loader
ModuleLoaderBase::CopyModulesTo is for step 1, and
ModuleLoaderBase::MoveModulesTo is for step 3.
The consumer should assert that there's no fetching modules.
Differential Revision: https://phabricator.services.mozilla.com/D199455
In order to perform sync load in arbitrary global, add
ModuleLoaderBase::mOverriddenBy field, and let
ModuleLoaderBase::GetCurrentModuleLoader return the overridden loader,
so that the module loading can be overridden by SyncModuleLoader.
AutoOverrideModuleLoader manages the lifetime of the override.
Differential Revision: https://phabricator.services.mozilla.com/D199454
On the main thread, single mozJSModuleLoader instance is shared across all
loads in non-shared global, with resetting the internal state after importing
a module graph.
NonSharedGlobalSyncModuleLoaderScope manages the lifetime of each usage.
Import into the same non-shared global can be nested, but import into the
different non-shared gloobal is not allowed while other import for non-shared
global is ongoing.
Differential Revision: https://phabricator.services.mozilla.com/D199456
In non-shared global, the sync load is performed by separate SyncModuleLoader,
with the following algorithm:
1. copy all loaded modules from async module loader, so that they can be
used in the module graph in SyncModuleLoader
2. import a module graph
3. move all modules to async module loader
ModuleLoaderBase::CopyModulesTo is for step 1, and
ModuleLoaderBase::MoveModulesTo is for step 3.
The consumer should assert that there's no fetching modules.
Differential Revision: https://phabricator.services.mozilla.com/D199455
In order to perform sync load in arbitrary global, add
ModuleLoaderBase::mOverriddenBy field, and let
ModuleLoaderBase::GetCurrentModuleLoader return the overridden loader,
so that the module loading can be overridden by SyncModuleLoader.
AutoOverrideModuleLoader manages the lifetime of the override.
Differential Revision: https://phabricator.services.mozilla.com/D199454
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
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
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
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
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
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
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
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
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
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