@@ -1032,16 +1032,18 @@ class DefaultActorImpl : public HeapObject {
1032
1032
1033
1033
struct Padding {
1034
1034
enum {
1035
- // Available space
1036
- x1 = (int )(sizeof (void *) * NumWords_DefaultActor),
1035
+ // Max object size
1036
+ x1 = (int )(sizeof (HeapObject) + sizeof ( void *) * NumWords_DefaultActor),
1037
1037
// ... subtracting size of footer
1038
1038
x2 = x1 - (int )sizeof (Footer),
1039
1039
// ... ensuring footer is aligned
1040
1040
x3 = x2 - (int )(x2 % alignof (Footer)),
1041
1041
// ... subtracting size of header
1042
1042
x4 = x3 - (int )sizeof (Header),
1043
1043
// ... subtracting padding before header
1044
- size = x4 - (int )((alignof (Header) - sizeof (HeapObject) % alignof (Header)) % alignof (Header))
1044
+ x5 = x4 - (int )((alignof (Header) - sizeof (HeapObject) % alignof (Header)) % alignof (Header)),
1045
+ // ... subtracting size of HeapObject
1046
+ size = x5 - (int )sizeof (HeapObject),
1045
1047
};
1046
1048
};
1047
1049
char padding[Padding::size];
@@ -1579,17 +1581,18 @@ void DefaultActorImpl::destroy() {
1579
1581
#if SWIFT_CONCURRENCY_ACTORS_AS_LOCKS
1580
1582
// TODO (rokhinip): Do something to assert that the lock is unowned
1581
1583
#else
1582
- auto oldState = _status ().load (std::memory_order_relaxed );
1584
+ auto oldState = _status ().load (std::memory_order_acquire );
1583
1585
// Tasks on an actor are supposed to keep the actor alive until they start
1584
1586
// running and we can only get here if ref count of the object = 0 which means
1585
1587
// there should be no more tasks enqueued on the actor.
1586
- // TODO: It is not safe to access prioritisedJobs here, right?
1587
1588
assert (!oldState.getFirstUnprioritisedJob () && " actor has queued jobs at destruction" );
1588
1589
1589
1590
if (oldState.isIdle ()) {
1591
+ assert (_prioritisedJobs ().empty () && " actor has queued jobs at destruction" );
1590
1592
return ;
1591
1593
}
1592
1594
assert (oldState.isRunning () && " actor scheduled but not running at destruction" );
1595
+ // In running state we cannot safely access prioritisedJobs to assert that it is empty.
1593
1596
#endif
1594
1597
}
1595
1598
@@ -1684,7 +1687,7 @@ retry:;
1684
1687
assert (oldState.getMaxPriority () == JobPriority::Unspecified);
1685
1688
assert (!oldState.getFirstUnprioritisedJob ());
1686
1689
// We cannot assert here that prioritisedJobs is empty,
1687
- // because lock is not held yet. Raise a flag to after getting the lock.
1690
+ // because lock is not held yet. Raise a flag to assert after getting the lock.
1688
1691
assertNoJobs = true ;
1689
1692
}
1690
1693
0 commit comments