Skip to content

Commit

Permalink
Update proposed/swift-interop.md
Browse files Browse the repository at this point in the history
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
  • Loading branch information
kotlarmilos and jkotas authored Dec 21, 2023
1 parent 5d9f282 commit 62087cf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion proposed/swift-interop.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ We have selected an approach for handling the error register in the Swift callin

1. Use a special type named something like `SwiftError*` to indicate the error parameter

This approach expresses that the to-be-called Swift function uses the Error Register in the signature and they both require signature manipulation in the JIT/AOT compilers. Like with `SwiftSelf`, we would throw an `InvalidProgramException` for a signature with multiple `SwiftError` parameters. We use a pointer-to-`SwiftError` type to indicate that the error register is a by-ref/out parameter. We don't use managed pointers as our modern JITs can reason about unmanaged pointers well enough that we do not end up losing any performance taking this route. The `UnmanagedCallersOnly` implementation will require a decent amount of JIT work to emulate a local variable for the register value, but we have prior art in the Clang implementation of the Swift error register that we can fall back on. Delegates annotated with `UnmanagedCallersOnly` will store the `SwiftError*` value in the error register in their epilog.
This approach expresses that the to-be-called Swift function uses the Error Register in the signature and they both require signature manipulation in the JIT/AOT compilers. Like with `SwiftSelf`, we would throw an `InvalidProgramException` for a signature with multiple `SwiftError` parameters. We use a pointer-to-`SwiftError` type to indicate that the error register is a by-ref/out parameter. We don't use managed pointers as our modern JITs can reason about unmanaged pointers well enough that we do not end up losing any performance taking this route. The `UnmanagedCallersOnly` implementation will require a decent amount of JIT work to emulate a local variable for the register value, but we have prior art in the Clang implementation of the Swift error register that we can fall back on. Methods annotated with `UnmanagedCallersOnly` will pass the `SwiftError*` value in the error register.

Additionally, we have selected this design as this provides consistency with the self register and async context register handling, discussed below.

Expand Down

0 comments on commit 62087cf

Please sign in to comment.