Skip to content

Commit f30d8a6

Browse files
committed
[CoroutineAccessors] Rehome runtime functions.
Put them where they're meant to be, in swiftCore.
1 parent 433ff59 commit f30d8a6

File tree

9 files changed

+35
-35
lines changed

9 files changed

+35
-35
lines changed

include/swift/Runtime/Concurrency.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#define SWIFT_RUNTIME_CONCURRENCY_H
1919

2020
#include "swift/ABI/AsyncLet.h"
21-
#include "swift/ABI/Coro.h"
2221
#include "swift/ABI/Task.h"
2322
#include "swift/ABI/TaskGroup.h"
2423

@@ -128,13 +127,6 @@ void swift_task_dealloc(void *ptr);
128127
SWIFT_EXPORT_FROM(swift_Concurrency)
129128
SWIFT_CC(swift) void swift_task_dealloc_through(void *ptr);
130129

131-
// TODO: CoroutineAccessors: Move these declarations back to swiftCore {{
132-
SWIFT_EXPORT_FROM(swift_Concurrency)
133-
SWIFT_CC(swift) void *swift_coro_alloc(CoroAllocator *allocator, size_t size);
134-
SWIFT_EXPORT_FROM(swift_Concurrency)
135-
SWIFT_CC(swift) void swift_coro_dealloc(CoroAllocator *allocator, void *ptr);
136-
// }} TODO: CoroutineAccessors
137-
138130
/// Cancel a task and all of its child tasks.
139131
///
140132
/// This can be called from any thread.

include/swift/Runtime/Coro.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
#include "swift/Runtime/Config.h"
2222
#include <cstddef>
2323

24-
namespace swift {} // end namespace swift
24+
namespace swift {
25+
SWIFT_RUNTIME_EXPORT
26+
SWIFT_CC(swift) void *swift_coro_alloc(CoroAllocator *allocator, size_t size);
27+
28+
SWIFT_RUNTIME_EXPORT
29+
SWIFT_CC(swift) void swift_coro_dealloc(CoroAllocator *allocator, void *ptr);
30+
} // end namespace swift
2531

2632
#endif

