@@ -18,7 +18,7 @@ extern "C" {
1818SWIFT_REMOTE_MIRROR_LINKAGE
1919unsigned long long swift_reflection_classIsSwiftMask = 2 ;
2020
21- SWIFT_REMOTE_MIRROR_LINKAGE uint32_t swift_reflection_libraryVersion = 1 ;
21+ SWIFT_REMOTE_MIRROR_LINKAGE uint32_t swift_reflection_libraryVersion = 2 ;
2222}
2323
2424#include " swift/Demangling/Demangler.h"
@@ -43,6 +43,7 @@ struct SwiftReflectionContext {
4343 std::vector<std::function<void ()>> freeFuncs;
4444 std::vector<std::tuple<swift_addr_t , swift_addr_t >> dataSegments;
4545 std::string lastString;
46+ std::vector<swift_async_task_allocation_chunk_t > lastChunks;
4647
4748 SwiftReflectionContext (MemoryReaderImpl impl) {
4849 auto Reader = std::make_shared<CMemoryReader>(impl);
@@ -774,22 +775,46 @@ const char *swift_reflection_iterateMetadataAllocationBacktraces(
774775 return returnableCString (ContextRef, Error);
775776}
776777
777- const char *swift_reflection_iterateAsyncTaskAllocations (
778- SwiftReflectionContextRef ContextRef, swift_reflection_ptr_t AsyncTaskPtr,
779- swift_asyncTaskAllocationIterator Call, void *ContextPtr) {
780- auto Context = ContextRef->nativeContext ;
781- auto Error = Context->iterateAsyncTaskAllocations (
782- AsyncTaskPtr, [&](auto AllocationPtr, auto Count, auto Chunks) {
783- std::vector<swift_async_task_allocation_chunk_t > ConvertedChunks;
784- ConvertedChunks.reserve (Count);
785- for (unsigned i = 0 ; i < Count; i++) {
786- swift_async_task_allocation_chunk_t Chunk;
787- Chunk.Start = Chunks[i].Start ;
788- Chunk.Length = Chunks[i].Length ;
789- Chunk.Kind = convertAllocationChunkKind (Chunks[i].Kind );
790- ConvertedChunks.push_back (Chunk);
791- }
792- Call (AllocationPtr, Count, ConvertedChunks.data (), ContextPtr);
793- });
794- return returnableCString (ContextRef, Error);
778+ swift_async_task_slab_return_t
779+ swift_reflection_asyncTaskSlabPointer (SwiftReflectionContextRef ContextRef,
780+ swift_reflection_ptr_t AsyncTaskPtr) {
781+ auto Context = ContextRef->nativeContext ;
782+ llvm::Optional<std::string> Error;
783+ NativeReflectionContext::StoredPointer SlabPtr;
784+ std::tie (Error, SlabPtr) = Context->asyncTaskSlabPtr (AsyncTaskPtr);
785+
786+ swift_async_task_slab_return_t Result = {};
787+ Result.Error = returnableCString (ContextRef, Error);
788+ Result.SlabPtr = SlabPtr;
789+ return Result;
790+ }
791+
792+ swift_async_task_slab_allocations_return_t
793+ swift_reflection_asyncTaskSlabAllocations (SwiftReflectionContextRef ContextRef,
794+ swift_reflection_ptr_t SlabPtr) {
795+ auto Context = ContextRef->nativeContext ;
796+ llvm::Optional<std::string> Error;
797+ NativeReflectionContext::AsyncTaskSlabInfo Info;
798+ std::tie (Error, Info) = Context->asyncTaskSlabAllocations (SlabPtr);
799+
800+ swift_async_task_slab_allocations_return_t Result = {};
801+ Result.Error = returnableCString (ContextRef, Error);
802+
803+ Result.NextSlab = Info.NextSlab ;
804+ Result.SlabSize = Info.SlabSize ;
805+
806+ ContextRef->lastChunks .clear ();
807+ ContextRef->lastChunks .reserve (Info.Chunks .size ());
808+ for (auto &Chunk : Info.Chunks ) {
809+ swift_async_task_allocation_chunk_t ConvertedChunk;
810+ ConvertedChunk.Start = Chunk.Start ;
811+ ConvertedChunk.Length = Chunk.Length ;
812+ ConvertedChunk.Kind = convertAllocationChunkKind (Chunk.Kind );
813+ ContextRef->lastChunks .push_back (ConvertedChunk);
814+ }
815+
816+ Result.ChunkCount = ContextRef->lastChunks .size ();
817+ Result.Chunks = ContextRef->lastChunks .data ();
818+
819+ return Result;
795820}
0 commit comments