Quench.
COMPILEDNOT ENTERED

blog / · 4 min read · jit

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.

Instructions per iteration (log scale), 17 November 2026 auditCinterpreterb-jitu-jitint-loop819415349int-switch133502,66628call-direct122712,5947call-method113782,100500field-read-write8465656708try-catch-throw8.87657642,197
Counted with callgrind on a tree combining the trunk and the JIT branch. Where u-jit works (the top three rows) it is within a few times of C. On the bottom three it runs more instructions than the interpreter.

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.

field-read-write, 50M iterations, optimizing tierinterpreter1.6 su-jit before2.6 su-jit after0.25 s
Before the fix the JIT configuration was slower than the interpreter: it paid for compiling and still interpreted. Commit 42fd6c98ce.

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.

One interpreted step from inside native codenative regionvalues in registersbox registersinto the frameruntime stepre-decode bytecodegeneric operationfull dynamic pathrefresh basesreload object tablesback to native code600 to 1,000 instructions later
The operation itself is a few dozen instructions. Everything around it is the cost of crossing.

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

FixBeforeAfter
Loop entry no longer widens integer slotsfield-read-write 2.6 s0.25 s
push, pop and charCodeAt inline in compiled loopsarray-push-pop 3.7 s, about 900 instructions per call0.53 s
Array .length kept as an integer factnbody position loop 144 instructions53
Calls from compiled loops use the callee's native entryabout 2,000 instructions per callabout 140
One predicate decides which tier owns a loop, plus follow-upscrc under b-jit 3.26 billion instructions1.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:

  1. 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.
  2. 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.

Try it

Quench builds from source with Cargo and runs TypeScript, JavaScript and WebAssembly.

Build and run

Work on it

Interpreter, JIT, AOT, GC, Node APIs. Every claim on this blog has a measurement you can rerun.

Where to start

Follow it

New posts land here as the engine moves. Star the repository or subscribe to the feed.

Star on GitHub Feed