mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user