3 ms·
>We also require every access to any stack variable to do math to figure out where on the stack it's arguments are. I suspect that on modern architectures thes
by simias 6y ago
>We also require every access to any stack variable to do math to figure out where on the stack it's arguments are.
I suspect that on modern architectures these trivial additions are effectively free most of the time. In my experience the hard part of optimizing for modern architectures is compensating for memory latency (cache optimization, prefetching) and pipeline flushes (branch prediction).
An inline, unconditional add is as cheap as it gets these days. A few additional bytes of stack that's (almost) always going to be super hot in cache is not really significant.
I suppose it could pose an issue for super deep function call tree where it would cause the stack to grow more than necessary, but given the usual memory overhead of JS I doubt that it's going to be very significant even then.