Skip to content

Commit 5c48918

Browse files
committed
Add a bit more detail to the ABI compatibility section.
1 parent 02a2e83 commit 5c48918

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

proposals/NNNN-async-function-isolation.md

+29-5
Original file line numberDiff line numberDiff line change
@@ -818,11 +818,35 @@ TBD
818818

819819
## ABI compatibility
820820

821-
TBD: I'm still figuring out whether this change can be staged in while
822-
preserving ABI for existing nonisolated async functions. A number of APIs
823-
in the concurrency library have transitioned to inheriting the isolation of
824-
the caller using isolated parameters and `#isolation`, and it may be possible
825-
to do this transformation automatically.
821+
**Open question.** I'm still figuring out whether this change can be staged in
822+
while preserving ABI for existing nonisolated async functions while also
823+
preserving source compatibility. A number of APIs in the concurrency library
824+
have transitioned to inheriting the isolation of the caller using isolated
825+
parameters and `#isolation`, and it may be possible to do this transformation
826+
automatically for resilient libraries.
827+
828+
For example, if a nonisolated async function is ABI-public and is available
829+
earlier than a version of the Swift runtime that includes this change, the
830+
compiler could emit two separate entry points for the function:
831+
832+
```swift
833+
@_alwaysEmitIntoClient
834+
public func myAsyncFunc() async {
835+
// original implementation
836+
}
837+
838+
@concurrent
839+
@_silgen_name(...) // to preserve the original symbol name
840+
@usableFromInline
841+
internal func abi_myAsyncFunc() async {
842+
// existing compiled code will continue to always run calls to this function
843+
// on the generic executor.
844+
await myAsyncFunc()
845+
}
846+
```
847+
848+
However, this transformation only works if the original function implementation
849+
can be made inlinable.
826850

827851
## Implications on adoption
828852

0 commit comments

Comments
 (0)