mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
invalidate_all_prototype_chains_leading_to_this used to scan every prototype shape in the realm and walk each one's chain looking for the mutated shape. That was O(N_prototype_shapes x chain_depth) per mutation and showed up hot in real profiles when a page churned a lot of prototype state during startup. Each prototype shape now keeps a weak list of the prototype shapes whose immediate [[Prototype]] points at the object that owns this shape. The list is registered on prototype-shape creation (clone_for_prototype, set_prototype_shape) and migrated to the new prototype shape when the owning prototype object transitions to a new shape. Invalidation is then a recursive walk over this direct- child registry, costing O(transitive descendants). Saves ~300 ms of main thread time when loading https://youtube.com/ on my Linux machine. :^)