mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
basic implementation of performing an init of the id after an assign of the actorSystem.
The resignID call within the initializer moved into DI, because an assignment to the actorSystem, and thus initialization of the id, is no longer guaranteed to happen. Thus, while we previously could model the resignation as a clean-up emitted on all unwind paths in an initializer, now it's conditional, based on whether the id was initialized. This is exactly what DI is designed to do, so we inject the resignation call just before we call the identity's deinit.
This commit is contained in:
@@ -186,4 +186,36 @@ void emitActorReadyCall(SILBuilder &B, SILLocation loc, SILValue actor,
|
||||
F.mapTypeIntoContext(actor->getType()), { actor });
|
||||
}
|
||||
|
||||
void emitResignIdentityCall(SILBuilder &B, SILLocation loc,
|
||||
ClassDecl* actorDecl,
|
||||
SILValue actor, SILValue idRef) {
|
||||
auto &F = B.getFunction();
|
||||
auto &C = F.getASTContext();
|
||||
|
||||
SILValue systemRef = refDistributedActorSystem(B, loc, actorDecl, actor);
|
||||
|
||||
emitDistributedActorSystemWitnessCall(
|
||||
B, loc, C.Id_resignID,
|
||||
systemRef,
|
||||
SILType(),
|
||||
{ idRef });
|
||||
}
|
||||
|
||||
/// Creates a reference to the distributed actor's \p actorSystem
|
||||
/// stored property.
|
||||
SILValue refDistributedActorSystem(SILBuilder &b,
|
||||
SILLocation loc,
|
||||
ClassDecl *actDecl,
|
||||
SILValue actorInstance) {
|
||||
assert(actDecl);
|
||||
assert(actDecl->isDistributedActor());
|
||||
|
||||
// get the VarDecl corresponding to the actorSystem.
|
||||
auto refs = actDecl->lookupDirect(actDecl->getASTContext().Id_actorSystem);
|
||||
assert(refs.size() == 1);
|
||||
VarDecl *actorSystemVar = dyn_cast<VarDecl>(refs.front());
|
||||
|
||||
return b.createRefElementAddr(loc, actorInstance, actorSystemVar);
|
||||
}
|
||||
|
||||
} // namespace swift
|
||||
|
||||
Reference in New Issue
Block a user