Hazel reports · ^report(56) · hazel-jit · 2026-11-18, revised 2026-11-18 08:37 MST · work in progress · after ^report(54) and ^report(55)
What Still Falls Back
hazel-jit compiles Hazel to JavaScript, and wherever it compiles a program it now gives the interpreter's answer, checked in CI (^report(54), The same answers, checked in CI). This report starts from that check, on build 50, and turns to the other side of it: every case where the interpreter still does the work, because hazel-jit does not compile the code or stops part way and falls back. It sorts those cases four ways: limits to lift now; decisions still open; holes, a project for John, kept apart from the rest; and stuck terms, later, which share machinery with holes. It also sets out the two uses of compiled code, livelit views and mixed mode, and how counting the interpreter's steps answers the worry about programs that never end.
Where hazel-jit compiles a program, it gives the interpreter's answer, and fast: run again and again, the median of the evaluator's 233 such programs is 227 times as fast compiled (36 µs against 0.19 µs), and all but one are faster, from 2.3 to 1,369 times. The exception, {} == {} at 0.64 times, 202 times as fast in build 50's other CI run (44211080673), is most likely a pause during its repeats: each of the two runs has one such program, a different one, and each is fast in the other. Run once, compiling included, the median is 1.1 times as fast, and 101 are slower: programs of a few microseconds, where compiling is the cost.
55e4757a4b, CI run 44319161267, the fast checks, Node on GitHub's machines; ^report(54)'s figure is the same plot for build 49). Each program's interpreter runs repeated until they added to 20 ms (10 to 1000 times), its compiled JS's until they added to 5 ms; each dot is a run's time, the total over the repeats. Below the line marked "as fast", compiled code was faster. One run; the dot above the line is discussed in the text. Not a build of the app.Outline#
- Where the check stands: on build 50, 233 of the evaluator's 313 test programs compile and give the interpreter's value; none differ.
- Two uses, and programs that never end: livelit views on the page's thread, mixed mode for all evaluation, and how step counts and a step limit keep a compiled run from running forever.
- Limits to lift: the 80 evaluator programs compiled code does not handle, listed again from
^report(54), the slides' limits, and the rest, apart from holes and stuck terms. - Open decisions: the seventeen of
^report(54), the four of^report(55), and four new ones, with our leans. - Holes in compiled code: John's project, its edges drawn so it can go on beside the rest.
- Stuck terms in compiled code: making the interpreter's stuck terms in JavaScript instead of stopping, the machinery holes need later too.
- What next, by whom, and how this was put together.
Where the check stands#
On build 50, every one of the evaluator's 313 test programs also runs compiled in CI: 260 compile, 235 agree with the interpreter and none differ. Of those 235, 233 give the same value and 2 stop where the interpreter's answer is stuck; the other 25 compiled are ill-typed tests with nothing to compare, and 53 are not compiled. (^ticket(756).)
55e4757a4b), the sweep in the fast checks of CI run 44319161267. Each of the evaluator's test programs also goes to hazel-jit, compiled and run in JavaScript, and its answer is compared with the interpreter's. "Both stop, stuck": a projection the interpreter leaves stuck, where the compiled run stops and the interpreter's answer is shown. "Ill-typed": the interpreter stops at a failed run-time check, which compiled code, its types erased, runs past; the page compiles no program with a static error. ^report(54)'s bar is build 49's.Build 50 is 55e4757a4b on trial/694-view-jit (hazelgrove/hazel#2817), the prototype branch, since 2026-11-18: build 49 and the slides' builtins. All of CI passed at this commit before the branch moved to it (CI run 44211080673, on the slides' branch: static checks, fast checks, and the full tests in 92 minutes). On the prototype branch, its own CI (run 44319161267) has passed the static and fast checks with the same counts, the numbers quoted here; its full tests passed too, in 94.5 minutes of their 100, and so did the Firefox check of the Witch slide (run 44319161252). Against build 49 (^report(54)), two programs moved: (true).a and the same with an ascription. The interpreter leaves these stuck. Compiled code once read undefined there and ran on, which the check counted as nothing to compare; it now stops, as the interpreter does, and the check counts that as agreeing.
How the check compares, from ^report(54): numbers exactly (floats within a relative 10-9), lists, tuples, labels and constructors by structure, and a function only as being a function. A compiled run that stops at an invalid operation agrees with an interpreter result stuck at the same error. Anything else that parts from the interpreter fails its test, and so fails CI.
The slides. Of the 129 programs in hazel-programs, 20 compile on build 50, and all 20 agree (the full tests of CI run 44211080673, at the same commit). Mixed mode. The check also runs each evaluator program a third way, mixed: on build 50, 6 programs have a function to compile (7 functions), all 6 agree, 16,843 calls ran compiled and 2 fell back; 29 functions were left to the interpreter because their whole type is not declared.
Two uses, and programs that never end#
hazel-jit began as a way to draw livelits within a frame, on the page's own thread, and is becoming a way to run any complete function, called by the interpreter in its worker. A compiled run that never ends cannot freeze the page today, because its stack overflows within a millisecond or its budget stops it; once compiled code counts the interpreter's own steps, it will also stop where the interpreter stops, so even a run out of steps gives the same answer.
The first use: livelit views#
A livelit is drawn by a view function written in Hazel, over the livelit's model. Dragging a slider changes the model and calls for a new picture at every step. Hazel's interpreter runs in a web worker, and a run there, with the round trip, takes longer than a frame on a large slide. So hazel-jit compiles each view function once, with the model as a parameter, and the page runs the JavaScript on its own thread at each step: a step of the Witch's slider in 2 to 3 ms (^report(50)), and 6.5 ms a frame, about 154 fps, over a whole drag on build 50 (^report(54), What it all costs). ^report(52) added a slide's whole run, compiled. The compiled answer is a preview: the interpreter still runs every program, and its answer is the result, with the probes, the tests and the result panel. When hazel-jit does not compile something, or a compiled run stops, the page waits for the interpreter, as it did before hazel-jit.
The latest idea: mixed mode, for all evaluation#
Mixed mode (^ticket(766), chosen after the meeting of 2026-11-13) keeps the interpreter in charge of every program, so holes, probes and the stepper work as they do, and gives its complete functions compiled speed. Each function bound at the program's top, or in a module there, whose whole type is declared (let f : A -> B = fun ...) is compiled, and the interpreter calls it as it calls a builtin: the argument goes into JavaScript, the compiled function runs, and its answer comes back by the declared type. If the call stops for any reason, that call alone falls back: the interpreter applies its own closure to the same argument. Here the compiled answer is the answer, not a preview. It runs in the tests only, so far, with no setting in the app. On build 50, in Node:
| Program (in Node, build 50) | The interpreter alone | Mixed | As fast, times |
|---|---|---|---|
| fib(16), all compiled | 66.5 ms | 0.1 ms | 665.0 |
| the Petri net rule, whole types declared, 100 events | 170.1 ms | 19.0 ms | 9.0 |
| the I Ching's rules, 200 readings | 1,028.0 ms | 197.1 ms | 5.2 |
| 500 calls of a one-line function (sq) from an interpreted loop | 20.6 ms | 21.8 ms | 0.9 |
The last row is the crossing's cost: a call into a one-line function costs more than the function saves (a limit).
Programs that never end#
Cyrus Omar's concern, at the meeting of 2026-11-13: "We need a way to limit compiled hazel functions that diverge --- we need a step limit. esp if we continue to optimize by including certain jit-compiled hazel functions into the main thread". The interpreter has its own limits (^report(54): a 20-second timer and 100 million transitions), but compiled code does not run through it.
Today, a budget of calls and time. (^ticket(763), on the prototype since build 46.) Hazel has no loops, so a program that never ends recurses forever. Every compiled function counts its calls, and every 16,384 calls reads the clock; a run past its budget stops, and the interpreter's run answers. Livelit views have 50 ms or 50 million calls a run, and a mixed-mode call a second or 50 million calls. Endless recursion turned out to be the smaller risk: JavaScript has no tail calls, so it overflows the stack in about a millisecond, and that error is caught like any other. The real risk is a run that ends, but late (fib(45)), and the clock catches that. In Node the counter costs 11 to 26%, and 20 to 33% with the clock. So a compiled run holds the page's thread for about its budget at most: the clock is read every 16,384 calls, and a builtin call, once begun, runs to its end. What it does not give is the interpreter's answer: a run the interpreter would finish, compiled code may give up on, and the reverse, because the two count different things.
Next, the interpreter's own steps. The meeting asked compiled code to count the steps the interpreter would take (^ticket(767)), and ^report(54) found it can: step counts and probes, as the interpreter's. hazel-jit translates construct by construct and runs in the interpreter's order, and most constructs take a fixed number of steps of their own, so the compiler adds the right number for each straight run of code, about what today's call counter costs. Then:
- One limit, in one unit. The budget becomes the interpreter's step limit (decision 9, answered 2026-11-13). A program that never ends stops at the same step both ways, and so does a long one, so "ran out of steps" is part of the same answer, and the consistency check can cover it as it covers values.
- In mixed mode, a compiled call adds its steps to the interpreter's count, so a program's count is the same mixed or not, and the interpreter's limit stops it wherever its steps are taken. Mixed mode is to run in the worker (decision 6's lean), where a long run makes results late but freezes nothing.
- On the page's thread, steps alone do not bound time: a step that calls a builtin on a long list or string is one step, and a frame is 16.7 ms. So the lean is to keep the clock there too, set by the frame, beside the step limit (decision 20). If the clock stops a view, the page waits for the interpreter, whose answer is the same, as now.
- What it cannot do is tell a program that never ends from one that ends late; no limit can. A step limit bounds both, and the same way in both, which is what the same answers need.
The work: casts carried by functions, and the interpreter's own bookkeeping, are where counts need care, and a check in CI compares each evaluator program's count with the interpreter's (^report(54) lists the steps). Probes follow from the counts.
Limits to lift#
Of the evaluator's 313 programs, compiled code does not handle 80, and none of them meets a limit worth lifting: they are holes, ill-typed tests, unbound names and stuck terms, which the next sections take up. The limits that cost the most are elsewhere: tests in the slides (28 of 129), static errors anywhere in a program, the stack's depth, and how far mixed mode reaches. The aim is to run compiled wherever the answer can be the interpreter's, and fall back only where it cannot. Holes and stuck terms are kept out of this section on purpose, so that work on them can go on apart.
The evaluator's test programs, again from ^report(54)#
^report(54)'s sweep table, brought to build 50, with each kind of program sent to the section that takes it up:
| The program meets | Programs | Today | Discussed under |
|---|---|---|---|
| an expression hole, a multihole, or a tuple label that is a hole | 15 | not compiled, by rule (2026-11-13) | holes: the rule stands |
a type hole, ? in a type | 10 | not compiled, by rule | holes: the rule stands |
a free variable: the test's own unbound name (y 13, s2 6, x 2, b2 2, a 1) | 24 | not compiled: a static error; the interpreter's answer holds the variable, stuck | stuck terms; decision 8 |
a fixpoint over a pattern that is not a name: fix _ : (), fix (_ : Bool), fix 0 and fix () | 4 | not compiled, a limit; ill-typed tests, left so on purpose | a limit: none planned |
| an ill-typed program: the interpreter stops at a failed run-time check | 25 | compiled by the sweep; compiled code runs past the check, so there is nothing to compare; the page compiles none of these | stuck terms; decision 8, decision 12 |
a projection the interpreter leaves stuck: (true).a, and the same with an ascription | 2 | compiled; the run stops, and the interpreter's answer is shown: agreeing, by falling back | stuck terms |
| Not handled in compiled code | 80 | of 313; the other 233 compile and give the interpreter's value |
The 53 programs not compiled, by the test that evaluates each, as the sweep on 8d7694d9ff (build 50 and one line that prints them, trial/756-sweep-names, CI run 44321800774)
- a hole (15):
3 == let (a,b,c) = (?=1, 2, b=3) in c(a=1, b=2, c=?).a?.a == ?.alet x = 5 in if ? then x else xif ? then ? : String else ? : String == (if ? then ? else ?) : String : String(case ? | 1 => true : String | _ => false : String end) == (case ? | 1 => true | _ => false end) : String?(_, _, 3)(1., true)? : [Int] == let x :: y = ((1 :: ?): [Int]) in yAscriptions don't do unnecessary unrollinglet T = 1 in ?Indet when unboxing constructor with payload without payloadIndet when unboxing constructor as listIndet when unboxing constructor as consIndet when unboxing constructor as tupletypfun y -> (?:y) == type y = Int in typfun y -> (? : y)
- the free variable y (13):
(x : Int) :: (y : [Int]) == (x :: y) : [Int](x : [Int]) @ (y : [Int]) == (x @ y) : [Int]x + y == (x + y) : Intx - y == (x - y) : Intx * y == (x * y) : Intx ** y == (x ** y) : Intx / y == (x / y) : Intx < y == (x < y) : Boolx <= y == (x <= y) : Boolx > y == (x > y) : Boolx >= y == (x >= y) : Boolx == y == (x == y) : Boolx != y == (x != y) : Bool
- a type hole (10):
2 == ((fun a -> a): ? -> ? )(2: ?): Int2 == (fun (a=a): ((a=Int)) -> a: ?)(a=2)"llo" == (string_sub : ?)(_, 2, 3)("hello")[] == let f : ? -> ? = map(_, fun _ -> 1) in f([])[1.0 : Int, 2.0 : Int] == let f : [Int] -> ? = map(_, fun i -> i) in f([1.0, 2.0] : ?)[1.0 : Int, 2.0 : Int] == let f : ? -> [Int] = map(_, fun i -> i) in f([1.0, 2.0] : ?)Hidden inconsistency caught in dynamicsHidden containing arrow in tuple caught in dynamicsA : (+A +B) : (+A + ?)Indet when unboxing constructor as typfun
- the free variable s2 (6):
s1 ++ s2 == (s1 ++ s2) : Strings1 +. s2 == (s1 +. s2) : Floats1 -. s2 == (s1 -. s2) : Floats1 *. s2 == (s1 *. s2) : Floats1 **. s2 == (s1 **. s2) : Floats1 /. s2 == (s1 /. s2) : Float
- a recursive definition by a pattern that is not a name or a tuple of names (3):
() == fix _ : () -> test B end() : Bool == fix (_ : Bool) -> test false end() : Int == fix 0 -> ()
- the free variable x (2):
(fun x -> x)(x)Indet Variables in sum constructors
- the free variable b2 (2):
b1 && b2 == (b1 && b2) : Boolb1 || b2 == (b1 || b2) : Bool
- a recursive definition of more than one name whose part that is not a function names one of them (1):
[] : () == fix () -> []
- the free variable a (1):
Indet when unboxing constructor as float
The 25 ill-typed programs, by test (the sweep's known list)
(a=3 : Bool, b= "": Float) == (a=3, b="") : (c=Bool, d=Float)(a=1,b=2).c == (a=1,b=2).cDuplicate labels projected are indetmismatched types1 : String == case 1 | (x : String) =>x endcase 1 | ("hello") => false | (x : String) => true end == case 1 | ("hello") => false | (x : String) => true end(case () | (1, 2) => true | _ => false end) == (case () | (1, 2) => true | _ => false end)[1 : String,2 : String,3 : String] == [1,2,3] : [String][1 : String,2 : String,3 : String] == type T = [String] in [1,2,3] : T[1, "hello" : Int] == 1 :: ["hello"]4 : String == 4 : Stringtrue : String == true : String1. : String == 1. : StringNatSInt(4 : String) == let x : String = 4 in x1 + (4 : String) == 1 + (4 : String)Hidden containing arrow caught in dynamicsLabeled tuple with different labelsLabeled tuple with rearragned labelsTypfun is not comparableA : (+A +B) : (+A +C)Indet when unboxing constructor as boolIndet when unboxing constructor as stringIndet when unboxing constructor as int
The 2 stuck projections
(true) . a == (true) . a((true) . a): Int == ((true) . a): Int
So the evaluator's tests hold no limit worth lifting. The four that meet one are ill-typed fixpoints over a pattern that is not a name, whose interpreter answers are failed casts, so compiling them would only add partings. One of them, fix () -> [], the compiler reports as a recursive definition of more than one name, since () is a tuple of no names; ^report(54) and ^report(55) took it for a recursive definition a finer check could compile, which the names show it is not (corrected there). The 24 programs with an unbound name are the evaluator's tests of indeterminate evaluation, such as x + y == (x + y) : Int: their answer is the stuck term itself.
The slides, and forms not yet compiled#
The slides meet more. One reason a slide, the first it meets (build 50's commit, the full tests of CI run 44211080673):
| The slide's program meets, first | Slides | Discussed under |
|---|---|---|
| a static error (the page compiles no program with one) | 21 | decision 8 |
| a type hole | 29 | holes |
| a hole | 28 | holes |
a test, test ... end | 28 | a limit |
| this kind of pattern (a splice) | 1 | a limit |
the builtin group_by_label | 1 | a limit |
| a closure with its own environment | 1 | a limit |
| compiled, and agreeing | 20 |
- Tests,
test ... end, on 28 slides: the largest limit left on the slides, and contained. Compiled code would record each test's outcome as the interpreter does (passed, failed, or indeterminate) and hand the outcomes back with the answer for the tests panel. It is the first of what the interpreter records (below) and the simplest, since a test's outcome is a value. - A splice in a pattern, the builtin
group_by_label, and a closure with its own environment, one slide each. The first two are small. The third is the assumption that a compiled program is closed; in mixed mode, free variables bound to the interpreter's values come in at the boundary, and an interpreter closure would have to be compiled too or called back. - A static error anywhere keeps the whole program interpreted (21 slides). In mixed mode the lean is per function: compile the functions that type well, and catch a value that does not fit where it crosses (decision 8).
- Forms neither the tests nor the slides meet today, each a reason the compiler names (
HazelJit.re): a tuple label that is not a name; an applied pattern that is not a constructor; a projection by something other than a label; a quotation; a module bound by a pattern that is not a name; a partial application's_outside one, or with a labeled argument; livelit names. Each is small, and none is urgent until a program meets it.
At run time: the stack, and the budget#
- The stack. JavaScript's stack holds thousands to tens of thousands of calls, depending on the browser, where the interpreter keeps its stack on the heap. A
List.mapover 100,000 elements works in the interpreter and overflows compiled; today that falls back, correct but slow. The common case is the list builtins, which the runtime could write as loops; a general fix (a trampoline, or code that keeps its own stack) costs every call. - The budget. A run past its budget falls back, correct and slower. With step counts it becomes the interpreter's limit (above), and for a view, a frame's clock too.
How far mixed mode reaches#
- Whole types declared. 29 of the evaluator's functions were left out because only part of their type is declared. The elaborated type of any function would reach more, but it can hold unknowns, and the answer is converted back by that type (decision 3). Declaring whole types pays in the interpreter too: 5 to 7 times cheaper a step (
^ticket(762)). - Across modules. A module's member that calls another module's member is not compiled yet, so the I Ching's rules do not compile whole.
- The crossing. Converting values in and out costs more than a one-line function saves (500 calls of
sq, 21.8 ms mixed against 20.6 ms interpreted, build 50). Convert a large value once and remember it, and leave very small functions to the interpreter. - In the app. No setting yet, and no hook where the worker evaluates.
What the interpreter records#
Tests (above), probes and the stepper. A probe shows the values that passed through it; today a probe always shows the interpreter's run, correct and never faster, and in mixed mode a compiled function's own probes record nothing (decision 5: until step counts land, a probe should take its function out of the compiled set). With the interpreter's step counts, compiled code can make the interpreter's own samples, with two limits (^report(54), steps). The stepper shows the terms between steps, and compiled code has none, so it stays the interpreter's, by rule.
Open decisions#
Twenty-five: ^report(54)'s seventeen, ^report(55)'s four, and four new ones here. Three were answered at the meeting of 2026-11-13; the rest were for the team's meeting of 2026-11-17, whose answers are not yet written down. Numbers 1 to 17 are ^report(54)'s, 22 to 25 ^report(55)'s; 18 to 21 are new. Each lean is ours, for discussion; ^report(54)'s Questions for the team and ^report(55)'s Questions to settle first give each one's reasons and what it decides.
| # | Decision | Our lean | From | Where it stands |
|---|---|---|---|---|
| What compiled code must match | ||||
| 1 | SInt at 32 bits, and overflow an error (hazelgrove/hazel#2828): agreed? | Yes; wrapping would be cheaper compiled, but silent. | 054 q1 | PR waiting on a review |
| 2 | Who reviews the fix for modulo by zero (hazelgrove/hazel#2825)? | Anyone who knows the evaluator; it is small. | 054 q2 | PR waiting on a review |
| 10 | String length in graphemes: intended? | Keep it; compiled code counts as the interpreter does. | 054 q10 | asked for 2026-11-17; the answer not yet written down |
| 11 | Labeled tuples as JavaScript arrays carrying their labels: fine? | Fine inside compiled code; the boundary converts. | 054 q11 | asked for 2026-11-17; the answer not yet written down |
| 12 | The evaluator's ill-typed tests (25 on build 50, 27 on build 49): keep them on a known list? | Keep them: they test the interpreter's casts, and the page compiles no program with a type error. | 054 q12 | asked for 2026-11-17; the answer not yet written down |
| 18 | The check counts a compiled run that stops where the interpreter's answer is stuck as agreeing (an invalid operation, undefined, a stuck projection). Keep that? | Keep it while compiled code makes no stuck terms; compare the terms themselves once it does (stuck terms). | new | open |
| Mixed mode | ||||
| 3 | Which functions does mixed mode compile? | Let-bound, complete, whole type declared, no probe. | 054 q3 | asked for 2026-11-17; the answer not yet written down |
| 4 | What does the stepper show for a compiled call? | Mixed mode off while the stepper is open. | 054 q4 | partly answered 2026-11-13: it counts the steps it would have taken |
| 5 | Probes in compiled code? | Until step counts land, a probe takes its function out of the compiled set. | 054 q5 | answered 2026-11-13: count the interpreter's steps, and make its samples |
| 6 | Main thread or worker? | Mixed mode in the worker; livelit views on the main thread, under a budget. | 054 q6 | asked for 2026-11-17; the answer not yet written down |
| 7 | Falling back runs a call again from the start: safe for good? | Yes while evaluation has no effects. | 054 q7 | asked for 2026-11-17; the answer not yet written down |
| 8 | A program with a type error elsewhere: compile its sound functions? | Yes, per function; a value that does not fit is caught where it crosses. | 054 q8 | asked for 2026-11-17; the answer not yet written down |
| Steps, budgets and stuck terms | ||||
| 9 | One step budget or two? | One, in the interpreter's steps. | 054 q9 | answered 2026-11-13: one, which compiled code will count exactly |
| 19 | Count every step, or only those that interpret the program? | Every step: probe samples' spans are in every step today. | 054 steps | open |
| 20 | On the main thread, a step limit alone, or steps and a clock? | Both: the steps make the same answer as the interpreter's, the clock keeps a frame (below). | new | open |
| 21 | Stuck terms: should compiled code make them, instead of stopping? | Not yet: stopping is correct, and rare in finished programs. Begin with overflow, after the limits, when the holes work needs it (below). | new | open |
Holes (^report(55)) | ||||
| 22 | Does the holes work live on the prototype branch? | Design and measure there; it lands on dev with mixed mode. | 055 q1 | open; settle before John starts |
| 23 | Which values are opaque: empty holes only, or every indeterminate term? | Every value to_js cannot represent. | 055 q2 | open |
| 24 | Must a hole keep its identity through compiled code? | Yes; the table gives back the very term that went in. | 055 q3 | open |
| 25 | The checked version: compiled up front, or the first time a hole arrives? | The first time. | 055 q4 | open |
| Landing, and the interpreter's side | ||||
| 13 | How does hazel-jit reach dev? | Small PRs (^report(53)): the two fixes; the compiler with the check in CI and nothing a user sees; mixed mode behind a setting; then livelit views. | 054 q13 | asked for 2026-11-17; the answer not yet written down |
| 14 | Should hazeljs ship the compiler? | No: a build-time tool; pages get only the runtime (about 17 kB). | 054 q14 | asked for 2026-11-17; the answer not yet written down |
| 15 | Undeclared result types cost a step 5 to 7 times (^ticket(762)): fix in elaboration? | Yes, with an owner who knows elaboration. | 054 q15 | asked for 2026-11-17; the answer not yet written down |
| 16 | An answer that is a function grows past gigabytes (hazelgrove/hazel#2832): fix Evaluator.finish? | Yes: leave a closure in the answer as a closure. | 054 q16 | asked for 2026-11-17; the answer not yet written down |
| 17 | Float literals print with six decimals (hazelgrove/hazel#2831): print them so they read back? | Yes, the shortest form that reads back; a warm-up PR for John (^report(55)). | 054 q17 | asked for 2026-11-17; the answer not yet written down |
Holes in compiled code#
Holes are John's project, drawn so that it touches as little of the rest as it can: values with holes cross into compiled code and out again unopened (^report(55)), and code with holes stays with the interpreter, by the rule of 2026-11-13. The only thing it shares with the limit work is one contract: compiled code stops with $R.indet, and that call falls back.
Where holes stand. No code with a hole or a type hole is compiled: 25 of the evaluator's programs, and 57 of the slides' as the first thing they meet (above). That is the rule, and it stays: the interpreter evaluates around holes, and its indeterminate results are the point of them. Where holes meet compiled code is mixed mode, where a value with a hole in it arrives as an argument: today to_js cannot carry it, so the call falls back whole, even when the function never looks at the hole (swap(1, ?), the length of [1, ?, 3]).
The project (^report(55), The idea, ^ticket(769)): carry such a value as an opaque JavaScript object; let compiled code store it, pass it and return it; stop the run wherever compiled code would look inside it; and give back the very term that went in. JavaScript will not stop by itself (a pattern test on an opaque object is simply false), so the checks have to be written, and the lean is a second, checked version of a function, compiled the first time a hole arrives, so that calls without holes cost what they cost today.
Its edges. To keep it apart from the limits Matthew is lifting:
- Its own branch, from the newest prototype build, merging each new build in (no rebases of shared branches).
- Its files: the boundary in
HazelJitValue.re(to_js,of_js, the table of opaque terms); one runtime helper for the check, inHazelJit.re's runtime; the checked version as a flag on code generation; mixed mode's choice of version inHazelJitMixed.re; and its tests in a group of their own beside the mixed-mode tests. - Where it meets the limit work: the checks sit in code generation for patterns (the empty list's
v === nulland a constructor'sv.c === ...,HazelJit.relines 570 and 618 on build 50), equality, arithmetic and a tuple's parts. The limit work touches patterns too (a splice pattern, above). So each check is one call to the runtime helper, written at those sites and nowhere else, and Matthew tells John before reshaping them. - Not in it: code with holes, step counts, the limits above, stuck terms (below), and how hazel-jit reaches dev.
- Measured by what already runs: the mixed sweep counts calls that fall back because an argument does not carry (one on build 50), the timings above come from the quick tests on every push, and the Witch slide's frame time from the Firefox check (on the prototype branch's pushes, or started by hand), so the checks' cost shows.
Before code: the four questions of ^report(55) (decisions 22 to 25), with Cyrus and Matthew, first of all where the work lives. A warm-up PR to dev, independent of all this, is decision 17's float printing (hazelgrove/hazel#2831).
Later, a second step that waits on stuck terms. Opaque values fall back when looked inside: inc(?) still goes to the interpreter, to make ? + 1. Compiling it, so that the run goes on around the hole as the interpreter's does, means making that term in compiled code, which is the next section's machinery.
Stuck terms in compiled code#
Where the interpreter's answer would hold a stuck term, compiled code stops, and the interpreter's run answers: correct, and costing speed only when it happens. Making those terms in JavaScript instead, and evaluating around them, takes the same machinery as compiling around holes, so it is one piece of work for both, Matthew's, after more of the limits.
Where compiled code stops today (build 50; each stop is $R.invalid or $R.indet in HazelJit.re's runtime, and in the evaluator's tests only the two stuck projections end this way):
| Where the compiled run meets | The interpreter's answer holds | Compiled code stops at |
|---|---|---|
| divide or modulo by zero, a negative power | DivideByZero, NegativeExponent | $R.invalid (^ticket(759)) |
| an SInt result past 32 bits | IntegerOverflow | $R.s32, $R.invalid (^ticket(758)) |
| a number that does not fit its type, text that is not a number | IntegerTooBig, and the others the builtins raise | $R.invalid (^ticket(759)) |
undefined, where a run reaches it | a stuck undefined | $R.indet (^ticket(761)) |
| a projection of something that is not a tuple or a list | a stuck projection | $R.indet, in $R.dot (build 50) |
| a run past its budget | none: the interpreter runs to its own limits | $R.out (^ticket(763)) |
Two more kinds of stuck term are kept out by rule rather than stopped at: a failed run-time check in an ill-typed program (25 evaluator programs; the page compiles no program with a static error), and a free variable (24). Overflow is the example to start from: since 2026-11-16 an SInt result past 32 bits is an error, a stuck term, in the interpreter (^report(54), Overflow). Compiled code checks every SInt result and stops; the interpreter's answer then holds the operation, its operands and the error.
Why stopping is not enough for good. For livelit views, the page waits for the interpreter, which is fine. In mixed mode, a call that stops is run again from the start in the interpreter, so an error deep in a long call costs the call twice. A program being edited meets errors often. And holes need the same thing: ? + 1 is a stuck term too.
What it takes, in order of difficulty:
- A stuck term as a JavaScript value. Where an operation fails, compiled code builds the term the interpreter would: the operation (known when compiling, with its id in the source), its operands carried back to Hazel by their types (the operation says them: an SInt sum has SInt operands), and the error.
of_jsgives it back as is. Overflow and divide by zero need only this, since their operands are values. - Going on around it. An operation that meets a stuck term builds a larger one (
(7 / 0) + 1), as the interpreter's evaluation does around anything indeterminate; a tuple or list holding one is still a value with a stuck part. This is the step that? + 1needs, and where an opaque hole of^report(55)and a stuck term become one kind of value. - Control that meets it. A
caseon a stuck term, anifon one, a call of one: the interpreter's answer holds the rest of the code, the arms, with the environment they close over. Compiled code has erased both, so it must give back the source of the arms and the values of their free variables, carried back to Hazel. This is the hard part, and the reverse of the limit on a closure with its own environment. - Ids and steps. The interpreter's stuck terms carry ids that tie them to the source, which compiled code knows when compiling; and building them must count the interpreter's steps too.
- The check. Once compiled code makes stuck terms, the consistency check should compare them with the interpreter's, not only that both stopped (decision 18).
Overflow first, then the other invalid operations, then going on around them, then control. The first two are Matthew's after more limits are lifted; the second step of the holes work builds on the second and third.
What next#
Matthew lifts limits and makes step counts; John starts on holes once four questions are settled; the team writes down its answers.
- Matthew, hazel-jit: tests on the slides; mixed mode across modules and its crossing cost; step counts, checked against the interpreter's in CI, then the budget in steps (decisions 9, 19, 20); then probes. Stuck terms after that, overflow first (decision 21).
- Matthew and Cyrus: write down the meeting of 2026-11-17's answers (decisions 3 to 17); settle
^report(55)'s four questions before John starts (22 to 25); decide how hazel-jit reaches dev (13). - John: after decisions 22 to 25, opaque values at the boundary, passing through only, with their tests; the warm-up PR, if wanted first.
- Anyone who knows the evaluator: reviews of hazelgrove/hazel#2828 (SInt) and hazelgrove/hazel#2825 (modulo by zero).
How this was put together#
Written on 2026-11-18 from build 50's CI at 55e4757a4b: the sweep, the timings, the mixed-mode numbers and the ill-typed programs' names from the prototype branch's own fast checks (run 44319161267); the slides from the full tests of run 44211080673, on the slides' branch at the same commit, the other run's sweep giving the same counts; from the code of build 50, and from ^report(54) and ^report(55), whose questions are carried over with their leans unchanged. The names of the programs not compiled come from one more CI run, on a branch that only adds a line printing them. Nothing here is measured in a browser; the timings are Node's on GitHub's machines. The numbers are in 056/data.
The data#
- The numbers, for programs too: every table in this report, and what its numbers measure, is also in this page as JSON, in its
<script type="application/json" id="report-data">element, so a reader or an agent that fetches the page alone has the dataset. The same, with any raw files that survive, is in056/data/.