include/swift/Runtime/RuntimeFunctions.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,7 +3010,7 @@ FUNCTION(MemsetS, c, memset_s, C_CC, AlwaysAvailable,
30103010

30113011
// void *swift_coro_alloc(CoroAllocator *, size_t size);
30123012
FUNCTION(CoroAlloc,
3013-
_Concurrency, swift_coro_alloc, SwiftCC,
3013+
Swift, swift_coro_alloc, SwiftCC,
30143014
CoroutineAccessorsAvailability,
30153015
RETURNS(Int8PtrTy),
30163016
ARGS(CoroAllocatorPtrTy, SizeTy),
@@ -3020,7 +3020,7 @@ FUNCTION(CoroAlloc,
30203020

30213021
// void swift_coro_dealloc(CoroAllocator *, void *ptr);
30223022
FUNCTION(CoroDealloc,
3023-
_Concurrency, swift_coro_dealloc, SwiftCC,
3023+
Swift, swift_coro_dealloc, SwiftCC,
30243024
CoroutineAccessorsAvailability,
30253025
RETURNS(VoidTy),
30263026
ARGS(CoroAllocatorPtrTy, Int8PtrTy),

stdlib/public/Concurrency/TaskAlloc.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,3 @@ void swift::_swift_task_dealloc_specific(AsyncTask *task, void *ptr) {
7272
void swift::swift_task_dealloc_through(void *ptr) {
7373
allocator(swift_task_getCurrent()).deallocThrough(ptr);
7474
}
75-
76-
void *swift::swift_coro_alloc(CoroAllocator *allocator, size_t size) {
77-
return allocator->allocate(size);
78-
}
79-
80-
void swift::swift_coro_dealloc(CoroAllocator *allocator, void *ptr) {
81-
if (!allocator)
82-
return;
83-
// Calls to swift_coro_dealloc are emitted in resume funclets for every
84-
// live-across dynamic allocation. Whether such calls immediately deallocate
85-
// memory depends on the allocator.
86-
if (!allocator->shouldDeallocateImmediately()) {
87-
return;
88-
}
89-
allocator->deallocate(ptr);
90-
}

stdlib/public/runtime/Coro.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,19 @@
1515
#include "swift/Basic/FlagSet.h"
1616

1717
using namespace swift;
18+
19+
void *swift::swift_coro_alloc(CoroAllocator *allocator, size_t size) {
20+
return allocator->allocate(size);
21+
}
22+
23+
void swift::swift_coro_dealloc(CoroAllocator *allocator, void *ptr) {
24+
if (!allocator)
25+
return;
26+
// Calls to swift_coro_dealloc are emitted in resume funclets for every
27+
// live-across dynamic allocation. Whether such calls immediately deallocate
28+
// memory depends on the allocator.
29+
if (!allocator->shouldDeallocateImmediately()) {
30+
return;
31+
}
32+
allocator->deallocate(ptr);
33+
}

test/abi/macOS/arm64/concurrency.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,7 @@ Added: _$sScf25isIsolatingCurrentContextSbyFTj
408408
Added: _$sScf25isIsolatingCurrentContextSbyFTq
409409
Added: _$sScfsE25isIsolatingCurrentContextSbyF
410410

411-
// add callee-allocated coro entrypoints
412-
// TODO: CoroutineAccessors: several of these symbols should be in swiftCore
413-
Added: _swift_coro_alloc
414-
Added: _swift_coro_dealloc
411+
// CoroutineAccessors
415412
Added: _swift_task_dealloc_through
416413

417414
// SwiftSettings

test/abi/macOS/arm64/stdlib.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,3 +942,7 @@ Added: _$ss18EnumeratedSequenceVsSlRzrlE7isEmptySbvpMV
942942
Added: _$ss18EnumeratedSequenceVsSlRzrlE8endIndexABsSlRzrlE0D0Vyx_GvpMV
943943
Added: _$ss18EnumeratedSequenceVsSlRzrlEySi6offset_7ElementQz7elementtABsSlRzrlE5IndexVyx_GcipMV
944944
Added: _$ss18EnumeratedSequenceVyxGSKsSkRzrlMc
945+
946+
// CoroutineAccessors
947+
Added: _swift_coro_alloc
948+
Added: _swift_coro_dealloc

test/abi/macOS/x86_64/concurrency.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,7 @@ Added: _$sScf25isIsolatingCurrentContextSbyFTj
408408
Added: _$sScf25isIsolatingCurrentContextSbyFTq
409409
Added: _$sScfsE25isIsolatingCurrentContextSbyF
410410

411-
// add callee-allocated coro entrypoints
412-
// TODO: CoroutineAccessors: several of these symbols should be in swiftCore
413-
Added: _swift_coro_alloc
414-
Added: _swift_coro_dealloc
411+
// CoroutineAccessors
415412
Added: _swift_task_dealloc_through
416413

417414
// SwiftSettings

test/abi/macOS/x86_64/stdlib.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,3 +942,7 @@ Added: _$ss18EnumeratedSequenceVsSlRzrlE7isEmptySbvpMV
942942
Added: _$ss18EnumeratedSequenceVsSlRzrlE8endIndexABsSlRzrlE0D0Vyx_GvpMV
943943
Added: _$ss18EnumeratedSequenceVsSlRzrlEySi6offset_7ElementQz7elementtABsSlRzrlE5IndexVyx_GcipMV
944944
Added: _$ss18EnumeratedSequenceVyxGSKsSkRzrlMc
945+
946+
// CoroutineAccessors
947+
Added: _swift_coro_alloc
948+
Added: _swift_coro_dealloc

0 commit comments

Comments
 (0)