3 ms·
I'm not sure about DOM elements, but tacking random new properties onto Javascript objects can cause them to become deoptimized by the runtime.
by rcfox 3y ago
I'm not sure about DOM elements, but tacking random new properties onto Javascript objects can cause them to become deoptimized by the runtime.
- ZachSaucier 3y agoAny reference for this?
- nirvdrum 3y agoI found [1] to be a pretty good summary of the key concepts that support the claim. The article, unfortunately, doesn't come right out and say it. But, it talks about how object shapes (a common JS object model) can be used as guards for inline caches (IC) to generate efficient machine code for property access. If you add a new property, you change the shape, which causes the cache guard to fail. That leads to deoptimization since the assumptions made about the call site when the code was compiled no longer hold. That call site is now either polymorphic or megamorphic, depending on the type of IC used and its level of polymorphism. [1] -- https://mathiasbynens.be/notes/shapes-ics https://mathiasbynens.be/notes/shapes-ics
- rcfox 3y agohttps://v8.dev/blog/fast-properties https://v8.dev/blog/fast-properties https://v8.dev/docs/hidden-classes https://v8.dev/docs/hidden-classes