0%

s12 — Full Runtime ABI Surface

Goal

The complete ~100-function ori_rt C-ABI surface is emit-able with attribute fidelity, the FunctionAbi classification is a SHARED single source both backends consume, and the full collections/strings/iterators/COW/drop-glue surface runs leak-clean on all targets.

Implementation Sketch

  • Shared ABI classification: extract the AB-* rules (ParamPassing/ReturnPassing, 16-byte direct/indirect threshold, sret) from ori_llvm/src/codegen/abi/mod.rs into a backend-neutral home (ori_repr or a small shared crate — decision recorded; cross-backend DRIFT here is silent miscompilation, so one implementation, two consumers; mixed-backend linking stays banned until promotion regardless).
  • Runtime declaration SSOT: execute the s07-recorded extraction — one backend-neutral runtime-declaration table (names, signatures, nounwind/C-unwind, memory attrs) consumed by ori_llvm’s runtime_functions.rs and ori_backend; consistency test pins zero drift.
  • Emission coverage by group (inventory verified at plan time): string ops (SSO 24-byte OriStr by-value passing!), list/buffer + COW family (cow_mode i32 plumbing from CowAnnotations), map/set families (hash/eq fn-pointer args), iterator constructors/consumers, format family, assertions (C-unwind), memory utilities. V5 header field access via named constants (CG:RT-2) only.
  • Drop glue: per-type drop function generation (cached by mangled name per the drop_gen precedent) for all 6 RcStrategy shapes incl. recursive aggregate walks and tag-switched enums; elem_dec_fn synthesis for collection buffers; reverse-declaration-order field drops.
  • FunctionAbi parity proof: for a signature corpus, both backends’ classifications are asserted EQUAL (the shared-extraction regression test).

Test Strategy

  • Matrix: runtime-group x element type {int, str, [int], Option, closure, struct, map, set} x target — execution parity + ORI_CHECK_LEAKS=1 clean per cell; valgrind suite (tests/valgrind incl. cow/) under the native backend.
  • Semantic pins: SSO boundary pin (23/24-byte strings cross the by-value ABI correctly); cow_mode pin per static/dynamic mode; drop-order pin (reverse declaration order observable via Drop side effects).
  • Negative pins: declaration-table drift test fails on a mutated signature; ABI-parity test fails on a diverged classification.

Work Items

  • Shared ABI classification extraction (one impl, both backends) + cross-backend parity regression test over a signature corpus.
  • Backend-neutral runtime declaration table extraction + zero-drift consistency pins.
  • Emission coverage: strings/SSO, list+COW, map/set, iterators, format, assertions, memory utils with attribute fidelity.
  • Drop-glue generation for all RcStrategy shapes + elem_dec_fn synthesis + reverse-order field drops.
  • Runtime-group x type x target matrix green with leaks/valgrind clean; SSO/cow/drop-order pins + negative drift pins landed.