@@ -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,12 @@ 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 { DefaultActorSize = sizeof (void *) * NumWords_DefaultActor + sizeof (HeapObject) };
1044
+
1039
1045
// / The default actor implementation.
1040
1046
// /
1041
1047
// / Ownership of the actor is subtle. Jobs are assumed to keep the actor
@@ -1087,9 +1093,13 @@ class DefaultActorImplFooter {
1087
1093
// / exist yet. As a result, the subset of rules that currently apply
1088
1094
// / are (1), (3), (5), (6).
1089
1095
class DefaultActorImpl
1090
- : public HeaderFooterLayout<DefaultActorImplHeader, DefaultActorImplFooter,
1091
- sizeof (HeapObject) +
1092
- sizeof (void *) * NumWords_DefaultActor> {
1096
+ : public HeaderFooterLayout<DefaultActorImplHeader, DefaultActorImplFooter, DefaultActorSize> {
1097
+ #pragma clang diagnostic push
1098
+ #pragma clang diagnostic ignored "-Wunused-private-field"
1099
+ // / Dummy variable, used to compute sizeWithoutTrailingPadding()
1100
+ // / Must not be accessed
1101
+ char const bytesPastTheEnd[1 ];
1102
+ #pragma clang diagnostic pop
1093
1103
public:
1094
1104
// / Properly construct an actor, except for the heap header.
1095
1105
void initialize (bool isDistributedRemote = false ) {
@@ -1159,6 +1169,13 @@ class DefaultActorImpl
1159
1169
}
1160
1170
#endif /* !SWIFT_CONCURRENCY_ACTORS_AS_LOCKS */
1161
1171
1172
+ static constexpr size_t sizeWithoutTrailingPadding () {
1173
+ #pragma clang diagnostic push
1174
+ #pragma clang diagnostic ignored "-Winvalid-offsetof"
1175
+ return offsetof (DefaultActorImpl, bytesPastTheEnd);
1176
+ #pragma clang diagnostic pop
1177
+ }
1178
+
1162
1179
private:
1163
1180
#if !SWIFT_CONCURRENCY_ACTORS_AS_LOCKS
1164
1181
#if SWIFT_CONCURRENCY_ENABLE_PRIORITY_ESCALATION
@@ -1213,11 +1230,7 @@ class NonDefaultDistributedActorImpl : public HeapObject {
1213
1230
1214
1231
} // / end anonymous namespace
1215
1232
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)) &&
1233
+ static_assert (DefaultActorImpl::sizeWithoutTrailingPadding() == DefaultActorSize &&
1221
1234
alignof (DefaultActorImpl) <= alignof (DefaultActor),
1222
1235
" DefaultActorImpl doesn't fit in DefaultActor" );
1223
1236
#if !SWIFT_CONCURRENCY_ACTORS_AS_LOCKS
0 commit comments