Skip to content

Commit 791c1fd

Browse files
authored
Merge pull request #76237 from swiftlang/revert-60057-mpokhylets/isolated-deinit
Revert "Isolated synchronous deinit"
2 parents c29788a + c5aa49b commit 791c1fd

File tree

88 files changed

+509
-4226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+509
-4226
lines changed

docs/ABI/Mangling.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ Entities
365365
entity-spec ::= 'fP' // property wrapper backing initializer
366366
entity-spec ::= 'fW' // property wrapper init from projected value
367367
entity-spec ::= 'fD' // deallocating destructor; untyped
368-
entity-spec ::= 'fZ' // isolated deallocating destructor; untyped
369368
entity-spec ::= 'fd' // non-deallocating destructor; untyped
370369
entity-spec ::= 'fE' // ivar destroyer; untyped
371370
entity-spec ::= 'fe' // ivar initializer; untyped

include/swift/ABI/Executor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ using ThrowingTaskFutureWaitContinuationFunction =
295295
SWIFT_CC(swiftasync)
296296
void (SWIFT_ASYNC_CONTEXT AsyncContext *, SWIFT_CONTEXT void *);
297297

298-
using DeinitWorkFunction = SWIFT_CC(swift) void(void *);
299298

300299
template <class AsyncSignature>
301300
class AsyncFunctionPointer;

include/swift/ABI/MetadataValues.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,8 +2490,7 @@ enum class JobKind : size_t {
24902490
DefaultActorInline = First_Reserved,
24912491
DefaultActorSeparate,
24922492
DefaultActorOverride,
2493-
NullaryContinuation,
2494-
IsolatedDeinit,
2493+
NullaryContinuation
24952494
};
24962495

24972496
/// The priority of a job. Higher priorities are larger values.

include/swift/AST/ASTMangler.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ class RootProtocolConformance;
3434

