Skip to content

Commit a58f3fa

Browse files
Updated SILGen for isolated deinit in @objc classes
Failing: Concurrency/flow_isolation.swift
1 parent 8255539 commit a58f3fa

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/SILGen/SILGen.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,17 @@ bool SILGenModule::requiresIVarDestroyer(ClassDecl *cd) {
15731573
/// TODO: This needs a better name.
15741574
void SILGenModule::emitObjCAllocatorDestructor(ClassDecl *cd,
15751575
DestructorDecl *dd) {
1576+
1577+
const bool isActorIsolated = getActorIsolation(dd).isActorIsolated();
1578+
1579+
// Emit the isolated deallocating destructor.
1580+
// If emitted, it implements actual deallocating and deallocating destructor
1581+
// only switches executor
1582+
if (dd->hasBody() && isActorIsolated) {
1583+
SILDeclRef dealloc(dd, SILDeclRef::Kind::IsolatedDeallocator);
1584+
emitFunctionDefinition(dealloc, getFunction(dealloc, ForDefinition));
1585+
}
1586+
15761587
// Emit the native deallocating destructor for -dealloc.
15771588
// Destructors are a necessary part of class metadata, so can't be delayed.
15781589
if (shouldEmitFunctionBody(dd)) {
@@ -1581,7 +1592,7 @@ void SILGenModule::emitObjCAllocatorDestructor(ClassDecl *cd,
15811592

15821593
// Emit the Objective-C -dealloc entry point if it has
15831594
// something to do beyond messaging the superclass's -dealloc.
1584-
if (!dd->getBody()->empty())
1595+
if (!dd->getBody()->empty() || isActorIsolated)
15851596
emitObjCDestructorThunk(dd);
15861597
}
15871598

@@ -1649,7 +1660,7 @@ void SILGenModule::emitDestructor(ClassDecl *cd, DestructorDecl *dd) {
16491660
emitFunctionDefinition(destroyer, getFunction(destroyer, ForDefinition));
16501661
}
16511662

1652-
// Emit the deallocating destructor.
1663+
// Emit the isolated deallocating destructor.
16531664
// If emitted, it implements actual deallocating and deallocating destructor
16541665
// only switches executor
16551666
if (getActorIsolation(dd).isActorIsolated()) {

0 commit comments

Comments
 (0)