Skip to content

Commit 6061de2

Browse files
authored
Merge pull request swiftlang#39762 from kavon/dactor-transport-lifecycle
[concurrency][distributed] Inject invocations of transport.actorReady in init
2 parents a96d220 + 191c996 commit 6061de2

32 files changed

+739
-736
lines changed

include/swift/AST/Builtins.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -737,10 +737,6 @@ BUILTIN_MISC_OPERATION(DestroyDefaultActor, "destroyDefaultActor", "", Special)
737737
BUILTIN_MISC_OPERATION(InitializeDistributedRemoteActor,
738738
"initializeDistributedRemoteActor", "", Special)
739739

740-
/// Destroy the distributed-actor instance in a "proxy" actor object.
741-
BUILTIN_MISC_OPERATION(DestroyDistributedActor,
742-
"destroyDistributedActor", "", Special)
743-
744740
/// Resume a non-throwing continuation normally with the given result.
745741
BUILTIN_MISC_OPERATION(ResumeNonThrowingContinuationReturning,
746742
"resumeNonThrowingContinuationReturning", "", Special)

include/swift/Runtime/Concurrency.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -727,10 +727,6 @@ SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
727727
OpaqueValue*
728728
swift_distributedActor_remote_initialize(const Metadata *actorType);
729729

730-
/// Destroy the runtime storage for a default actor.
731-
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
732-
void swift_distributedActor_destroy(DefaultActor *actor);
733-
734730
/// Enqueue a job on the default actor implementation.
735731
///
736732
/// The job must be ready to run. Notably, if it's a task, that

include/swift/Runtime/RuntimeFunctions.def

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,14 +1725,6 @@ FUNCTION(DistributedActorInitializeRemote,
17251725
ARGS(TypeMetadataPtrTy),
17261726
ATTRS(NoUnwind))
17271727

1728-
// void swift_distributedActor_destroy(DefaultActor *actor);
1729-
FUNCTION(DistributedActorDestroy,
1730-
swift_distributedActor_destroy, SwiftCC,
1731-
ConcurrencyAvailability, // TODO(distributed): Introduce DistributedAvailability once shipping somewhere
1732-
RETURNS(VoidTy),
1733-
ARGS(RefCountedPtrTy),
1734-
ATTRS(NoUnwind))
1735-
17361728
/// void swift_asyncLet_start(
17371729
/// AsyncLet *alet,
17381730
/// TaskOptionRecord *options,
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
/// Finds the first `ActorTransport`-compatible parameter of the given function.
28+
/// \returns nullptr if the function does not have such a parameter.
29+
SILArgument *findFirstActorTransportArg(SILFunction &F);
30+
31+
/// Emits code that notifies the distributed actor's transport that the
32+
/// actor is ready for execution.
33+
/// \param B the builder to use when emitting the code.
34+
/// \param actor the distributed actor instance to pass to the transport as
35+
/// being "ready" \param transport a value representing the ActorTransport
36+
void emitActorReadyCall(SILBuilder &B, SILLocation loc, SILValue actor,
37+
SILValue transport);
38+
39+
} // namespace swift
40+
41+
#endif

lib/AST/Builtins.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,13 +1480,6 @@ static ValueDecl *getDistributedActorInitializeRemote(ASTContext &ctx,
14801480
_rawPointer);
14811481
}
14821482

