Skip to content

Commit 62dbc6c

Browse files
Fixed some tests. Using extract_executor SIL instruction instead of custom code.
1 parent b13da72 commit 62dbc6c

12 files changed

+95
-90
lines changed

lib/SILGen/SILGenDestructor.cpp

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -283,18 +283,6 @@ void SILGenFunction::emitDeallocatingMoveOnlyDestructor(DestructorDecl *dd) {
283283
B.createReturn(loc, emitEmptyTuple(loc));
284284
}
285285

286-
// Copied from LowerHopToExecutor.cpp
287-
static AccessorDecl *getUnownedExecutorGetter(ASTContext &ctx,
288-
ProtocolDecl *actorProtocol) {
289-
for (auto member : actorProtocol->getAllMembers()) {
290-
if (auto var = dyn_cast<VarDecl>(member)) {
291-
if (var->getName() == ctx.Id_unownedExecutor)
292-
return var->getAccessor(AccessorKind::Get);
293-
}
294-
}
295-
return nullptr;
296-
}
297-
298286
bool SILGenFunction::shouldEmitIsolatingDestructor(DestructorDecl *dd) {
299287
auto ai = swift::getActorIsolation(dd);
300288
if (!ai.isActorIsolated()) {
@@ -344,44 +332,7 @@ void SILGenFunction::emitIsolatingDestructor(DestructorDecl *dd) {
344332
{
345333
FullExpr CleanupScope(Cleanups, CleanupLocation(loc));
346334
auto actor = *emitExecutor(loc, ai, ManagedValue::forUnmanagedOwnedValue(selfValue));
347-
// hop_to_executor allows actors to be used, which later are lowered to
348-
// executors We don't have such luxury here, and need to lower to executor
349-
// manually.
350-
auto actorType = actor->getType().getASTType();
351-
if (actorType.isExistentialType()) {
352-
auto openedType = OpenedArchetypeType::get(actor->getType().getASTType(),
353-
F.getGenericSignature());
354-
auto opened =
355-
emitOpenExistential(loc, ManagedValue::forBorrowedObjectRValue(actor),
356-
getLoweredType(openedType), AccessKind::Read);
357-
358-
auto actorProtocol =
359-
getASTContext().getProtocol(KnownProtocolKind::Actor);
360-
auto executorAccessor =
361-
getUnownedExecutorGetter(getASTContext(), actorProtocol);
362-
SILDeclRef accessorRef(executorAccessor, SILDeclRef::Kind::Func);
363-
auto conformance = getForwardingSubstitutionMap().lookupConformance(
364-
opened.getType().getASTType(), actorProtocol);
365-
auto constantInfo =
366-
getConstantInfo(getTypeExpansionContext(), accessorRef);
367-
B.createWitnessMethod(loc, openedType, conformance, accessorRef,
368-
constantInfo.getSILType());
369-
370-
executor = opened.getValue();
371-
} else {
372-
ClassDecl *actorClass = actorType.getClassOrBoundGenericClass();
373-
AccessorDecl *unownedExecutorDecl =
374-
actorClass->getUnownedExecutorProperty()->getAccessor(
375-
AccessorKind::Get);
376-
assert(unownedExecutorDecl &&
377-
"no unownedExecutor property in global actor");
378-
SILDeclRef accessorRef(unownedExecutorDecl, SILDeclRef::Kind::Func);
379-
auto accessorFunc = SGM.getFunction(accessorRef, NotForDefinition);
380-
auto accessorFuncRef = B.createFunctionRef(loc, accessorFunc);
381-
SubstitutionMap subs =
382-
actorType->getContextSubstitutionMap(SGM.SwiftModule, actorClass);
383-
executor = B.createApply(loc, accessorFuncRef, subs, {actor});
384-
}
335+
executor = B.createExtractExecutor(loc, actor);
385336
}
386337

387338
// Get performOnExecutor

stdlib/public/Concurrency/Executor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,4 +565,4 @@ internal final class DispatchQueueShim: @unchecked Sendable, SerialExecutor {
565565
@usableFromInline
566566
internal func _performOnExecutor(_ ctx: __owned AnyObject,
567567
_ work: @convention(thin) (__owned AnyObject) -> Void,
568-
_ executor: UnownedSerialExecutor)
568+
_ executor: Builtin.Executor)

test/Concurrency/flow_isolation.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ actor Demons {
125125
self.ns = x
126126
}
127127

128-
deinit {
128+
nonisolated deinit {
129129
let _ = self.ns // expected-warning {{cannot access property 'ns' with a non-sendable type 'NonSendableType' from non-isolated deinit; this is an error in the Swift 6 language mode}}
130130
}
131131
}
@@ -156,7 +156,7 @@ actor ExampleFromProposal {
156156
}
157157

158158

159-
deinit {
159+
nonisolated deinit {
160160
_ = self.immutableSendable // ok
161161
_ = self.mutableSendable // ok
162162
_ = self.nonSendable // expected-warning {{cannot access property 'nonSendable' with a non-sendable type 'NonSendableType' from non-isolated deinit; this is an error in the Swift 6 language mode}}
@@ -196,7 +196,7 @@ class CheckGAIT1 {
196196
silly += 2 // expected-warning {{cannot access property 'silly' here in non-isolated initializer; this is an error in the Swift 6 language mode}}
197197
}
198198

199-
deinit {
199+
nonisolated deinit {
200200
_ = ns // expected-warning {{cannot access property 'ns' with a non-sendable type 'NonSendableType' from non-isolated deinit; this is an error in the Swift 6 language mode}}
201201
f() // expected-note {{after calling instance method 'f()', only non-isolated properties of 'self' can be accessed from a deinit}}
202202
_ = silly // expected-warning {{cannot access property 'silly' here in deinitializer; this is an error in the Swift 6 language mode}}
@@ -729,7 +729,7 @@ actor OhBrother {
729729
@available(SwiftStdlib 5.1, *)
730730
class CheckDeinitFromClass: AwesomeUIView {
731731
var ns: NonSendableType?
732-
deinit {
732+
nonisolated deinit {
733733
ns?.f() // expected-warning {{cannot access property 'ns' with a non-sendable type 'NonSendableType?' from non-isolated deinit; this is an error in the Swift 6 language mode}}
734734
ns = nil // expected-warning {{cannot access property 'ns' with a non-sendable type 'NonSendableType?' from non-isolated deinit; this is an error in the Swift 6 language mode}}
735735
}
@@ -738,7 +738,7 @@ class CheckDeinitFromClass: AwesomeUIView {
738738
@available(SwiftStdlib 5.1, *)
739739
actor CheckDeinitFromActor {
740740
var ns: NonSendableType?
741-
deinit {
741+
nonisolated deinit {
742742
ns?.f() // expected-warning {{cannot access property 'ns' with a non-sendable type 'NonSendableType?' from non-isolated deinit; this is an error in the Swift 6 language mode}}
743743
ns = nil // expected-warning {{cannot access property 'ns' with a non-sendable type 'NonSendableType?' from non-isolated deinit; this is an error in the Swift 6 language mode}}
744744
}

test/Concurrency/predates_concurrency_import_deinit.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ actor ActorWithDeinit {
1515
var ns: NonStrictClass = NonStrictClass()
1616
var ss: StrictStruct = StrictStruct()
1717

18-
deinit {
18+
nonisolated deinit {
1919
print(ns)
2020
print(ss) // expected-warning{{cannot access property 'ss' with a non-sendable type 'StrictStruct' from non-isolated deinit}}
2121
}

test/Distributed/Runtime/distributed_actor_deinit.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ distributed actor DA_userDefined {
2525
self.actorSystem = system
2626
}
2727

28-
deinit {}
28+
nonisolated deinit {}
2929
}
3030

3131
distributed actor DA_userDefined2 {
3232
init(system: FakeActorSystem) {
3333
self.actorSystem = system
3434
}
3535

36-
deinit {
36+
nonisolated deinit {
3737
print("Deinitializing \(self.id) remote:\(__isRemoteActor(self))")
3838
}
3939
}
@@ -46,7 +46,7 @@ distributed actor DA_state {
4646
self.actorSystem = system
4747
}
4848

49-
deinit {
49+
nonisolated deinit {
5050
print("Deinitializing \(self.id) remote:\(__isRemoteActor(self))")
5151
return
5252
}

test/Distributed/Runtime/distributed_actor_remote_fieldsDontCrashDeinit.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ distributed actor SomeSpecificDistributedActor {
2828
self.age = 42
2929
}
3030

31-
deinit {
31+
nonisolated deinit {
3232
print("deinit \(self.id)")
3333
}
3434

test/Distributed/Runtime/distributed_actor_remote_retains_system.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import Distributed
1212

1313
distributed actor SomeSpecificDistributedActor {
14-
deinit {
14+
nonisolated deinit {
1515
print("deinit \(self.id)")
1616
}
1717
}
@@ -40,7 +40,7 @@ final class FakeActorSystem: DistributedActorSystem {
4040
typealias SerializationRequirement = Codable
4141
typealias ResultHandler = FakeResultHandler
4242

43-
deinit {
43+
nonisolated deinit {
4444
print("deinit \(self)")
4545
}
4646

test/ModuleInterface/SmokeTest.swiftinterface

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// RUN: %target-swift-frontend -compile-module-from-interface -o %t/SmokeTest.swiftmodule %s
1414
// RUN: %target-swift-ide-test -print-module -module-to-print SmokeTest -I %t -source-filename x -print-interface > %t/SmokeTest.txt
1515
// RUN: %FileCheck %s < %t/SmokeTest.txt
16-
// RUN: %FileCheck -check-prefix NEGATIVE %s < %t/SmokeTest.txt
1716
// RUN: llvm-bcanalyzer -dump %t/SmokeTest.swiftmodule | grep FILE_DEPENDENCY
1817

1918
// CHECK-LABEL: public class TestClass
@@ -33,7 +32,7 @@ public class TestClass {
3332
// CHECK: public static var propWithNoAccessors: Int{{$}}
3433
public static var propWithNoAccessors: Int
3534

36-
// NEGATIVE-NOT: deinit
35+
// CHECK: deinit
3736
deinit
3837
} // CHECK: {{^}$}}
3938

test/Serialization/Recovery/implementation-only-override.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import FooKit
1818
// CHECK-NEXT: /* placeholder for rwPropSECRET */
1919
// CHECK-NEXT: /* placeholder for subscript(_:) */
2020
// CHECK-NEXT: @_implementationOnly override var redefinedPropSECRET: Parent?
21+
// CHECK-NEXT: deinit
2122
// CHECK-NEXT: }
2223
public class GoodChild: Parent {
2324
public override init() { super.init() }
@@ -48,6 +49,7 @@ public class GoodChild: Parent {
4849
// CHECK-NEXT: /* placeholder for rwPropSECRET */
4950
// CHECK-NEXT: /* placeholder for subscript(_:) */
5051
// CHECK-NEXT: @_implementationOnly override var redefinedPropSECRET: Parent?
52+
// CHECK-NEXT: deinit
5153
// CHECK-NEXT: }
5254
public class GoodGenericChild<Toy>: Parent {
5355
public override init() { super.init() }
@@ -72,6 +74,7 @@ public class GoodGenericChild<Toy>: Parent {
7274
// CHECK-LABEL: class QuietChild : Parent {
7375
// CHECK-NEXT: /* placeholder for init(SECRET:) */
7476
// CHECK-NEXT: /* placeholder for init(requiredSECRET:) */
77+
// CHECK-NEXT: deinit
7578
// CHECK-NEXT: }
7679
public class QuietChild: Parent {
7780
internal override init() { super.init() }
@@ -109,6 +112,7 @@ internal class PrivateGrandchild: GoodChild {
109112

110113
// CHECK-LABEL: class SubscriptChild : SubscriptParent {
111114
// CHECK-NEXT: @_implementationOnly override subscript(index: Int32) -> Parent?
115+
// CHECK-NEXT: deinit
112116
// CHECK-NEXT: }
113117
public class SubscriptChild: SubscriptParent {
114118
@_implementationOnly public override subscript(_ index: Int32) -> Parent? {

0 commit comments

Comments
 (0)