Closed Bug 1984091 Opened 1 year ago Closed 1 year ago

WeakRefs and FinalizationRegistries use CCWs that don't work with symbol targets

Categories

(Core :: JavaScript: GC, task, P3)

task

Tracking

()

RESOLVED FIXED
144 Branch
Tracking Status
firefox144 --- fixed

People

(Reporter: jonco, Assigned: jonco)

References

Details

Attachments

(3 external files)

Currently our implementation for these wraps the WeakRef/FinalizationRegistry object into the target zone. That doesn't work for symbol targets as the target zone is the atoms zone and we don't support allocating CCWs (or any object) in the atoms zone.

Severity: -- → N/A
Priority: -- → P3

Elements are added to these list on the main thread and removed by foreground
finalizers (also main thread). The elements will be WeakRefObjects and
FinalizationRecordObjcts (referred to as finalization observers).

Using this list removes the need to use cross compartment wrappers to refer to
these observers which is a problem because we can't create wrappers in the
atoms zone, where symbol targets live.

It also removes the need to have observers and targets in the same sweep group
which makes incremental sweeping less effective.

Finally it removes the overhead of allocating these extra wrapper objects.

This removes wrapper creation, updating the cross-zone wrapper map for weak
refs and handling nuking of the wrappers.

One effect of this change is to make this test code throw an exception when it
didn't before. I think what's happening is that nuking CCWs previously stopped
the finalization registry from calling the cleanup callback, whereas now this
happens and an exception is correctly thrown. This doesn't have any effect on
the original purpose of the testcase which was to trigger an over-eager
assertion, or correctness of the finalization regisry implementation.

Can you send an Intent to Ship?

Flags: needinfo?(jcoppeard)

This bug is preparatory work. The actual change is in bug 1863140, and will be preffed off to start with. But thanks for reminding me, I will send an intent to ship before turning this on.

Flags: needinfo?(jcoppeard)
Blocks: 1986862
Regressions: CVE-2026-2795
Regressions: 2031152
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: