Skip to content

🍒[5.7][Distributed] Revert "#59481 distributed-computed-properties" #59701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/swift/AST/ASTMangler.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class ASTMangler : public Mangler {
Type GlobalActorBound,
ModuleDecl *Module);

std::string mangleDistributedThunk(const AbstractFunctionDecl *thunk);
std::string mangleDistributedThunk(const FuncDecl *thunk);

/// Mangle a completion handler block implementation function, used for importing ObjC
/// APIs as async.
Expand Down
8 changes: 1 addition & 7 deletions include/swift/AST/Attr.def
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ SIMPLE_DECL_ATTR(_inheritActorContext, InheritActorContext,
// 117 was 'spawn' and is now unused

CONTEXTUAL_SIMPLE_DECL_ATTR(distributed, DistributedActor,
DeclModifier | OnClass | OnFunc | OnAccessor | OnVar |
DeclModifier | OnClass | OnFunc | OnVar |
ABIBreakingToAdd | ABIBreakingToRemove |
APIBreakingToAdd | APIBreakingToRemove,
118)
Expand Down Expand Up @@ -732,12 +732,6 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(_local, KnownToBeLocal,
APIBreakingToAdd | APIBreakingToRemove,
130)

SIMPLE_DECL_ATTR(_distributed_thunk, DistributedThunk,
OnFunc | UserInaccessible |
ABIBreakingToAdd | ABIBreakingToRemove |
APIBreakingToAdd | APIBreakingToRemove,
131)

// If you're adding a new underscored attribute here, please document it in
// docs/ReferenceGuides/UnderscoredAttributes.md.

Expand Down
8 changes: 0 additions & 8 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5345,10 +5345,6 @@ class VarDecl : public AbstractStorageDecl {
/// Does this have a 'distributed' modifier?
bool isDistributed() const;

/// Return a distributed thunk if this computed property is marked as
/// 'distributed' and and nullptr otherwise.
FuncDecl *getDistributedThunk() const;

/// Is this var known to be a "local" distributed actor,
/// if so the implicit throwing ans some isolation checks can be skipped.
bool isKnownToBeLocal() const;
Expand Down Expand Up @@ -6419,10 +6415,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
/// Returns 'true' if the function is distributed.
bool isDistributed() const;

/// Is this a thunk function used to access a distributed method outside
/// of its actor isolation context?
bool isDistributedThunk() const;

/// For a 'distributed' target (func or computed property),
/// get the 'thunk' responsible for performing the 'remoteCall'.
///
Expand Down
6 changes: 0 additions & 6 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -4633,9 +4633,6 @@ ERROR(distributed_actor_isolated_method,none,
ERROR(distributed_local_cannot_be_used,none,
"'local' cannot be used in user-defined code currently",
())
ERROR(distributed_thunk_cannot_be_used,none,
"'distributed_thunk' cannot be used in user-defined code",
())
ERROR(distributed_actor_func_param_not_codable,none,
"parameter '%0' of type %1 in %2 does not conform to serialization requirement '%3'",
(StringRef, Type, DescriptiveDeclKind, StringRef))
Expand Down Expand Up @@ -4833,9 +4830,6 @@ ERROR(distributed_property_cannot_be_static,none,
ERROR(distributed_property_can_only_be_computed,none,
"%0 %1 cannot be 'distributed', only computed properties can",
(DescriptiveDeclKind, DeclName))
ERROR(distributed_property_accessor_only_get_can_be_distributed,none,
"only 'get' accessors may be 'distributed'",
())
NOTE(distributed_actor_isolated_property,none,
"access to %0 %1 is only permitted within distributed actor %2",
(DescriptiveDeclKind, DeclName, DeclName))
Expand Down
12 changes: 6 additions & 6 deletions include/swift/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class alignas(8) Expr : public ASTAllocated<Expr> {
ImplicitlyAsync : 1,
ImplicitlyThrows : 1,
NoAsync : 1,
UsesDistributedThunk : 1
ShouldApplyDistributedThunk : 1
);

SWIFT_INLINE_BITFIELD_EMPTY(CallExpr, ApplyExpr);
Expand Down Expand Up @@ -4445,7 +4445,7 @@ class ApplyExpr : public Expr {
Bits.ApplyExpr.ImplicitlyAsync = false;
Bits.ApplyExpr.ImplicitlyThrows = false;
Bits.ApplyExpr.NoAsync = false;
Bits.ApplyExpr.UsesDistributedThunk = false;
Bits.ApplyExpr.ShouldApplyDistributedThunk = false;
}

public:
Expand Down Expand Up @@ -4532,11 +4532,11 @@ class ApplyExpr : public Expr {

/// Informs IRGen to that this expression should be applied as its distributed
/// thunk, rather than invoking the function directly.
bool usesDistributedThunk() const {
return Bits.ApplyExpr.UsesDistributedThunk;
bool shouldApplyDistributedThunk() const {
return Bits.ApplyExpr.ShouldApplyDistributedThunk;
}
void setUsesDistributedThunk(bool flag) {
Bits.ApplyExpr.UsesDistributedThunk = flag;
void setShouldApplyDistributedThunk(bool flag) {
Bits.ApplyExpr.ShouldApplyDistributedThunk = flag;
}

ValueDecl *getCalledValue() const;
Expand Down
13 changes: 5 additions & 8 deletions include/swift/AST/TypeCheckRequests.h
Original file line number Diff line number Diff line change
Expand Up @@ -1279,20 +1279,17 @@ class GetDistributedRemoteCallArgumentInitFunctionRequest :
///
/// The thunk is responsible for invoking 'remoteCall' when invoked on a remote
/// 'distributed actor'.
class GetDistributedThunkRequest
: public SimpleRequest<
GetDistributedThunkRequest,
FuncDecl *(llvm::PointerUnion<VarDecl *, AbstractFunctionDecl *>),
RequestFlags::Cached> {
using Originator = llvm::PointerUnion<VarDecl *, AbstractFunctionDecl *>;

class GetDistributedThunkRequest :
public SimpleRequest<GetDistributedThunkRequest,
FuncDecl *(AbstractFunctionDecl *),
RequestFlags::Cached> {
public:
using SimpleRequest::SimpleRequest;

private:
friend SimpleRequest;

FuncDecl *evaluate(Evaluator &evaluator, Originator originator) const;
FuncDecl *evaluate(Evaluator &evaluator, AbstractFunctionDecl *distributedFunc) const;

public:
// Caching
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/TypeCheckerTypeIDZone.def
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ SWIFT_REQUEST(TypeChecker, GetDistributedTargetInvocationResultHandlerOnReturnFu
AbstractFunctionDecl *(NominalTypeDecl *),
Cached, NoLocationInfo)
SWIFT_REQUEST(TypeChecker, GetDistributedThunkRequest,
FuncDecl *(llvm::PointerUnion<VarDecl *, AbstractFunctionDecl *>),
FuncDecl *(AbstractFunctionDecl *),
Cached, NoLocationInfo)
SWIFT_REQUEST(TypeChecker, GetDistributedActorIDPropertyRequest,
VarDecl *(NominalTypeDecl *),
Expand Down
9 changes: 0 additions & 9 deletions lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,6 @@ namespace {

void visitVarDecl(VarDecl *VD) {
printCommon(VD, "var_decl");
if (VD->isDistributed())
PrintWithColorRAII(OS, DeclModifierColor) << " distributed";
if (VD->isLet())
PrintWithColorRAII(OS, DeclModifierColor) << " let";
if (VD->getAttrs().hasAttribute<LazyAttr>())
Expand Down Expand Up @@ -874,9 +872,6 @@ namespace {
if (D->isDistributed()) {
PrintWithColorRAII(OS, ExprModifierColor) << " distributed";
}
if (D->isDistributedThunk()) {
PrintWithColorRAII(OS, ExprModifierColor) << " distributed-thunk";
}

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

if (getAttrs().hasAttribute<DistributedThunkAttr>()) {
os << " distributed-thunk";
}

// Print location.
auto &srcMgr = getASTContext().SourceMgr;
if (getLoc().isValid()) {
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/ASTMangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3484,7 +3484,7 @@ ASTMangler::mangleOpaqueTypeDescriptorRecord(const OpaqueTypeDecl *decl) {
return finalize();
}

std::string ASTMangler::mangleDistributedThunk(const AbstractFunctionDecl *thunk) {
std::string ASTMangler::mangleDistributedThunk(const FuncDecl *thunk) {
// Marker protocols cannot be checked at runtime, so there is no point
// in recording them for distributed thunks.
llvm::SaveAndRestore<bool> savedAllowMarkerProtocols(AllowMarkerProtocols,
Expand Down
13 changes: 0 additions & 13 deletions lib/AST/DistributedDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1330,10 +1330,6 @@ bool AbstractFunctionDecl::isDistributed() const {
return getAttrs().hasAttribute<DistributedActorAttr>();
}

bool AbstractFunctionDecl::isDistributedThunk() const {
return getAttrs().hasAttribute<DistributedThunkAttr>();
}

ConstructorDecl *
NominalTypeDecl::getDistributedRemoteCallTargetInitFunction() const {
auto mutableThis = const_cast<NominalTypeDecl *>(this);
Expand Down Expand Up @@ -1377,15 +1373,6 @@ AbstractFunctionDecl *ASTContext::getRemoteCallOnDistributedActorSystem(
/********************** Distributed Actor Properties **************************/
/******************************************************************************/

FuncDecl *VarDecl::getDistributedThunk() const {
if (!isDistributed())
return nullptr;

auto mutableThis = const_cast<VarDecl *>(this);
return evaluateOrDefault(getASTContext().evaluator,
GetDistributedThunkRequest{mutableThis}, nullptr);
}

FuncDecl*
AbstractFunctionDecl::getDistributedThunk() const {
if (!isDistributed())
Expand Down
16 changes: 8 additions & 8 deletions lib/SILGen/SILGenApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,8 +1122,10 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
SILDeclRef constant = SILDeclRef(e->getDecl());

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

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

Expand Down Expand Up @@ -5899,8 +5900,7 @@ SILGenFunction::emitCoroutineAccessor(SILLocation loc, SILDeclRef accessor,
Callee callee =
emitSpecializedAccessorFunctionRef(*this, loc, accessor,
substitutions, selfValue,
isSuper, isDirectUse,
isOnSelfParameter);
isSuper, isDirectUse, isOnSelfParameter);

// We're already in a full formal-evaluation scope.
// Make a dead writeback scope; applyCoroutine won't try to pop this.
Expand Down
1 change: 0 additions & 1 deletion lib/SILGen/SILGenDistributed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ void SILGenFunction::emitDistActorIdentityInit(ConstructorDecl *ctor,
initializeProperty(*this, loc, borrowedSelfArg, var, temp);
}

// TODO(distributed): rename to DistributedActorID
InitializeDistActorIdentity::InitializeDistActorIdentity(ConstructorDecl *ctor,
ManagedValue actorSelf)
: ctor(ctor),
Expand Down
3 changes: 1 addition & 2 deletions lib/SILGen/SILGenFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -1477,8 +1477,7 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
ManagedValue emitAddressorAccessor(
SILLocation loc, SILDeclRef addressor, SubstitutionMap substitutions,
ArgumentSource &&optionalSelfValue, bool isSuper,
bool isDirectAccessorUse,
PreparedArguments &&optionalSubscripts,
bool isDirectAccessorUse, PreparedArguments &&optionalSubscripts,
SILType addressType, bool isOnSelfParameter);

CleanupHandle emitCoroutineAccessor(SILLocation loc, SILDeclRef accessor,
Expand Down
Loading