JIT/AOT execution boundary
This document defines the execution boundary between lowering, runtime, JIT, and AOT. It specifies what MUST remain identical across backends and what MAY differ.
Boundary invariants (immutable unless ABI version bump)
Section titled “Boundary invariants (immutable unless ABI version bump)”-
Lowering parity
- JIT and AOT consume the same lowered artifact semantics.
- No backend-specific language behavior is allowed.
-
Runtime symbol parity
- JIT symbol binding and AOT linker/runtime bridge resolve the same runtime symbol surface.
- Runtime exports are defined by
beskid_abi::RUNTIME_EXPORT_SYMBOLS.
-
Runtime-mediated platform execution
- Platform-specific execution policy (syscalls/OS APIs/blocking behavior) is owned by
beskid_runtime. - JIT and AOT must not implement backend-specific syscall policy.
- Compiler lowering may target runtime ABI entrypoints only for runtime/system functionality.
- Platform-specific execution policy (syscalls/OS APIs/blocking behavior) is owned by
-
Single ABI boundary
- Runtime entrypoints are exposed through stable C ABI symbols.
- AOT and JIT must not introduce backend-only ABI hooks.
-
Interop dispatch scope
- Runtime interop dispatch symbols remain ABI-level runtime exports.
- Interop dispatch is for language/runtime interop boundaries, not a required stdlib generation workflow.
- Return-group routing remains fixed to:
unit->interop_dispatch_unitusize->interop_dispatch_usizeptr->interop_dispatch_ptr
-
Versioned ABI compatibility
- ABI compatibility is controlled by
BESKID_RUNTIME_ABI_VERSION. - ABI-breaking changes require:
- ABI version bump,
- migration note,
- updated boundary validation notes.
- ABI compatibility is controlled by
Allowed backend differences
Section titled “Allowed backend differences”The following differences are allowed and do not violate the boundary:
- Packaging and linkage strategy (in-memory JIT finalization vs object/link pipeline).
- Target selection (host ISA for JIT, explicit target triple for AOT).
- Final artifact form (in-memory executable code vs object/static/shared/executable outputs).
Forbidden backend differences
Section titled “Forbidden backend differences”The following differences violate the boundary and require architecture review:
- Different language behavior between JIT and AOT for the same source.
- Different runtime symbol surfaces imported by JIT and AOT.
- Backend-owned syscall/OS policy that bypasses
beskid_runtime. - Backend-specific ABI entrypoints not versioned through runtime ABI policy.
Validation intent
Section titled “Validation intent”Boundary compliance should be validated through architecture tests and review of:
- Runtime symbol allowlist and ABI version checks.
- JIT/AOT import-surface consistency.
- Runtime dispatch routing behavior.
- Execution behavior parity for runtime ABI calls.
- Absence of backend-specific platform execution policy.
Maintenance workflow
Section titled “Maintenance workflow”- Keep runtime as the only platform policy owner during refactors.
- Treat boundary changes as architecture changes, not implementation-only edits.
- Document any ABI-surface change with version, rationale, and migration note.