hidden class
An internal record V8 keeps of an object's property names and their order, so it can find properties quickly.
In more detail
Objects created with the same properties added in the same order share one hidden class, also called a shape or map. Knowing the shape lets TurboFan read a property from a fixed position instead of searching for it. Adding properties in a different order, or deleting them, creates new shapes and can make code slower.
Related terms
- monomorphic — Describes a place in the code that always sees objects of one single shape, which lets TurboFan optimise it best.
- polymorphic and megamorphic — Describes code that sees objects of a few different shapes (polymorphic) or very many (megamorphic), which makes optimisation harder.
- inlining — An optimisation that copies a small function's body, or a property lookup, straight into the code that uses it, avoiding the cost of a call or a search.
Taught in
- V8 Engine & JIT Pipeline: Bytecode & Turbofan — Node.js Internals & Backend Services