Hand-written Cranelift calls bypass the shared ABI catalog and desynchronize JIT, AOT, and runtime extern "C-unwind" implementations.
Verification and traceability
Platform spec article
Verification and traceability
Spec standingStandard
-
Codegen must not invent alternate calling conventions for runtime builtins.
Context
Decision
Rule Detail Catalog BUILTIN_SPECSinbeskid_abi::builtinsis the sole source of Cranelift import signatures (ABI-002)Codegen declare_builtin_importsbuildsFuncIds only from specsDiverging builtins AbiReturnKind::Neverforpanicso unreachable blocks are correctParity Symbol strings in specs must match RUNTIME_EXPORT_SYMBOLSentries (ABI-001)Consequences
New builtins require spec,
BUILTIN_SPECS,symbols.rs, andbeskid_runtime::builtinsin one change set.Verification anchors
compiler/crates/beskid_codegen;compiler/crates/beskid_abi/src/builtins.rs. -
no_mangle extern C-unwind symbols implement the stable host surface.
Context
Generated code calls runtime entrypoints across JIT relink and AOT link. Rust panics across the boundary must use the platform unwind ABI expected by Cranelift
callsites.Decision
Rule Detail Export attribute Implementations use #[unsafe(no_mangle)] pub extern "C-unwind"inbeskid_runtime::builtinsRegistry RUNTIME_EXPORT_SYMBOLSlists every export the linker/JIT registersLayout types BeskidStr{ ptr, len }andBeskidArray{ ptr, len, cap }are normative payload headersFamilies Allocation, GC, fibers, channels, interop dispatch, IO, and panicshare one catalogConsequences
Host tooling resolves imports by symbol name +
BUILTIN_SPECSsignature, not Rust mangling.Verification anchors
compiler/crates/beskid_runtime/src/builtins/mod.rs;compiler/crates/beskid_runtime/src/lib.rsre-exports.
- Contracts and edge cases MUST rules for builtin signatures, return kinds, and export name stability.
- Design model BuiltinFnSpec catalog, runtime export symbols, and codegen import boundaries.
- Examples Reading BUILTIN_SPECS, mapping symbols to runtime modules, and typical call patterns.
- FAQ and troubleshooting Builtin symbol drift, signature mismatches, and codegen/runtime debugging.
- Flow and algorithm From lowering call sites through BUILTIN_SPECS to runtime C exports.
- Verification and traceability Crate paths and tests that pin builtin specs to runtime exports.
0 revisions (git unavailable at build; counts may be empty)
No commits recorded for this path.
| Section id | Required | Found |
|---|---|---|
what-this-feature-specifies | yes | yes |
implementation-anchors | yes | yes |
Full tree: run pnpm verify:platform-spec-layout (writes src/generated/platform-spec-layout-report.json).
Canonical files
Section titled “Canonical files”| File | Contract |
|---|---|
compiler/crates/beskid_abi/src/builtins.rs | BUILTIN_SPECS, AbiParamKind, AbiReturnKind |
compiler/crates/beskid_abi/src/symbols.rs | RUNTIME_EXPORT_SYMBOLS |
compiler/crates/beskid_runtime/src/builtins/mod.rs | Module routing to alloc/gc/fiber/… |
compiler/crates/beskid_codegen (host helpers) | declare_builtin_imports |
compiler/crates/beskid_engine/src/jit_module.rs | Function pointer table for JIT |
| Location | Covers |
|---|---|
compiler/crates/beskid_tests/src/runtime/jit.rs | Builtin calls through JIT |
compiler/crates/beskid_e2e_tests/src/tests/runtime_cases.rs | Panic, IO, runtime smoke |
compiler/crates/beskid_runtime benches | Microbenchmarks for alloc/GC hot paths |
Requirement mapping
Section titled “Requirement mapping”| ID | Check |
|---|---|
| BLT-001 | Grep BUILTIN_SPECS symbols against pub extern exports in builtins/ |
| BLT-002 | RUNTIME_EXPORT_SYMBOLS contains every BUILTIN_SPECS.symbol |
| BLT-005–006 | Symbol rename tests in fiber/channel integration tests |
Review checklist (PRs touching builtins)
Section titled “Review checklist (PRs touching builtins)”- Update
builtins.rs,symbols.rs, runtime impl, and platform-spec together. - Decide if ABI versioning bump is required.
- Run
cargo test -p beskid_tests runtimeand relevantbeskid_e2e_teststargets.