Two objects are built field-by-field. Why does this pattern defeat V8's monomorphic inline cache optimization even though both objects end up with the same property names?
function makePoint(a, b, swap) {
const p = {};
if (swap) {
p.y = b;
p.x = a;
} else {
p.x = a;
p.y = b;
}
return p;
}
const p1 = makePoint(1, 2, false);
const p2 = makePoint(1, 2, true);