Skip to content

Commit 51b7697

Browse files
committed
decouple the emission of actorReady from SILGen
We need to be able to inject a call to a distributed actor's transport.actorReady, passing the actor instance to it, during definite initialization. This means that its dependence on SILGenFunction must be broken, hence this refactoring as a SILOptimizer utility.
1 parent b7d5e0a commit 51b7697

File tree

6 files changed

+228
-185
lines changed

6 files changed

+228
-185
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//===---- DistributedActor.h - SIL utils for distributed actors -*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef SWIFT_SILOPTIMIZER_UTILS_DISTRIBUTED_ACTOR_H
14+
#define SWIFT_SILOPTIMIZER_UTILS_DISTRIBUTED_ACTOR_H
15+
16+
namespace swift {
17+
18+
class ASTContext;
19+
class ConstructorDecl;
20+
class ClassDecl;
21+
class SILBuilder;
22+
class SILArgument;
23+
class SILFunction;
24+
class SILLocation;
25+
class SILValue;
26+
27+
/// Perform a load of the given distributed actor's transport.
28+
/// \param actorSelf the value representing `self` for the distributed actor
29+
/// instance. \returns the transport value
30+
SILValue loadActorTransport(SILBuilder &B, SILLocation loc,
31+
ClassDecl *actorDecl, SILValue actorSelf);
32+
33+
/// Emits code that notifies the distributed actor's transport that the
34+
/// actor is ready for execution.
35+
/// \param B the builder to use when emitting the code.
36+
/// \param actor the distributed actor instance to pass to the transport as
37+
/// being "ready" \param transport a value representing the ActorTransport
38+
void emitActorReadyCall(SILBuilder &B, SILLocation loc, ClassDecl *actorDecl,
39+
SILValue actor, SILValue transport);
40+
41+
} // namespace swift
42+
43+
#endif

lib/SILGen/SILGenConstructor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ void SILGenFunction::emitClassConstructorInitializer(ConstructorDecl *ctor) {
785785

786786
// Distributed actor initializers implicitly initialize their transport and id
787787
if (isDesignatedDistActorInit) {
788-
initializeDistributedActorImplicitStorageInit(ctor, selfArg);
788+
emitDistActorImplicitPropertyInits(ctor, selfArg);
789789
}
790790

791791
// Prepare the end of initializer location.

0 commit comments

Comments
 (0)