@@ -881,16 +881,18 @@ class DefaultActorImpl : public HeapObject {
881
881
882
882
struct Padding {
883
883
enum {
884
- // Available space
885
- x1 = (int )(sizeof (void *) * NumWords_DefaultActor),
884
+ // Max object size
885
+ x1 = (int )(sizeof (HeapObject) + sizeof ( void *) * NumWords_DefaultActor),
886
886
// ... subtracting size of footer
887
887
x2 = x1 - (int )sizeof (Footer),
888
888
// ... ensuring footer is aligned
889
889
x3 = x2 - (int )(x2 % alignof (Footer)),
890
890
// ... subtracting size of header
891
891
x4 = x3 - (int )sizeof (Header),
892
892
// ... subtracting padding before header
893
- size = x4 - (int )((alignof (Header) - sizeof (HeapObject) % alignof (Header)) % alignof (Header))
893
+ x5 = x4 - (int )((alignof (Header) - sizeof (HeapObject) % alignof (Header)) % alignof (Header)),
894
+ // ... subtracting size of HeapObject
895
+ size = x5 - (int )sizeof (HeapObject),
894
896
};
895
897
};
896
898
char padding[Padding::size];
@@ -1428,17 +1430,18 @@ void DefaultActorImpl::destroy() {
1428
1430
#if SWIFT_CONCURRENCY_ACTORS_AS_LOCKS
1429
1431
// TODO (rokhinip): Do something to assert that the lock is unowned
1430
1432
#else
1431
- auto oldState = _status ().load (std::memory_order_relaxed );
1433
+ auto oldState = _status ().load (std::memory_order_acquire );
1432
1434
// Tasks on an actor are supposed to keep the actor alive until they start
1433
1435
// running and we can only get here if ref count of the object = 0 which means
1434
1436
// there should be no more tasks enqueued on the actor.
1435
- // TODO: It is not safe to access prioritisedJobs here, right?
1436
1437
assert (!oldState.getFirstUnprioritisedJob () && " actor has queued jobs at destruction" );
1437
1438
1438
1439
if (oldState.isIdle ()) {
1440
+ assert (_prioritisedJobs ().empty () && " actor has queued jobs at destruction" );
1439
1441
return ;
1440
1442
}
1441
1443
assert (oldState.isRunning () && " actor scheduled but not running at destruction" );
1444
+ // In running state we cannot safely access prioritisedJobs to assert that it is empty.
1442
1445
#endif
1443
1446
}
1444
1447
@@ -1533,7 +1536,7 @@ retry:;
1533
1536
assert (oldState.getMaxPriority () == JobPriority::Unspecified);
1534
1537
assert (!oldState.getFirstUnprioritisedJob ());
1535
1538
// We cannot assert here that prioritisedJobs is empty,
1536
- // because lock is not held yet. Raise a flag to after getting the lock.
1539
+ // because lock is not held yet. Raise a flag to assert after getting the lock.
1537
1540
assertNoJobs = true ;
1538
1541
}
1539
1542
0 commit comments