There are shared path between "save bytecode" vs "cache stencil".
This patch just renames everything, and the subsequent bugs and patches will
split the flag and methods.
Differential Revision: https://phabricator.services.mozilla.com/D260911
This already takes the referrer script. We can use the referrer script to keep
its private value alive in DynamicImportContextObject which is much simpler.
Differential Revision: https://phabricator.services.mozilla.com/D260943
Previously we passed the module object for modules and nullptr for other cases.
This patch makes it so we pass the script for both module and classic script
referrers, and nullptr for the realm case.
Differential Revision: https://phabricator.services.mozilla.com/D260942
Per the spec we should pass this to the module load hook. This means we can
remove JS::GetLoadingModuleHostDefinedValue.
Differential Revision: https://phabricator.services.mozilla.com/D260673
This makes it the responsibility of the JS engine to deal with failure if the
module load hook fails. It's more convenient for the embedding to have this
handled for you.
Differential Revision: https://phabricator.services.mozilla.com/D260670
This makes it so FinishLoadingImportedModuleFailedWithPendingException gets the
current exception and calls FinishLoadingImportedModuleFailed.
Differential Revision: https://phabricator.services.mozilla.com/D259612
We use ScopeExit here to ensure we call FinishLoadingImportedModuleFailed on
error. However sometimes we call this directly and then exit without releasing
the guard and so call it again.
The patch cleans this up and makes the guard report the pending exception if
set but still report an exception otherwise. (In future we might think about
insisting that an exception is set if we leave early.)
Differential Revision: https://phabricator.services.mozilla.com/D259611
Similar to the previous patch, this makes the FinishLoadingImportedModuleFailed and
FinishLoadingImportedModuleFailedWithPendingException APIs take a single
payload argument.
Differential Revision: https://phabricator.services.mozilla.com/D259610
This merges the two versions of FinishLoadingImportedModule so there's a single
API that takes a payload rather than separate ones for promise/statePrivate.
Differential Revision: https://phabricator.services.mozilla.com/D259609
We usually use function pointers for callbacks into the JS engine.
These are simpler to deal with and also std::function can alocate memory in
some situations which is undesirable.
The patch converts these to function pointers and also refactors
ModuleLoaderBase.cpp where these are defined for the main module loader.
Differential Revision: https://phabricator.services.mozilla.com/D259606
This reverts commit 3e05c64268.
Revert "Bug 1980126 - Part 12: Tidy error handling in StartDynamicModuleImport r=allstarschh"
This reverts commit 8a67a2ece6.
Revert "Bug 1980126 - Part 11: Remove unused data from dynamic import context r=allstarschh"
This reverts commit e9878305e6.
Revert "Bug 1980126 - Part 10: Pass a single payload argument to HostLoadImportedModule callback r=allstarschh"
This reverts commit d90f9d6674.
Revert "Bug 1980126 - Part 9: Update test expectations r=allstarschh"
This reverts commit eee20ec5f4.
Revert "Bug 1980126 - Part 8: Add missing steps for FinishLoadingImportedModule for dynamic import r=allstarschh"
This reverts commit a904cdf9b8.
Revert "Bug 1980126 - Part 7: Combine internal FinishLoadingImportedModule failure paths r=allstarschh"
This reverts commit 1a80705381.
Revert "Bug 1980126 - Part 6: Refactor error handling in module load hook implementation r=allstarschh"
This reverts commit 47cd46fb6b.
Revert "Bug 1980126 - Part 5: Unify JS::FinishLoadingImportedModuleFailed APIs r=allstarschh"
This reverts commit dff70a55ad.
Revert "Bug 1980126 - Part 4: Unify JS::FinishLoadingImportedModule API r=allstarschh"
This reverts commit 8de76d7f72.
Revert "Bug 1980126 - Part 3: Move dynamic module code to vm/Modules.cpp from builtin/ModuleObject.cpp r=allstarschh"
This reverts commit e7d409880f.
Revert "Bug 1980126 - Part 2: Make GraphLoadingStateRecordObject background finalized and refactor r=allstarschh"
This reverts commit bec492ffcd.
Revert "Bug 1980126 - Part 1: Make LoadModuleResolved/RejectedCallbacks into function pointers r=allstarschh"
This reverts commit 20ca6df255.
This makes it so FinishLoadingImportedModuleFailedWithPendingException gets the
current exception and calls FinishLoadingImportedModuleFailed.
Differential Revision: https://phabricator.services.mozilla.com/D259612
We use ScopeExit here to ensure we call FinishLoadingImportedModuleFailed on
error. However sometimes we call this directly and then exit without releasing
the guard and so call it again.
The patch cleans this up and makes the guard report the pending exception if
set but still report an exception otherwise. (In future we might think about
insisting that an exception is set if we leave early.)
Differential Revision: https://phabricator.services.mozilla.com/D259611
Similar to the previous patch, this makes the FinishLoadingImportedModuleFailed and
FinishLoadingImportedModuleFailedWithPendingException APIs take a single
payload argument.
Differential Revision: https://phabricator.services.mozilla.com/D259610
This merges the two versions of FinishLoadingImportedModule so there's a single
API that takes a payload rather than separate ones for promise/statePrivate.
Differential Revision: https://phabricator.services.mozilla.com/D259609
We usually use function pointers for callbacks into the JS engine.
These are simpler to deal with and also std::function can alocate memory in
some situations which is undesirable.
The patch converts these to function pointers and also refactors
ModuleLoaderBase.cpp where these are defined for the main module loader.
Differential Revision: https://phabricator.services.mozilla.com/D259606
In mochitest-browser tests, it's possible for the about:neterror page to
load. This triggers aboutNetError.html, which in turn loads
aboutNetError.mjs, eventually importing pkijs.js. The pkijs.js module is
compiled off-thread.
However, when the test framework proceeds to the next test, the
associated document may be detached before the off-thread compilation of
pkijs.js completes. If this happens while TaskController is shutting
down, the compilation task may never finish.
Currently, ScriptLoader only tracks top-level off-thread compilation
requests, not submodules involved in those tasks. To address this, we
now call CancelFetchingModules when ScriptLoader cancels ongoing
requests, ensuring submodule fetches are also properly aborted.
Differential Revision: https://phabricator.services.mozilla.com/D257677
Since the module graph is now traversed within the JS engine itself, the
related data structures in the host layer are no longer necessary.
Differential Revision: https://phabricator.services.mozilla.com/D255129
When there's a ParseError, the error should be dispatched asynchronously.
However, workers can't handle the micro task, therefore we still call
ModuleErrored synchronously.
WPT test: /html/semantics/scripting-1/the-script-element/module/inline-async-inserted-execorder.html
Differential Revision: https://phabricator.services.mozilla.com/D255128
- Move UpdateReferrerPolicy from ScriptLoadRequest to ModuleLoadRequest,
as this can only happend for a module load.
- Add UpdateReferrerPolicy method to ModuleScript.
Introduces a new UpdateReferrerPolicy method for ModuleScript,
allowing the referrer policy to be updated based on the associated
ModuleLoadRequest.
Differential Revision: https://phabricator.services.mozilla.com/D255127
In mochitest-browser tests, it's possible for the about:neterror page to
load. This triggers aboutNetError.html, which in turn loads aboutNetError.mjs.
(The same situation also happens in devtools test when loading
json-viewer.mjs)
Occasionally, the load promise from LoadRequestedModules is never resolved
because the PromiseJobRunnable is not executed if the global is in the process
of shutting down.
To avoid this issue, we now use the synchronous version of
LoadRequestedModules when loading chrome resources.
Differential Revision: https://phabricator.services.mozilla.com/D257676
In mochitest-browser tests, it's possible for the about:neterror page to
load. This triggers aboutNetError.html, which in turn loads
aboutNetError.mjs, eventually importing pkijs.js. The pkijs.js module is
compiled off-thread.
However, when the test framework proceeds to the next test, the
associated document may be detached before the off-thread compilation of
pkijs.js completes. If this happens while TaskController is shutting
down, the compilation task may never finish.
Currently, ScriptLoader only tracks top-level off-thread compilation
requests, not submodules involved in those tasks. To address this, we
now call CancelFetchingModules when ScriptLoader cancels ongoing
requests, ensuring submodule fetches are also properly aborted.
Differential Revision: https://phabricator.services.mozilla.com/D257677
Since the module graph is now traversed within the JS engine itself, the
related data structures in the host layer are no longer necessary.
Differential Revision: https://phabricator.services.mozilla.com/D255129
When there's a ParseError, the error should be dispatched asynchronously.
However, workers can't handle the micro task, therefore we still call
ModuleErrored synchronously.
WPT test: /html/semantics/scripting-1/the-script-element/module/inline-async-inserted-execorder.html
Differential Revision: https://phabricator.services.mozilla.com/D255128