Skip to content

Commit 5c05da0

Browse files
authored
Merge pull request #59699 from ktoso/revert-dist-properties
[Distributed] Revert "#59481 distributed-computed-properties"
2 parents acbaec9 + 6a27786 commit 5c05da0

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
@@ -664,7 +664,7 @@ SIMPLE_DECL_ATTR(_inheritActorContext, InheritActorContext,
664664
// 117 was 'spawn' and is now unused
665665

666666
CONTEXTUAL_SIMPLE_DECL_ATTR(distributed, DistributedActor,
667-
DeclModifier | OnClass | OnFunc | OnAccessor | OnVar |
667+
DeclModifier | OnClass | OnFunc | OnVar |
668668
ABIBreakingToAdd | ABIBreakingToRemove |
669669
APIBreakingToAdd | APIBreakingToRemove,
670670
118)
@@ -735,12 +735,6 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(_local, KnownToBeLocal,
735735
APIBreakingToAdd | APIBreakingToRemove,
736736
130)
737737

738-
SIMPLE_DECL_ATTR(_distributed_thunk, DistributedThunk,
739-
OnFunc | UserInaccessible |
740-
ABIBreakingToAdd | ABIBreakingToRemove |
741-
APIBreakingToAdd | APIBreakingToRemove,
742-
131)
743-
744738
// If you're adding a new underscored attribute here, please document it in
745739
// docs/ReferenceGuides/UnderscoredAttributes.md.
746740

include/swift/AST/Decl.h

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

5358-
/// Return a distributed thunk if this computed property is marked as
5359-
/// 'distributed' and and nullptr otherwise.
5360-
FuncDecl *getDistributedThunk() const;
5361-
53625358
/// Is this var known to be a "local" distributed actor,
53635359
/// if so the implicit throwing ans some isolation checks can be skipped.
53645360
bool isKnownToBeLocal() const;
@@ -6433,10 +6429,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
64336429
/// Returns 'true' if the function is distributed.
64346430
bool isDistributed() const;
64356431

6436-
/// Is this a thunk function used to access a distributed method outside
6437-
/// of its actor isolation context?
6438-
bool isDistributedThunk() const;
6439-
64406432
/// For a 'distributed' target (func or computed property),
64416433
/// get the 'thunk' responsible for performing the 'remoteCall'.
64426434
///

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4607,9 +4607,6 @@ ERROR(distributed_actor_isolated_method,none,
46074607
ERROR(distributed_local_cannot_be_used,none,
46084608
"'local' cannot be used in user-defined code currently",
46094609
())
4610-
ERROR(distributed_thunk_cannot_be_used,none,
4611-
"'distributed_thunk' cannot be used in user-defined code",
4612-
())
46134610
ERROR(distributed_actor_func_param_not_codable,none,
46144611
"parameter '%0' of type %1 in %2 does not conform to serialization requirement '%3'",
46154612
(StringRef, Type, DescriptiveDeclKind, StringRef))
@@ -4807,9 +4804,6 @@ ERROR(distributed_property_cannot_be_static,none,
48074804
ERROR(distributed_property_can_only_be_computed,none,
48084805
"%0 %1 cannot be 'distributed', only computed properties can",
48094806
(DescriptiveDeclKind, DeclName))
4810-
ERROR(distributed_property_accessor_only_get_can_be_distributed,none,
4811-
"only 'get' accessors may be 'distributed'",
4812-
())
48134807
NOTE(distributed_actor_isolated_property,none,
48144808
"access to %0 %1 is only permitted within distributed actor %2",
48154809
(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
@@ -1237,20 +1237,17 @@ class GetDistributedRemoteCallArgumentInitFunctionRequest :
12371237
///
12381238
/// The thunk is responsible for invoking 'remoteCall' when invoked on a remote
12391239
/// 'distributed actor'.
1240-
class GetDistributedThunkRequest
1241-
: public SimpleRequest<
1242-
GetDistributedThunkRequest,
1243-
FuncDecl *(llvm::PointerUnion<VarDecl *, AbstractFunctionDecl *>),
1244-
RequestFlags::Cached> {
1245-
using Originator = llvm::PointerUnion<VarDecl *, AbstractFunctionDecl *>;
1246-
1240+
class GetDistributedThunkRequest :
1241+
public SimpleRequest<GetDistributedThunkRequest,
1242+
FuncDecl *(AbstractFunctionDecl *),
1243+
RequestFlags::Cached> {
12471244
public:
12481245
using SimpleRequest::SimpleRequest;
12491246

12501247
private:
12511248
friend SimpleRequest;
12521249

1253-
FuncDecl *evaluate(Evaluator &evaluator, Originator originator) const;
1250+
FuncDecl *evaluate(Evaluator &evaluator, AbstractFunctionDecl *distributedFunc) const;
12541251

12551252
public:
12561253
// Caching

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ SWIFT_REQUEST(TypeChecker, GetDistributedTargetInvocationResultHandlerOnReturnFu
127127
AbstractFunctionDecl *(NominalTypeDecl *),
128128
Cached, NoLocationInfo)
129129
SWIFT_REQUEST(TypeChecker, GetDistributedThunkRequest,
130-
FuncDecl *(llvm::PointerUnion<VarDecl *, AbstractFunctionDecl *>),
130+
FuncDecl *(AbstractFunctionDecl *),
131131
Cached, NoLocationInfo)
132132
SWIFT_REQUEST(TypeChecker, GetDistributedActorIDPropertyRequest,
133133
VarDecl *(NominalTypeDecl *),

lib/AST/ASTDumper.cpp

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

746746
void visitVarDecl(VarDecl *VD) {
747747
printCommon(VD, "var_decl");
748-
if (VD->isDistributed())
749-
PrintWithColorRAII(OS, DeclModifierColor) << " distributed";
750748
if (VD->isLet())
751749
PrintWithColorRAII(OS, DeclModifierColor) << " let";
752750
if (VD->getAttrs().hasAttribute<LazyAttr>())
@@ -877,9 +875,6 @@ namespace {
877875
if (D->isDistributed()) {
878876
PrintWithColorRAII(OS, ExprModifierColor) << " distributed";
879877
}
880-
if (D->isDistributedThunk()) {
881-
PrintWithColorRAII(OS, ExprModifierColor) << " distributed-thunk";
882-
}
883878

884879
if (auto fac = D->getForeignAsyncConvention()) {
885880
OS << " foreign_async=";
@@ -1353,10 +1348,6 @@ void ValueDecl::dumpRef(raw_ostream &os) const {
13531348
os << " known-to-be-local";
13541349
}
13551350

1356-
if (getAttrs().hasAttribute<DistributedThunkAttr>()) {
1357-
os << " distributed-thunk";
1358-
}
1359-
13601351
// Print location.
13611352
auto &srcMgr = getASTContext().SourceMgr;
13621353
if (getLoc().isValid()) {

lib/AST/ASTMangler.cpp

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

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

lib/AST/DistributedDecl.cpp

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

1293-
bool AbstractFunctionDecl::isDistributedThunk() const {
1294-
return getAttrs().hasAttribute<DistributedThunkAttr>();
1295-
}
1296-
12971293
ConstructorDecl *
12981294
NominalTypeDecl::getDistributedRemoteCallTargetInitFunction() const {
12991295
auto mutableThis = const_cast<NominalTypeDecl *>(this);
@@ -1337,15 +1333,6 @@ AbstractFunctionDecl *ASTContext::getRemoteCallOnDistributedActorSystem(
13371333
/********************** Distributed Actor Properties **************************/
13381334
/******************************************************************************/
13391335

1340-
FuncDecl *VarDecl::getDistributedThunk() const {
1341-
if (!isDistributed())
1342-
return nullptr;
1343-
1344-
auto mutableThis = const_cast<VarDecl *>(this);
1345-
return evaluateOrDefault(getASTContext().evaluator,
1346-
GetDistributedThunkRequest{mutableThis}, nullptr);
1347-
}
1348-
13491336
FuncDecl*
13501337
AbstractFunctionDecl::getDistributedThunk() const {
13511338
if (!isDistributed())

lib/SILGen/SILGenApply.cpp

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

11271127
/// Some special handling may be necessary for thunks:
1128-
if (callSite && callSite->usesDistributedThunk()) {
1129-
constant = SILDeclRef(e->getDecl()).asDistributed();
1128+
if (callSite && callSite->shouldApplyDistributedThunk()) {
1129+
if (auto distributedThunk = cast<AbstractFunctionDecl>(e->getDecl())->getDistributedThunk()) {
1130+
constant = SILDeclRef(distributedThunk).asDistributed();
1131+
}
11301132
} else if (afd->isBackDeployed()) {
11311133
// If we're calling a back deployed function then we need to call a
11321134
// thunk instead that will handle the fallback when the original
@@ -5771,8 +5773,7 @@ RValue SILGenFunction::emitGetAccessor(SILLocation loc, SILDeclRef get,
57715773
ArgumentSource &&selfValue, bool isSuper,
57725774
bool isDirectUse,
57735775
PreparedArguments &&subscriptIndices,
5774-
SGFContext c,
5775-
bool isOnSelfParameter) {
5776+
SGFContext c, bool isOnSelfParameter) {
57765777
// Scope any further writeback just within this operation.
57775778
FormalEvaluationScope writebackScope(*this);
57785779

@@ -5846,8 +5847,8 @@ void SILGenFunction::emitSetAccessor(SILLocation loc, SILDeclRef set,
58465847
ManagedValue SILGenFunction::emitAddressorAccessor(
58475848
SILLocation loc, SILDeclRef addressor, SubstitutionMap substitutions,
58485849
ArgumentSource &&selfValue, bool isSuper, bool isDirectUse,
5849-
PreparedArguments &&subscriptIndices,
5850-
SILType addressType, bool isOnSelfParameter) {
5850+
PreparedArguments &&subscriptIndices, SILType addressType,
5851+
bool isOnSelfParameter) {
58515852
// Scope any further writeback just within this operation.
58525853
FormalEvaluationScope writebackScope(*this);
58535854

@@ -5908,8 +5909,7 @@ SILGenFunction::emitCoroutineAccessor(SILLocation loc, SILDeclRef accessor,
59085909
Callee callee =
59095910
emitSpecializedAccessorFunctionRef(*this, loc, accessor,
59105911
substitutions, selfValue,
5911-
isSuper, isDirectUse,
5912-
isOnSelfParameter);
5912+
isSuper, isDirectUse, isOnSelfParameter);
59135913

59145914
// We're already in a full formal-evaluation scope.
59155915
// 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
@@ -212,7 +212,6 @@ void SILGenFunction::emitDistActorIdentityInit(ConstructorDecl *ctor,
212212
initializeProperty(*this, loc, borrowedSelfArg, var, temp);
213213
}
214214

215-
// TODO(distributed): rename to DistributedActorID
216215
InitializeDistActorIdentity::InitializeDistActorIdentity(ConstructorDecl *ctor,
217216
ManagedValue actorSelf)
218217
: 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)