In V8:
A function that is so short and has no context-sensitive variables will go into it. Unless, of course, too many inlays have already accumulated, in which case the call is still very cheap, since the entire executable part of the function fits into the command cache line of 64 bytes.
The listed context variables occur when your function uses, for example, arguments , not in strict mode or defines internal functions that reference function variables. Another problem is that x64 functions cannot be inlined if the caller and the callee cannot use the same context, so generally avoid closures like the plague.
See: http://jsperf.com/312319sakd , although firefox seems to be using dead code removal (which is disappointing, why waste time on this?).
Bonus: this jsperf deliberately makes the getter function impracticable (through a huge comment that will result in a heuristic failure in functional size) in the current V8. You can see that even if the function was not built in, it is still only 25% slower than the link to prop directly.
Note that when a function cannot be inlined, it is considered a black box, the side effects of which are not known to the calling function, so the speed is highly dependent on the context of the code.
Esailija
source share