Add a wrapper to Cu.import return value that supports lexical variables
Categories
(Core :: XPConnect, task)
Tracking
()
Tracking | Status | |
---|---|---|
firefox102 | --- | fixed |
People
(Reporter: arai, Assigned: arai)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
(deleted),
text/x-phabricator-request
|
Details |
During ESM-ification, existing functions needs to keep working, to avoid breaking not-in-tree code.
This includes the return value of Cu.import
, that's the per-JSM global.
This can break for 2 reasons:
- if any global binding inside JSM is converted from
var
/function
to lexical (let
,const
,class
), it disappears from per-JSM global property (bug 1610653) - once ESM-ified there's no global object that has global bindings as properties
Possible options:
- (a) Return
exports
object instead - (b) Return a proxy for both
exports
object and per-JSM global
(a) is simpler, but if there's not-in-tree code that retrieves not-exported symbols from the Cu.import
return value, it breaks.
Bug 1609271 has context what kind of breakage happens and what change was needed.
(b) is more backward-compatible, but it's not guaranteed to work once ESM-ified.
Assignee | ||
Comment 1•3 years ago
|
||
Investigated the proxy way.
The global variables, especially var
, can be optimized away (to LOCAL slot) and in that case it's not accessible from ModuleEnvironmentObject
.
Possible workaround is to force de-optimize the top-level variables during compiling the ESM.
Assignee | ||
Comment 2•3 years ago
|
||
Checked Privileged Firefox extensions, and also Thunderbird/SeaMonkey extensions that's compatible with recent versions, and I don't see any case that not-exported symbols are extracted from the Cu.import
return value.
So this isn't a problem for extensions.
Remaining case is AutoConfig.
Assignee | ||
Comment 3•3 years ago
|
||
for ESM-ified case, the patch in bug 1766761 solves (including the LOCAL slot issue above).
for not-ESM-ified case, we might need yet another proxy.
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Comment 4•3 years ago
|
||
Depends on D145784
Assignee | ||
Comment 5•3 years ago
|
||
Mildly depends on bug 1766761, to share the test code.
the implementation itself doesn't have dependency.
Updated•2 years ago
|
Comment 7•2 years ago
|
||
Backed out for causing spidermonkey failures on Modules.cpp
- Backout link
- Push with failures
- Failure Log
- Failure line: /builds/worker/checkouts/gecko/js/src/vm/Modules.cpp:237:10: error: cannot initialize return object of type 'JSObject *' with an rvalue of type 'js::ModuleEnvironmentObject *'
Assignee | ||
Updated•2 years ago
|
Comment 9•2 years ago
|
||
bugherder |
Description
•