@@ -1006,13 +1006,13 @@ class DefaultActorImplHeader : public HeapObject {
10061006 // escalation logic
10071007 Mutex drainLock;
10081008#else
1009+ // TODO (rokhinip): Make this a flagset
1010+ bool isDistributedRemoteActor;
10091011 // Note: There is some padding that is added here by the compiler in order to
10101012 // enforce alignment. This is space that is available for us to use in
10111013 // the future
10121014 alignas (sizeof (ActiveActorStatus)) char StatusStorage[sizeof(ActiveActorStatus)];
10131015#endif
1014- // TODO (rokhinip): Make this a flagset
1015- bool isDistributedRemoteActor;
10161016};
10171017
10181018// All the fields accessed under the actor's lock should be moved
@@ -1036,6 +1036,14 @@ class DefaultActorImplFooter {
10361036#endif
10371037};
10381038
1039+ // We can't use sizeof(DefaultActor) since the alignment requirement on the
1040+ // default actor means that we have some padding added when calculating
1041+ // sizeof(DefaultActor). However that padding isn't available for us to use
1042+ // in DefaultActorImpl.
1043+ enum {
1044+ DefaultActorSize = sizeof (void *) * NumWords_DefaultActor + sizeof (HeapObject)
1045+ };
1046+
10391047// / The default actor implementation.
10401048// /
10411049// / Ownership of the actor is subtle. Jobs are assumed to keep the actor
@@ -1088,8 +1096,13 @@ class DefaultActorImplFooter {
10881096// / are (1), (3), (5), (6).
10891097class DefaultActorImpl
10901098 : public HeaderFooterLayout<DefaultActorImplHeader, DefaultActorImplFooter,
1091- sizeof (HeapObject) +
1092- sizeof (void *) * NumWords_DefaultActor> {
1099+ DefaultActorSize> {
1100+ #pragma clang diagnostic push
1101+ #pragma clang diagnostic ignored "-Wunused-private-field"
1102+ // / Dummy variable, used to compute sizeWithoutTrailingPadding()
1103+ // / Must not be accessed
1104+ char const bytesPastTheEnd[1 ];
1105+ #pragma clang diagnostic pop
10931106public:
10941107 // / Properly construct an actor, except for the heap header.
10951108 void initialize (bool isDistributedRemote = false ) {
@@ -1159,6 +1172,13 @@ class DefaultActorImpl
11591172 }
11601173#endif /* !SWIFT_CONCURRENCY_ACTORS_AS_LOCKS */
11611174
1175+ static constexpr size_t sizeWithoutTrailingPadding () {
1176+ #pragma clang diagnostic push
1177+ #pragma clang diagnostic ignored "-Winvalid-offsetof"
1178+ return offsetof (DefaultActorImpl, bytesPastTheEnd);
1179+ #pragma clang diagnostic pop
1180+ }
1181+
11621182private:
11631183#if !SWIFT_CONCURRENCY_ACTORS_AS_LOCKS
11641184#if SWIFT_CONCURRENCY_ENABLE_PRIORITY_ESCALATION
@@ -1213,12 +1233,9 @@ class NonDefaultDistributedActorImpl : public HeapObject {
12131233
12141234} // / end anonymous namespace
12151235
1216- // We can't use sizeof(DefaultActor) since the alignment requirement on the
1217- // default actor means that we have some padding added when calculating
1218- // sizeof(DefaultActor). However that padding isn't available for us to use
1219- // in DefaultActorImpl.
1220- static_assert (sizeof (DefaultActorImpl) <= ((sizeof (void *) * NumWords_DefaultActor) + sizeof (HeapObject)) &&
1221- alignof (DefaultActorImpl) <= alignof (DefaultActor),
1236+ static_assert (DefaultActorImpl::sizeWithoutTrailingPadding() ==
1237+ DefaultActorSize &&
1238+ alignof (DefaultActorImpl) <= alignof (DefaultActor),
12221239 " DefaultActorImpl doesn't fit in DefaultActor" );
12231240#if !SWIFT_CONCURRENCY_ACTORS_AS_LOCKS
12241241static_assert (DefaultActorImpl::offsetOfActiveActorStatus() % ACTIVE_ACTOR_STATUS_SIZE == 0 ,
0 commit comments