Closed Bug 1806136 Opened 2 years ago Closed 2 years ago

Create fewer ModuleRequestObjects


(Core :: JavaScript Engine, task, P3)




110 Branch
Tracking Status
firefox110 --- fixed


(Reporter: jonco, Assigned: jonco)




(4 files)

The way module metadata works at the moment is that we create a separate ModuleRequestObject per stencil StencilModuleEntry. Since there is an entry for every requested module and also one entry per import we will usually create about twice as many as needed. Import statements that import multiple names are worse because there is a separate entry per name.

We should try and share ModuleRequestObjects where possible.

I spent a while investigating turning ModuleRequestObject from a separate GC thing into a sub-object of RequestedModule/ImportEntry/etc. However ModuleRequestObject is used in the asynchronous dynamic module loading APIs however and the fact that we don't need to worry about it staying alive makes this easier to reason about.

The following patches do the simple thing and share a ModuleRequestObject between the RequestedModule/ImportEntry/ExportEntry data for a single JS import or export statement. The improvement from doing a full deduplication is likely marginal.

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.

For local exports there is no module specifier (and no assertions) present so
there's no need to create an object for them. The module request is never
accessed for local exports, except in test code.

Depends on D164914

This moves the module specifier and assertion information out of
StencilModuleEntry into a new StencilModuleRequest structure. These are
referred to by (optional) index into a vector of all requests for that mode. We
only create one request per statement.

Depends on D164915

Finally, this creates a vector of ModuleRequestObjects at the start of
StencilModuleMetadata::initModule so we can use the index from the stencil data
to get the right one.

Depends on D164916

Pushed by
Part 0: Change the API so that the supported assertions are set once on initialization r=arai
Part 1: Don't create ModuleObjectRequests when there's no specifier r=arai
Part 2: Factor out StencilModuleRequest from StencilModuleEntry r=arai
Part 3: Create one ModuleRequestObject per StencilModuleRequest r=arai
Regressions: 1811737
You need to log in before you can comment on or make changes to this bug.