Merge pull request #29219 from aschwaighofer/irgen_fix_zero_size_field_instanceStart_2

IRGen: Correctly compute instanceStart for a Swift class that starts …
This commit is contained in:
Arnold Schwaighofer
2020-01-15 13:06:14 -08:00
committed by GitHub
4 changed files with 53 additions and 4 deletions

View File

@@ -165,6 +165,8 @@ namespace {
ClassMetadataOptions Options;
Size HeaderSize;
public:
ClassLayoutBuilder(IRGenModule &IGM, SILType classType,
ReferenceCounting refcounting,
@@ -178,11 +180,13 @@ namespace {
case ReferenceCounting::Native:
// For native classes, place a full object header.
addHeapHeader();
HeaderSize = CurSize;
break;
case ReferenceCounting::ObjC:
// For ObjC-inheriting classes, we don't reliably know the size of the
// base class, but NSObject only has an `isa` pointer at most.
addNSObjectHeader();
HeaderSize = CurSize;
break;
case ReferenceCounting::Block:
case ReferenceCounting::Unknown:
@@ -222,7 +226,7 @@ namespace {
auto allElements = IGM.Context.AllocateCopy(Elements);
return ClassLayout(*this, Options, classTy,
allStoredProps, allFieldAccesses, allElements);
allStoredProps, allFieldAccesses, allElements, HeaderSize);
}
private: