polymorphic and megamorphic

Describes code that sees objects of a few different shapes (polymorphic) or very many (megamorphic), which makes optimisation harder.

In more detail

Polymorphic code must check which of several shapes it has before each property read, and megamorphic code gives up on caching altogether. This is V8's meaning of the words, unrelated to polymorphism in object-oriented design.

Related terms

Taught in

References