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:
- Define simple SSA-like IR
- Compile to native code (via Cranelift when available)
- Cache compiled functions
- 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 v6Structs§
- Array
Fields - Simple array-based field storage.
- Compiled
Filter - Compiled filter that can be executed.
- Filter
Cache - 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§
Traits§
- Field
Access - Field accessor for runtime.