Skip to content

Commit 966339d

Browse files
committed
[Concurrency] Remove ClosureActorIsolation.
(cherry picked from commit 549b452)
1 parent 8bac434 commit 966339d

File tree

6 files changed

+18
-145
lines changed

6 files changed

+18
-145
lines changed

include/swift/AST/Expr.h

Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -3774,92 +3774,6 @@ class SequenceExpr final : public Expr,
37743774
}
37753775
};
37763776

3777-
/// Actor isolation for a closure.
3778-
class ClosureActorIsolation {
3779-
public:
3780-
enum Kind {
3781-
/// The closure is not isolated to any actor.
3782-
Nonisolated,
3783-
3784-
/// The closure is tied to the actor instance described by the given
3785-
/// \c VarDecl*, which is the (captured) `self` of an actor.
3786-
ActorInstance,
3787-
3788-
/// The closure is tied to the global actor described by the given type.
3789-
GlobalActor,
3790-
};
3791-
3792-
private:
3793-
/// The actor to which this closure is isolated, plus a bit indicating
3794-
/// whether the isolation was imposed by a preconcurrency declaration.
3795-
///
3796-
/// There are three possible states for the pointer:
3797-
/// - NULL: The closure is independent of any actor.
3798-
/// - VarDecl*: The 'self' variable for the actor instance to which
3799-
/// this closure is isolated. It will always have a type that conforms
3800-
/// to the \c Actor protocol.
3801-
/// - Type: The type of the global actor on which
3802-
llvm::PointerIntPair<llvm::PointerUnion<VarDecl *, Type>, 1, bool> storage;
3803-
3804-
ClosureActorIsolation(VarDecl *selfDecl, bool preconcurrency)
3805-
: storage(selfDecl, preconcurrency) { }
3806-
ClosureActorIsolation(Type globalActorType, bool preconcurrency)
3807-
: storage(globalActorType, preconcurrency) { }
3808-
3809-
public:
3810-
ClosureActorIsolation(bool preconcurrency = false)
3811-
: storage(nullptr, preconcurrency) { }
3812-
3813-
static ClosureActorIsolation forNonisolated(bool preconcurrency) {
3814-
return ClosureActorIsolation(preconcurrency);
3815-
}
3816-
3817-
static ClosureActorIsolation forActorInstance(VarDecl *selfDecl,
3818-
bool preconcurrency) {
3819-
return ClosureActorIsolation(selfDecl, preconcurrency);
3820-
}
3821-
3822-
static ClosureActorIsolation forGlobalActor(Type globalActorType,
3823-
bool preconcurrency) {
3824-
return ClosureActorIsolation(globalActorType, preconcurrency);
3825-
}
3826-
3827-
/// Determine the kind of isolation.
3828-
Kind getKind() const {
3829-
if (storage.getPointer().isNull())
3830-
return Kind::Nonisolated;
3831-
3832-
if (storage.getPointer().is<VarDecl *>())
3833-
return Kind::ActorInstance;
3834-
3835-
return Kind::GlobalActor;
3836-
}
3837-
3838-
/// Whether the closure is isolated at all.
3839-
explicit operator bool() const {
3840-
return getKind() != Kind::Nonisolated;
3841-
}
3842-
3843-
/// Whether the closure is isolated at all.
3844-
operator Kind() const {
3845-
return getKind();
3846-
}
3847-
3848-
VarDecl *getActorInstance() const {
3849-
return storage.getPointer().dyn_cast<VarDecl *>();
3850-
}
3851-
3852-
Type getGlobalActor() const {
3853-
return storage.getPointer().dyn_cast<Type>();
3854-
}
3855-
3856-
bool preconcurrency() const {
3857-
return storage.getInt();
3858-
}
3859-
3860-
ActorIsolation getActorIsolation() const;
3861-
};
3862-
38633777
/// A base class for closure expressions.
38643778
class AbstractClosureExpr : public DeclContext, public Expr {
38653779
CaptureInfo Captures;
@@ -3957,29 +3871,6 @@ class AbstractClosureExpr : public DeclContext, public Expr {
39573871
this->actorIsolation = actorIsolation;
39583872
}
39593873

3960-
ClosureActorIsolation getClosureActorIsolation() const {
3961-
bool preconcurrency = actorIsolation.preconcurrency();
3962-
3963-
switch (actorIsolation) {
3964-
case ActorIsolation::Unspecified:
3965-
case ActorIsolation::Nonisolated:
3966-
return ClosureActorIsolation::forNonisolated(preconcurrency);
3967-
3968-
case ActorIsolation::ActorInstance:
3969-
return ClosureActorIsolation::forActorInstance(
3970-
actorIsolation.getActorInstance(), preconcurrency);
3971-
3972-
case ActorIsolation::GlobalActor:
3973-
case ActorIsolation::GlobalActorUnsafe:
3974-
return ClosureActorIsolation::forGlobalActor(
3975-
actorIsolation.getGlobalActor(), preconcurrency);
3976-
}
3977-
}
3978-
3979-
void setActorIsolation(ClosureActorIsolation closureIsolation) {
3980-
this->actorIsolation = closureIsolation.getActorIsolation();
3981-
}
3982-
39833874
static bool classof(const Expr *E) {
39843875
return E->getKind() >= ExprKind::First_AbstractClosureExpr &&
39853876
E->getKind() <= ExprKind::Last_AbstractClosureExpr;

lib/AST/ASTDumper.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2592,16 +2592,18 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
25922592
PrintWithColorRAII(OS, DiscriminatorColor)
25932593
<< " discriminator=" << E->getRawDiscriminator();
25942594

2595-
switch (auto isolation = E->getClosureActorIsolation()) {
2596-
case ClosureActorIsolation::Nonisolated:
2595+
switch (auto isolation = E->getActorIsolation()) {
2596+
case ActorIsolation::Unspecified:
2597+
case ActorIsolation::Nonisolated:
25972598
break;
25982599

2599-
case ClosureActorIsolation::ActorInstance:
2600+
case ActorIsolation::ActorInstance:
26002601
PrintWithColorRAII(OS, CapturesColor) << " actor-isolated="
26012602
<< isolation.getActorInstance()->printRef();
26022603
break;
26032604

2604-
case ClosureActorIsolation::GlobalActor:
2605+
case ActorIsolation::GlobalActor:
2606+
case ActorIsolation::GlobalActorUnsafe:
26052607
PrintWithColorRAII(OS, CapturesColor) << " global-actor-isolated="
26062608
<< isolation.getGlobalActor().getString();
26072609
break;

lib/AST/Decl.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10209,12 +10209,14 @@ bool VarDecl::isSelfParamCaptureIsolated() const {
1020910209
}
1021010210

1021110211
if (auto closure = dyn_cast<AbstractClosureExpr>(dc)) {
10212-
switch (auto isolation = closure->getClosureActorIsolation()) {
10213-
case ClosureActorIsolation::Nonisolated:
10214-
case ClosureActorIsolation::GlobalActor:
10212+
switch (auto isolation = closure->getActorIsolation()) {
10213+
case ActorIsolation::Unspecified:
10214+
case ActorIsolation::Nonisolated:
10215+
case ActorIsolation::GlobalActor:
10216+
case ActorIsolation::GlobalActorUnsafe:
1021510217
return false;
1021610218

10217-
case ClosureActorIsolation::ActorInstance:
10219+
case ActorIsolation::ActorInstance:
1021810220
auto isolatedVar = isolation.getActorInstance();
1021910221
return isolatedVar->isSelfParameter() ||
1022010222
isolatedVar-isSelfParamCapture();

lib/AST/Expr.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,29 +1873,6 @@ RebindSelfInConstructorExpr::getCalledConstructor(bool &isChainToSuper) const {
18731873
return otherCtorRef;
18741874
}
18751875

1876-
ActorIsolation ClosureActorIsolation::getActorIsolation() const {
1877-
switch (getKind()) {
1878-
case ClosureActorIsolation::Nonisolated:
1879-
return ActorIsolation::forNonisolated().withPreconcurrency(
1880-
preconcurrency());
1881-
1882-
case ClosureActorIsolation::GlobalActor: {
1883-
return ActorIsolation::forGlobalActor(getGlobalActor(), /*unsafe=*/false)
1884-
.withPreconcurrency(preconcurrency());
1885-
}
1886-
1887-
case ClosureActorIsolation::ActorInstance: {
1888-
auto selfDecl = getActorInstance();
1889-
auto actor =
1890-
selfDecl->getTypeInContext()->getReferenceStorageReferent()->getAnyActor();
1891-
assert(actor && "Bad closure actor isolation?");
1892-
// FIXME: This could be a parameter... or a capture... hmmm.
1893-
return ActorIsolation::forActorInstanceCapture(
1894-
getActorInstance()).withPreconcurrency(preconcurrency());
1895-
}
1896-
}
1897-
}
1898-
18991876
unsigned AbstractClosureExpr::getDiscriminator() const {
19001877
auto raw = getRawDiscriminator();
19011878
if (raw != InvalidDiscriminator)

lib/SILGen/SILGenProlog.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,19 +1380,21 @@ void SILGenFunction::emitProlog(
13801380
}
13811381
} else if (auto *closureExpr = dyn_cast<AbstractClosureExpr>(FunctionDC)) {
13821382
bool wantExecutor = F.isAsync() || wantDataRaceChecks;
1383-
auto actorIsolation = closureExpr->getClosureActorIsolation();
1383+
auto actorIsolation = closureExpr->getActorIsolation();
13841384
switch (actorIsolation.getKind()) {
1385-
case ClosureActorIsolation::Nonisolated:
1385+
case ActorIsolation::Unspecified:
1386+
case ActorIsolation::Nonisolated:
13861387
break;
13871388

1388-
case ClosureActorIsolation::ActorInstance: {
1389+
case ActorIsolation::ActorInstance: {
13891390
if (wantExecutor) {
13901391
loadExpectedExecutorForLocalVar(actorIsolation.getActorInstance());
13911392
}
13921393
break;
13931394
}
13941395

1395-
case ClosureActorIsolation::GlobalActor:
1396+
case ActorIsolation::GlobalActor:
1397+
case ActorIsolation::GlobalActorUnsafe:
13961398
if (wantExecutor) {
13971399
ExpectedExecutor =
13981400
emitLoadGlobalActorExecutor(actorIsolation.getGlobalActor());

lib/Sema/TypeCheckConcurrency.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class ActorIsolation;
3333
class AnyFunctionType;
3434
class ASTContext;
3535
class ClassDecl;
36-
class ClosureActorIsolation;
3736
class ClosureExpr;
3837
class ConcreteDeclRef;
3938
class CustomAttr;

0 commit comments

Comments
 (0)