Skip to content
gioser
ES

tawasuyu · Perceive

hayma: a JavaScript engine written from scratch in one month — it passes 99.7 % of Test262 and already runs Octane in less time than QuickJS

There are three JavaScript engines in the world that matter, and all three belong to three companies: Google's V8, Mozilla's SpiderMonkey and Apple's JavaScriptCore. Every browser runs on one of them. Someone wrote a fourth one, from scratch and in Rust, for tawasuyu's browser. It is called hayma, it was born on October 15, and one month later it passes 99.7 % of JavaScript's official suite —51,971 tests, 9,678 more than QuickJS— and runs Octane in less time than native QuickJS.

24 min readBy Gioser Editorial

Every web page you open carries a program inside it, written in JavaScript, and something has to run it: the JavaScript engine. There are three engines in the world that matter —Google's V8, Mozilla's SpiderMonkey and Apple's JavaScriptCore— and every browser you use runs on one of them. This article tells how someone wrote a fourth one, from scratch and in Rust, for tawasuyu's browser: hayma. It was born on October 15, 2026. One month later it passes 51,971 of the 52,133 tests of JavaScript's official suite —99.7 %, 9,678 more than QuickJS, the engine it is meant to replace—, has the whole new date API, Temporal, runs all seven programs of Google's Octane benchmark in 66 % of the time QuickJS compiled for the machine takes, loads react.dev, google.com and github.com without a single error, and a build of it boots inside a home-grown operating system. With the numbers in plain sight, including the ones that still fall short.

Bar chart: Test262 tests hayma passes. On October 15, zero; on the 16th, 6,730; on the 23rd, 41,121; on the 29th, 42,290; on the 30th, 44,421; on November 2, 51,710; on the 14th, 51,971, out of 52,133. A dotted line marks QuickJS at 42,293. Behind it, an illustration of a glowing gyroscope in space.
Test262 tests, from JavaScript's official suite, that hayma passes: from zero to beating QuickJS by 9,417 in eighteen days, and by 9,678 at one month.

The name

In Quechua, hayma names community collaboration: work done among many so that something comes out that nobody would lift alone. It is a tribute to that way of working, not a flag: the project does not speak for any people, it learns from them. And it suits an engine that was written exactly that way, as told below: between one person and several AI agents, with a judge that believes no one.

Why write another JavaScript engine

tawasuyu has its own browser, puriy, with its own page engine: no Chromium or WebKit underneath. Until now it ran JavaScript with QuickJS, a small and excellent engine written in C, locked inside a WebAssembly virtual machine so a page could not escape. It works. But it has a ceiling that patches don't fix, and the ceiling is in the core:

So on October 15 the question stopped being how to improve QuickJS and became another one: if the core has to be rewritten anyway, let it be born built for this. An engine of its own, in Rust, compiling to machine code, with one rule that is not reopened: the semantics are not invented. The parser and every library function follow the ECMA-262 specification step by step; originality goes into the core, never into the language.

First the judges, then the engine

The first thing written was not the engine. It was the instruments to know whether the engine was right, and they were run against QuickJS before hayma existed, so that the starting number was measured and not assumed:

And one rule for all of them: QuickJS is the oracle. If hayma does something different from QuickJS on the same input, it is a hayma bug until proven otherwise. Every judge also carries its control arm: programs written to fail on purpose along each path, which must come out wrong. A judge that approves everything is not measuring anything.

One month, counted by the same judge

The first commit is from the afternoon of October 15, 2026. Since then:

The full table, with the same suite (Test262 at commit d53ebc8b1, all of test/ except staging/, 52,133 tests) and the same harness for both engines:

areatestshaymaQuickJS
everything52,13351,710 (99.2 %)42,293 (81.1 %)
without intl402/ or Temporal44,14643,766 (99.1 %)42,270 (95.8 %)
language/, the language23,72623,608 (99.5 %)23,314 (98.3 %)
built-ins/ without Temporal, the library19,21819,002 (98.9 %)17,831 (92.8 %)
annexB/, the old web1,0861,042 (95.9 %)1,013 (93.3 %)
intl402/ without Temporal, languages1,3531,312 (97.0 %)23 (1.7 %)
ShadowRealm6459 (92.2 %)0 (0.0 %)
Atomics389350 (90.0 %)0 (0.0 %)
Temporal (in both directories)6,6346,632 (99.9 %)0 (0.0 %)

