@@ -1006,13 +1006,13 @@ class DefaultActorImplHeader : public HeapObject {
1006
1006
// escalation logic
1007
1007
Mutex drainLock;
1008
1008
#else
1009
+ // TODO (rokhinip): Make this a flagset
1010
+ bool isDistributedRemoteActor;
1009
1011
// Note: There is some padding that is added here by the compiler in order to
1010
1012
// enforce alignment. This is space that is available for us to use in
1011
1013
// the future
1012
1014
alignas (sizeof (ActiveActorStatus)) char StatusStorage[sizeof(ActiveActorStatus)];
1013
1015
#endif
1014
- // TODO (rokhinip): Make this a flagset
1015
- bool isDistributedRemoteActor;
1016
1016
};
1017
1017
1018
1018
// All the fields accessed under the actor's lock should be moved
@@ -1036,6 +1036,14 @@ class DefaultActorImplFooter {
1036
1036
#endif
1037
1037
};
1038
1038
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
+
1039
1047
// / The default actor implementation.
1040
1048
// /
1041
1049
// / Ownership of the actor is subtle. Jobs are assumed to keep the actor
@@ -1088,8 +1096,13 @@ class DefaultActorImplFooter {
1088
1096
// / are (1), (3), (5), (6).
1089
1097
class DefaultActorImpl
1090
1098
: 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
1093
1106
public:
1094
1107
// / Properly construct an actor, except for the heap header.
1095
1108
void initialize (bool isDistributedRemote = false ) {
@@ -1159,6 +1172,13 @@ class DefaultActorImpl
1159
1172
}
1160
1173
#endif /* !SWIFT_CONCURRENCY_ACTORS_AS_LOCKS */
1161
1174
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
+
1162
1182
private:
1163
1183
#if !SWIFT_CONCURRENCY_ACTORS_AS_LOCKS
1164
1184
#if SWIFT_CONCURRENCY_ENABLE_PRIORITY_ESCALATION
@@ -1213,12 +1233,9 @@ class NonDefaultDistributedActorImpl : public HeapObject {
1213
1233
1214
1234
} // / end anonymous namespace
1215
1235
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),
1222
1239
" DefaultActorImpl doesn't fit in DefaultActor" );
1223
1240
#if !SWIFT_CONCURRENCY_ACTORS_AS_LOCKS
1224
1241
static_assert (DefaultActorImpl::offsetOfActiveActorStatus() % ACTIVE_ACTOR_STATUS_SIZE == 0,
0 commit comments