Merge pull request #76250 from ktoso/wip-experimental-isolated-deinit

This commit is contained in:
Konrad `ktoso` Malawski
2024-10-03 17:19:10 +09:00
committed by GitHub
88 changed files with 4172 additions and 504 deletions

View File

@@ -1011,3 +1011,25 @@ bool Lowering::usesObjCAllocator(ClassDecl *theClass) {
// allocation methods because they may have been overridden.
return theClass->getObjectModel() == ReferenceCounting::ObjC;
}
bool Lowering::needsIsolatingDestructor(DestructorDecl *dd) {
auto ai = swift::getActorIsolation(dd);
if (!ai.isActorIsolated()) {
return false;
}
DestructorDecl *firstIsolated = dd;
while (true) {
DestructorDecl *next = firstIsolated->getSuperDeinit();
if (!next)
break;
auto ai = swift::getActorIsolation(next);
if (!ai.isActorIsolated())
break;
firstIsolated = next;
}
// If isolation was introduced in ObjC code, then we assume that ObjC code
// also overrides retain/release to make sure that dealloc is called on the
// correct executor in the first place.
return firstIsolated->getClangNode().isNull();
}