Skip to content

Commit f5927a9

Browse files
committed
review follow ups
1 parent 2ce311e commit f5927a9

File tree

6 files changed

+17
-46
lines changed

6 files changed

+17
-46
lines changed

include/swift/AST/TypeCheckRequests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ class GetDistributedRemoteCallTargetInitFunctionRequest :
11841184
bool isCached() const { return true; }
11851185
};
11861186

1187-
/// Obtain the 'distributed thunk' for the in passed function.
1187+
/// Obtain the 'distributed thunk' for the passed-in function.
11881188
///
11891189
/// The thunk is responsible for invoking 'remoteCall' when invoked on a remote
11901190
/// 'distributed actor'.

lib/AST/DistributedDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Type swift::getConcreteReplacementForProtocolActorSystemType(ValueDecl *member)
9393
return signature->getConcreteType(ActorSystemAssocType);
9494
}
9595

96-
llvm_unreachable("Unable to fetch ActorSystem type! Un");
96+
llvm_unreachable("Unable to fetch ActorSystem type!");
9797
}
9898

9999
Type swift::getDistributedActorSystemType(NominalTypeDecl *actor) {

lib/SILGen/SILGenFunction.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,6 @@ void SILGenFunction::emitFunction(FuncDecl *fd) {
522522
fd->getResultInterfaceType(), fd->hasThrows(), fd->getThrowsLoc());
523523

524524
if (fd->isDistributedActorFactory()) {
525-
// TODO(distributed): generalize as "emit body synthesized in SIL" marker
526525
// Synthesize the factory function body
527526
emitDistributedActorFactory(fd);
528527
} else {

lib/Sema/CodeSynthesisDistributedActor.cpp

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@
3232
using namespace swift;
3333

3434

35-
/******************************************************************************/
36-
/****************************** UTILS *****************************************/
37-
/******************************************************************************/
38-
39-
static DeclName createDistributedFuncName(ASTContext &C, FuncDecl* func) {
40-
// std::string localFuncNameString = "$dist_";
41-
std::string localFuncNameString = "";
42-
localFuncNameString.append(std::string(func->getBaseName().getIdentifier().str()));
43-
auto thunkBaseName = DeclBaseName(C.getIdentifier(StringRef(localFuncNameString)));
44-
return DeclName(C, thunkBaseName, func->getParameters());
45-
}
46-
4735
/******************************************************************************/
4836
/************************ PROPERTY SYNTHESIS **********************************/
4937
/******************************************************************************/
@@ -106,7 +94,7 @@ static void forwardParameters(AbstractFunctionDecl *afd,
10694
forwardingParams.push_back(new (C) DeclRefExpr(
10795
ConcreteDeclRef(param), DeclNameLoc(), /*implicit=*/true,
10896
swift::AccessSemantics::Ordinary,
109-
param->getInterfaceType()));
97+
afd->mapTypeIntoContext(param->getInterfaceType())));
11098
}
11199
}
112100

