Skip to content

Commit cee89ec

Browse files
authored
[Distributed] DistributedActorSystem renaming and redesign (#40387)
* [Distributed] towards DistributedActorSystem; synthesize the id earlier, since Identifiable.id * Fix execute signature to what Pavel is working with * funcs are ok in sil * fixed lifetime of id in inits * fix distributed_actor_deinit * distributed_actor_local * update more tests fixing tests fix TBD test fix Serialization/distributed fix irgen test Fix null pointer crashes * prevent issues with null func ptrs and fix Distributed prorotocol test * fix deinit sil test
1 parent 9801a05 commit cee89ec

File tree

78 files changed

+2911
-1457
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2911
-1457
lines changed

include/swift/AST/Decl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3309,6 +3309,9 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
33093309
/// If the passed in function is not distributed this function returns null.
33103310
AbstractFunctionDecl* lookupDirectRemoteFunc(AbstractFunctionDecl *func);
33113311

3312+
/// Find, or potentially synthesize, the implicit 'id' property of this actor.
3313+
ValueDecl *getDistributedActorIDProperty() const;
3314+
33123315
/// Collect the set of protocols to which this type should implicitly
33133316
/// conform, such as AnyObject (for classes).
33143317
void getImplicitProtocols(SmallVectorImpl<ProtocolDecl *> &protocols);

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4681,13 +4681,13 @@ ERROR(distributed_actor_func_static,none,
46814681
ERROR(distributed_actor_func_not_in_distributed_actor,none,
46824682
"'distributed' method can only be declared within 'distributed actor'",
46834683
())
4684-
ERROR(distributed_actor_designated_ctor_must_have_one_transport_param,none,
4684+
ERROR(distributed_actor_designated_ctor_must_have_one_distributedactorsystem_param,none,
46854685
"designated distributed actor initializer %0 must accept exactly one "
4686-
"ActorTransport parameter, found %1",
4686+
"DistributedActorSystem parameter, found %1",
46874687
(DeclName, int))
46884688
ERROR(distributed_actor_designated_ctor_missing_transport_param,none,
46894689
"designated distributed actor initializer %0 is missing required "
4690-
"ActorTransport parameter",
4690+
"DistributedActorSystem parameter",
46914691
(DeclName))
46924692
ERROR(distributed_actor_user_defined_special_property,none,
46934693
"property %0 cannot be defined explicitly, as it conflicts with "

include/swift/AST/Expr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ class DeclRefExpr : public Expr {
12391239

12401240
/// Set whether this reference must account for a `throw` occurring for reasons
12411241
/// other than the function implementation itself throwing, e.g. an
1242-
/// `ActorTransport` implementing a `distributed func` call throwing a
1242+
/// `DistributedActorSystem` implementing a `distributed func` call throwing a
12431243
/// networking error.
12441244
void setImplicitlyThrows(bool isImplicitlyThrows) {
12451245
Bits.DeclRefExpr.IsImplicitlyThrows = isImplicitlyThrows;
@@ -1619,7 +1619,7 @@ class LookupExpr : public Expr {
16191619

16201620
/// Set whether this reference must account for a `throw` occurring for reasons
16211621
/// other than the function implementation itself throwing, e.g. an
1622-
/// `ActorTransport` implementing a `distributed func` call throwing a
1622+
/// `DistributedActorSystem` implementing a `distributed func` call throwing a
16231623
/// networking error.
16241624
void setImplicitlyThrows(bool isImplicitlyThrows) {
16251625
Bits.LookupExpr.IsImplicitlyThrows = isImplicitlyThrows;

include/swift/AST/KnownIdentifiers.def

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ IDENTIFIER(decode)
6565
IDENTIFIER(decodeIfPresent)
6666
IDENTIFIER(Decoder)
6767
IDENTIFIER(decoder)
68-
IDENTIFIER(DefaultActorTransport)
68+
IDENTIFIER(DefaultDistributedActorSystem)
6969
IDENTIFIER_(Differentiation)
7070
IDENTIFIER_WITH_NAME(PatternMatchVar, "$match")
7171
IDENTIFIER(dynamicallyCall)
@@ -142,7 +142,6 @@ IDENTIFIER_WITH_NAME(SwiftObject, "_TtCs12_SwiftObject")
142142
IDENTIFIER(SwiftNativeNSObject)
143143
IDENTIFIER(to)
144144
IDENTIFIER(toRaw)
145-
IDENTIFIER(Transport)
146145
IDENTIFIER(Type)
147146
IDENTIFIER(type)
148147
IDENTIFIER(typeMismatch)
@@ -256,18 +255,20 @@ IDENTIFIER_(regexString)
256255
IDENTIFIER_(StringProcessing)
257256

258257
// Distributed actors
259-
IDENTIFIER(transport)
260-
IDENTIFIER(using)
261258
IDENTIFIER(actor)
262-
IDENTIFIER(actorTransport)
263-
IDENTIFIER(actorType)
264259
IDENTIFIER(actorReady)
265-
IDENTIFIER(assignIdentity)
266-
IDENTIFIER(resignIdentity)
260+
IDENTIFIER(ActorSystem)
261+
IDENTIFIER(actorSystem)
262+
IDENTIFIER(ActorID)
263+
IDENTIFIER(actorType)
264+
IDENTIFIER(using)
265+
IDENTIFIER(assignID)
266+
IDENTIFIER(resignID)
267267
IDENTIFIER(resolve)
268+
IDENTIFIER(system)
269+
IDENTIFIER(ID)
268270
IDENTIFIER(id)
269-
IDENTIFIER(identity)
270-
IDENTIFIER(identifier)
271+
IDENTIFIER(Invocation)
271272
IDENTIFIER(_distributedActorRemoteInitialize)
272273
IDENTIFIER(_distributedActorDestroy)
273274
IDENTIFIER(__isRemoteActor)

include/swift/AST/KnownProtocols.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ PROTOCOL(Differentiable)
9898
// Distributed Actors
9999
PROTOCOL(DistributedActor)
100100
PROTOCOL(ActorIdentity)
101-
PROTOCOL(ActorTransport)
101+
PROTOCOL(DistributedActorSystem)
102102

103103
PROTOCOL(AsyncSequence)
104104
PROTOCOL(AsyncIteratorProtocol)

include/swift/AST/KnownSDKDecls.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# define KNOWN_SDK_FUNC_DECL(Module, Name, Id)
2020
#endif
2121

22-
KNOWN_SDK_FUNC_DECL(Distributed, MissingDistributedActorTransport, "_missingDistributedActorTransport")
22+
KNOWN_SDK_FUNC_DECL(Distributed, MissingDistributedActorSystem, "_missingDistributedActorSystem")
2323
KNOWN_SDK_FUNC_DECL(Distributed, IsRemoteDistributedActor, "__isRemoteActor")
2424

2525
#undef KNOWN_SDK_FUNC_DECL

include/swift/AST/TypeCheckRequests.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,24 @@ class GetDistributedRemoteFuncRequest :
10351035
bool isCached() const { return true; }
10361036
};
10371037

1038+
/// Obtain the 'id' property of a 'distributed actor'.
1039+
class GetDistributedActorIDPropertyRequest :
1040+
public SimpleRequest<GetDistributedActorIDPropertyRequest,
1041+
ValueDecl *(NominalTypeDecl *),
1042+
RequestFlags::Cached> {
1043+
public:
1044+
using SimpleRequest::SimpleRequest;
1045+
1046+
private:
1047+
friend SimpleRequest;
1048+
1049+
ValueDecl *evaluate(Evaluator &evaluator, NominalTypeDecl *actor) const;
1050+
1051+
public:
1052+
// Caching
1053+
bool isCached() const { return true; }
1054+
};
1055+
10381056
/// Retrieve the static "shared" property within a global actor that provides
10391057
/// the actor instance representing the global actor.
10401058
///
@@ -2215,8 +2233,8 @@ enum class ImplicitMemberAction : uint8_t {
22152233
ResolveEncodable,
22162234
ResolveDecodable,
22172235
ResolveDistributedActor,
2218-
ResolveDistributedActorIdentity,
2219-
ResolveDistributedActorTransport,
2236+
ResolveDistributedActorID,
2237+
ResolveDistributedActorSystem,
22202238
};
22212239

22222240
class ResolveImplicitMemberRequest

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ SWIFT_REQUEST(TypeChecker, IsDistributedActorRequest, bool(NominalTypeDecl *),
107107
Cached, NoLocationInfo)
108108
SWIFT_REQUEST(TypeChecker, GetDistributedRemoteFuncRequest, AbstractFunctionDecl *(AbstractFunctionDecl *),
109109
Cached, NoLocationInfo)
110+
SWIFT_REQUEST(TypeChecker, GetDistributedActorIDPropertyRequest, ValueDecl *(NominalTypeDecl *),
111+
Cached, NoLocationInfo)
110112
SWIFT_REQUEST(TypeChecker, GlobalActorInstanceRequest,
111113
VarDecl *(NominalTypeDecl *),
112114
Cached, NoLocationInfo)

include/swift/SILOptimizer/Utils/DistributedActor.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,32 @@ class SILLocation;
3131
class SILType;
3232
class SILValue;
3333

34-
/// Finds the first `ActorTransport`-compatible parameter of the given function.
34+
/// Finds the first `DistributedActorSystem`-compatible parameter of the given function.
3535
/// \returns nullptr if the function does not have such a parameter.
36-
SILArgument *findFirstActorTransportArg(SILFunction &F);
36+
SILArgument *findFirstDistributedActorSystemArg(SILFunction &F);
3737

38-
/// Emit a call to a witness of the actor transport protocol.
38+
/// Emit a call to a witness of the actor actorSystem protocol.
3939
///
40-
/// \param methodName The name of the method on the ActorTransport protocol.
41-
/// \param transport The transport on which to invoke the method
40+
/// \param methodName The name of the method on the DistributedActorSystem protocol.
41+
/// \param actorSystem The actorSystem on which to invoke the method
4242
/// \param actorType If non-empty, the type of the distributed actor that is
4343
/// provided as one of the arguments.
44-
/// \param args The arguments provided to the call, not including the transport.
44+
/// \param args The arguments provided to the call, not including the actorSystem.
4545
/// \param tryTargets For a call that can throw, the normal and error basic
4646
/// blocks that the call will branch to.
47-
void emitActorTransportWitnessCall(
47+
void emitDistributedActorSystemWitnessCall(
4848
SILBuilder &B, SILLocation loc, DeclName methodName,
49-
SILValue transport, SILType actorType, llvm::ArrayRef<SILValue> args,
49+
SILValue actorSystem, SILType actorType, llvm::ArrayRef<SILValue> args,
5050
llvm::Optional<std::pair<SILBasicBlock *, SILBasicBlock *>> tryTargets =
5151
llvm::None);
5252

53-
/// Emits code that notifies the distributed actor's transport that the
53+
/// Emits code that notifies the distributed actor's actorSystem that the
5454
/// actor is ready for execution.
5555
/// \param B the builder to use when emitting the code.
56-
/// \param actor the distributed actor instance to pass to the transport as
57-
/// being "ready" \param transport a value representing the ActorTransport
56+
/// \param actor the distributed actor instance to pass to the actorSystem as
57+
/// being "ready" \param actorSystem a value representing the DistributedActorSystem
5858
void emitActorReadyCall(SILBuilder &B, SILLocation loc, SILValue actor,
59-
SILValue transport);
59+
SILValue actorSystem);
6060

6161
} // namespace swift
6262

lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ ProtocolDecl *ASTContext::getProtocol(KnownProtocolKind kind) const {
10311031
M = getLoadedModule(Id_Concurrency);
10321032
break;
10331033
case KnownProtocolKind::DistributedActor:
1034-
case KnownProtocolKind::ActorTransport:
1034+
case KnownProtocolKind::DistributedActorSystem:
10351035
case KnownProtocolKind::ActorIdentity:
10361036
M = getLoadedModule(Id_Distributed);
10371037
break;

0 commit comments

Comments
 (0)