The JIT compiled the code and then never ran it
On 33 of 44 primitive operations our optimizing JIT was no faster than the interpreter. For many of them the reason was simple and embarrassing: the native code existed and nothing ever jumped to it.
A just-in-time compiler has two jobs. It has to produce good machine code, and it has to arrange for that code to run. In November 2026 we audited every tier of Quench at the level of individual instructions and found that the second job was the one failing.
The audit
We took 44 primitive operations (an integer loop, a field read and write, a method call, a closure call, a try/catch) and for each one counted the machine instructions executed per iteration in four configurations: the C equivalent, the interpreter, the baseline b-jit and the optimizing u-jit.
The verdict across all 44: u-jit gave no real benefit over the interpreter on 33, and b-jit executed more instructions than the interpreter on 28.
Look at the top three rows first. Where the optimizing tier engages, it is good: an integer loop at 49 instructions against C's 8, a switch at 28 against 13, a direct call inlined down to 7. The code generator is not the problem.
Finding 1: compiled and not entered
The field-read-write test is a loop that reads and writes one object field 50 million times. The counters said the loop body had been compiled. They also said the number of completed native runs was zero. All 50 million iterations ran in the interpreter, at 708 instructions each against 8 in C.
The compiled code was fine. It was never entered because of a mismatch at the door. Entering native code in the middle of a running loop (on-stack replacement) requires converting the interpreter's live values into the form the compiled code expects. One entry path widened integer slots to raw doubles. Every later attempt to enter saw values in the wrong form and declined, silently, forever.
The fix was a few lines.
The same pattern, with a different cause, hid behind every loop that contained a call. The loop analysis rejected them with an "unsupported instruction" code and fell back without a trace.
The general failure is that engagement was asserted and never measured. A tier could engage zero times on a workload and no test, counter or dashboard would say so. The principle that came out of it is short: engagement is measured, not asserted. The rule now is that every tier reports how often it was entered on every corpus program, and zero is an error.
Finding 2: asking the interpreter for help costs 600 to 1,000 instructions
Compiled code cannot handle everything inline. When it meets an operation it has no fast path for, it asks the runtime to do that one step. In Quench that was shockingly expensive.
A remainder by a constant, i % 7, took 69 instructions in the interpreter and 671 in the baseline JIT. An integer compare took 83 against 767. The actual work was the same. The other 600 were boxing the registers, re-decoding the instruction, going through the fully generic operation, and reloading state afterwards.
That is why the baseline tier lost to the interpreter on 28 primitives. Any operation without a stencil turned into a round trip ten times the cost of interpreting it.
Finding 3: three controllers and two gatekeepers
Three separate pieces of code decided when to compile (one for loops, one for function bodies, one for call sites), and two decided what was allowed in. The two gatekeepers disagreed: the lowering could compile calls that the analysis rejected. So a loop could be judged hot by one controller, rejected by one gatekeeper, and compiled anyway by a path that then could not be entered.
What landed in the following two days
| Fix | Before | After |
|---|---|---|
| Loop entry no longer widens integer slots | field-read-write 2.6 s | 0.25 s |
push, pop and charCodeAt inline in compiled loops | array-push-pop 3.7 s, about 900 instructions per call | 0.53 s |
Array .length kept as an integer fact | nbody position loop 144 instructions | 53 |
| Calls from compiled loops use the callee's native entry | about 2,000 instructions per call | about 140 |
| One predicate decides which tier owns a loop, plus follow-ups | crc under b-jit 3.26 billion instructions | 1.07 billion |
Nine primitives were still slower in the optimizing tier than in the interpreter when this was written, among them method calls, constructors, try/catch and rest and spread arguments. They are tracked by name.
The lesson
We had spent weeks improving the code the compiler generated. The audit showed that for most programs the generated code was not what was running. Two habits changed:
- Count instructions per operation, per tier, against a reference. A whole-benchmark score cannot tell you that a tier never engaged. An operation that costs the same in every tier can.
- Make silence impossible. Every decline, every fallback and every refused entry is counted and has a named reason. A tier that does nothing has to say so.