Closed Bug 2044578 Opened 5 months ago Closed 5 months ago

Make GC barrier wrappers atomic under concurrent marking

Categories

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

task

Tracking

()

RESOLVED FIXED
153 Branch
Tracking Status
firefox153 --- fixed

People

(Reporter: jonco, Assigned: jonco)

References

(Blocks 1 open bug, Regressed 1 open bug)

Details

Attachments

(7 external files)

Most heap accesses in the VM go through GC barrier wrappers such as GCPtr. For data touched by concurrent making we need to ensure that main thread writes and marking thread reads are atomic. Therefore we can change barriers to:

  • add atomic getters and setters
  • make setters atomic by default in concurrent marking builds
  • make the generic marking path use atomic getters (in this bug)
  • make the marking fast path use atomic getters (will be handled in a later bug)

This only applies to data traced by core GC types (not object trace hooks). The cut point chosen is that HeapPtr is out and GCPtr, HeapSlot, GCBuffer and GCStruct are in.

This adds the AtomicMethods template to write up atomic accessors for the
various barriered types and adds BarrierOption_AtomicWrites to have
BarrieredPtrImpl make writes atomic.

We're going to make GCPtr use atomic writes in concurrent marking builds but
that's a problem for wasm::Val because it's larger than 64 bits and so can't
support support atomic operations. Instead work around this by using HeapPtr
which will not be affected.

This does mean there will be an extra write barrier triggered on destruction of
WasmGlobalObject for the mutable value, but this shouldn't be a big cost. This
makes the barrier requirements slightly more broad and we need to allow setting
the value to invalid during destruction.

We don't just need atomic accesses to GC edges but also supplemenatal data used
in tracing (e.g. flags, element counts and the like) that may be touched by
both the main thread and the marking thread.

This adds GCData (like GCPtr) for this kind of data.

This uses the new GCData to wrap non-pointer data that may be accessed by both
the main thread and the marking thread during concurrent marking.

This includes object flags and object slots and elements pointers, which are
not GC edges themselves since they are internal pointers.

This makes the generic path use atomic loads to read edge pointers. Updates the
the marking fast path will be in a later bug.

Pushed by jcoppeard@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/657c8d6c241f https://hg.mozilla.org/integration/autoland/rev/fe39db3352d9 Part 1: Add atomic accessor methods to tagged pointers types r=jandem https://github.com/mozilla-firefox/firefox/commit/3841c31b34f3 https://hg.mozilla.org/integration/autoland/rev/6085b3379a19 Part 2: Add atomic write option to barriered pointers r=sfink https://github.com/mozilla-firefox/firefox/commit/adfac6dea1cb https://hg.mozilla.org/integration/autoland/rev/7e0f6a1dc16b Part 3: Make wasm instance mutable value use HeapPtr rather than GCPtr r=rhunt https://github.com/mozilla-firefox/firefox/commit/f5a76d1396ff https://hg.mozilla.org/integration/autoland/rev/2f742b129a2b Part 4: Make writes to GCPtrs, GCBuffers and HeapSlots atomic in concurrent marking builds r=sfink https://github.com/mozilla-firefox/firefox/commit/6a70c1df993f https://hg.mozilla.org/integration/autoland/rev/bddac9ba98eb Part 5: Add GCData wrapper for non-GC-pointer data that may need atomic operations r=sfink https://github.com/mozilla-firefox/firefox/commit/661286333bed https://hg.mozilla.org/integration/autoland/rev/1aa2c53c3cdc Part 6: Use GCData for non-GC pointers touched by marking r=jandem https://github.com/mozilla-firefox/firefox/commit/009562f1edfe https://hg.mozilla.org/integration/autoland/rev/132fabf569ea Part 7: Use atomic reads in the generic marking path r=sfink https://github.com/mozilla-firefox/firefox/commit/023676e5d9a6 https://hg.mozilla.org/integration/autoland/rev/e8b41d10df01 apply code formatting via Lando
Regressions: 2050826
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: