Expand description
High-performance bytecode VM for v2 Jetro expressions.
§Architecture
String expression
│ parser::parse()
▼
Expr (AST)
│ Compiler::compile()
▼
Program ← flat Arc<[Opcode]> (cached: compile_cache)
│ VM::execute()
▼
Val ← result (structural: resolution_cache)§Optimisations over the tree-walker
- Compile cache — parse + compile once per unique expression string.
- Val type —
Arc-wrapped compound nodes; every clone is O(1). - BuiltinMethod enum — O(1) method dispatch (jump-table vs string hash).
- Pre-compiled sub-programs — lambda/arg bodies compiled to
Arc<Program>once at compile time; never re-compiled per call. - Resolution cache — structural programs (
$.a.b[0]) cache their pointer path after the first traversal; subsequent calls skip traversal. - Peephole pass 1 — RootChain —
PushRoot + GetField+fused into a single pointer-resolve opcode. - Peephole pass 2 — FilterCount —
CallMethod(filter) + CallMethod(len/count)fused; counts matches without materialising the intermediate filtered array. - Peephole pass 3 — ConstFold — arithmetic on adjacent integer literals folded at compile time.
- Stack machine — iterative
exec()loop; no per-opcode stack-frame overhead for simple navigation / arithmetic opcodes.
Structs§
- Bind
ObjSpec - Compiled bind-object destructure spec.
- Comp
Spec - Compiled comprehension spec.
- Compiled
Call - A compiled method call stored inside
Opcode::CallMethod. - Compiler
- Dict
Comp Spec - Pass
Config - High-performance v2 virtual machine.
- Program
- A compiled, immutable v2 program. Cheap to clone (
Arcinternals). - VM
Enums§
- Builtin
Method - Pre-resolved method identifier — eliminates string comparison at dispatch.
- CompiledFS
Part - A compiled f-string interpolation part.
- Compiled
ObjEntry - A compiled object field for
Opcode::MakeObj. - Opcode