Skip to content

Commit c09a88f

Browse files
authored
[Runtime] Use MetadataAllocator to allocate runtime instantiated layout strings (#66055) (#66068)
rdar://109660582 This will create more visibility into layout string allocations when using swift-inspect.
1 parent ae5afe0 commit c09a88f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

stdlib/public/runtime/Metadata.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2729,8 +2729,8 @@ void swift::swift_initStructMetadataWithLayoutString(
27292729
const size_t fixedLayoutStringSize = layoutStringHeaderSize +
27302730
sizeof(uint64_t) * 2;
27312731

2732-
uint8_t *layoutStr = (uint8_t *)malloc(fixedLayoutStringSize +
2733-
refCountBytes);
2732+
uint8_t *layoutStr = (uint8_t *)MetadataAllocator(LayoutStringTag)
2733+
.Allocate(fixedLayoutStringSize + refCountBytes, alignof(uint8_t));
27342734

27352735
*((size_t*)(layoutStr + sizeof(uint64_t))) = refCountBytes;
27362736

stdlib/public/runtime/MetadataAllocatorTags.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@ TAG(ExtendedExistentialTypes, 22)
4848
TAG(ExtendedExistentialTypeShapes, 23)
4949
TAG(MetadataPack, 24)
5050
TAG(WitnessTablePack, 25)
51+
TAG(LayoutString, 26)
5152

5253
#undef TAG

0 commit comments

Comments
 (0)