Closed Bug 1880464 Opened 1 year ago Closed 1 year ago

Modules sometimes don't have filenames

Categories

(Core :: JavaScript Engine, task)

task

Tracking

()

RESOLVED FIXED
125 Branch
Tracking Status
firefox125 --- fixed

People

(Reporter: jonco, Assigned: jonco)

References

Details

Attachments

(1 file)

It would be helpful for error reporting if we could assume that all modules have a filename.

The filename comes from the script source associated with the script source object associated with the module's script. This is usually set from the CompileOptions supplied when compiling the script.

Adding an assert in ModuleObject::initScriptSlots shows that the filename is not always present.

The above patch sets a default filename in the compile options in a couple of places in the shell where we create modules and then asserts that a filename is present during module initialisation.

This passes browser module tests but fails some shell tests:

    parser/compile-script.js
    parser/stencil-laziness-validate.js
    xdr/module-exports.js
    xdr/module-imports.js
    xdr/module-oom.js
    xdr/module.js

Looking at the parser/compile-script.js failure it seems that InstantiateModuleStencil has input containing the filename but this is not transferred to the module created by CompilationStencil::instantiateStencils.

arai would you know what's going on here?

Flags: needinfo?(arai.unmht)

The filename is set during compilation.

The JS::CompileOptions created inside InstantiateModuleStencil is used as JS::InstantiateOptions, which is very small subset of JS::CompileOptions.

If module needs filename, it should be set while compilation:

OffThreadCompileModuleToStencil already sets the filename, so this doesn't need fix I think.

Flags: needinfo?(arai.unmht)
Blocks: 1872671
No longer blocks: 1872671
Blocks: 1873610
Assignee: nobody → jcoppeard
Attachment #9380399 - Attachment description: WIP: Bug 1880464 - Ensure that all modules have a filename → Bug 1880464 - Ensure that all modules have a filename r?arai
Status: NEW → ASSIGNED
Pushed by jcoppeard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/213e2c05e438 Ensure that all modules have a filename r=arai
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 125 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: