1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//! Driving the Swift runtime directly: the ABI this crate speaks.
//!
//! Nothing here goes through a Swift source file. A SwiftUI view is built by
//! finding a mangled symbol with `dlsym`, arranging registers the way the
//! Swift compiler would have, and branching to it. That works because Swift's
//! arm64 convention is stable and documented — but three of its registers have
//! no counterpart in a Rust signature, so every call has to be written out:
//!
//! | register | role |
//! |----------|------|
//! | `x0`–`x7` | integer and pointer arguments, then any generic metadata, then any witness tables |
//! | `d0`–`d7` | floating-point arguments |
//! | `x8` | address of an indirect (`@out`) result |
//! | `x20` | the *self* register: a receiver, or a type's metadata for an initialiser or static |
//! | `x21` | the error register, which nothing here throws through and everything clobbers |
//!
//! Whether a value travels *in* a register or *by address* is the question
//! that decides whether a call works, and it is not visible in the symbol
//! name. A `@frozen` type of at most four registers is passed directly; a
//! resilient one is passed by address, because the caller is not allowed to
//! know its size. Two traps follow from that and both cost real time here:
//!
//! * An `Optional`'s payload is **not** destructured. `Optional<UnitPoint>` is
//! two `CGFloat`s and a tag, and it arrives as three *integer* registers —
//! a `Double` inside an optional reaches the callee in x0, not d0.
//! * Getting a return convention wrong rarely faults at the call. A function
//! that writes through x8 while the caller reads x0 hands back a stale
//! register, which SwiftUI stores and dereferences much later.
//!
//! [`call`] holds the primitives that make those choices explicit, and the
//! rest of this module is built on them:
//!
//! * `value` — enum tags, optionals, strings and arrays
//! * `metadata` — type metadata, witness tables and layout queries
//! * `modifier` — applying a `View` modifier and wrapping the result
//! * `closure` — Rust functions Swift can call back into
pub use ;
use crateresolve;
pub use *;
pub use *;
pub use *;
pub use *;