File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -818,11 +818,34 @@ 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
821+ ** Open question. ** I'm still figuring out whether this change can be staged in
822+ while preserving ABI for existing nonisolated async functions. A number of APIs
823823in the concurrency library have transitioned to inheriting the isolation of
824824the caller using isolated parameters and ` #isolation ` , and it may be possible
825- to do this transformation automatically.
825+ to do this transformation automatically for resilient libraries.
826+
827+ For example, if a nonisolated async function is ABI-public and is available
828+ earlier than a version of the Swift runtime that includes this change, the
829+ compiler could emit two separate entry points for the function:
830+
831+ ``` swift
832+ @_alwaysEmitIntoClient
833+ public func myAsyncFunc () async {
834+ // original implementation
835+ }
836+
837+ @concurrent
838+ @_silgen_name (... ) // to preserve the original symbol name
839+ @usableFromInline
840+ internal func abi_myAsyncFunc () async {
841+ // existing compiled code will continue to always run calls to this function
842+ // on the generic executor.
843+ await myAsyncFunc ()
844+ }
845+ ```
846+
847+ However, this transformation only works if the original function implementation
848+ can be made inlinable.
826849
827850## Implications on adoption
828851
You can’t perform that action at this time.
0 commit comments