Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
5302c96
chore(quest): claim quest/m1/ffi-export/checks-raise.md
kixelated Nov 13, 2026
eda9dac
wip(ffi): failed run-time checks raise the language's error
kixelated Nov 13, 2026
62749c8
wip(ffi): uncounted borrows for unchecked types, docs, quest
kixelated Nov 13, 2026
ac9e245
wip(ffi): fixture expectations, clippy, fmt
kixelated Nov 13, 2026
101799e
Merge main
kixelated Nov 13, 2026
d998361
test(ffi): Swift's within(0) waits, so Rust's first poll pends
kixelated Nov 13, 2026
82c6901
wip(ffi): close takes the value through Rust's TAKEN in Kotlin and Py…
kixelated Nov 13, 2026
68750d2
wip(ffi): Go's Close drops the value through Rust and returns an error
kixelated Nov 13, 2026
2c9f87f
wip(ffi): Dart's close drops the value through Rust
kixelated Nov 13, 2026
eef1898
wip(ffi): Swift's description, ==, clone and a closed class nested in…
kixelated Nov 13, 2026
6992b61
test(ffi): C's drop is refused under a recv, then moves the value
kixelated Nov 13, 2026
2e74375
fix(ffi): an unchecked Copy object lifts uncounted, so a checking lis…
kixelated Nov 13, 2026
730b0e0
Merge remote-tracking branch 'origin/main' into HEAD
kixelated Nov 13, 2026
0c16210
chore(quest): swift-gives-up is finished; object-ownership profiles f…
kixelated Nov 13, 2026
527edd1
fix(ffi): C++ passes a record's trait status; the fixture's Seat cove…
kixelated Nov 13, 2026
b1854f4
fix(ffi): the moq bench passes C's statuses and tries Swift's throwin…
kixelated Nov 13, 2026
35ccd28
perf(ffi): Dart's calls share one status cell per isolate
kixelated Nov 13, 2026
d9f1ee7
docs: bench the per-handle rows, and leave checks-raise the handle-fr…
kixelated Nov 13, 2026
530fc0d
fix(ffi): Go and Kotlin count a checked handle's calls, so close and …
kixelated Nov 13, 2026
d72ec44
docs: Go and Kotlin keep their counts; checks-raise is finished; Go's…
kixelated Nov 13, 2026
38bdd3f
style(ffi): format with the workspace's rustfmt
kixelated Nov 13, 2026
a19f986
fix(ffi): a refused call changes no argument, records' receivers chec…
kixelated Nov 13, 2026
0d798f9
Merge origin/main into quest/m1/ffi-export/checks-raise
kixelated Nov 13, 2026
1c1cf99
fix(ffi): answer #730's review threads, and port moq's programs and M…
kixelated Nov 13, 2026
f906312
Merge remote-tracking branch 'origin/main' into HEAD
kixelated Nov 13, 2026
729415a
test(ffi): name the Kotlin seat beside main's numbers apart
kixelated Nov 13, 2026
78a500c
fix(ffi): report a type's handle becoming checked, or no longer, as a…
kixelated Nov 14, 2026
909e5aa
docs(ffi): place a pending future's out pointer before a checked call…
kixelated Nov 14, 2026
69dfec3
Merge remote-tracking branch 'origin/main' into HEAD
kixelated Nov 14, 2026
a2b0bcc
quest: drop ffi-abort-cores' link to the checks-raise quest this bran…
kixelated Nov 14, 2026
b527ab2
test(ffi): pass main's new checked calls a status, and match the rese…
kixelated Nov 14, 2026
88b2059
Merge remote-tracking branch 'origin/main' into HEAD
kixelated Nov 14, 2026
bdafdbe
Merge origin/main into checks-raise
kixelated Nov 14, 2026
7925088
Merge origin/main into checks-raise
kixelated Nov 14, 2026
5c91484
Merge origin/main into checks-raise
kixelated Nov 14, 2026
faec530
Merge origin/main into checks-raise
kixelated Nov 14, 2026
8526179
fix(ffi): quests outlive checks-raise's deletion, and rustfmt
kixelated Nov 14, 2026
b5b99ca
fix(ffi): Kotlin's move cleanup binds no name a parameter takes
kixelated Nov 14, 2026
c033d8e
Merge origin/main into checks-raise
kixelated Nov 14, 2026
6cb60db
Merge origin/main into checks-raise
kixelated Nov 14, 2026
c5104a4
Merge origin/main into checks-raise
kixelated Nov 14, 2026
9fed597
test(ffi): a refused Score::note leaves the score as it was
kixelated Nov 15, 2026
78882d5
Merge remote-tracking branch 'origin/main' into HEAD
kixelated Nov 15, 2026
880c2de
Merge branch 'base' into pr-730
Nov 15, 2026
41d9a71
fix(ffi): reconcile Dart waker with object runtime checks
Nov 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Each project lives in its own top-level directory; the [quest tree](quest/README

- An unsupported construct or malformed input is a compile error with a source span, never a warning, a silent fallback, or a runtime failure. Generated code panics only where the Rust source does.
One exception is an `unsafe` pointer from elsewhere whose origin translation can't see, such as a parameter's: a loud run-time check may stand in for the refusal, under m3's [unsafe policy](quest/m3/README.md), since refusing every such pointer would refuse pointer arithmetic on any parameter.
The other is a binding, which checks at run time only the Rust rules its language cannot express: borrow exclusivity, use after a move or close, and the thread of a value that is not `Send`. A failed check raises the language's own error, or aborts where it has none; a Rust panic aborts.
The other is a binding, which checks at run time only the Rust rules its language cannot express: borrow exclusivity, use after a move or close, the thread of a value that is not `Send`, and a call of an item the library's target lacks. A failed check raises the language's own error, or aborts where it has none; a Rust panic aborts.
- Generated output must match the source's semantics exactly: integer widths and overflow, drop order, laziness, and error paths. Prove it with differential tests against native Rust, not by inspection.
- A binding's types are lossless: every value of the Rust type crosses and returns exactly. A native type stands in only where it is exact; otherwise the runtime's own type crosses, with checked conversions to and from the idiomatic one. Speed ranks above ergonomics.
- Everything is configless, with opinionated names and defaults. Translators take stock crates as they are: no annotations, and no config beyond true platform boundaries. Each config key or source change a consumer needs is a gap to close.
Expand Down
63 changes: 50 additions & 13 deletions bench/ffi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,23 +396,60 @@ frame path:
7. **The binding's own call.** Over C's getter: Swift adds 8 ns (its hold count's two
atomics, since dropped from all but its classes, as below), Kotlin 14 wall (JNI and its hold count), Dart 19 (an `_Arena` per call and
its hold), Go 31 (cgo, `defer`, and its hold), and Python 37 (argument parsing and the
GIL released and taken back, so Rust may call Python from another thread). BoltFFI's
GIL released and taken back, so Rust may call Python from another thread); Python's and
Dart's hold counts are since dropped for a checked type, as below. BoltFFI's
Python getter, which holds the GIL, measured 63 ns.

