Skip to content

Commit 16a459d

Browse files
committed
IRGen: Refactor ClassLayoutBuilder a bit to help distinguish resilient-metadata from resilient-storage
We want @_fixed_layout classes to have non-resilient storage, but still have resilient metadata.
1 parent 4289f76 commit 16a459d

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

lib/IRGen/ClassMetadataVisitor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ template <class Impl> class ClassMetadataVisitor
118118
// This must always be the first item in the immediate members.
119119
asImpl().addGenericFields(theClass, theClass);
120120

121-
// If the class is resilient, we cannot make any assumptions about its
122-
// member layout at all, so skip the rest of this method.
121+
// If the class has resilient storage, we cannot make any assumptions about
122+
// its storage layout, so skip the rest of this method.
123123
if (IGM.isResilient(theClass, ResilienceExpansion::Maximal))
124124
return;
125125

lib/IRGen/GenClass.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ namespace {
200200
bool ClassHasGenericLayout = false;
201201

202202
// Is this class or any of its superclasses resilient from the viewpoint
203-
// of the current module? This means that their metadata can change size
204-
// and field offsets, generic arguments and virtual methods must be
203+
// of the current module? This means that their metadata can change size,
204+
// hence field offsets, generic arguments and virtual methods must be
205205
// accessed relative to a metadata base global variable.
206206
bool ClassHasResilientAncestry = false;
207207

@@ -261,14 +261,11 @@ namespace {
261261
return Elements;
262262
}
263263

264-
/// Does the class metadata have a completely known, static layout that
265-
/// does not require initialization at runtime beyond registeration of
266-
/// the class with the Objective-C runtime?
264+
/// Do instances of the class have a completely known, static layout?
267265
bool isFixedSize() const {
268266
return !(ClassHasMissingMembers ||
269267
ClassHasResilientMembers ||
270268
ClassHasGenericLayout ||
271-
ClassHasResilientAncestry ||
272269
ClassHasObjCAncestry);
273270
}
274271

@@ -336,6 +333,7 @@ namespace {
336333
// If the class is resilient, don't walk over its fields; we have to
337334
// calculate the layout at runtime.
338335
ClassHasResilientAncestry = true;
336+
ClassHasResilientMembers = true;
339337

340338
// Furthermore, if the superclass is generic, we have to assume
341339
// that its layout depends on its generic parameters. But this only
@@ -358,6 +356,7 @@ namespace {
358356

359357
if (IGM.isResilient(theClass, ResilienceExpansion::Maximal)) {
360358
ClassHasResilientAncestry = true;
359+
ClassHasResilientMembers = true;
361360
return;
362361
}
363362

lib/IRGen/Linking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ SILLinkage LinkEntity::getLinkage(ForDefinition_t forDefinition) const {
484484

485485
auto linkage = getDeclLinkage(varDecl);
486486

487-
// Resilient classes don't expose field offset symbols.
487+
// Classes with resilient storage don't expose field offset symbols.
488488
if (cast<ClassDecl>(varDecl->getDeclContext())->isResilient()) {
489489
assert(linkage != FormalLinkage::PublicNonUnique &&
490490
"Cannot have a resilient class with non-unique linkage");

0 commit comments

Comments
 (0)