Yesterday, by accident, we've seen an article about some design principles
It made clearer what techniques are used in today's script implementations.
In particular V8 engine optimizes property access using "dynamically
hidden classes". These are structures to store object's layout, they
are derived when ש new property is created (deleted) on the object. When code
accesses a property, and if a cached object's dynamic hidden class is available
at the code point then access time is comparable to one of native fields.
In our opinion this tactics might lead to a proliferation of such dynamic hidden
classes, which requires a considerable housekeeping, which also slows property
write access, especially when it's written for the first time.
We would like to suggest a slightly different strategy, which exploits the
cache matches, and does not require a dynamic hidden classes.
Consider an implementation data type with following characteristics:
A pseudo code for the property access looks like this:
pair = object.values[cachedIndex];
if (pair.ID == propertyID)
value = pair.Value;
// Cache miss.
cachedIndex = object.index(propertyID);
value = objec.values[cachedIndex].Value;
This approach brings us back to dictionary like implementation but with
important optimization of array speed access when property index is cached, and
with no dynamic hidden classes.
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u