A call site is polymorphic when it has observed between two and four object shapes. V8 records those shapes in an inline cache so property access can reuse known locations instead of repeating full lookups. section 5.10.2
Watching a property load widen
For `readX(point)`, the first object shape makes the property-load site monomorphic. A second shape changes it to polymorphic; the third and fourth remain polymorphic while adding maps. A fifth shape makes it megamorphic. The transition is visible in `--log-ic` output as `0 → 1 → P → P → P → N`. section 5.10.2
function readX(point) {
return point.x;
}Use the minimal property-reading function to locate the call site whose observed shapes determine the inline-cache state. section 5.10.2
const shapes = [
{ x: 1, a: 0 }, { x: 2, b: 0 }, { x: 3, c: 0 },
{ x: 4, d: 0 }, { x: 5, e: 0 }, { x: 6, f: 0 },
];
let total = 0;
for (let limit = 1; limit <= shapes.length; limit++) {
for (let i = 0; i < limit * 2; i++) total += readX(shapes[i % limit]);
}Run the shape sequence to reproduce the progression from monomorphic through polymorphic to megamorphic behavior. section 5.10.2
Use these distinctions when interpreting V8 performance behavior:
- Monomorphic means one observed shape; polymorphic means two to four; megamorphic means more than four. section 5.10.2
- Polymorphic degradation is gradual: 20 million loads take 31.73 ms with two shapes and 41.88 ms with four, versus 22.31 ms with one. section 5.10.2
- Five or more shapes can trigger megamorphic behavior, with the benchmark reaching 108.29 ms for five shapes. section 5.10.2











