JIT backbone specification
Purpose
Section titled “Purpose”The JIT is a thin development-time execution engine for fast feedback. AOT is the primary production path. Both use the same frontend, CLIF lowering, and runtime ABI boundary.
Primary components
Section titled “Primary components”cranelift_jit::JITModulecranelift_module::Moduletraitcranelift_frontend::FunctionBuilder
JIT flow (per module)
Section titled “JIT flow (per module)”- Build target ISA via
cranelift_native::builder(). - Create
JITModulewith aJITBuilder. - Declare function signatures and import runtime ABI symbols.
- Lower HIR into CLIF and call
define_function. - Call
finalize_definitions(). - Retrieve function pointers with
get_finalized_function.
JIT scope and constraints
Section titled “JIT scope and constraints”- The frontend emits CLIF once.
- The module abstraction is shared with AOT.
- JIT must not implement platform syscall policy or backend-specific execution behavior.
- JIT imports runtime builtins through the shared ABI manifest used by AOT.
- For AOT, replace
JITModulewithObjectModule.
JIT responsibilities
Section titled “JIT responsibilities”- Fast host-platform compilation and execution for development feedback.
- Runtime ABI symbol binding through shared runtime surface.
- Reuse of lowering semantics identical to AOT.
JIT non-goals
Section titled “JIT non-goals”- Production artifact packaging and linker orchestration.
- Platform ownership for syscall behavior.
- Runtime ABI shape ownership.
Safety model
Section titled “Safety model”- All finalized function pointers remain valid until
free_memory(). - Do not hold or call pointers after memory is freed.
Debug strategy
Section titled “Debug strategy”- Allow optional CLIF emission to files for testing.
- Use
cranelift_readerto parse CLIF for golden tests. - Keep JIT validation focused on thin-backend behavior over shared lowering/runtime boundaries.