@@ -145,7 +133,6 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) {
145133
assert(systemConfRef && "ActorSystem must conform to DistributedActorSystem");
146134

147135
// === ActorSystem.InvocationEncoder
148-
ProtocolDecl *DTIE = C.getDistributedTargetInvocationEncoderDecl();
149136
Type invocationEncoderTy =
150137
getDistributedActorSystemInvocationEncoderType(systemDecl);
151138
NominalTypeDecl *invocationEncoderDecl = invocationEncoderTy->getAnyNominal();
@@ -195,7 +182,7 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) {
195182

196183
auto *systemVar =
197184
new (C) VarDecl(/*isStatic=*/false, VarDecl::Introducer::Let, sloc,
198-
C.getIdentifier("system"), thunk);
185+
C.Id_system, thunk);
199186
systemVar->setInterfaceType(systemProperty->getInterfaceType());
200187
systemVar->setImplicit();
201188
systemVar->setSynthesized();
@@ -212,7 +199,7 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) {
212199
// --- invocationEncoder = system.makeInvocationEncoder()
213200
auto *invocationVar =
214201
new (C) VarDecl(/*isStatic=*/false, VarDecl::Introducer::Var, sloc,
215-
C.getIdentifier("invocation"), thunk);
202+
C.Id_invocation, thunk);
216203
invocationVar->setInterfaceType(invocationEncoderTy);
217204
invocationVar->setImplicit();
218205
invocationVar->setSynthesized();
@@ -228,7 +215,6 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) {
228215
auto *makeInvocationArgs = ArgumentList::createImplicit(C, {});
229216
auto makeInvocationCallExpr =
230217
CallExpr::createImplicit(C, makeInvocationExpr, makeInvocationArgs);
231-
makeInvocationCallExpr->setType(DTIE->getInterfaceType());
232218
makeInvocationCallExpr->setThrows(false);
233219

234220
auto invocationEncoderPB = PatternBindingDecl::createImplicit(
@@ -384,7 +370,7 @@ deriveBodyDistributed_thunk(AbstractFunctionDecl *thunk, void *context) {
384370
// === Prepare the 'RemoteCallTarget'
385371
VarDecl *targetVar =
386372
new (C) VarDecl(/*isStatic=*/false, VarDecl::Introducer::Let, sloc,
387-
C.getIdentifier("target"), thunk);
373+
C.Id_target, thunk);
388374

389375
{
390376
// --- Mangle the thunk name
@@ -510,7 +496,7 @@ static FuncDecl *createDistributedThunkFunction(FuncDecl *func) {
510496
assert(systemTy &&
511497
"Thunk synthesis must have concrete actor system type available");
512498

513-
DeclName thunkName = createDistributedFuncName(C, func);
499+
DeclName thunkName = func->getName();
514500

515501
// --- Prepare generic parameters
516502
GenericParamList *genericParamList = nullptr;
@@ -571,14 +557,14 @@ static FuncDecl *createDistributedThunkFunction(FuncDecl *func) {
571557
/******************************************************************************/
572558

573559
FuncDecl *GetDistributedThunkRequest::evaluate(
574-
Evaluator &evaluator, AbstractFunctionDecl *afd) const {
575-
if (!afd->isDistributed())
560+
Evaluator &evaluator, AbstractFunctionDecl *distributedTarget) const {
561+
if (!distributedTarget->isDistributed())
576562
return nullptr;
577563

578-
auto &C = afd->getASTContext();
579-
auto DC = afd->getDeclContext();
564+
auto &C = distributedTarget->getASTContext();
565+
auto DC = distributedTarget->getDeclContext();
580566

581-
if (!getConcreteReplacementForProtocolActorSystemType(afd)) {
567+
if (!getConcreteReplacementForProtocolActorSystemType(distributedTarget)) {
582568
// Don't synthesize thunks, unless there is a *concrete* ActorSystem.
583569
// TODO(distributed): we should be able to lift this eventually,
584570
// and allow resolving distributed actor protocols.
@@ -588,12 +574,12 @@ FuncDecl *GetDistributedThunkRequest::evaluate(
588574
// Force type-checking the original function, so we can avoid synthesizing
589575
// the thunks (which would have many of the same errors, if they are caused
590576
// by a bad source function signature, e.g. missing conformances etc).
591-
(void) TypeChecker::typeCheckDecl(afd);
592-
if (afd->getDiags().hadAnyError()) {
577+
(void) TypeChecker::typeCheckDecl(distributedTarget);
578+
if (distributedTarget->getDiags().hadAnyError()) {
593579
return nullptr;
594580
}
595581

596-
if (auto func = dyn_cast<FuncDecl>(afd)) {
582+
if (auto func = dyn_cast<FuncDecl>(distributedTarget)) {
597583
// not via `ensureDistributedModuleLoaded` to avoid generating a warning,
598584
// we won't be emitting the offending decl after all.
599585
if (!C.getLoadedModule(C.Id_Distributed))

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,12 +1926,6 @@ namespace {
19261926

19271927
if (auto conversion = dyn_cast<ImplicitConversionExpr>(expr))
19281928
expr = conversion->getSubExpr();
1929-
1930-
// // Map opaque values.
1931-
// if (auto opaqueValue = dyn_cast<OpaqueValueExpr>(expr)) {
1932-
// if (auto *value = getExistentialValue(opaqueValue))
1933-
// expr = value;
1934-
// }
19351929
} while (prior != expr);
19361930

19371931
if (auto call = dyn_cast<DotSyntaxCallExpr>(expr)) {
@@ -2867,7 +2861,6 @@ namespace {
28672861

28682862
case ActorIsolationRestriction::CrossActorSelf:
28692863
case ActorIsolationRestriction::ActorSelf:
2870-
valueRef.dump();
28712864
llvm_unreachable("non-member reference into an actor");
28722865

28732866
case ActorIsolationRestriction::GlobalActorUnsafe:
@@ -3110,10 +3103,6 @@ namespace {
31103103
}
31113104
}
31123105

3113-
// /// Determine whether the given reference is to a method on
3114-
// /// a remote distributed actor in the given context.
3115-
// bool isDistributedThunk(ConcreteDeclRef ref, Expr *context,
3116-
// bool isInAsyncLetInitializer);
31173106
};
31183107
}
31193108

@@ -4862,10 +4851,7 @@ bool swift::isPotentiallyIsolatedActor(
48624851
if (!var)
48634852
return false;
48644853

4865-
if (var->getName().str().equals("__secretlyKnownToBeLocal")
4866-
) {
4867-
// ||
4868-
// var->getAttrs().hasAttribute<KnownToBeLocalAttr>()) { /// FIXME(distributed): NOT QUITE, as this also would trim the implicit 'await', but we do still want it
4854+
if (var->getName().str().equals("__secretlyKnownToBeLocal")) {
48694855
// FIXME(distributed): we did a dynamic check and know that this actor is
48704856
// local, but we can't express that to the type system; the real
48714857
// implementation will have to mark 'self' as "known to be local" after

test/Distributed/distributed_actor_accessor_section_macho.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -disable-availability-checking %S/Inputs/FakeDistributedActorSystems.swift
3-
// RUN: %target-swift-frontend -emit-irgen -module-name distributed_actor_accessors -enable-experimental-distributed -disable-availability-checking -I %t 2>&1 %s | %IRGenFileCheck %s --dump-input=always
3+
// RUN: %target-swift-frontend -emit-irgen -module-name distributed_actor_accessors -enable-experimental-distributed -disable-availability-checking -I %t 2>&1 %s | %IRGenFileCheck %s
44

55
// UNSUPPORTED: back_deploy_concurrency
66
// REQUIRES: concurrency

0 commit comments

Comments
 (0)