Draft specification, RFCs, reference registries and examples, plus the reference-implementation skeleton: build.zig, diagnostic envelope with error-code registry synced to docs, aji CLI, conformance runner with seed tests, CI and contributor docs.
1.7 KiB
09. Runtime, FFI and ABI
1. Runtime principle
The runtime should be small, explicit and auditable.
Core responsibilities may include:
- allocator adapters;
- task scheduler;
- synchronization primitives;
- I/O integration;
- capability materialization;
- platform intrinsics;
- deterministic/replay hooks.
2. System calls
Direct syscalls are runtime/unsafe-only by default.
A syscall wrapper must describe:
- argument types;
- memory read/write regions;
- created/consumed resources;
- effects;
- failure behavior;
- blocking behavior.
3. FFI
Foreign calls are explicit and unsafe unless wrapped in a verified safe abstraction.
Illustrative declaration:
extern "C"
unsafe fn read(
fd: i32,
buf: addr<u8>,
len: usize
) -> isize
effects [ffi];
Safe wrappers must state and uphold ownership, aliasing and thread-safety assumptions.
4. Volatile
volatile.load and volatile.store affect compiler access elimination/reordering as defined by the volatile contract.
Volatile does not itself imply atomicity or inter-thread synchronization.
5. MMIO
Device memory should use a distinct Mmio<T> abstraction obtained through cap<device.mmio>.
CPU-memory atomics and device-ordering barriers are separate concepts.
6. DMA
DMA buffers are explicitly pinned. A buffer cannot be freed, reset or physically relocated while a device operation owns it.
7. Signal/interrupt profiles
Signal and interrupt handlers use restricted capabilities/effects. Allocation, ordinary locking and blocking I/O are forbidden unless a profile explicitly defines a safe mechanism.
8. Backend
The initial native backend should lower AIR to LLVM IR.
A custom native backend is deferred until AIR and verifier semantics stabilize.