1483-
static ValueDecl *getDistributedActorDestroy(ASTContext &ctx,
1484-
Identifier id) {
1485-
return getBuiltinFunction(ctx, id, _thin,
1486-
_parameters(_nativeObject),
1487-
_void);
1488-
}
1489-
14901483
static ValueDecl *getResumeContinuationReturning(ASTContext &ctx,
14911484
Identifier id) {
14921485
return getBuiltinFunction(ctx, id, _thin,
@@ -2842,9 +2835,6 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
28422835
case BuiltinValueKind::InitializeDistributedRemoteActor:
28432836
return getDistributedActorInitializeRemote(Context, Id);
28442837

2845-
case BuiltinValueKind::DestroyDistributedActor:
2846-
return getDistributedActorDestroy(Context, Id);
2847-
28482838
case BuiltinValueKind::StartAsyncLet:
28492839
case BuiltinValueKind::StartAsyncLetWithLocalBuffer:
28502840
return getStartAsyncLet(Context, Id);

lib/IRGen/GenBuiltin.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,6 @@ void irgen::emitBuiltinCall(IRGenFunction &IGF, const BuiltinInfo &Builtin,
397397
return;
398398
}
399399

400-
if (Builtin.ID == BuiltinValueKind::DestroyDistributedActor) {
401-
auto actor = args.claimNext();
402-
emitDistributedActorDestroy(IGF, actor);
403-
return;
404-
}
405-
406400
// If this is an LLVM IR intrinsic, lower it to an intrinsic call.
407401
const IntrinsicInfo &IInfo = IGF.getSILModule().getIntrinsicInfo(FnId);
408402
llvm::Intrinsic::ID IID = IInfo.ID;

lib/IRGen/GenDistributed.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,3 @@ llvm::Value *irgen::emitDistributedActorInitializeRemote(
5353

5454
return result;
5555
}
56-
57-
void irgen::emitDistributedActorDestroy(IRGenFunction &IGF,
58-
llvm::Value *actor) {
59-
auto fn = IGF.IGM.getDistributedActorDestroyFn();
60-
actor = IGF.Builder.CreateBitCast(actor, IGF.IGM.RefCountedPtrTy);
61-
62-
auto call = IGF.Builder.CreateCall(fn, {actor});
63-
call->setCallingConv(IGF.IGM.SwiftCC);
64-
call->setDoesNotThrow();
65-
}

lib/IRGen/GenDistributed.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ llvm::Value *emitDistributedActorInitializeRemote(
4747
llvm::Value *actorMetatype,
4848
Explosion &out);
4949

50-
/// Destroy the distributed actor.
51-
/// E.g. a remote actor has to be destroyed differently from a local one.
52-
void emitDistributedActorDestroy(
53-
IRGenFunction &IGF,
54-
llvm::Value *actor);
55-
5650
} // end namespace irgen
5751
} // end namespace swift
5852

lib/SIL/IR/OperandOwnership.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,6 @@ BUILTIN_OPERAND_OWNERSHIP(InteriorPointer, InitializeDefaultActor)
846846
BUILTIN_OPERAND_OWNERSHIP(InteriorPointer, DestroyDefaultActor)
847847

848848
BUILTIN_OPERAND_OWNERSHIP(InteriorPointer, InitializeDistributedRemoteActor)
849-
BUILTIN_OPERAND_OWNERSHIP(InteriorPointer, DestroyDistributedActor)
850849

851850
// FIXME: Why do these reqiuire a borrowed value at all?
852851
BUILTIN_OPERAND_OWNERSHIP(ForwardingBorrow, AutoDiffAllocateSubcontext)

lib/SIL/IR/ValueOwnership.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,6 @@ CONSTANT_OWNERSHIP_BUILTIN(None, ConvertTaskToJob)
538538
CONSTANT_OWNERSHIP_BUILTIN(None, InitializeDefaultActor)
539539
CONSTANT_OWNERSHIP_BUILTIN(None, DestroyDefaultActor)
540540
CONSTANT_OWNERSHIP_BUILTIN(None, InitializeDistributedRemoteActor)
541-
CONSTANT_OWNERSHIP_BUILTIN(None, DestroyDistributedActor)
542541
CONSTANT_OWNERSHIP_BUILTIN(Owned, AutoDiffCreateLinearMapContext)
543542
CONSTANT_OWNERSHIP_BUILTIN(None, AutoDiffProjectTopLevelSubcontext)
544543
CONSTANT_OWNERSHIP_BUILTIN(None, AutoDiffAllocateSubcontext)

0 commit comments

Comments
 (0)