Fakta teknis dan catatan pengukuran dipelihara dalam bahasa Inggris untuk mencegah perbedaan antar-terjemahan.
Solver
Whole-program facts for native JavaScript/
Research · status as of November 24, 2026 · not released
What Solver is
Perry compiles JavaScript and TypeScript ahead of time to native code. When the compiler cannot tell what a property read, a call or a store can touch, it has to emit generic dynamic code: look up the shape, find the slot, dispatch at runtime. Solver (the perry-wpfacts crate, short for whole-program facts) removes that guesswork wherever it can be removed soundly.
It treats the whole program, together with a declared model of the JavaScript realm built from Perry's own runtime sources, as one constraint system. From that it proves facts at each source site, for example:
- this read hits exactly these object layouts, at this slot;
- this call goes to exactly this function;
- this store cannot reach a builtin.
Codegen uses a fact only when it is proven. Sites without a proof keep the generic path, so a missing fact costs speed and never correctness.
Exact or nothing
Solver uses no heuristics and no guessed fallbacks. An unknown value (⊤, "top") is tracked explicitly rather than hidden. The trouble with unknowns is that they spread: one early unknown value can flow into the rest of the program and make everything downstream unprovable. We call this the cliff.
The current work removes the places where unknowns are created, one seed at a time. The solver can stop at the first unknown value and report the source line and the rule that produced it, which turns "why is this slow?" into a concrete, fixable line of code in either the program or the realm model.
How we measure it
Progress is measured on a ladder of 46 rungs: successively larger builds of one real application, a chess game built on three.js with a headless web/canvas layer. Each rung adds more of the real program, so each one exposes new code that the realm model and the solver have to handle exactly.
Integration branch · not released
Where it stands
Released Perry: on the larger rungs only about 14–20% of read/call sites are proven. Rung c08, for example, has 4,082 of 24,498. An early unknown floods the rest of the program.
Integration branch (all current Solver work merged onto main, not yet released): the cliff is gone up to rung c08, with 22,848 of 26,656 read/call sites proven (about 86%, 5.6× main) and 4,016 of 4,106 stores proven. At rung c09, which adds OrbitControls and the DOM style Proxy layer, the cliff comes back (4,362 of 28,181). The root cause has been found and the fix is in progress.
Soundness. Exact modelling turns up real bugs. Along the way the work found and fixed actual miscompiles: the thisArg model for Array.prototype.forEach, and a streamdestroy() that did not call a subclass's _destroy (now matching Node). A third, a constructor-static store through a passed reference, is being fixed.
Compile cost. The integration branch currently compiles large rungs 6–12× slower than main (rung c08: 619 s against 63 s). Profiling points to two causes: an activation pre-pass that grew into a full solve, and a blow-up on Proxy any-key traps. The first fix, one solve per compile, is approved and starting.
Done
- Whole-program facts wired into the compiler: codegen consumes a fact only when it is proven.
- Stop-on-first-unknown mode: the solver halts at the first unknown value and reports its source line and rule.
- A model of the JavaScript realm (getters, Proxy, globals) derived from Perry's own runtime sources.
- Source positions on every compiler operation (PR #15375, open): codegen stays byte-identical apart from two stated improvements.
- All Solver work integrated onto main and measured across the full 46-rung ladder.
In progress
- Removing the unknown-value seed that brings the cliff back at rung c09 (OrbitControls plus a DOM style Proxy with any-key traps).
- A receiver-family model for methods passed around as values, landing together with the runtime check that enforces it.
- Exact names for globals read at runtime.
- One solve per compile, the first of two fixes for compile time.
Next
- Walk the ladder rung by rung to the end with zero unknown seeds.
- Land the work on main in order: source positions, realm and escape fixes, then the receiver-family model with its runtime check.
- Bring compile time back into main's range.
Open problems and limits
- The c09 cliff (a DOM style Proxy with any-key traps) is still open.
- Compile time and memory on large programs are well above main on the integration branch: rung c08 takes 619 s against 63 s on main.
- From rung c16 on, the solve reaches its work bound and widens, so the numbers for those rungs do not mean much yet under the new model.
- Some modelling premises are enforced by a runtime check that is still being built.
Solver is research. None of the integration-branch numbers above are in a released Perry build yet, and they will change as the work lands. This page is updated as milestones ship; release notes are in the changelog.
Follow the research
Solver work lands in Perry as small, reviewed PRs. Follow along on GitHub or ask questions on Discord.