Skip to content

Commit 829a5d6

Browse files
committed
[Distributed] Review followup and cleanups
1 parent 879dc37 commit 829a5d6

11 files changed

+10
-48
lines changed

lib/IRGen/GenDistributed.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
using namespace swift;
3232
using namespace irgen;
3333

34-
namespace {} // end anonymous namespace
35-
3634
llvm::Value *irgen::emitDistributedActorInitializeRemote(
3735
IRGenFunction &IGF, llvm::Value *actorMetatype, Explosion &out) {
3836
auto fn = IGF.IGM.getDistributedActorInitializeRemoteFn();

lib/SILGen/SILGenDistributed.cpp

-12
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,6 @@ void SILGenFunction::emitDistributedActorReady(
445445

446446
// --- prepare conformance subs
447447
auto genericSig = actorReadyMethod->getGenericSignature();
448-
fprintf(stderr, "[%s:%d] (%s) GENERIC SIG\n", __FILE__, __LINE__, __FUNCTION__);
449-
genericSig->dump();
450448

451449
SubstitutionMap subs =
452450
SubstitutionMap::get(genericSig,
@@ -478,9 +476,6 @@ void SILGenFunction::emitDistributedActorFactory(FuncDecl *fd) {
478476
auto &C = getASTContext();
479477
SILLocation loc = fd;
480478

481-
fd->dump();
482-
F.dump();
483-
484479
// ==== Prepare argument references
485480
// --- Parameter: identity
486481
SILArgument *identityArg = F.getArgument(0);
@@ -535,15 +530,11 @@ void SILGenFunction::emitDistributedActorFactory(FuncDecl *fd) {
535530
// type: SpecificDistributedActor
536531
auto returnTy = getLoweredType(
537532
F.mapTypeIntoContext(selfTyDecl->getDeclaredInterfaceType()));
538-
fprintf(stderr, "[%s:%d] (%s) auto returnTy = selfArg.getType().getDeclaredInterfaceType();\n", __FILE__, __LINE__, __FUNCTION__);
539-
returnTy.dump();
540533

541534
// type: SpecificDistributedActor.Type
542535
auto selfMetatype =
543536
getLoweredType(F.mapTypeIntoContext(selfArg.getType().getASTType()));
544537
SILValue selfMetatypeValue = B.createMetatype(loc, selfMetatype);
545-
fprintf(stderr, "[%s:%d] (%s) SILValue selfMetatypeValue = B.createMetatype(loc, selfMetatype);\n", __FILE__, __LINE__, __FUNCTION__);
546-
selfMetatypeValue->dump();
547538

548539
// --- get the uninitialized allocation from the runtime system.
549540
FullExpr scope(Cleanups, CleanupLocation(fd));
@@ -595,9 +586,6 @@ void SILGenFunction::emitDistributedActorFactory(FuncDecl *fd) {
595586
// B.createThrow(loc, error);
596587
// }
597588
}
598-
599-
fprintf(stderr, "[%s:%d] (%s) DONE HERE\n", __FILE__, __LINE__, __FUNCTION__);
600-
F.dump();
601589
}
602590

603591
/******************************************************************************/

lib/SILGen/SILGenFunction.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -547,12 +547,6 @@ void SILGenFunction::emitFunction(FuncDecl *fd) {
547547
emitEpilog(fd);
548548

549549
mergeCleanupBlocks();
550-
551-
if (fd->isDistributedActorFactory()) {
552-
fprintf(stderr, "[%s:%d] (%s) DONEDONEDONEDONEDONEDONEDONEDONEDONEDONEDONEDONE\n", __FILE__, __LINE__, __FUNCTION__);
553-
F.dump();
554-
fprintf(stderr, "[%s:%d] (%s) DONEDONEDONEDONEDONEDONEDONEDONEDONEDONEDONEDONE\n", __FILE__, __LINE__, __FUNCTION__);
555-
}
556550
}
557551

558552
void SILGenFunction::emitClosure(AbstractClosureExpr *ace) {

lib/Sema/TypeCheckAvailability.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1684,8 +1684,6 @@ static void diagnosePotentialConcurrencyUnavailability(
16841684
fixAvailability(ReferenceRange, ReferenceDC, RequiredRange, Context);
16851685
}
16861686

1687-
// TODO(concurrency): implement checkDistributedAvailability
1688-
16891687
void TypeChecker::checkConcurrencyAvailability(SourceRange ReferenceRange,
16901688
const DeclContext *ReferenceDC) {
16911689
// Check the availability of concurrency runtime support.

lib/Sema/TypeCheckConcurrency.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -2514,14 +2514,7 @@ void swift::checkFunctionActorIsolation(AbstractFunctionDecl *decl) {
25142514
}
25152515
}
25162516

2517-
/// Some actor constructors are special, so we need to check rules about them.
2518-
void swift::checkActorConstructor(ClassDecl *decl, ConstructorDecl *ctor) {
2519-
if (decl->isDistributedActor())
2520-
checkDistributedActorConstructor(decl, ctor);
2521-
}
2522-
25232517
void swift::checkInitializerActorIsolation(Initializer *init, Expr *expr) {
2524-
25252518
ActorIsolationChecker checker(init);
25262519
expr->walk(checker);
25272520
}

lib/Sema/TypeCheckConcurrency.h

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ void addAsyncNotes(AbstractFunctionDecl const* func);
5454
/// Check actor isolation rules.
5555
void checkTopLevelActorIsolation(TopLevelCodeDecl *decl);
5656
void checkFunctionActorIsolation(AbstractFunctionDecl *decl);
57-
void checkActorConstructor(ClassDecl *decl, ConstructorDecl *ctor);
5857
void checkInitializerActorIsolation(Initializer *init, Expr *expr);
5958
void checkEnumElementActorIsolation(EnumElementDecl *element, Expr *expr);
6059
void checkPropertyWrapperActorIsolation(VarDecl *wrappedVar, Expr *expr);

lib/Sema/TypeCheckDistributed.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ void swift::checkDistributedActorConstructor(const ClassDecl *decl, ConstructorD
207207
if (transportParamsCount == 1)
208208
return;
209209

210-
// TODO(distributed): could list exact parameters
210+
// TODO(distributed): rdar://81824959 report the error on the offending (2nd) matching parameter
211+
// Or maybe we can issue a note about the other offending params?
211212
ctor->diagnose(diag::distributed_actor_designated_ctor_must_have_one_transport_param,
212213
ctor->getName(), transportParamsCount);
213214
}
@@ -222,7 +223,7 @@ void TypeChecker::checkDistributedActor(ClassDecl *decl) {
222223

223224
// ==== Constructors
224225
// --- Get the default initializer
225-
// If applicable, this will the default 'init(transport:)' initializer
226+
// If applicable, this will create the default 'init(transport:)' initializer
226227
(void)decl->getDefaultInitializer();
227228

228229
// --- Check all constructors

lib/Sema/TypeCheckDistributed.h

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- TypeCheckDistributed.h - Distributed -------------------*- C++ -*-===//
1+
//===-- TypeCheckDistributed.h - Distributed actor typechecking -*- C++ -*-===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
@@ -23,19 +23,10 @@
2323

2424
namespace swift {
2525

26-
class AbstractFunctionDecl;
27-
class ConstructorDecl;
28-
class ASTContext;
2926
class ClassDecl;
27+
class ConstructorDecl;
3028
class Decl;
31-
class DeclContext;
32-
class Expr;
3329
class FuncDecl;
34-
class Initializer;
35-
class PatternBindingDecl;
36-
class ProtocolConformance;
37-
class ValueDecl;
38-
3930

4031
/******************************************************************************/
4132
/********************* Distributed Actor Type Checking ************************/

stdlib/public/Concurrency/Actor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1751,7 +1751,7 @@ void swift::swift_defaultActor_deallocateResilient(HeapObject *actor) {
17511751
metadata->getInstanceAlignMask());
17521752
}
17531753

1754-
/// FIXME: only exists for the quick-and-dirtraKASASAasasy MainActor implementation.
1754+
/// FIXME: only exists for the quick-and-dirty MainActor implementation.
17551755
namespace swift {
17561756
Metadata* MainActorMetadata = nullptr;
17571757
}

stdlib/public/Distributed/DistributedActor.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public protocol DistributedActor:
4848
///
4949
/// - Parameter identity: identity uniquely identifying a, potentially remote, actor in the system
5050
/// - Parameter transport: `transport` which should be used to resolve the `identity`, and be associated with the returned actor
51-
// FIXME: move to generic identity here; depends on
51+
// FIXME: Partially blocked on SE-309, because then we can store ActorIdentity directly
52+
// We want to move to accepting a generic or existential identity here
5253
// static func resolve<Identity>(_ identity: Identity, using transport: ActorTransport)
5354
// throws -> Self where Identity: ActorIdentity
5455
static func resolve(_ identity: AnyActorIdentity, using transport: ActorTransport)

test/Distributed/Runtime/distributed_actor_isRemote.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ func test_remote() async {
9696
assert(__isLocalActor(local) == true, "should be local")
9797
assert(__isRemoteActor(local) == false, "should be local")
9898
print("isRemote(local) = \(__isRemoteActor(local))") // CHECK: isRemote(local) = false
99-
print("local.id = \(local.id)") // CHECK: local.id = AnyActorIdentity(ActorAddress(address: "sact://127.0.0.1/example#1234"))
100-
print("local.transport = \(local.id)") // CHECK: local.transport = FakeTransport()
99+
print("local.id = \(local.id)") // CHECK: local.id = AnyActorIdentity(ActorAddress(address: "xxx"))
100+
print("local.transport = \(local.actorTransport)") // CHECK: local.transport = FakeTransport()
101101

102102
// assume it always makes a remote one
103103
let remote = try! SomeSpecificDistributedActor.resolve(.init(address), using: transport)
@@ -110,7 +110,6 @@ func test_remote() async {
110110
print("remote.transport = \(remote.actorTransport)") // CHECK: remote.transport = FakeTransport()
111111

112112
print("done") // CHECK: done
113-
let xxx = remote
114113
}
115114

116115
@available(SwiftStdlib 5.5, *)

0 commit comments

Comments
 (0)