Refers to an es-discuss thread  (just here for reference, it's not necessary to read to understand the bug) In a strict function, it's possible to prove that the "arguments" won't be used (if neither 'arguments' nor 'eval' appear in the function body). It costs a one-time full-function-body analysis (can even be done in a different thread), but once proven, all calls to the function can be cheaper because they don't need to allocate the arguments object at all. I think we can decently assume that most JS functions don't use neither 'arguments' nor direct eval, so it seems worth it. A couple of questions: 1) does the current implementation always allocate an arguments object for all function calls? 2) Is the suggested optimization already performed?  https://mail.mozilla.org/pipermail/es-discuss/2012-December/026868.html  https://mail.mozilla.org/pipermail/es-discuss/2012-December/026893.html
Unless I'm missing what you're saying, we already do this. We even avoid creating an arguments object if the function *does* mention 'arguments' but only uses 'arguments[i]' and 'arguments.length' and there are no writes to formals.
> 1) does the current implementation always allocate an arguments object for all function > calls? No. > 2) Is the suggested optimization already performed? Hard to say what exactly the suggested optimization is. Right now we detect whether a function might need an arguments object. Note that just using arguments[i] does NOT on its own force creation of an arguments object, because it can compile to direct access to the arglist, unless there's weirdness going on (vars aliasing arguments, etc). If we decide the function doesn't need an arguments object, it's not created (and some other stuff; for example right now Ion will only compile functions that don't need an arguments object).