Skip to content

Commit bc9b9a5

Browse files
authored
Runtime: make padding explicit for ElementStorage
The `ElementStorage` member `Capacity` will be padded up to the next pointer alignment due to the storage of the `ElemTy` by C's struct layout rules. However, this is implicit and not entirely guaranteed. Instead, make the storage a pointer sized value, and then truncate to 32-bits to maintain ABI compatibility. This becomes important as we expand on the runtime metadata handling.
1 parent dde3291 commit bc9b9a5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/swift/Runtime/Concurrent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ struct ConcurrentReadableHashMap {
812812
/// the first element of a variable-length array, whose size is determined by
813813
/// the allocation.
814814
struct ElementStorage {
815-
uint32_t Capacity;
815+
uintptr_t Capacity : 32;
816816
ElemTy Elem;
817817

818818
static ElementStorage *allocate(size_t capacity) {

0 commit comments

Comments
 (0)