Skip to content
Beskid Platform specification

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

Flow and algorithm

Spec standingStandard

Owner
Piotr Mikstacki
Submitter
Piotr Mikstacki

Document the end-to-end algorithm from compiler build through JIT/AOT link to first user entry, including where ABI version and export symbols are validated.

See the design model diagram for actor boundaries.

  1. Construct BeskidJitModule (compiler/crates/beskid_engine/src/jit_module.rs) with an optional extras table for resolved user Extern addresses when dynamic linking is enabled.
  2. On first compile, call declare_builtin_imports once, wiring every name in BUILTIN_SPECS to the in-process beskid_runtime function pointer of the same symbol string.
  3. Declare user functions and validated extern imports from the CodegenArtifact, emit string literals and type descriptors, then define and finalize Cranelift bodies.
  4. Before transferring control to generated code, the host should call beskid_runtime_abi_version() and compare the result to BESKID_RUNTIME_ABI_VERSION embedded in the compiler’s beskid_abi dependency (ABI-003).
  1. Backend emits object code that imports the same symbol names listed in RUNTIME_EXPORT_SYMBOLS.
  2. Link step resolves symbols against the bundled beskid_runtime static or shared library built for the target triple.
  3. Packaging must record the ABI version used at link time in release metadata when distributing standalone binaries (tooling convention; see verification).

For each BuiltinFnSpec entry in compiler/crates/beskid_abi/src/builtins.rs:

  1. Map symbol to a host extern "C-unwind" function in beskid_runtime::builtins.
  2. Build a Cranelift function signature from params: &[AbiParamKind] and returns: AbiReturnKind (Ptr, I64, Void, Never, …).
  3. Store the FuncId in the JIT module’s func_ids map so lowering can emit direct calls.

Missing symbols surface as JitError::MissingFunction at finalize time rather than as undefined behavior at runtime.

  1. Increment BESKID_RUNTIME_ABI_VERSION in beskid_abi/src/version.rs.
  2. Update RUNTIME_EXPORT_SYMBOLS and BUILTIN_SPECS together with runtime #[unsafe(no_mangle)] implementations.
  3. Refresh platform-spec articles and compiler/crates/beskid_tests / beskid_e2e_tests fixtures that pin version or symbol lists.
  4. Publish runtime and compiler artifacts in lockstep; mixed versions are unsupported for production (ABI-004).