Skip to main content

Module jit_ir

Module jit_ir 

Source
Expand description

JIT Compilation for Small IR

This module provides a minimal SSA-like IR for filter expressions that can be JIT-compiled for hot paths.

§Problem

Interpreted filter evaluation has overhead:

  • Function call per operation
  • Branch misprediction from expression dispatch
  • No optimization across operations

§Solution

JIT compilation for hot filters:

  1. Define simple SSA-like IR
  2. Compile to native code (via Cranelift when available)
  3. Cache compiled functions
  4. Fall back to interpreter for cold paths

§IR Design

  • Three-address code style
  • Explicit types (i64, f64, bool, ptr)
  • No control flow (single basic block)
  • Used for simple filter expressions

§Example

Filter: age >= 18 AND score > 50.0

v0 = load_i64 field:0     ; load age
v1 = const_i64 18
v2 = gte_i64 v0, v1       ; age >= 18
v3 = load_f64 field:1     ; load score
v4 = const_f64 50.0
v5 = gt_f64 v3, v4        ; score > 50.0
v6 = and v2, v5           ; AND
ret v6

Structs§

ArrayFields
Simple array-based field storage.
CompiledFilter
Compiled filter that can be executed.
FilterCache
Filter cache for compiled filters.
IrBuilder
IR builder helper.
IrFunction
IR function (single basic block).
IrInterpreter
IR interpreter (fallback when JIT not available).
Reg
Virtual register.

Enums§

IrInst
IR instruction.
IrType
Value type in the IR.
RtValue
Runtime value for interpreter.

Traits§

FieldAccess
Field accessor for runtime.