r/javascript • u/QuarterSilver5245 • 15h ago
Every scenario that triggers V8's "slow mode" for objects
yuval.hashnode.devV8 usually saves direct pointers to memory addresses of actual raw object property values - in a way that allows an optimized "Inline Caching" (IC). Apparently for some scenarios - they switch an object to "slow mode" - which uses a different structure to save those (a hash table instead of an array) - this affects the way it's cached on the IC (it forces an additional look-up via the hash-table) - they call it "Dictionary mode" (aka "Slow mode"). I recently learned about this, while working on an open-source project of mine - which is a client-side State library that heavily relies on native Prototype lookups for composition.
I also found out that it's possible in NodeJS (with a switch flag) - to expose functions that can test if an object is in 'slow mode' - so I asked an AI to create a test suite that summarizes all (hopefully) scenarios where a switch to 'slow mode' is made. There is a link to the github repo for it at the end of the article, plus a summary of the findings.