Skip to content

Commit ee5deee

Browse files
committed
TBDGen: Emit method descriptors
1 parent 771eacb commit ee5deee

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

lib/TBDGen/TBDGen.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ void TBDGenVisitor::addDispatchThunk(SILDeclRef declRef) {
8484
addSymbol(entity);
8585
}
8686

87+
void TBDGenVisitor::addMethodDescriptor(SILDeclRef declRef) {
88+
auto entity = LinkEntity::forMethodDescriptor(declRef);
89+
addSymbol(entity);
90+
}
91+
8792
void TBDGenVisitor::addConformances(DeclContext *DC) {
8893
for (auto conformance : DC->getLocalConformances()) {
8994
auto protocol = conformance->getProtocol();
@@ -289,15 +294,8 @@ void TBDGenVisitor::visitClassDecl(ClassDecl *CD) {
289294
}
290295

291296
// Types with resilient superclasses have some extra symbols.
292-
if (!hasResilientAncestor)
293-
return;
294-
295-
addSymbol(LinkEntity::forClassMetadataBaseOffset(CD));
296-
297-
// And classes that are themselves resilient (not just a superclass) have even
298-
// more.
299-
if (!CD->isResilient())
300-
return;
297+
if (hasResilientAncestor)
298+
addSymbol(LinkEntity::forClassMetadataBaseOffset(CD));
301299

302300
// Emit dispatch thunks for every new vtable entry.
303301
struct VTableVisitor : public SILVTableVisitor<VTableVisitor> {
@@ -309,8 +307,11 @@ void TBDGenVisitor::visitClassDecl(ClassDecl *CD) {
309307
: TBD(TBD), CD(CD) {}
310308

311309
void addMethod(SILDeclRef method) {
312-
if (method.getDecl()->getDeclContext() == CD)
313-
TBD.addDispatchThunk(method);
310+
if (method.getDecl()->getDeclContext() == CD) {
311+
if (CD->isResilient())
312+
TBD.addDispatchThunk(method);
313+
TBD.addMethodDescriptor(method);
314+
}
314315
}
315316

316317
void addMethodOverride(SILDeclRef baseRef, SILDeclRef derivedRef) {}
@@ -363,11 +364,9 @@ void TBDGenVisitor::visitProtocolDecl(ProtocolDecl *PD) {
363364

364365
if (PD->isResilient()) {
365366
for (auto *member : PD->getMembers()) {
366-
if (auto *funcDecl = dyn_cast<FuncDecl>(member)) {
367+
if (auto *funcDecl = dyn_cast<AbstractFunctionDecl>(member)) {
367368
addDispatchThunk(SILDeclRef(funcDecl));
368-
}
369-
if (auto *ctorDecl = dyn_cast<ConstructorDecl>(member)) {
370-
addDispatchThunk(SILDeclRef(ctorDecl, SILDeclRef::Kind::Allocator));
369+
addMethodDescriptor(SILDeclRef(funcDecl));
371370
}
372371
}
373372
}

lib/TBDGen/TBDGenVisitor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ class TBDGenVisitor : public ASTVisitor<TBDGenVisitor> {
6262

6363
void addDispatchThunk(SILDeclRef declRef);
6464

65+
void addMethodDescriptor(SILDeclRef declRef);
66+
6567
public:
6668
TBDGenVisitor(tapi::internal::InterfaceFile &symbols,
6769
tapi::internal::ArchitectureSet archs, StringSet *stringSymbols,

0 commit comments

Comments
 (0)