Percentages over all the tests in the area, the same number for both engines; in bold, whichever passes more. hayma ran on main at commit 2e7e99344, on November 2, with 2 threads, in 10,036 s —almost three hours, on a machine shared with other builds—; the binary of that run is, byte for byte, the one built from that commit. QuickJS ran on October 15, with 4 threads, in 1,211 s: it is QuickJS-ng 0.15, the one puriy runs, and it ships neither Temporal nor ShadowRealm nor Atomics. Against the October 30 run, the one behind the previous version of this article, hayma passes 7,292 more tests and loses three, all three from Atomics.waitAsync waiting on other threads, which time out when the machine is loaded.

How to read it: hayma is ahead in every area. In the language, by 294 (23,608 against 23,314); in the library, by 1,171 (19,002 against 17,831); in Annex B, compatibility with the old web, by 29 (1,042 against 1,013). And there are four rows where QuickJS is at zero:

And the count the other way around shrank to almost nothing: there are 9,422 tests hayma passes and QuickJS does not —6,632 from Temporal, 1,289 from languages, 350 from Atomics, 195 from regular expressions, 204 from typed arrays, 299 from the language— and 5 the other way around, which are in «What is not there yet».

What is inside

Writing an engine that passes tests is one thing; writing it so that one day it runs like V8 is another. The deep decisions, each with what was measured:

Two compilers to machine code

An interpreter reads the program one instruction at a time. Fast engines also translate what repeats most into machine code. hayma has the two tiers a big engine has:

Measured in processor instructions —wall-clock time on the shared machine varied twofold between two identical runs—, against the interpreter: Octane's NavierStokes runs with 31 times fewer instructions and Richards with about 5 times fewer. In a minimal test, a loop without calls comes out 24 to 26 times faster with T1 than interpreted.

And what matters most in a compiler that speculates is not that it is fast but that it gives the same result. A random program generator ran each program in the interpreter, in T1 and in T2, and compared: 24 hours, 440,543 programs, zero differences. When deoptimization arrived a fourth mode was added —T2 giving up on purpose at every guard—: 162,460 more programs, zero differences. Compiled-code memory is W^X: it is either written or executed, never both.

Regular expressions have their own compiler to machine code, with the same Cranelift: checked against the regex interpreter over 49,024 runs, zero differences in captures and in steps.

Speed, against the real QuickJS

Until November 2 this article compared against QuickJS as it runs in puriy, compiled to WebAssembly. That yardstick favoured hayma, because a QuickJS in WebAssembly runs slower than one compiled for the machine. So the yardstick changed: native QuickJS, QuickJS-ng 0.15.0 built with -O3 for this same machine, measured the same way as hayma. Against that one, on November 2 hayma was 2.0 times slower on Octane: 27.0 s of CPU against 13.5.

The next two weeks went only to speed, in two lanes at once: one on the optimizing compiler (T2), the other on the interpreter and its caches. The final clean measurement is the one from November 16, on main at commit a3d140683: hayma with its real tiering —the interpreter starts, T2 compiles what repeats on another thread—, five rounds alternating with native QuickJS, with the machine's load under 4. The ratio is hayma's time ÷ QuickJS's time: below 1, hayma takes less.

casehayma, wall clockQuickJSratioratio in CPU of the program threadratio in total CPU
Richards350 ms637 ms0.550.530.59
DeltaBlue1,166 ms1,174 ms0.990.911.25
NavierStokes596 ms1,766 ms0.340.370.38
Splay298 ms257 ms1.161.021.12
RayTrace630 ms797 ms0.790.800.83
Crypto219 ms533 ms0.410.380.79
RegExp3,440 ms4,711 ms0.730.750.72
all seven6,673 ms10,128 ms0.660.690.76

What it says, without makeup:

A week earlier, on November 9, the same measurement gave 0.81 on the wall clock and 1.05 in total CPU, with DeltaBlue 1.32 times slower. What went in between: T2 generates less intermediate code for each operation, and compiling costs less; == between two integers, two objects or two booleans no longer calls into Rust. In the interpreter, a property load that always misses stops trying to be cached. And the TypeScript type check, the largest program in the benchmark, went from 370 to 256 billion instructions with the interpreter, 31 % fewer, and with tiering from 178 to 140.

And there is one where hayma loses by a lot: uglify-js, which minifies code. In the same November 16 run, minifying takes hayma 2,154 ms and QuickJS 425 ms: five times slower on the clock, and 9.6 times in total CPU. Its work is spread over thousands of functions that each run a few times, and compiling them costs more than it saves: with synchronous tiering it is 9.1 billion instructions, with the interpreter alone 4.3. Since November 11 that figure with tiering dropped 32 %, but it is not enough.

And node, with all of V8's JIT, is in another league: Octane's seven cases took it 0.71 s on October 31.

The web: the DOM in the same heap