3535
namespace Mangle {
3636

37-
enum class DestructorKind {
38-
NonDeallocating,
39-
Deallocating,
40-
IsolatedDeallocating
41-
};
42-
4337
/// The mangler for AST declarations.
4438
class ASTMangler : public Mangler {
4539
protected:
@@ -211,7 +205,7 @@ class ASTMangler : public Mangler {
211205
SymbolKind SKind = SymbolKind::Default);
212206

213207
std::string mangleDestructorEntity(const DestructorDecl *decl,
214-
DestructorKind kind,
208+
bool isDeallocating,
215209
SymbolKind SKind = SymbolKind::Default);
216210

217211
std::string mangleConstructorEntity(const ConstructorDecl *ctor,
@@ -709,8 +703,8 @@ class ASTMangler : public Mangler {
709703
bool tryAppendStandardSubstitution(const GenericTypeDecl *type);
710704

711705
void appendConstructorEntity(const ConstructorDecl *ctor, bool isAllocating);
712-
713-
void appendDestructorEntity(const DestructorDecl *decl, DestructorKind kind);
706+
707+
void appendDestructorEntity(const DestructorDecl *decl, bool isDeallocating);
714708

715709
/// \param accessorKindCode The code to describe the accessor and addressor
716710
/// kind. Usually retrieved using getCodeForAccessorKind.

include/swift/AST/Decl.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,10 +1368,6 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
13681368
std::optional<std::pair<CustomAttr *, NominalTypeDecl *>>
13691369
getGlobalActorAttr() const;
13701370

1371-
/// Determine whether there is an explicit isolation attribute
1372-
/// of any kind.
1373-
bool hasExplicitIsolationAttribute() const;
1374-
13751371
/// If an alternative module name is specified for this decl, e.g. using
13761372
/// @_originalDefinedIn attribute, this function returns this module name.
13771373
StringRef getAlternateModuleName() const;
@@ -3147,10 +3143,6 @@ class ValueDecl : public Decl {
31473143
/// Retrieve the declaration that this declaration overrides, if any.
31483144
ValueDecl *getOverriddenDecl() const;
31493145

3150-
/// Retrieve the declaration that this declaration overrides, including super
3151-
/// deinit.
3152-
ValueDecl *getOverriddenDeclOrSuperDeinit() const;
3153-
31543146
/// Retrieve the declarations that this declaration overrides, if any.
31553147
llvm::TinyPtrVector<ValueDecl *> getOverriddenDecls() const;
31563148

@@ -8915,10 +8907,6 @@ class DestructorDecl : public AbstractFunctionDecl {
89158907
/// Retrieve the Objective-C selector for destructors.
89168908
ObjCSelector getObjCSelector() const;
89178909

8918-
/// Retrieves destructor decl from the superclass, or nil if there is no
8919-
/// superclass
8920-
DestructorDecl *getSuperDeinit() const;
8921-
89228910
static bool classof(const Decl *D) {
89238911
return D->getKind() == DeclKind::Destructor;
89248912
}

include/swift/AST/DeclAttr.def

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,17 +434,14 @@ SIMPLE_DECL_ATTR(rethrows, Rethrows,
434434
CONTEXTUAL_SIMPLE_DECL_ATTR(indirect, Indirect,
435435
DeclModifier | OnEnum | OnEnumElement | ABIBreakingToAdd | ABIBreakingToRemove | APIStableToAdd | APIStableToRemove,
436436
60)
437-
CONTEXTUAL_SIMPLE_DECL_ATTR(isolated, Isolated,
438-
DeclModifier | OnDestructor | ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove,
439-
103)
440437
CONTEXTUAL_SIMPLE_DECL_ATTR(async, Async,
441438
DeclModifier | OnVar | OnFunc | ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove,
442439
106)
443440
SIMPLE_DECL_ATTR(reasync, Reasync,
444441
OnFunc | OnConstructor | RejectByParser | ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove,
445442
109)
446443
CONTEXTUAL_DECL_ATTR(nonisolated, Nonisolated,
447-
DeclModifier | OnFunc | OnConstructor | OnDestructor | OnVar | OnSubscript | ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove,
444+
DeclModifier | OnFunc | OnConstructor | OnVar | OnSubscript | ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove,
448445
112)
449446
CONTEXTUAL_SIMPLE_DECL_ATTR(distributed, DistributedActor,
450447
DeclModifier | OnClass | OnFunc | OnAccessor | OnVar | ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove,

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5883,12 +5883,9 @@ ERROR(global_actor_not_usable_from_inline,none,
58835883
NOTE(move_global_actor_attr_to_storage_decl,none,
58845884
"move global actor attribute to %kind0", (const ValueDecl *))
58855885

5886-
ERROR(actor_isolation_multiple_attr_2,none,
5886+
ERROR(actor_isolation_multiple_attr,none,
58875887
"%kind0 has multiple actor-isolation attributes ('%1' and '%2')",
58885888
(const Decl *, StringRef, StringRef))
5889-
ERROR(actor_isolation_multiple_attr_3,none,
5890-
"%0 %1 has multiple actor-isolation attributes ('%2', '%3' and '%4')",
5891-
(const Decl *, StringRef, StringRef, StringRef))
58925889
ERROR(actor_isolation_override_mismatch,none,
58935890
"%0 %kind1 has different actor isolation from %2 overridden declaration",
58945891
(ActorIsolation, const ValueDecl *, ActorIsolation))
@@ -5905,14 +5902,6 @@ ERROR(async_named_decl_must_be_available_from_async,none,
59055902
ERROR(async_unavailable_decl,none,
59065903
"%kindbase0 is unavailable from asynchronous contexts%select{|; %1}1",
59075904
(const ValueDecl *, StringRef))
5908-
5909-
5910-
ERROR(isolated_deinit_no_isolation,none,
5911-
"deinit is marked isolated, but containing class %0 is not isolated to an actor",
5912-
(DeclName))
5913-
ERROR(isolated_deinit_on_value_type,none,
5914-
"only classes and actors can have isolated deinit",
5915-
())
59165905

59175906
//------------------------------------------------------------------------------
59185907
// MARK: String Processing

include/swift/AST/PrintOptions.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ class DeclContext;
3737
class Type;
3838
class ModuleDecl;
3939
enum class DeclAttrKind : unsigned;
40-
class DeclAttribute;
41-
class CustomAttr;
4240
class SynthesizedExtensionAnalyzer;
4341
struct PrintOptions;
4442
class SILPrintContext;
@@ -344,10 +342,6 @@ struct PrintOptions {
344342
/// Suppress emitting @available(*, noasync)
345343
bool SuppressNoAsyncAvailabilityAttr = false;
346344

347-
/// Suppress emitting isolated or async deinit, and emit open containing class
348-
/// as public
349-
bool SuppressIsolatedDeinit = false;
350-
351345
/// Whether to print the \c{/*not inherited*/} comment on factory initializers.
352346
bool PrintFactoryInitializerComment = true;
353347

@@ -399,8 +393,6 @@ struct PrintOptions {
399393
DeclAttrKind::FixedLayout, DeclAttrKind::ShowInInterface,
400394
};
401395

402-
std::vector<CustomAttr *> ExcludeCustomAttrList = {};
403-
404396
/// List of attribute kinds that should be printed exclusively.
405397
/// Empty means allow all.
406398
std::vector<AnyAttrKind> ExclusiveAttrList;
@@ -635,8 +627,6 @@ struct PrintOptions {
635627
return false;
636628
}
637629

638-
bool excludeAttr(const DeclAttribute *DA) const;
639-
640630
/// Retrieve the set of options for verbose printing to users.
641631
static PrintOptions printVerbose() {
642632
PrintOptions result;
@@ -692,8 +682,7 @@ struct PrintOptions {
692682
result.SkipPrivateSystemDecls = true;
693683
result.SkipUnderscoredSystemProtocols = true;
694684
result.SkipUnsafeCXXMethods = true;
695-
result.SkipDeinit = false; // Deinit may have isolation attributes, which
696-
// are part of the interface
685+
result.SkipDeinit = true;
697686
result.EmptyLineBetweenDecls = true;
698687
result.CascadeDocComment = true;
699688
result.ShouldQualifyNestedDeclarations =

include/swift/Basic/Features.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,6 @@ SUPPRESSIBLE_EXPERIMENTAL_FEATURE(AllowUnsafeAttribute, true)
408408
/// Warn on use of unsafe constructs.
409409
EXPERIMENTAL_FEATURE(WarnUnsafe, true)
410410

411-
SUPPRESSIBLE_LANGUAGE_FEATURE(IsolatedDeinit, 371, "isolated/async deinit")
412-
413411
#undef EXPERIMENTAL_FEATURE_EXCLUDED_FROM_MODULE_INTERFACE
414412
#undef EXPERIMENTAL_FEATURE
415413
#undef UPCOMING_FEATURE

include/swift/Demangling/DemangleNodes.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ NODE(InfixOperator)
153153
CONTEXT_NODE(Initializer)
154154
CONTEXT_NODE(InitAccessor)
155155
NODE(Isolated)
156-
CONTEXT_NODE(IsolatedDeallocator)
157156
NODE(Sending)
158157
NODE(IsolatedAnyFunctionType)
159158
NODE(SendingResultFunctionType)

include/swift/Runtime/Concurrency.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -605,11 +605,6 @@ swift_task_createNullaryContinuationJob(
605605
size_t priority,
606606
AsyncTask *continuation);
607607

608-
SWIFT_EXPORT_FROM(swift_Concurrency)
609-
SWIFT_CC(swift)
610-
void swift_task_deinitOnExecutor(void *object, DeinitWorkFunction *work,
611-
SerialExecutorRef newExecutor, size_t flags);
612-
613608
/// Report error about attempting to bind a task-local value from an illegal context.
614609
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
615610
void swift_task_reportIllegalTaskLocalBindingWithinWithTaskGroup(

include/swift/Runtime/RuntimeFunctions.def

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,7 +2278,7 @@ FUNCTION(GetTypeByMangledNameInContextInMetadataState2,
22782278
EFFECT(MetaData),
22792279
MEMEFFECTS(ArgMemOnly))
22802280

2281-
// AsyncTask *swift_task_getCurrent();
2281+
// AsyncTask *swift_task_getCurrent();s
22822282
FUNCTION(GetCurrentTask,
22832283
swift_task_getCurrent, SwiftCC,
22842284
ConcurrencyAvailability,
@@ -2347,20 +2347,6 @@ FUNCTION(TaskSwitchFunc,
23472347
ATTRS(NoUnwind),
23482348
EFFECT(Concurrency),
23492349
UNKNOWN_MEMEFFECTS)
2350-
2351-
// void swift_task_deinitOnExecutor(void *object,
2352-
// DeinitWorkFunction *work,
2353-
// SerialExecutorRef newExecutor,
2354-
// size_t flags);
2355-
FUNCTION(DeinitOnExecutorFunc,
2356-
swift_task_deinitOnExecutor, SwiftCC,
2357-
ConcurrencyAvailability,
2358-
RETURNS(VoidTy),
2359-
ARGS(Int8PtrTy, Int8PtrTy, ExecutorFirstTy, ExecutorSecondTy, SizeTy),
2360-
ATTRS(NoUnwind),
2361-
EFFECT(Concurrency),
2362-
UNKNOWN_MEMEFFECTS)
2363-
23642350

23652351
// AsyncTask *swift_continuation_init(AsyncContext *continuationContext,
23662352
// AsyncContinuationFlags);

include/swift/SIL/SILDeclRef.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,23 +111,19 @@ struct SILDeclRef {
111111
/// Initializer - this constant references the initializing constructor
112112
/// entry point of the class ConstructorDecl in loc.
113113
Initializer,
114-
114+
115115
/// EnumElement - this constant references the injection function for
116116
/// an EnumElementDecl.
117117
EnumElement,
118-
118+
119119
/// Destroyer - this constant references the destroying destructor for the
120120
/// DestructorDecl in loc.
121121
Destroyer,
122122

123123
/// Deallocator - this constant references the deallocating
124124
/// destructor for the DestructorDecl in loc.
125125
Deallocator,
126-
127-
/// Deallocator - this constant references the isolated deallocating
128-
/// destructor for the DestructorDecl in loc.
129-
IsolatedDeallocator,
130-
126+
131127
/// GlobalAccessor - this constant references the lazy-initializing
132128
/// accessor for the global VarDecl in loc.
133129
GlobalAccessor,
@@ -343,8 +339,7 @@ struct SILDeclRef {
343339
}
344340
/// True if the SILDeclRef references a destructor entry point.
345341
bool isDestructor() const {
346-
return kind == Kind::Destroyer || kind == Kind::Deallocator ||
347-
kind == Kind::IsolatedDeallocator;
342+
return kind == Kind::Destroyer || kind == Kind::Deallocator;
348343
}
349344
/// True if the SILDeclRef references an enum entry point.
350345
bool isEnumElement() const {

include/swift/SIL/SILModule.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,9 +1113,6 @@ namespace Lowering {
11131113
/// Determine whether the given class will be allocated/deallocated using the
11141114
/// Objective-C runtime, i.e., +alloc and -dealloc.
11151115
LLVM_LIBRARY_VISIBILITY bool usesObjCAllocator(ClassDecl *theClass);
1116-
/// Determine if isolating destructor is needed.
1117-
LLVM_LIBRARY_VISIBILITY bool needsIsolatingDestructor(DestructorDecl *dd);
1118-
11191116
} // namespace Lowering
11201117
} // namespace swift
11211118

lib/AST/ASTMangler.cpp

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ std::string ASTMangler::mangleEntity(const ValueDecl *decl, SymbolKind SKind) {
129129
}
130130

131131
std::string ASTMangler::mangleDestructorEntity(const DestructorDecl *decl,
132-
DestructorKind kind,
132+
bool isDeallocating,
133133
SymbolKind SKind) {
134134
llvm::SaveAndRestore X(AllowInverses, inversesAllowed(decl));
135135
beginMangling();
136-
appendDestructorEntity(decl, kind);
136+
appendDestructorEntity(decl, isDeallocating);
137137
appendSymbolKind(SKind);
138138
return finalize();
139139
}
@@ -838,7 +838,7 @@ void ASTMangler::appendAnyDecl(const ValueDecl *Decl) {
838838
if (auto Ctor = dyn_cast<ConstructorDecl>(Decl)) {
839839
appendConstructorEntity(Ctor, /*isAllocating=*/false);
840840
} else if (auto Dtor = dyn_cast<DestructorDecl>(Decl)) {
841-
appendDestructorEntity(Dtor, DestructorKind::NonDeallocating);
841+
appendDestructorEntity(Dtor, /*isDeallocating=*/false);
842842
} else if (auto GTD = dyn_cast<GenericTypeDecl>(Decl)) {
843843
appendAnyGenericType(GTD);
844844
} else if (isa<AssociatedTypeDecl>(Decl)) {
@@ -940,7 +940,7 @@ std::string ASTMangler::mangleHasSymbolQuery(const ValueDecl *Decl) {
940940
if (auto Ctor = dyn_cast<ConstructorDecl>(Decl)) {
941941
appendConstructorEntity(Ctor, /*isAllocating=*/false);
942942
} else if (auto Dtor = dyn_cast<DestructorDecl>(Decl)) {
943-
appendDestructorEntity(Dtor, DestructorKind::NonDeallocating);
943+
appendDestructorEntity(Dtor, /*isDeallocating=*/false);
944944
} else if (auto GTD = dyn_cast<GenericTypeDecl>(Decl)) {
945945
appendAnyGenericType(GTD);
946946
} else if (isa<AssociatedTypeDecl>(Decl)) {
@@ -2447,8 +2447,8 @@ void ASTMangler::appendContext(const DeclContext *ctx,
24472447
}
24482448

24492449
if (auto dtor = dyn_cast<DestructorDecl>(fn))
2450-
return appendDestructorEntity(dtor, DestructorKind::NonDeallocating);
2451-
2450+
return appendDestructorEntity(dtor, /*deallocating*/ false);
2451+
24522452
return appendEntity(fn);
24532453
}
24542454

@@ -3953,20 +3953,10 @@ void ASTMangler::appendConstructorEntity(const ConstructorDecl *ctor,
39533953
}
39543954

39553955
void ASTMangler::appendDestructorEntity(const DestructorDecl *dtor,
3956-
DestructorKind kind) {
3956+
bool isDeallocating) {
39573957
BaseEntitySignature base(dtor);
39583958
appendContextOf(dtor, base);
3959-
switch (kind) {
3960-
case DestructorKind::NonDeallocating:
3961-
appendOperator("fd");
3962-
break;
3963-
case DestructorKind::Deallocating:
3964-
appendOperator("fD");
3965-
break;
3966-
case DestructorKind::IsolatedDeallocating:
3967-
appendOperator("fZ");
3968-
break;
3969-
}
3959+
appendOperator(isDeallocating ? "fD" : "fd");
39703960
}
39713961

39723962
void ASTMangler::appendAccessorEntity(StringRef accessorKindCode,

0 commit comments

Comments
 (0)