Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Arguments object myths and truth #57

mraleph opened this Issue Mar 21, 2011 · 3 comments


None yet
2 participants

mraleph commented Mar 21, 2011

The arguments object is always created with the only two exceptions being the cases where it > is declared as a name inside of a function or one of its formal parameters. It does not matter
whether it is used or not.

This is incorrect at least for V8. Arguments object is not created if it is not used and even if it is used in some cases V8 can avoid creating arguments object.

In the above code, foo can no longer be a subject to inlining since it needs to know about both itself and its caller.

This logic is also incorrect. Inlining can take care of the fact that foo accesses it's caller.

Speaking of V8:

  • Accessing arguments.callee currently in function makes function non-optimizable.

  • But accessing it does not disable inling of functions above it. Consider the following example:

    function baz() {
    if (arguments.callee.caller != foo || arguments.callee.caller.caller != bar)
    throw new Error("something fishy is going on");

    function foo() { return baz(); }
    function bar() { return foo(); }

    for (var i = 0; i < 1000000; i++) bar();

    Here V8's optimizing backend will be able to inline foo into bar despite the fact that baz accesses the fact that foo is called from bar.

mraleph commented Mar 25, 2011

Why this is marked with "additional details"?

Claiming that "It does not matter whether it is used or not." is pure mis-information.


timruffles commented Oct 9, 2013

I think I'll look at removing a lot of the micro-perf text. People shouldn't be worrying too much about this, especially as loads of it depends on ephemeral interpreter implementations!

Having seen your LXJS talk I don't want to engender your wrath (unless your blood pressure is too low ;) )

mraleph commented Oct 19, 2013

@timruffles that would be great. feel free to reach out to me directly if you need any clarifications.

[strangely github did not notify me about your comment, I discovered this update by pure accident :-/]

@timruffles timruffles closed this Apr 30, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment