Skip to content

Commit 4bc9ad4

Browse files
committed
[JSC] Assert that Heap::resumeTheMutator finds the mutator stopped
https://bugs.webkit.org/show_bug.cgi?id=329005 rdar://191056975 Reviewed by Vassili Bykov. Heap::resumeTheMutator returned early when the mutator was not stopped, and its asserts allowed a mutator that has heap access and is not stopped. Neither happens: only the collector thread calls resumeTheMutator, when it is conducting, and it conducts a stopped phase only after it has stopped the mutator. A mutator that held heap access would have been handed the conn instead, a stopped mutator cannot take heap access, and only resumeTheMutator clears the stopped bit. Replace the early return and the old asserts with three asserts, one for each part of that state: the mutator is stopped, has no heap access, and does not hold the conn. Canonical link: https://commits.webkit.org/324804@main
1 parent 1b4f243 commit 4bc9ad4

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

‎Source/JavaScriptCore/heap/Heap.cpp‎

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,20 +1438,11 @@ NEVER_INLINE void Heap::resumeTheMutator()
14381438
dataLogLnIf(HeapInternal::verbose, "Resuming the mutator.");
14391439
for (;;) {
14401440
unsigned oldState = m_worldState.load();
1441-
if (!!(oldState & hasAccessBit) != !(oldState & stoppedBit)) {
1442-
dataLog("Fatal: hasAccess = ", !!(oldState & hasAccessBit), ", stopped = ", !!(oldState & stoppedBit), "\n");
1443-
RELEASE_ASSERT_NOT_REACHED();
1444-
}
1445-
if (oldState & mutatorHasConnBit) {
1446-
dataLog("Fatal: mutator has the conn.\n");
1447-
RELEASE_ASSERT_NOT_REACHED();
1448-
}
1449-
1450-
if (!(oldState & stoppedBit)) {
1451-
dataLogLnIf(HeapInternal::verbose, "Returning because not stopped.");
1452-
return;
1453-
}
1454-
1441+
// Only called by the collector thread when it is conducting, after it stopped the mutator.
1442+
RELEASE_ASSERT(oldState & stoppedBit, oldState);
1443+
RELEASE_ASSERT(!(oldState & hasAccessBit), oldState);
1444+
RELEASE_ASSERT(!(oldState & mutatorHasConnBit), oldState);
1445+
14551446
if (m_worldState.compareExchangeWeak(oldState, oldState & ~stoppedBit)) {
14561447
dataLogLnIf(HeapInternal::verbose, "CASing and returning.");
14571448
ParkingLot::unparkAll(&m_worldState);

0 commit comments

Comments
 (0)