Hidden-class shape tracking for plain JS objects.
When objects are created with a consistent set of property names, they share a "shape" that maps each property name to a fixed tuple offset. Property access becomes O(1) tuple indexing instead of O(log n) map lookup.
Shape-backed objects are stored as
{:shape, shape_id, offsets_map, values_tuple, proto_ref}in the process dictionary under the object's integer ID key.
Objects that gain accessors, internal keys, or otherwise become non-plain deopt back to regular maps.
Summary
Functions
Returns the canonical empty object shape id.
Convert a plain map (without __proto__) into a shape and values tuple.
Returns {:ok, shape_id, values_tuple} or :ineligible.
Returns shape metadata for a shape id.
Return the ordered list of keys for shape_id.
Return the offset for key in shape_id, or :error.
Grow or update a values tuple at offset.
Check whether a stored heap value is shape-backed.
Reconstruct a plain map from a shape-backed representation.
Transition shape_id by adding key.
Returns {new_shape_id, offset}.
Functions
Returns the canonical empty object shape id.
Convert a plain map (without __proto__) into a shape and values tuple.
Returns {:ok, shape_id, values_tuple} or :ineligible.
Returns shape metadata for a shape id.
Return the ordered list of keys for shape_id.
Return the offset for key in shape_id, or :error.
Grow or update a values tuple at offset.
Check whether a stored heap value is shape-backed.
Reconstruct a plain map from a shape-backed representation.
Transition shape_id by adding key.
Returns {new_shape_id, offset}.