Bug 1802897 - Part 5: Add methods to update the mark bitmap atomically r=sfink
commitf381628593b5fdeea2b4bbdbe665dc090a8f3074
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 6 Dec 2022 18:19:29 +0000 (6 18:19 +0000)
committerJon Coppeard <jcoppeard@mozilla.com>
Tue, 6 Dec 2022 18:19:29 +0000 (6 18:19 +0000)
treef1e98bf3fde12267e4fc5aa7ea2a3faba5e7140d
parent41c7731c2681b11bb887020f9f644549510ad25a
Bug 1802897 - Part 5: Add methods to update the mark bitmap atomically r=sfink

The mark bitmap is represented using relaxed atomics. Currently we update this
using separate load and store operations where possible as this is more
efficient but this is only possible if there are no concurrent writes.

Parallel marking will perform concurrent writes to the marking bitmap so
requires updates to be performed atomically.

The patch adds methods that are correct in the face of multiple writes
(different threads won't stomp over each others' updates) however the
markIfUnmarkedAtomic method can return false positives. It works out faster
overall to allow this and tolerate multiple threads trying to mark the same
thing at the same time occasionally than to have the extra synchronisation
overhead of avoiding it.

Differential Revision: https://phabricator.services.mozilla.com/D163465
js/public/HeapAPI.h
js/src/gc/Cell.h
js/src/gc/Heap.h