3 ms·
> our implementation of the Lua table uses hidden class, instead of a naive hash table as in Lua/LuaJIT. What is "hidden class"? Is this a data structure?
by HexDecOctBin 4y ago
> our implementation of the Lua table uses hidden class, instead of a naive hash table as in Lua/LuaJIT.
What is "hidden class"? Is this a data structure?
- albntomat0 4y agoIn languages with dynamic properties on objects, it’s a data structure that keeps track of which properties are present, and how to access them. Short example In JavaScript: Var a = {}; a.b = 15; The hidden class object a maps the property b to where its stored, may include type information, etc.
- inglor 4y agoThe optimization is usually called shapes outside of JS. The idea is that shapes (we represent objects like C like structs and not hash maps) are used for relatively non-dynamic objects and then we keep the shape metadata on functions themselves (inline caches) which means property access becomes just a byte offset. See https://v8.dev/blog/fast-properties https://v8.dev/blog/fast-properties