Quench.
VALUESAND OBJECTS

blog / · 4 min read · internals

One 64-bit word, two narrow slots and three loads per field

How Quench represents values and objects, why an object reference is an index and not a pointer, and what that choice costs every time you read a field.

Every JavaScript engine makes two decisions early that it lives with forever: what a value looks like in memory, and how an object finds its fields. This post describes Quench's answers as of October and November 2026, including the part we are not happy with.

A value is one 64-bit word

Quench uses NaN-boxing. A double is stored as its raw IEEE 754 bits. Everything else (integers, booleans, strings, object references) lives in the bit patterns that would otherwise be NaNs, marked by a tag in the high bits.

Value layouta doubleraw IEEE 754 bits64 bits, no taganything elsetaghigh bitspayloadint32, record id, string id, ...
Schematic: the exact tag width is an implementation detail. The point is that every value is one word.

Two details matter later:

  • An object reference is an index. The payload is a record id, not an address. The heap can grow and reorganize its tables without rewriting every value that points at an object.
  • Integers are canonical. A double that happens to hold a whole number in int32 range is turned back into an int32 when it is stored.

An object is a small cell plus an arena

An object has two inline slots of 32 bits each, called narrow slots. Small integers, booleans and references fit there directly. Everything else, and every array element, lives in a size-classed property arena as a full 64-bit value.

An experiment on 12 October trimmed the object header to 8 bytes, which made a two-property object 24 bytes in total.

Where a field lives is decided by the object's shape (what other engines call a hidden class or map). Shapes are indices into a shape table too. If a shape is proven, a field read is one load. That change alone, on 5 November, cut Richards from 5.83 million to 4.95 million instructions, 15% less, because Richards is mostly field reads.

The cost: three dependent loads

Here is the part we are not happy with. When the shape is not already proven, reading a field goes through three loads that each depend on the one before.

Reading obj.x when nothing is known yetindexshape idslotvaluetag + record idrecord tableload 1shape tableload 2slot storageload 3the field
Each load waits for the previous one. A C struct field read is one load at a constant offset.
Instructions for one field access in the interpreter, November 2026C struct field1Quench field read34Quench field store47
Instruction counts from the 17 November audit of all tiers.

Indices buy us compact values and a heap we can reorganize. They cost us a level of indirection that pointer-based engines do not pay. The fix is to prove the shape once per region of code and then treat the object like a struct. It is not a different object model.

Tuning the inline slot count is a trap

Why two inline slots and not three? We tried three. Splay's peak memory went from 162 MB to 204 MB, because the inline count is global and every small object now carried the extra slot.

A global constant that helps one program and hurts another is a sign the constant should not be global. The plan now is the opposite of tuning it: property runs that are 4 bytes wide by default and widen only when a value needs it. The working name for the principle is "bytes equal information". On the TypeScript compiler workload only 48 of 218 MB was live data, and the first step of narrow runs took its peak from 236 to 224 MB.

Canonical integers have a price too

Turning every whole-number double back into an int32 keeps integer code fast and makes values compact. It also means the engine can never know statically that a slot holds a double, so numeric code re-tests the tag after every operation. That is 8 to 11 instructions per floating-point result, on every result.

In an interpreter that cost hides in the noise. In compiled code it is most of what is left. Raw double slots for values that are proven to be doubles are the current work on the JIT branch.

Summary

DecisionWhat it buysWhat it costs
NaN-boxed 64-bit valuesone word per value, doubles unboxedtag tests on every use
References are indicescompact values, relocatable tablesthree dependent loads per unproven field
Two narrow inline slotssmall objects stay smallthird field goes to the arena
Canonical int32fast, compact integersno static "this is a double" fact

Every row in that table is a trade we would make again for an interpreter. The native tiers need the right-hand column to go away, and the way to do that is to prove facts once and keep them. Later posts cover how.

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