Why do .callee arguments degrade performance?

An alternative to using arguments.calleeis simply the name of the function, as such:

// Snippet 1, using arguments.callee:
(function(){
    document.body.innerHTML += 'qwe';
    setTimeout(arguments.callee, 1);
})()

// Snippet 2, using naming:
(function f(){
    document.body.innerHTML += 'qwe';
    setTimeout(f, 1);
})()

What stops the JavaScript engine / compiler from automatically optimizing Snippet 1 in Snippet 2 above? Is there any inherent limitation?

  • The MDN argument basically boils down to:

    .. arguments.calleesignificantly complicates optimization, for example, the embedding of functions, since it is necessary to provide a link to the un-inlined function, if access to arguments.callee.

    However, if we manually call this function and call it through this name, we already provide a link to this function and, thus, “impede optimizations such as nesting functions”.

  • Olliej " [] [ , ]". , (. ).

, arguments.callee?

+4
1

, MDN " - "; , : " , arguments.callee - ".

( , , arguments.callee , arguments, this , , , . , , MDN .)

0

Source: https://habr.com/ru/post/1538821/


All Articles