Skip to content

Revert Initial distributed, some issues to be fixed first #37556

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 2 commits into from
May 21, 2021
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
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,6 @@ option(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY
"Enable experimental Swift concurrency model"
FALSE)

option(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED
"Enable experimental distributed actors and functions"
FALSE)

option(SWIFT_ENABLE_DISPATCH
"Enable use of libdispatch"
TRUE)
Expand Down Expand Up @@ -905,7 +901,6 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)

message(STATUS "Differentiable Programming Support: ${SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING}")
message(STATUS "Concurrency Support: ${SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY}")
message(STATUS "Distributed Support: ${SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED}")
message(STATUS "")
else()
message(STATUS "Not building Swift standard library, SDK overlays, and runtime")
Expand Down
1 change: 0 additions & 1 deletion include/swift/AST/ASTMangler.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class ASTMangler : public Mangler {
DynamicThunk,
SwiftAsObjCThunk,
ObjCAsSwiftThunk,
DistributedThunk,
};

ASTMangler(bool DWARFMangling = false)
Expand Down
11 changes: 1 addition & 10 deletions include/swift/AST/ActorIsolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ class ActorIsolation {
/// For example, a mutable stored property or synchronous function within
/// the actor is isolated to the instance of that actor.
ActorInstance,
/// The declaration is isolated to a (potentially) distributed actor.
/// Distributed actors may access _their_ state (same as 'ActorInstance')
/// however others may not access any properties on other distributed actors.
DistributedActorInstance,
/// The declaration is explicitly specified to be independent of any actor,
/// meaning that it can be used from any actor but is also unable to
/// refer to the isolated state of any given actor.
Expand Down Expand Up @@ -92,10 +88,6 @@ class ActorIsolation {
return ActorIsolation(ActorInstance, actor);
}

static ActorIsolation forDistributedActorInstance(NominalTypeDecl *actor) {
return ActorIsolation(DistributedActorInstance, actor);
}

static ActorIsolation forGlobalActor(Type globalActor, bool unsafe) {
return ActorIsolation(
unsafe ? GlobalActorUnsafe : GlobalActor, globalActor);
Expand All @@ -108,7 +100,7 @@ class ActorIsolation {
bool isUnspecified() const { return kind == Unspecified; }

NominalTypeDecl *getActor() const {
assert(getKind() == ActorInstance || getKind() == DistributedActorInstance);
assert(getKind() == ActorInstance);
return actor;
}

Expand Down Expand Up @@ -139,7 +131,6 @@ class ActorIsolation {
return true;

case ActorInstance:
case DistributedActorInstance:
return lhs.actor == rhs.actor;

case GlobalActor:
Expand Down
15 changes: 0 additions & 15 deletions include/swift/AST/Attr.def
Original file line number Diff line number Diff line change
Expand Up @@ -655,21 +655,6 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(spawn, Spawn,
APIBreakingToAdd | APIBreakingToRemove,
117)

CONTEXTUAL_SIMPLE_DECL_ATTR(distributed, DistributedActor,
DeclModifier | OnClass | OnFunc |
DistributedOnly |
ABIBreakingToAdd | ABIBreakingToRemove |
APIBreakingToAdd | APIBreakingToRemove,
118)

SIMPLE_DECL_ATTR(_distributedActorIndependent, DistributedActorIndependent,
OnFunc | OnVar |
DistributedOnly | UserInaccessible |
ABIStableToAdd | ABIStableToRemove |
APIBreakingToAdd | APIBreakingToRemove,
119)


#undef TYPE_ATTR
#undef DECL_ATTR_ALIAS
#undef CONTEXTUAL_DECL_ATTR_ALIAS
Expand Down
7 changes: 0 additions & 7 deletions include/swift/AST/Attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,6 @@ class DeclAttribute : public AttributeBase {

/// Whether this attribute is only valid when concurrency is enabled.
ConcurrencyOnly = 1ull << (unsigned(DeclKindIndex::Last_Decl) + 16),

/// Whether this attribute is only valid when distributed is enabled.
DistributedOnly = 1ull << (unsigned(DeclKindIndex::Last_Decl) + 17),
};

LLVM_READNONE
Expand Down Expand Up @@ -391,10 +388,6 @@ class DeclAttribute : public AttributeBase {
return getOptions(DK) & ConcurrencyOnly;
}

static bool isDistributedOnly(DeclAttrKind DK) {
return getOptions(DK) & DistributedOnly;
}

static bool isUserInaccessible(DeclAttrKind DK) {
return getOptions(DK) & UserInaccessible;
}
Expand Down
8 changes: 0 additions & 8 deletions include/swift/AST/Builtins.def
Original file line number Diff line number Diff line change
Expand Up @@ -724,14 +724,6 @@ BUILTIN_MISC_OPERATION(InitializeDefaultActor, "initializeDefaultActor", "", Spe
/// Destroy the default-actor instance in a default actor object.
BUILTIN_MISC_OPERATION(DestroyDefaultActor, "destroyDefaultActor", "", Special)

/// Initialize a "proxy" for a distributed remote actor.
BUILTIN_MISC_OPERATION(InitializeDistributedRemoteActor,
"initializeDistributedRemoteActor", "", Special)

/// Destroy the distributed-actor instance in a "proxy" actor object.
BUILTIN_MISC_OPERATION(DestroyDistributedActor,
"destroyDistributedActor", "", Special)

/// Resume a non-throwing continuation normally with the given result.
BUILTIN_MISC_OPERATION(ResumeNonThrowingContinuationReturning,
"resumeNonThrowingContinuationReturning", "", Special)
Expand Down
43 changes: 1 addition & 42 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2346,8 +2346,6 @@ class ValueDecl : public Decl {
/// Is this declaration marked with 'dynamic'?
bool isDynamic() const;

bool isDistributedActorIndependent() const;

private:
bool isObjCDynamic() const {
return isObjC() && isDynamic();
Expand Down Expand Up @@ -3166,11 +3164,6 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
OptionSet<LookupDirectFlags> flags =
OptionSet<LookupDirectFlags>());

/// Find the '_remote_<...>' counterpart function to a 'distributed func'.
///
/// If the passed in function is not distributed this function returns null.
AbstractFunctionDecl* lookupDirectRemoteFunc(AbstractFunctionDecl *func);

/// Collect the set of protocols to which this type should implicitly
/// conform, such as AnyObject (for classes).
void getImplicitProtocols(SmallVectorImpl<ProtocolDecl *> &protocols);
Expand Down Expand Up @@ -3227,10 +3220,6 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
/// `Actor` protocol.
bool isActor() const;

/// Whether this nominal type qualifies as a distributed actor, meaning that
/// it is either a distributed actor.
bool isDistributedActor() const;

/// Return the range of semantics attributes attached to this NominalTypeDecl.
auto getSemanticsAttrs() const
-> decltype(getAttrs().getSemanticsAttrs()) {
Expand Down Expand Up @@ -3299,8 +3288,6 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
/// for types that are not global actors.
VarDecl *getGlobalActorInstance() const;

bool hasDistributedActorLocalInitializer() const;

/// Whether this type is a global actor, which can be used as an
/// attribute to decorate declarations for inclusion in the actor-isolated
/// state denoted by this type.
Expand Down Expand Up @@ -4016,7 +4003,6 @@ enum class KnownDerivableProtocolKind : uint8_t {
AdditiveArithmetic,
Differentiable,
Actor,
DistributedActor,
};

/// ProtocolDecl - A declaration of a protocol, for example:
Expand Down Expand Up @@ -4210,10 +4196,6 @@ class ProtocolDecl final : public NominalTypeDecl {
/// semantics but has no corresponding witness table.
bool isMarkerProtocol() const;

/// Is a protocol that can only be conformed by distributed actors.
/// Such protocols are allowed to contain distributed functions.
bool inheritsFromDistributedActor() const;

private:
void computeKnownProtocolKind() const;

Expand Down Expand Up @@ -4732,8 +4714,6 @@ class AbstractStorageDecl : public ValueDecl {

bool hasAnyNativeDynamicAccessors() const;

bool isDistributedActorIndependent() const;

// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
return D->getKind() >= DeclKind::First_AbstractStorageDecl &&
Expand Down Expand Up @@ -5190,20 +5170,14 @@ class VarDecl : public AbstractStorageDecl {
return getAttrs().getAttributes<SemanticsAttr>();
}

/// Returns true if this VarDecl has the string \p attrValue as a semantics
/// Returns true if this VarDelc has the string \p attrValue as a semantics
/// attribute.
bool hasSemanticsAttr(StringRef attrValue) const {
return llvm::any_of(getSemanticsAttrs(), [&](const SemanticsAttr *attr) {
return attrValue.equals(attr->Value);
});
}

/// Whether the given name is actorAddress, which is used for distributed actors.
static bool isDistributedActorAddressName(ASTContext &ctx, DeclName name);

/// Whether the given name is actorTransport, which is used for distributed actors.
static bool isDistributedActorTransportName(ASTContext &ctx, DeclName name);

// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
return D->getKind() == DeclKind::Var || D->getKind() == DeclKind::Param;
Expand Down Expand Up @@ -5881,9 +5855,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
/// Returns if the function is 'rethrows' or 'reasync'.
bool hasPolymorphicEffect(EffectKind kind) const;

/// Returns 'true' if the function is distributed.
bool isDistributed() const;

PolymorphicEffectKind getPolymorphicEffectKind(EffectKind kind) const;

// FIXME: Hack that provides names with keyword arguments for accessors.
Expand Down Expand Up @@ -6893,18 +6864,6 @@ class ConstructorDecl : public AbstractFunctionDecl {
/// \endcode
bool isObjCZeroParameterWithLongSelector() const;

/// Checks if the initializer is a distributed actor's 'local' initializer:
/// ```
/// init(transport: ActorTransport)
/// ```
bool isDistributedActorLocalInit() const;

/// Checks if the initializer is a distributed actor's 'resolve' initializer:
/// ```
/// init(resolve address: ActorAddress, using transport: ActorTransport)
/// ```
bool isDistributedActorResolveInit() const;

static bool classof(const Decl *D) {
return D->getKind() == DeclKind::Constructor;
}
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/DiagnosticsParse.def
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,7 @@ ERROR(pound_available_package_description_not_allowed, none,
ERROR(availability_query_repeated_platform, none,
"version for '%0' already specified", (StringRef))

ERROR(attr_requires_concurrency, none,
ERROR(attr_requires_concurrency,none,
"'%0' %select{attribute|modifier}1 is only valid when experimental "
"concurrency is enabled",
(StringRef, bool))
Expand Down
91 changes: 2 additions & 89 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -4362,13 +4362,6 @@ ERROR(actor_isolated_non_self_reference,none,
"actor-isolated %0 %1 can only be %select{referenced|mutated|used 'inout'}3 "
"%select{from inside the actor|on 'self'}2",
(DescriptiveDeclKind, DeclName, bool, unsigned))
ERROR(distributed_actor_isolated_non_self_reference,none,
"distributed actor-isolated %0 %1 can only be referenced "
"inside the distributed actor",
(DescriptiveDeclKind, DeclName))
ERROR(distributed_actor_needs_explicit_distributed_import,none,
"'_Distributed' module not imported, required for 'distributed actor'",
())
ERROR(actor_isolated_self_independent_context,none,
"actor-isolated %0 %1 can not be %select{referenced|mutated|used 'inout'}2 from a "
"non-isolated context",
Expand Down Expand Up @@ -4418,8 +4411,8 @@ ERROR(actor_isolated_from_async_let,none,
"actor-isolated %0 %1 cannot be %select{referenced|mutated|used 'inout'}2 from 'async let' initializer",
(DescriptiveDeclKind, DeclName, unsigned))
ERROR(actor_isolated_keypath_component,none,
"cannot form key path to%select{| distributed}0 actor-isolated %1 %2",
(bool, DescriptiveDeclKind, DeclName))
"cannot form key path to actor-isolated %0 %1",
(DescriptiveDeclKind, DeclName))
ERROR(effectful_keypath_component,none,
"cannot form key path to %0 with 'throws' or 'async'",
(DescriptiveDeclKind))
Expand All @@ -4434,32 +4427,6 @@ NOTE(actor_isolated_sync_func,none,
"calls to %0 %1 from outside of its actor context are "
"implicitly asynchronous",
(DescriptiveDeclKind, DeclName))
NOTE(distributed_actor_isolated_method_note,none,
"only 'distributed' functions can be called from outside the distributed actor",
())
ERROR(distributed_actor_isolated_method,none,
"only 'distributed' functions can be called from outside the distributed actor", // TODO: more like 'non-distributed' ... defined here
())
ERROR(distributed_actor_func_param_not_codable,none,
"distributed function parameter '%0' of type %1 does not conform to 'Codable'",
(StringRef, Type))
ERROR(distributed_actor_func_result_not_codable,none,
"distributed function result type %0 does not conform to 'Codable'",
(Type))
ERROR(distributed_actor_func_missing_remote_func,none,
"distributed function is missing its remote static func implementation (%0). "
"You may want to use a distributed actor SwiftPM plugin to generate those, "
"or implement it manually.",
(Identifier))
ERROR(distributed_actor_remote_func_is_not_static,none,
"remote function %0 must be static.",
(DeclName))
ERROR(distributed_actor_remote_func_is_not_async_throws,none,
"remote function %0 must be 'async throws'.",
(DeclName))
ERROR(distributed_actor_remote_func_must_not_be_distributed,none,
"remote function %0 must be 'async throws'.",
(DeclName))
NOTE(actor_mutable_state,none,
"mutation of this %0 is only permitted within the actor",
(DescriptiveDeclKind))
Expand Down Expand Up @@ -4538,60 +4505,6 @@ ERROR(actor_instance_property_wrapper,none,
"the actor instance; consider 'nonisolated'",
(Identifier, Identifier))

ERROR(distributed_actor_func_defined_outside_of_distributed_actor,none,
"distributed function %0 is declared outside of an distributed actor",
(DeclName))
ERROR(distributed_actor_local_init_explicitly_defined,none,
"'distributed actor' local-initializer 'init(transport:)' "
"cannot be implemented explicitly.",
())
ERROR(distributed_actor_init_resolve_must_not_be_user_defined,none,
"'distributed actor' resolve-initializer 'init(resolve:using:)' "
"cannot be implemented explicitly.",
())
ERROR(distributed_actor_init_user_defined_must_be_convenience,none,
"'distributed actor' initializer %0 must be 'convenience' initializer. "
"Distributed actors have an implicitly synthesized designated "
"'init(transport:)' local-initializer, which other initializers must delegate to",
(DeclName))
ERROR(distributed_actor_init_must_delegate_to_local_init,none,
"'distributed actor' initializer %0 must (directly or indirectly) delegate "
"to 'init(transport:)'",
(DeclName))
ERROR(distributed_actor_init_must_not_delegate_to_resolve_init,none,
"'distributed actor' initializer %0 cannot delegate to resolve-initializer "
"'init(resolve:using:)', as it may result resolving a storageless proxy instance",
(DeclName))
ERROR(distributed_actor_local_var,none,
"'distributed' can not be applied to local variables",
())
ERROR(distributed_actor_property,none,
"'distributed' can not be applied to local properties",
())
ERROR(distributed_actor_storage,none,
"'distributed' can not be applied to actor properties; "
"Only functions can be 'distributed'",
())
ERROR(distributed_actor_not_actor,none,
"'distributed' can only be applied to 'actor' definitions, "
"and distributed actor-isolated async functions",
())
ERROR(distributed_actor_not_actor_func,none,
"'distributed' can only be applied to distributed actor async functions",
())
ERROR(distributed_actor_func_static,none,
"'distributed' functions cannot be 'static'",
())
ERROR(distributed_actor_func_not_in_distributed_actor,none,
"'distributed' function can only be declared within 'distributed actor'",
())
ERROR(distributed_actor_independent_property_must_be_let,none,
"_distributedActorIndependent can be applied to properties, however they must be 'let'",
())
NOTE(distributed_actor_isolated_property,none,
"distributed actor state is only available within the actor instance",
())

ERROR(concurrency_lib_missing,none,
"missing '%0' declaration, probably because the '_Concurrency' "
"module was not imported", (StringRef))
Expand Down
Loading