Skip to content

Commit

Permalink
Add a bit more detail to the ABI compatibility section.
Browse files Browse the repository at this point in the history
  • Loading branch information
hborla committed Sep 22, 2024
1 parent 02a2e83 commit aa7ca5a
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions proposals/NNNN-async-function-isolation.md
Original file line number Diff line number Diff line change
Expand Up @@ -818,11 +818,34 @@ TBD

## ABI compatibility

TBD: I'm still figuring out whether this change can be staged in while
preserving ABI for existing nonisolated async functions. A number of APIs
**Open question.** I'm still figuring out whether this change can be staged in
while preserving ABI for existing nonisolated async functions. A number of APIs
in the concurrency library have transitioned to inheriting the isolation of
the caller using isolated parameters and `#isolation`, and it may be possible
to do this transformation automatically.
to do this transformation automatically for resilient libraries.

For example, if a nonisolated async function is ABI-public and is available
earlier than a version of the Swift runtime that includes this change, the
compiler could emit two separate entry points for the function:

```swift
@_alwaysEmitIntoClient
public func myAsyncFunc() async {
// original implementation
}

@concurrent
@_silgen_name(...) // to preserve the original symbol name
@usableFromInline
internal func abi_myAsyncFunc() async {
// existing compiled code will continue to always run calls to this function
// on the generic executor.
await myAsyncFunc()
}
```

However, this transformation only works if the original function implementation
can be made inlinable.

## Implications on adoption

Expand Down

0 comments on commit aa7ca5a

Please sign in to comment.