### Per-handle baseline

For [checks-raise](/quest/m1/ffi-export/checks-raise.md)'s one accounting: the u64
getter is one borrowed handle and nothing else, so its row less Rust's 0.4 ns is what a
handle costs a call. C, C++: 10 ns, the runtime's two atomics. Swift: 9.9, with no hold
count since the change below. Kotlin: 24 wall, Go 38, Dart 28, Python 49, each with its call's own
transition besides.

Swift has since made each object a noncopyable struct and dropped its hold count, but for
a class: one thrown as an error. A `Copy` type is a value since [Copy values](#copy-values). Measured 2026-11-11 at that change, 5
rounds interleaved with C at a load average of 7 to 12, its getter costs 10 ns, as C's
does, and `track.is_closed()`, on `TrackProducer`, still a class since moq throws it, 26
against C's 18, as in the table. A change to the accounting moves this row and the handle call's by the
same amount; measure both, CPU first, at the load beside them.
For [#730](https://github.com/kixel-ai/rust2/pull/730)'s one accounting: the u64 getter
is one borrowed handle and nothing else, so its row less Rust's 0.4 ns is what a handle
costs a call. Measured 2026-11-13 on desktop at a load average of 2.4 to 4.1, main at
`7b0958b3` against #730 before Go and Kotlin took their counts back, run alternately: 12
rounds of main and 6 of #730, median wall ns (CPU ns where it differs). #730 drops the hold
counts Python and Dart kept beside the runtime's for a checked type, so its call borrows
through the runtime's two atomics alone, and close drops the value through Rust.

| row | C | Python | Swift | Dart |
|---|---|---|---|---|
| handle call, main | 18 | 54 | 26 | 41 (45) |
| handle call, #730 | 18 | 53 | 26 | 42 (45) |
| u64 getter, main | 10 | 48 | 10 | 27 |
| u64 getter, #730 | 10 | 47 | 10 | 28 |
| object return, main | 29 | 99 | 37 | 238 |
| object return, #730 | 30 | 98 | 38 | 214 |
| stamped write, main | 159 | 337 | 205 | 433 |
| stamped write, #730 | 168 | 332 | 212 | 450 |

Go and Kotlin dropped theirs too at first, and gained 5 to 8 ns on the getter, but a
handle closed or moved out of was then freed only once the GC found its object
unreachable, which kept Go's cleanup and Kotlin's phantom reference registered: Go's
object return went from 183 to 691 ns and its stamped write from 429 to 1,061, Kotlin's
stamped write from 310 to 613. So each still counts its calls, freeing the handle once a
close or a move leaves no call holding it. Measured 2026-11-13 on nixos (AMD, 32 threads)
at a load average of 28 to 47, main at `e9cca797` against #730, 10 runs of each program
alternating, median wall ns:

| row | Kotlin | Go |
|---|---|---|
| handle call, main | 13 | 35 |
| handle call, #730 | 14 | 49 |
| u64 getter, main | 12 | 34 |
| u64 getter, #730 | 11 | 50 |
| object return, main | 156 | 261 |
| object return, #730 | 66 | 317 |
| stamped write, main | 457 | 745 |
| stamped write, #730 | 441 | 835 |

Kotlin's rows match main's within the noise: its object return's fastest runs took 57 and
60 ns. Go's checked call allocates its status,
since cgo moves to the heap a local whose address it passes C, which costs 6 ns in a
cgo call alone; its close calls Rust's `_drop`, a second crossing an object return and a
stamped write pay. Dart's checked calls first lost 4 ns to a status allocated per call,
now one cell per isolate, which the glue fills from the call's own once the call stopped
serving the isolate, for 1 ns more. Swift's getter costs C's since it dropped its hold count for
each noncopyable object (2026-11-11), and a `Copy` type is a value since [Copy values](#copy-values). A change to the accounting moves these rows;
measure them at the load beside them.

### Copy values

Expand Down
Loading