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
This commit is contained in:
Jon Coppeard
2023-12-21 13:30:34 +00:00
parent 7ac6d1def4
commit 9c329cdb6e
13 changed files with 27 additions and 29 deletions

View File

@@ -304,8 +304,7 @@ already_AddRefed<ModuleLoadRequest> ModuleLoader::CreateStaticImport(
already_AddRefed<ModuleLoadRequest> ModuleLoader::CreateDynamicImport(
JSContext* aCx, nsIURI* aURI, LoadedScript* aMaybeActiveScript,
JS::Handle<JS::Value> aReferencingPrivate, JS::Handle<JSString*> aSpecifier,
JS::Handle<JSObject*> aPromise) {
JS::Handle<JSString*> aSpecifier, JS::Handle<JSObject*> aPromise) {
MOZ_ASSERT(aSpecifier);
MOZ_ASSERT(aPromise);
@@ -357,7 +356,7 @@ already_AddRefed<ModuleLoadRequest> ModuleLoader::CreateDynamicImport(
/* is top level */ true, /* is dynamic import */
this, ModuleLoadRequest::NewVisitedSetForTopLevelImport(aURI), nullptr);
request->mDynamicReferencingPrivate = aReferencingPrivate;
request->mDynamicReferencingScript = aMaybeActiveScript;
request->mDynamicSpecifier = aSpecifier;
request->mDynamicPromise = aPromise;