@@ -109,16 +109,14 @@ class SILIsolationInfo {
109
109
// / Unknown -> Disconnected -> TransferringParameter -> Task -> Actor.
110
110
// /
111
111
// / Unknown means no information. We error when merging on it.
112
- enum Kind {
112
+ enum Kind : uint8_t {
113
113
Unknown,
114
114
Disconnected,
115
115
Task,
116
116
Actor,
117
117
};
118
118
119
119
private:
120
- Kind kind;
121
-
122
120
// / The actor isolation if this value has one. The default unspecified case
123
121
// / otherwise.
124
122
ActorIsolation actorIsolation;
@@ -131,11 +129,14 @@ class SILIsolationInfo {
131
129
// / derived isolatedValue from.
132
130
ActorInstance actorInstance;
133
131
132
+ unsigned kind : 8 ;
133
+ unsigned unsafeNonIsolated : 1 ;
134
+
134
135
SILIsolationInfo (SILValue isolatedValue, SILValue actorInstance,
135
- ActorIsolation actorIsolation)
136
- : kind(Actor ), actorIsolation(actorIsolation ),
137
- isolatedValue (isolatedValue ),
138
- actorInstance(ActorInstance::getForValue(actorInstance) ) {
136
+ ActorIsolation actorIsolation, bool isUnsafeNonIsolated )
137
+ : actorIsolation(actorIsolation ), isolatedValue(isolatedValue ),
138
+ actorInstance (ActorInstance::getForValue(actorInstance)), kind(Actor ),
139
+ unsafeNonIsolated(isUnsafeNonIsolated ) {
139
140
assert ((!actorInstance ||
140
141
(actorIsolation.getKind () == ActorIsolation::ActorInstance &&
141
142
actorInstance->getType ()
@@ -146,31 +147,44 @@ class SILIsolationInfo {
146
147
}
147
148
148
149
SILIsolationInfo (SILValue isolatedValue, ActorInstance actorInstance,
149
- ActorIsolation actorIsolation)
150
- : kind(Actor), actorIsolation(actorIsolation),
151
- isolatedValue(isolatedValue), actorInstance(actorInstance) {
150
+ ActorIsolation actorIsolation, bool isUnsafeNonIsolated)
151
+ : actorIsolation(actorIsolation), isolatedValue(isolatedValue),
152
+ actorInstance(actorInstance), kind(Actor),
153
+ unsafeNonIsolated(isUnsafeNonIsolated) {
152
154
assert (actorInstance);
153
155
assert (actorIsolation.getKind () == ActorIsolation::ActorInstance);
154
156
}
155
157
156
158
SILIsolationInfo (Kind kind, SILValue isolatedValue)
157
- : kind(kind), actorIsolation(), isolatedValue(isolatedValue) {}
159
+ : actorIsolation(), isolatedValue(isolatedValue), kind(kind),
160
+ unsafeNonIsolated(false ) {}
158
161
159
- SILIsolationInfo (Kind kind) : kind(kind), actorIsolation() {}
162
+ SILIsolationInfo (Kind kind, bool isUnsafeNonIsolated)
163
+ : actorIsolation(), kind(kind), unsafeNonIsolated(isUnsafeNonIsolated) {}
160
164
161
165
public:
162
- SILIsolationInfo () : kind(Kind::Unknown), actorIsolation() {}
166
+ SILIsolationInfo ()
167
+ : actorIsolation(), kind(Kind::Unknown), unsafeNonIsolated(false ) {}
163
168
164
169
operator bool () const { return kind != Kind::Unknown; }
165
170
166
- operator Kind () const { return kind ; }
171
+ operator Kind () const { return getKind () ; }
167
172
168
- Kind getKind () const { return kind; }
173
+ Kind getKind () const { return Kind ( kind) ; }
169
174
170
175
bool isDisconnected () const { return kind == Kind::Disconnected; }
171
176
bool isActorIsolated () const { return kind == Kind::Actor; }
172
177
bool isTaskIsolated () const { return kind == Kind::Task; }
173
178
179
+ bool isUnsafeNonIsolated () const { return unsafeNonIsolated; }
180
+
181
+ SILIsolationInfo withUnsafeNonIsolated (bool newValue = true ) const {
182
+ assert (*this && " Cannot be unknown" );
183
+ auto self = *this ;
184
+ self.unsafeNonIsolated = newValue;
185
+ return self;
186
+ }
187
+
174
188
void print (llvm::raw_ostream &os) const ;
175
189
176
190
SWIFT_DEBUG_DUMP {
@@ -212,7 +226,9 @@ class SILIsolationInfo {
212
226
213
227
[[nodiscard]] SILIsolationInfo merge (SILIsolationInfo other) const ;
214
228
215
- static SILIsolationInfo getDisconnected () { return {Kind::Disconnected}; }
229
+ static SILIsolationInfo getDisconnected (bool isUnsafeNonIsolated) {
230
+ return {Kind::Disconnected, isUnsafeNonIsolated};
231
+ }
216
232
217
233
// / Create an actor isolation for a value that we know is actor isolated to a
218
234
// / specific actor, but we do not know the specific instance yet.
@@ -228,7 +244,8 @@ class SILIsolationInfo {
228
244
static SILIsolationInfo
229
245
getFlowSensitiveActorIsolated (SILValue isolatedValue,
230
246
ActorIsolation actorIsolation) {
231
- return {isolatedValue, SILValue (), actorIsolation};
247
+ return {isolatedValue, SILValue (), actorIsolation,
248
+ false /* nonisolated(unsafe)*/ };
232
249
}
233
250
234
251
// / Only use this as a fallback if we cannot find better information.
@@ -237,7 +254,8 @@ class SILIsolationInfo {
237
254
if (crossing.getCalleeIsolation ().isActorIsolated ()) {
238
255
// SIL level, just let it through
239
256
return SILIsolationInfo (SILValue (), SILValue (),
240
- crossing.getCalleeIsolation ());
257
+ crossing.getCalleeIsolation (),
258
+ false /* nonisolated(unsafe)*/ );
241
259
}
242
260
243
261
return {};
@@ -253,7 +271,8 @@ class SILIsolationInfo {
253
271
return {};
254
272
}
255
273
return {isolatedValue, actorInstance,
256
- ActorIsolation::forActorInstanceSelf (typeDecl)};
274
+ ActorIsolation::forActorInstanceSelf (typeDecl),
275
+ false /* nonisolated(unsafe)*/ };
257
276
}
258
277
259
278
static SILIsolationInfo getActorInstanceIsolated (SILValue isolatedValue,
@@ -266,7 +285,8 @@ class SILIsolationInfo {
266
285
return {};
267
286
}
268
287
return {isolatedValue, actorInstance,
269
- ActorIsolation::forActorInstanceSelf (typeDecl)};
288
+ ActorIsolation::forActorInstanceSelf (typeDecl),
289
+ false /* nonisolated(unsafe)*/ };
270
290
}
271
291
272
292
// / A special actor instance isolated for partial apply cases where we do not
@@ -281,13 +301,15 @@ class SILIsolationInfo {
281
301
return {};
282
302
}
283
303
return {isolatedValue, SILValue (),
284
- ActorIsolation::forActorInstanceSelf (typeDecl)};
304
+ ActorIsolation::forActorInstanceSelf (typeDecl),
305
+ false /* nonisolated(unsafe)*/ };
285
306
}
286
307
287
308
static SILIsolationInfo getGlobalActorIsolated (SILValue value,
288
309
Type globalActorType) {
289
310
return {value, SILValue () /* no actor instance*/ ,
290
- ActorIsolation::forGlobalActor (globalActorType)};
311
+ ActorIsolation::forGlobalActor (globalActorType),
312
+ false /* nonisolated(unsafe)*/ };
291
313
}
292
314
293
315
static SILIsolationInfo getGlobalActorIsolated (SILValue value,
0 commit comments