4 ms·
variable and property lookups do go through different processes (and hence optimized differently). variables are stored on activation records (a Context object
by chewxy 12y ago
variable and property lookups do go through different processes (and hence optimized differently).
variables are stored on activation records (a Context object in v8), while properties are stored in well, a magic hidden class type of thing (for v8).
The latter can be cached, the former not so much. Plus, the former also creates quite a bit of garbage, so gc should theroetically kick in more often
- comex 12y agoI would expect any local variables to be stored in registers once the optimizer kicks in. I bet there's a different explanation.
- Stratoscope 12y agoThat is true, but I don't see how it explains the difference either. The function version and method version both reference a local variable, named makeKeyCodepoint or makeKeyCodepointObj respectively. The method version doesn't appear to have any fewer variable references than the function version.