Skip to main content

Module shape

Module shape 

Source
Expand description

Shapes: the transition tree, dictionary mode and prototype validity cells.

A transition shape describes one property added on top of its parent; the tree has one root per (prototype, kind). Lookup walks parent for eight properties or fewer and otherwise uses a table built on first lookup. Transition shapes are immutable and shared; reconfiguring a property or changing the prototype replays the object’s keys from another root, so the slots keep their positions.

Dictionary mode gives an object an unshared shape with its own hash table and insertion-ordered entry list. It is entered on deletion, past DICTIONARY_THRESHOLD properties, and always for the global object.

Every object used as a prototype has a PrototypeInfo: a lazily created validity cell and the list of prototype objects that inherit from it. Any change to a prototype object clears its cell and, through the dependents lists, every cell downstream. A shape caches its prototype’s cell; the prototype IC records (holder, slot, cell) and tests one boolean.

Structs§

DictEntry
Dictionary
The unshared table of a dictionary-mode object.
PropertyFlags
PrototypeInfo
Per-prototype bookkeeping. The table holding it is weak in its key and in dependents; the collector prunes dead objects after marking.
Shape
ValidityCell

Enums§

Transitions
A shape’s outgoing transitions: a vector for up to four entries, a map beyond. Entries are weak: the collector drops those whose child died.

Constants§

DICTIONARY_THRESHOLD
Adding a property beyond this count moves the object to dictionary mode.
STATIC_CELL
The always-valid cell of shapes without a prototype.
TABLE_THRESHOLD
Past this many properties a transition shape builds a lookup table.