hayma's most valuable decision is the one that goes after that 72–92 %: a DOM node is an object in hayma's heap. The collector traces it like any other object, and reading el.textContent does not have to cross any border. Chrome pays for the same thing with two heaps, V8's and the DOM's, and cross-tracing between them.

WPT areaQuickJS, Oct 16hayma, Oct 30
url/168 of 236469 of 555
encoding/ (the area's root)111 of 1,30611,194 of 11,321
dom/nodes758 of 3,0367,727 of 9,144
dom/ranges6 of 30540,198 of 40,478
dom/events161 of 451442 of 714
all of html/not run79,593 of 90,175 (88.3 %)

What goes the other way is counted too: 253 subtests that QuickJS passed and hayma does not, by name —105 of them in a single file, and some are the same test reported under a different name by each engine—. Same WPT commit (e58225abb), same files preprocessed by the same code for both judges, no WPT server: whatever needs a server comes out as «no host», not as a failure. Since last week html/ includes a real 2D canvas on tiny-skia, which draws and lets you read the pixels back.

All the way inside a home-grown operating system

Since the core needs no operating system, the whole interpreter —parser, compiler, machine and library— compiles to a WebAssembly module with not a single import. On October 19, run under wasmtime against Test262's language tests, it gave exactly the same results as the native build, with the same error message on every test: 23,726 compared, zero different (about 3.8 times slower). And that module is an application of wawa, tawasuyu's own operating system, which boots on the hardware with no Linux underneath.

That part broke that same October 19 and nobody saw it for eleven days. A change to use math functions from Rust's standard library pulled it in unconditionally in three crates, and with it the module stopped linking; the rest of the repository stayed green, because no check compiled hayma for WebAssembly. It turned up when someone tried to compile it again, eleven days later. On October 30 it came back (e62beb274): the math functions, on top of libm when there is no standard library, and a 35-second guard that compiles both modules and fails if either breaks. The module gives the same as the native build in Math, Number and Date —1,249 of 1,261 both—.

And it no longer fit inside wawa: the engine had grown from 860 KB to 2.36 MB, while an object in wawa's file system has a 1 MiB ceiling, and building its JavaScript realm cost 40.6 million units of fuel against the 20 an application gets to start. No trimming fit in 1 MiB —with the most aggressive WebAssembly optimizer it stays at 1.84 MB—, so the ceiling was left alone: wawa's boot stores the module split into 512 KiB chunks with an index in front, the same shape large files already used, and the kernel joins them when loading it, checking each one. The realm is built piece by piece, at start-up and over the first four frames (a092cadbb, and with Atomics and ShadowRealm inside, cd1f8858d). In a virtual machine, 54 seconds after power-on, it prints over the serial port the result of its script —a recursion, a caught error, a stack overflow turned into a RangeError— identical to what it gives on an ordinary computer.

What varies, through a single door

The clock, randomness, the network, the order of events: everything that makes a program not always give the same result enters hayma through a single host interface. With that, a session can be recorded and replayed exactly. Seven test sessions —timers, randomness, keystrokes, promises, clock, errors, channels— record identically twice on QuickJS, and four of them record on hayma byte for byte equal to the QuickJS recording; the other three part ways at the first event that asks for something hayma did not have that day, and the replayer says which. It is the harness with which, later on, a page recorded on QuickJS will be run on hayma for comparison.

How an engine is written in one month

There is no trick, but there is method. hayma was written by one person directing AI agents, with a division of labor written down from day one: the core —memory, collector, caches, compilers— is written by a large model; the library functions, which are mechanical work with an objective judge, are assigned one Test262 directory at a time to another, cheaper model.

What makes it work is the rule that governs everything above: the agent's word closes nothing. Every task carries its yardstick —«Test262 built-ins/Iterator greater than or equal to QuickJS», «WPT url/ without losing a subtest»— and the judge closes it, run separately, with zero regressions against the previous run. The first stage had 126 tasks in fourteen lines of work; 83 closed with their number. The second, since October 23, is organized by goal: parity with QuickJS, what QuickJS does not have, the web, speed, and WebAssembly.

The result, as of November 2: about 133,000 lines of Rust in the engine's 42 crates, plus 30,000 in the browser integration, across 390 commits.

What went wrong, told

What is not there yet

How to see it

hayma lives in the tawasuyu repository —git.tawasuyu.net— under shared/hayma. The design is in SDD.md (in Spanish), with each judge's baseline tables; the lines of work are in shared/hayma/lineas/, each task with its yardstick, its commit and its number, and those of the first stage in etapa-1/, without a word changed. Both judges run with hayma-test262 and hayma-bench, against whatever engine you like.

Background