Compilation Pipeline

Kria 2.0.0 processes .krx source through the lexer and parser into SSA/module instructions. The command-line runtime uses the LLVM JIT by default for source files, while the interactive REPL runs on RegisterVM:

Source (.krx) → Lexer → Parser → SSA/module → LLVM JIT (source files, default)
                                       └──────────→ RegisterVM (REPL; optional for source files)

Run one entry file; other files are loaded through relative import statements. Imports are not supported in the REPL.

Execution Backends

Kria 2.0.0 provides two active execution backends. The LLVM-based JIT is the default for source-file execution; the interactive REPL always uses RegisterVM. The KRIA_BACKEND setting selects the source-file backend and does not change the REPL.

# Use RegisterVM for a source file
# Linux / macOS
KRIA_BACKEND=register kria program.krx

# Windows PowerShell
$env:KRIA_BACKEND="register"
.\kria.exe program.krx

Remove the variable with unset KRIA_BACKEND on Linux/macOS or Remove-Item Env:KRIA_BACKEND in PowerShell to return to the default JIT.

LLVM JIT

The experimental native JIT compiles generated LLVM IR to a platform-native shared library (.dll, .dylib, or .so) and loads it through a cross-platform dynamic-library API. The JIT requires Clang from LLVM to be available on PATH.

Compiled artifacts are cached in the operating system's temporary directory. The cache key includes generated IR, the Clang version and target, and the JIT optimization level.

RegisterVM

RegisterVM is the default backend for Kria's interactive REPL and can also be selected for source files with KRIA_BACKEND=register. Its register instructions use global, local, and upvalue storage, with call frames for functions and closures.

The REPL keeps globals and functions between inputs, supports multi-line blocks, and auto-prints expressions. Its commands include :help, :reset, and :exit.

The former StackVM was removed from the runtime in 2.0.0 and is retained only as a read-only legacy component; it is not an execution backend.

Optimizations

Kria 2.0.0 includes backend-specific fixes and performance improvements. The current implementation documents hot-loop optimizations for global and local counters, specialized global string appends, monomorphic object-property caches, and shared closure environments.

For measurements, use the benchmark suite in the Kria language repository. It compares RegisterVM and JIT workloads and reports VM execution separately from compilation, process time, and startup overhead.

Source Code

Kria is implemented in Rust. The current repository organizes implementation code into modules including lexer, parser, register, vm, jit, repl, modules, and project.

Explore the kria-lang 2.0.0 source and release notes for implementation details and changes.