Reflection: Compute if types are bitwise takable

Bitwise takability is now part of the layout of a type, because
non-bitwise takable types are never stored inline in an
existential or resilient global's buffer, even if they would
fit.

The basic rule is that weak references, unknown-refcounted
unowned references, and aggregates that contain them, are not
bitwise takable, whereas everything else is bitwise takable.

Also, since the bitwise takable for an unowned reference
depends on the reference counting style, we have to record the
superclass of a protocol, if any, to correctly determine the
reference counting style of the protocol existential.
This commit is contained in:
Slava Pestov
2018-11-05 22:48:55 -05:00
parent 50e5a66bd5
commit 00c1279dbb
44 changed files with 1311 additions and 991 deletions

View File

@@ -541,13 +541,17 @@ private:
return nullptr;
// Initialize the builder.
Builder.addField(*OffsetToFirstCapture, sizeof(StoredPointer),
/*numExtraInhabitants=*/0);
Builder.addField(*OffsetToFirstCapture,
/*alignment=*/sizeof(StoredPointer),
/*numExtraInhabitants=*/0,
/*bitwiseTakable=*/true);
// Skip the closure's necessary bindings struct, if it's present.
auto SizeOfNecessaryBindings = Info.NumBindings * sizeof(StoredPointer);
Builder.addField(SizeOfNecessaryBindings, sizeof(StoredPointer),
/*numExtraInhabitants=*/0);
Builder.addField(/*size=*/SizeOfNecessaryBindings,
/*alignment=*/sizeof(StoredPointer),
/*numExtraInhabitants=*/0,
/*bitwiseTakable=*/true);
// FIXME: should be unordered_set but I'm too lazy to write a hash
// functor