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 ori_target descriptors plus ori_repr::CompiledLayoutPlan classification. Cross-backend drift is silent miscompilation, so there is one implementation and two thin 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 semantics) classified through CompiledLayoutPlan and consumed by ori_llvm and ori_backend; consistency tests pin zero drift while backend-specific IR attribute objects stay local.
  • 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: generate one physical implementation for every reachable ExecutableDropPlanId, using CompiledLayoutPlan(TargetSpec) for traversal, header/count mechanics, and helper ABI while preserving AIMS-owned logical field identity and reverse-declaration-order cleanup. Cover the six shipped RcStrategy shapes as migration evidence, not as the production AIMS seam; synthesize collection element cleanup from the same bound plan.
  • Enum runtime ABI and drop glue consume the typed runtime constraint and per-variant field map from CompiledEnumLayout defined by plans/enum-layout-ssot; LLVM and ori_backend share fixtures and neither reconstructs {tag,payload} locally.
  • FunctionAbi identity proof: for a signature corpus and every target, both backends consume the same plan entry rather than comparing independently computed classifications; a mutation negative pin proves drift is detected.

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 into TargetSpec/CompiledLayoutPlan (one impl, both backends) + shared-entry identity and drift-negative tests 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 reachable ExecutableDropPlanId values, including migrated six-shape coverage, compiled-plan element cleanup, and reverse-order logical field drops.
  • Runtime-group x type x target matrix green with leaks/valgrind clean; SSO/cow/drop-order pins + negative drift pins landed.