V8 memory quiz
mattzeunert.com
mattzeunert.com
It's interesting to compare this to a "NaN-boxing" approach, which allows pointers and doubles (and other simple values) to all exist in a single "namespace" of 8-byte values. In the (uncommon?) case of a heterogeneous array, this can save memory by avoiding the need to box simple values. The downside is that NaN-boxing prevents the use of full 64-bit pointers.
And shouldn't stuff like this be in the specs, so that the language becomes more consistent and predictable?
SpiderMonkey uses NaN-boxing, so pointers to objects will sometimes take up less space than in V8. As for hidden classes, I'm not sure about how shapes (SpiderMonkey's term for hidden classes) interact with constructors.
> And shouldn't stuff like this be in the specs, so that the language becomes more consistent and predictable?
That would stifle compiler innovation. Not even the "low-level", "predictable" C and C++ mandate particular implementations, beyond specifying the bare minimum necessary to ensure pointer arithmetic works portably.
But at least with C and C++ a developer can test the performance before deployment.