My intuition is that objects with few properties are accessed often.
Can we verify this with our tracing framework?
Sure. I might have time to look at that tomorrow.
Initially a linear search would be done, and when there are greater
than "Pmax" properties, then a hash-table would be used. We just have to arrange for the inlined "linear search" algorithm to immediately fail, and fallback to the hash-table lookup done in the out-of-line handler.
I have my doubts that it's worth it to try very hard to optimize this, as hidden classes would probably be faster... But consider this:
If objects contain an "inline" table with a small, constant number of slots, say K = 7 or K = 11, we could use this for objects with few properties, either for linear search or as a hash table. Furthermore, if we used it as a hash table, the actual index after hashing of the property name could be pre-computed in most cases (startIndex = hash(propName) % K). Meaning the lookup would always hopefully begin at the "right" place.
- Maxime