Skip to content

Commit 3445d04

Browse files
authored
Merge pull request #59701 from ktoso/wip-revert-dist-properties-57
🍒[5.7][Distributed] Revert "#59481 distributed-computed-properties"
2 parents a505698 + 5b906c6 commit 3445d04

26 files changed

+153
-477
lines changed

include/swift/AST/ASTMangler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class ASTMangler : public Mangler {
197197
Type GlobalActorBound,
198198
ModuleDecl *Module);
199199

200-
std::string mangleDistributedThunk(const AbstractFunctionDecl *thunk);
200+
std::string mangleDistributedThunk(const FuncDecl *thunk);
201201

202202
/// Mangle a completion handler block implementation function, used for importing ObjC
203203
/// APIs as async.

include/swift/AST/Attr.def

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ SIMPLE_DECL_ATTR(_inheritActorContext, InheritActorContext,
661661
// 117 was 'spawn' and is now unused
662662

663663
CONTEXTUAL_SIMPLE_DECL_ATTR(distributed, DistributedActor,
664-
DeclModifier | OnClass | OnFunc | OnAccessor | OnVar |
664+
DeclModifier | OnClass | OnFunc | OnVar |
665665
ABIBreakingToAdd | ABIBreakingToRemove |
666666
APIBreakingToAdd | APIBreakingToRemove,
667667
118)
@@ -732,12 +732,6 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(_local, KnownToBeLocal,
732732
APIBreakingToAdd | APIBreakingToRemove,
733733
130)
734734

735-
SIMPLE_DECL_ATTR(_distributed_thunk, DistributedThunk,
736-
OnFunc | UserInaccessible |
737-
ABIBreakingToAdd | ABIBreakingToRemove |
738-
APIBreakingToAdd | APIBreakingToRemove,
739-
131)
740-
741735
// If you're adding a new underscored attribute here, please document it in
742736
// docs/ReferenceGuides/UnderscoredAttributes.md.
743737

include/swift/AST/Decl.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5345,10 +5345,6 @@ class VarDecl : public AbstractStorageDecl {
53455345
/// Does this have a 'distributed' modifier?
53465346
bool isDistributed() const;
53475347

5348-
/// Return a distributed thunk if this computed property is marked as
5349-
/// 'distributed' and and nullptr otherwise.
5350-
FuncDecl *getDistributedThunk() const;
5351-
53525348
/// Is this var known to be a "local" distributed actor,
53535349
/// if so the implicit throwing ans some isolation checks can be skipped.
53545350
bool isKnownToBeLocal() const;
@@ -6419,10 +6415,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
64196415
/// Returns 'true' if the function is distributed.
64206416
bool isDistributed() const;
64216417

6422-
/// Is this a thunk function used to access a distributed method outside
6423-
/// of its actor isolation context?
6424-
bool isDistributedThunk() const;
6425-
64266418
/// For a 'distributed' target (func or computed property),
64276419
/// get the 'thunk' responsible for performing the 'remoteCall'.
64286420
///

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4633,9 +4633,6 @@ ERROR(distributed_actor_isolated_method,none,
46334633
ERROR(distributed_local_cannot_be_used,none,
46344634
"'local' cannot be used in user-defined code currently",
46354635
())
4636-
ERROR(distributed_thunk_cannot_be_used,none,
4637-
"'distributed_thunk' cannot be used in user-defined code",
4638-
())
46394636
ERROR(distributed_actor_func_param_not_codable,none,
46404637
"parameter '%0' of type %1 in %2 does not conform to serialization requirement '%3'",
46414638
(StringRef, Type, DescriptiveDeclKind, StringRef))
@@ -4833,9 +4830,6 @@ ERROR(distributed_property_cannot_be_static,none,
48334830
ERROR(distributed_property_can_only_be_computed,none,
48344831
"%0 %1 cannot be 'distributed', only computed properties can",
48354832
(DescriptiveDeclKind, DeclName))
4836-
ERROR(distributed_property_accessor_only_get_can_be_distributed,none,
4837-
"only 'get' accessors may be 'distributed'",
4838-
())
48394833
NOTE(distributed_actor_isolated_property,none,
48404834
"access to %0 %1 is only permitted within distributed actor %2",
48414835
(DescriptiveDeclKind, DeclName, DeclName))

include/swift/AST/Expr.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ class alignas(8) Expr : public ASTAllocated<Expr> {
319319
ImplicitlyAsync : 1,
320320
ImplicitlyThrows : 1,
321321
NoAsync : 1,
322-
UsesDistributedThunk : 1
322+
ShouldApplyDistributedThunk : 1
323323
);
324324

325325
SWIFT_INLINE_BITFIELD_EMPTY(CallExpr, ApplyExpr);
@@ -4445,7 +4445,7 @@ class ApplyExpr : public Expr {
44454445
Bits.ApplyExpr.ImplicitlyAsync = false;
44464446
Bits.ApplyExpr.ImplicitlyThrows = false;
44474447
Bits.ApplyExpr.NoAsync = false;
4448-
Bits.ApplyExpr.UsesDistributedThunk = false;
4448+
Bits.ApplyExpr.ShouldApplyDistributedThunk = false;
44494449
}
44504450

44514451
public:
@@ -4532,11 +4532,11 @@ class ApplyExpr : public Expr {
45324532

45334533
/// Informs IRGen to that this expression should be applied as its distributed
45344534
/// thunk, rather than invoking the function directly.
4535-
bool usesDistributedThunk() const {
4536-
return Bits.ApplyExpr.UsesDistributedThunk;
4535+
bool shouldApplyDistributedThunk() const {
4536+
return Bits.ApplyExpr.ShouldApplyDistributedThunk;
45374537
}
4538-
void setUsesDistributedThunk(bool flag) {
4539-
Bits.ApplyExpr.UsesDistributedThunk = flag;
4538+
void setShouldApplyDistributedThunk(bool flag) {
4539+
Bits.ApplyExpr.ShouldApplyDistributedThunk = flag;
45404540
}
45414541

45424542
ValueDecl *getCalledValue() const;

include/swift/AST/TypeCheckRequests.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,20 +1279,17 @@ class GetDistributedRemoteCallArgumentInitFunctionRequest :
12791279
///
12801280
/// The thunk is responsible for invoking 'remoteCall' when invoked on a remote
12811281
/// 'distributed actor'.
1282-
class GetDistributedThunkRequest
1283-
: public SimpleRequest<
1284-
GetDistributedThunkRequest,
1285-
FuncDecl *(llvm::PointerUnion<VarDecl *, AbstractFunctionDecl *>),
1286-
RequestFlags::Cached> {
1287-
using Originator = llvm::PointerUnion<VarDecl *, AbstractFunctionDecl *>;
1288-
1282+
class GetDistributedThunkRequest :
1283+
public SimpleRequest<GetDistributedThunkRequest,
1284+
FuncDecl *(AbstractFunctionDecl *),
1285+
RequestFlags::Cached> {
12891286
public:
12901287
using SimpleRequest::SimpleRequest;
12911288

12921289
private:
12931290
friend SimpleRequest;
12941291

1295-
FuncDecl *evaluate(Evaluator &evaluator, Originator originator) const;
1292+
FuncDecl *evaluate(Evaluator &evaluator, AbstractFunctionDecl *distributedFunc) const;
12961293

12971294
public:
12981295
// Caching

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ SWIFT_REQUEST(TypeChecker, GetDistributedTargetInvocationResultHandlerOnReturnFu
137137
AbstractFunctionDecl *(NominalTypeDecl *),
138138
Cached, NoLocationInfo)
139139
SWIFT_REQUEST(TypeChecker, GetDistributedThunkRequest,
140-
FuncDecl *(llvm::PointerUnion<VarDecl *, AbstractFunctionDecl *>),
140+
FuncDecl *(AbstractFunctionDecl *),
141141
Cached, NoLocationInfo)
142142
SWIFT_REQUEST(TypeChecker, GetDistributedActorIDPropertyRequest,
143143
VarDecl *(NominalTypeDecl *),

lib/AST/ASTDumper.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -742,8 +742,6 @@ namespace {
742742

743743
void visitVarDecl(VarDecl *VD) {
744744
printCommon(VD, "var_decl");
745-
if (VD->isDistributed())
746-
PrintWithColorRAII(OS, DeclModifierColor) << " distributed";
747745
if (VD->isLet())
748746
PrintWithColorRAII(OS, DeclModifierColor) << " let";
749747
if (VD->getAttrs().hasAttribute<LazyAttr>())
@@ -874,9 +872,6 @@ namespace {
874872
if (D->isDistributed()) {
875873
PrintWithColorRAII(OS, ExprModifierColor) << " distributed";
876874
}
877-
if (D->isDistributedThunk()) {
878-
PrintWithColorRAII(OS, ExprModifierColor) << " distributed-thunk";
879-
}
880875

881876
if (auto fac = D->getForeignAsyncConvention()) {
882877
OS << " foreign_async=";
@@ -1340,10 +1335,6 @@ void ValueDecl::dumpRef(raw_ostream &os) const {
13401335
os << " known-to-be-local";
13411336
}
13421337

1343-
if (getAttrs().hasAttribute<DistributedThunkAttr>()) {
1344-
os << " distributed-thunk";
1345-
}
1346-
13471338
// Print location.
13481339
auto &srcMgr = getASTContext().SourceMgr;
13491340
if (getLoc().isValid()) {

lib/AST/ASTMangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3484,7 +3484,7 @@ ASTMangler::mangleOpaqueTypeDescriptorRecord(const OpaqueTypeDecl *decl) {
34843484
return finalize();
34853485
}
34863486

3487-
std::string ASTMangler::mangleDistributedThunk(const AbstractFunctionDecl *thunk) {
3487+
std::string ASTMangler::mangleDistributedThunk(const FuncDecl *thunk) {
34883488
// Marker protocols cannot be checked at runtime, so there is no point
34893489
// in recording them for distributed thunks.
34903490
llvm::SaveAndRestore<bool> savedAllowMarkerProtocols(AllowMarkerProtocols,

lib/AST/DistributedDecl.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,10 +1330,6 @@ bool AbstractFunctionDecl::isDistributed() const {
13301330
return getAttrs().hasAttribute<DistributedActorAttr>();
13311331
}
13321332

1333-
bool AbstractFunctionDecl::isDistributedThunk() const {
1334-
return getAttrs().hasAttribute<DistributedThunkAttr>();
1335-
}
1336-
13371333
ConstructorDecl *
13381334
NominalTypeDecl::getDistributedRemoteCallTargetInitFunction() const {
13391335
auto mutableThis = const_cast<NominalTypeDecl *>(this);
@@ -1377,15 +1373,6 @@ AbstractFunctionDecl *ASTContext::getRemoteCallOnDistributedActorSystem(
13771373
/********************** Distributed Actor Properties **************************/
13781374
/******************************************************************************/
13791375

1380-
FuncDecl *VarDecl::getDistributedThunk() const {
1381-
if (!isDistributed())
1382-
return nullptr;
1383-
1384-
auto mutableThis = const_cast<VarDecl *>(this);
1385-
return evaluateOrDefault(getASTContext().evaluator,
1386-
GetDistributedThunkRequest{mutableThis}, nullptr);
1387-
}
1388-
13891376
FuncDecl*
13901377
AbstractFunctionDecl::getDistributedThunk() const {
13911378
if (!isDistributed())

lib/SILGen/SILGenApply.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,8 +1122,10 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
11221122
SILDeclRef constant = SILDeclRef(e->getDecl());
11231123

11241124
/// Some special handling may be necessary for thunks:
1125-
if (callSite && callSite->usesDistributedThunk()) {
1126-
constant = SILDeclRef(e->getDecl()).asDistributed();
1125+
if (callSite && callSite->shouldApplyDistributedThunk()) {
1126+
if (auto distributedThunk = cast<AbstractFunctionDecl>(e->getDecl())->getDistributedThunk()) {
1127+
constant = SILDeclRef(distributedThunk).asDistributed();
1128+
}
11271129
} else if (afd->isBackDeployed()) {
11281130
// If we're calling a back deployed function then we need to call a
11291131
// thunk instead that will handle the fallback when the original
@@ -5762,8 +5764,7 @@ RValue SILGenFunction::emitGetAccessor(SILLocation loc, SILDeclRef get,
57625764
ArgumentSource &&selfValue, bool isSuper,
57635765
bool isDirectUse,
57645766
PreparedArguments &&subscriptIndices,
5765-
SGFContext c,
5766-
bool isOnSelfParameter) {
5767+
SGFContext c, bool isOnSelfParameter) {
57675768
// Scope any further writeback just within this operation.
57685769
FormalEvaluationScope writebackScope(*this);
57695770

@@ -5837,8 +5838,8 @@ void SILGenFunction::emitSetAccessor(SILLocation loc, SILDeclRef set,
58375838
ManagedValue SILGenFunction::emitAddressorAccessor(
58385839
SILLocation loc, SILDeclRef addressor, SubstitutionMap substitutions,
58395840
ArgumentSource &&selfValue, bool isSuper, bool isDirectUse,
5840-
PreparedArguments &&subscriptIndices,
5841-
SILType addressType, bool isOnSelfParameter) {
5841+
PreparedArguments &&subscriptIndices, SILType addressType,
5842+
bool isOnSelfParameter) {
58425843
// Scope any further writeback just within this operation.
58435844
FormalEvaluationScope writebackScope(*this);
58445845

@@ -5899,8 +5900,7 @@ SILGenFunction::emitCoroutineAccessor(SILLocation loc, SILDeclRef accessor,
58995900
Callee callee =
59005901
emitSpecializedAccessorFunctionRef(*this, loc, accessor,
59015902
substitutions, selfValue,
5902-
isSuper, isDirectUse,
5903-
isOnSelfParameter);
5903+
isSuper, isDirectUse, isOnSelfParameter);
59045904

59055905
// We're already in a full formal-evaluation scope.
59065906
// Make a dead writeback scope; applyCoroutine won't try to pop this.

lib/SILGen/SILGenDistributed.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ void SILGenFunction::emitDistActorIdentityInit(ConstructorDecl *ctor,
213213
initializeProperty(*this, loc, borrowedSelfArg, var, temp);
214214
}
215215

216-
// TODO(distributed): rename to DistributedActorID
217216
InitializeDistActorIdentity::InitializeDistActorIdentity(ConstructorDecl *ctor,
218217
ManagedValue actorSelf)
219218
: ctor(ctor),

lib/SILGen/SILGenFunction.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,8 +1477,7 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
14771477
ManagedValue emitAddressorAccessor(
14781478
SILLocation loc, SILDeclRef addressor, SubstitutionMap substitutions,
14791479
ArgumentSource &&optionalSelfValue, bool isSuper,
1480-
bool isDirectAccessorUse,
1481-
PreparedArguments &&optionalSubscripts,
1480+
bool isDirectAccessorUse, PreparedArguments &&optionalSubscripts,
14821481
SILType addressType, bool isOnSelfParameter);
14831482

14841483
CleanupHandle emitCoroutineAccessor(SILLocation loc, SILDeclRef accessor,

0 commit comments

Comments
 (0)