You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9207c83
Browse filesBrowse the repository at this point in the historyBrowse files
[JSC] Add thread-safety capabilities for the GC protocol's roles
https://bugs.webkit.org/show_bug.cgi?id=329878
rdar://191634814
Reviewed by Yusuke Suzuki.
The mutator-collector protocol has rules about which thread may call what: only
a thread with heap access polls, requests and waits for the Collector; only the
conductor runs the phases, including each heap's part of them; and only the
collector thread stops and resumes the mutator. Only assertConn checked any of
this, and only the conn bits. Encoding the rules lets the compiler and debug
asserts check that they still hold as the protocol changes for global
collections.
Add a capability for each role, checked at compile time by thread-safety
analysis and established by asserts that check the thread at run time:
- HeapAccessHolderRole, per heap. assertIsAccessHolder() checks that the
current thread has access to the heap, using a debug-only record of the
thread that acquired it. In iOS's legacy WebKit, where the UI thread and
WebThread share access, it checks that the current thread holds the web lock
instead.
- CollectorThreadRole, per Collector. assertIsCollectorThread() compares with
the thread recorded when the collector thread starts.
- ConductorRole, one global token. checkIsConductor(), which replaces
assertConn, checks the conn bits and that the current thread is the conductor
they name. It runs in every build where a thread starts conducting and at
each phase change; assertIsConductor() runs it elsewhere in debug builds
only, so release builds check no more than before.
- ConductorWithWorldStoppedRole, another global token, for the phases that
stop the world. assertIsConductorWithWorldStopped() grants both it and
ConductorRole, and in debug builds checks that the phase stops the world and
that every heap has been stopped. Methods that rely on the mutators being
stopped require it, so calling them in the Concurrent phase fails to build.
A method requires a role when it is only safe to run in that role. Public entry
points assert their role, since their callers do not hold the capability. The
analysis does not carry a capability into a lambda, so each forEachHeap lambda
that calls a method requiring a conductor role first asserts it. Heap's methods
for the collector thread assert it at run time instead: the capability is a
Collector member, and Heap.h only forward-declares Collector, so an annotation
there cannot name it. clearMutatorWaiting and applyMembershipChangeWithLock run
in either of two roles, which the analysis cannot express, so they assert at run
time only.
A later change will rebuild assertIsMutatorOrMutatorIsStopped(), and the places
where BlockDirectory reads its bits without its lock, on these roles.
Also remove five unused declarations, including hasHeapAccess(), whose last use
this replaces.
Canonical link: https://commits.webkit.org/325851@main
0 commit comments