Pass #1 at localizing assumptions about fixed layout and

handling non-fixed layouts.

This uncovered a bug where we weren't rounding up the header
size to the element alignment when allocating an array of archetypes.

Writing up a detailed test case for *that* revealed that we were
never initializing the length field of heap arrays.  Fixing that
caused a bunch of tests to crash trying to release stuff.  So...
I've left this in a workaround state right now because I have to
catch a plane.

Swift SVN r4804
This commit is contained in:
John McCall
2013-04-18 07:58:21 +00:00
parent 4d617d8508
commit 38b34b7307
20 changed files with 659 additions and 233 deletions

View File

@@ -95,8 +95,8 @@ public:
};
/// A metaprogrammed TypeInfo implementation for sequential types.
template <class Impl, class FieldImpl_>
class SequentialTypeInfo : public FixedTypeInfo { // FIXME: not true!
template <class Impl, class Base, class FieldImpl_>
class SequentialTypeInfo : public Base {
public:
typedef FieldImpl_ FieldImpl;
@@ -116,8 +116,8 @@ private:
protected:
SequentialTypeInfo(llvm::Type *ty, unsigned numFields)
: FixedTypeInfo(ty, Size(0), Alignment(0), IsPOD), NumFields(numFields) {
assert(!isComplete());
: Base(ty, Size(0), Alignment(0), IsPOD), NumFields(numFields) {
assert(!this->isComplete());
}
public:
@@ -208,8 +208,10 @@ public:
void initializeWithCopy(IRGenFunction &IGF, Address dest,
Address src) const {
// If we're POD, use the generic routine.
if (isPOD(ResilienceScope::Local))
return FixedTypeInfo::initializeWithCopy(IGF, dest, src);
if (this->isPOD(ResilienceScope::Local) && Base::isFixedSize()) {
return cast<FixedTypeInfo>(this)->
FixedTypeInfo::initializeWithCopy(IGF, dest, src);
}
for (auto &field : getFields()) {
if (field.isEmpty()) continue;
@@ -343,7 +345,7 @@ public:
minimalExplosionSize += fieldTI.getExplosionSize(ExplosionKind::Minimal);
fieldInfo.MinimalEnd = minimalExplosionSize;
bool isEmpty = fieldTI.isEmpty(ResilienceScope::Local);
bool isEmpty = fieldTI.isKnownEmpty();
fieldInfo.IsEmpty = isEmpty;
}