Closed Bug 1941472 Opened 1 year ago Closed 1 year ago

Stop setting JS::TransitiveCompileOptions.deoptimizeModuleGlobalVars

Categories

(Core :: XPConnect, task, P3)

task

Tracking

()

RESOLVED FIXED
138 Branch
Tracking Status
firefox138 --- fixed

People

(Reporter: arai, Assigned: arai)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

Split out from bug 1881888.

deoptimizeModuleGlobalVars was added for backward compatibility layer in the system module loader, to keep the global variable behavior match to the JSM.
Given the JSM loader and the JSM to ESM shim are going to be removed, this option is no longer necessary, but this adds another behavior difference due to XPCOM and some privileged API that allows getting strong ref from weak ref,
given that in the standard ECMAScript modules, non-exported module globals no longer have the same lifetime as the module itself.
Some system module code expects the globals to have the same lifetime as the module itself, and they use weak reference to those values to simplify the cleanup (e.g. addObserver without removeObserver).

Currently the following usage looks affected:

  • nsIObserverService::addObserver with ownsWeak=true, and wrappers around it
  • any other things takes nsISupportsWeakReference
  • ChromeUtils.nondeterministicGetWeakMapKeys

The problematic behaviors are the following:

  • get strong ref from weak ref
  • iterate over weak-ref-ed objects

Given the above, flipping the option can break some code (e.g. bug 1940741 ), and this need to be done carefully.

Depends on: 1941481
No longer depends on: 1941481
See Also: → 1941481
Severity: -- → N/A
Priority: -- → P3
Depends on: 1941772
Pushed by arai_a@mac.com: https://hg.mozilla.org/integration/autoland/rev/90f5357eb239 Stop setting JS::TransitiveCompileOptions.deoptimizeModuleGlobalVars. r=jonco
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 137 Branch
Regressions: 1946592

Backed out as requested by arai for causing Bug 1946592.

Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: 137 Branch → ---
Attachment #9464540 - Attachment is obsolete: true

There was misunderstanding about the effect of deoptimizeModuleGlobalVars.
Module's varScope contains all top-level variables, including lexial variables, such as let, const, and class,
and iterating over modulepc.varScope().bindings(pc_) results in handling all of them.

We should audit all top-level variables, not only vars.

Depends on: 1946792
Pushed by arai_a@mac.com: https://hg.mozilla.org/integration/autoland/rev/352cc7cae254 Stop setting JS::TransitiveCompileOptions.deoptimizeModuleGlobalVars. r=jonco
Status: REOPENED → RESOLVED
Closed: 1 year ago → 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 138 Branch
Flags: needinfo?(arai.unmht)
Depends on: 1952714
Pushed by arai_a@mac.com: https://hg.mozilla.org/integration/autoland/rev/4f1ca8a80220 Stop setting JS::TransitiveCompileOptions.deoptimizeModuleGlobalVars. r=jonco
Status: REOPENED → RESOLVED
Closed: 1 year ago → 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 138 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: