A cached add transition checks that the receiver is extensible
Date: 2026-11-29
Area: engine, inline-caches, jit
Related: ADR 0206, #2321
Context
ES2026 §10.1.9.2 OrdinarySetWithOwnDescriptor adds a missing property through CreateDataProperty, and §10.1.6.3
ValidateAndApplyPropertyDescriptor step 2.a refuses it when the object is not extensible, so a strict-mode store
throws a TypeError. A store site that added a property caches the add transition: the receiver's shape before the
add and the shape after it (TPropIC.NewShape). The interpreter, FastLoop, the baseline JIT and the optimizing tier
take that transition for any receiver of the cached shape.
[[Extensible]] is not part of a shape: it is bit 8 of TObj.OFlags. Object.preventExtensions gives the object a
forked shape that no cache holds (ShapeFork), and ADR 0206 keeps a non-extensible object off shared shapes on a
delete. Attribute changes still put it back on them. Object.freeze and Object.seal change each property's
attributes through ChangeFlags, which rebuilds the shape along the prototype's transition tree, so a frozen
object shares its shape with extensible objects built with the same keys and attributes. A store site warmed on
those then added a property to the frozen object in every tier, and Object.isFrozen turned false. The class-field
definition (opDefField) already tested the bit in every tier; plain stores (opSetProp) did not.
The alternatives:
- Keep every non-extensible object off shared shapes, forking its shape after each attribute change. Objects
frozen alike would no longer share a shape, and a site reading them would see a new shape on each one. On Linux
x86-64, 200 passes reading a property of 10,000 objects took 38 ms when each had a forked shape (as
Object.preventExtensionsgives) and 7 ms when they were frozen and shared one. Every future way of rebuilding a shape would also have to fork. - Make extensibility part of the shape, with a shared non-extensible transition from each tree shape, as V8 does. It keeps the sharing, but changes what a shape's parent chain means for every walk of it (deletes, the add-transition fill sites, the optimizing tier's shape facts).
Decision
- Every cached add transition tests the receiver's extensibility before it applies. The interpreter's and
FastLoop's
opSetProp,XSetPropSlow, the baseline JIT's inline store and its overflow-slot block, and the optimizing tier's adding store (PROP_EXT, as for a class field) leave a non-extensible receiver to the uncached store, which refuses the add. An own store to an existing property needs no test: a property's attributes are part of the shape, so a read-only property is never in a store cache. - The optimizing tier skips the test for an object the region allocated since its last embedded instruction
(
PROP_YOUNG): only an embedded call can make it non-extensible, and an embed forgets the facts. - The forked shapes stay.
Object.preventExtensionsand ADR 0206's deletes still keep a non-extensible object off shared shapes; the caches no longer rely on it.
Consequences
- A store site warmed on extensible objects refuses an add to a frozen, sealed or non-extensible object of the same shape in every tier, and frozen objects keep sharing shapes with each other, so reads of them stay monomorphic.
- An adding store's fast path reads one more byte of the object header. An own store's fast path is unchanged.
- A new path that applies a cached add transition must test the bit as well.
tests/language/expressions/assignment-non-extensible-receiver.jswarms a store site for each kind of receiver, with properties in inline and overflow slots.GocciaTestRunnerruns it in FastLoop, andgoccia --test(the engine gate) in the baseline and optimizing tiers; taking out any one of those tiers' tests made a case fail in that tier.Executeruns only under an instruction budget, coverage or profiling, and the suite cannot give one directory a budget yet (#2347): its two tests were checked by running the same cases under--max-instructions.tests/language/classes/field-definition-non-extensible-receiver.jscovers the class-field site.