Closed Bug 1693590 Opened 4 years ago Closed 4 years ago

Use a weak map to store the DebugScript associated with a JSScript

Categories

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

task

Tracking

()

RESOLVED FIXED
88 Branch
Tracking Status
firefox88 --- fixed

People

(Reporter: jonco, Assigned: jonco)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Currently DebugScripts are problematic for concurrent marking because to trace the DebugScript associated with a JSScript it must be looked up in a hash table that can also be modified by the main thread.

Instead we could store these in a weak map, using the existing WeakMap class. This would move marking of DebugScripts to the weak marking part of collection. This would require wrapping each DebugScript in a JSObject as WeakMap doesn't support non-GC thing values.

This changes Zone::debugScriptMap to be a WeakMap rather than having its entries marked from BaseScript::traceChildren.

This simplifies script marking and removes some code from Zone.cpp. Unfortunately it does also adds a couple of complications:

  1. We need to wrap DebugScript in a JSObject so we can use it as a WeakMap value. That leads to:

  2. We need to do a bunch of extra rooting whenever we might create a DebugScript.

I tried making WeakMaps allow non-GC thing values but that also got complicated as marking relies on comparing the mark state of the key to that of the value (and the map) and this would require tracing the value and then combining the mark state of child pointers.

(In reply to Jon Coppeard (:jonco) from comment #1)

I tried making WeakMaps allow non-GC thing values but that also got complicated as marking relies on comparing the mark state of the key to that of the value (and the map) and this would require tracing the value and then combining the mark state of child pointers.

Huh. Isn't this just a matter of iterating over the breakpoints and or-ing their scripts' mark bits? Well, I guess if the code was gnarly, that's all there is to it.

Pushed by jcoppeard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/34803577fc5d Use a WeakMap to store DebugScripts associated with a JSScript r=sfink,jimb
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 88 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: