Optional loop compiler for tight numeric code. When a loop matches the pattern, SPL runs it in a small stack VM instead of walking the AST every iteration. Same results as the interpreter — just fewer Python trips.
Off by default. Set
SPL_JIT=1 in the shell before
run-spl. The CLI banner shows
[JIT] when it is on. Browser / Pyodide
runs stay interpreted.
# shell SPL_JIT=1 run-spl myscript.spl # see compile hits vs fallbacks on stderr SPL_JIT=trace run-spl myscript.spl
test.forLoop when
every body statement is
name.setVar(<numeric expr>)
(one or many statements).
test.while when the condition is
test.isEqualNumber,
test.isLess, or
test.isGreater, and the body is the
same numeric setVar pattern.
math.add /
subtract /
multiply /
div /
mod,
unary math.floor /
ceil /
round /
sqrtR,
numeric literals, the loop variable, and other variables visible in the
scope chain.
Sum 1…100 — classic JIT win:
sum.setVar(0); test.forLoop(1, 100, i): sum.setVar(math.add(sum, i)); end; print.number(sum);
Multi-statement body (both lines compile):
a.setVar(0); b.setVar(0); test.forLoop(1, 5, i): a.setVar(math.add(a, i)); b.setVar(math.add(b, 1)); end;
Numeric while:
n.setVar(0); test.while(test.isLess(n, 10)): n.setVar(math.add(n, 1)); end;
Anything else keeps using the normal interpreter — no error, just no speedup. Common reasons:
print.*, if, break / continue inside the loopuse, error.try
Use SPL_JIT=trace to print fallback
reasons to stderr (e.g.
forloop fallback: body not all numeric setVar).
DivisionByZeroError from math.div in a compiled loop.forLoop bounds promote math to float).SPL_JIT=1 run-spl tests/jit/bench_sum.spl python3 -m unittest tests.test_jit
Implementation: someProgrammingLanguage/spl_jit.py
· backlog: JIT_ROADMAP.md