Is it possible to compile default parameters without usage of "arguments"? #1814

Closed
SkReD opened this Issue Jun 24, 2015 · 4 comments

Projects

None yet

4 participants

@SkReD
SkReD commented Jun 24, 2015

Generated code is not optimizing in v8 because of this

@sebmckbot
Member

We have closed this issue as we've detected it to be a question. Please see the README:

For questions and support please visit the gitter room or StackOverflow. The Babel issue tracker is exclusively for bug reports and feature requests.

Thank you!

@sebmckbot sebmckbot closed this Jun 24, 2015
@kittens
Member
kittens commented Jun 24, 2015

No it doesn't. Specific cases of arguments usage are optimised and this is one of them. No way to do default parameters without it since the arity shouldn't be changed.

@kpdecker
Contributor

(function(foo = 1){}).length === 0 certainly surprised me but I must admit the spec is a bit difficult for my mere mortal brain to comprehend :)
{edit} For those who may find this later, the behavior is defined here

Regardless this is a large performance impact, with up to 2000x performance hit.
image
http://kpdecker.github.io/six-speed/

Is this something that could be a candidate for a loose mode flag?

@kpdecker
Contributor

For magnitude, the Firefox operations per second are on the order of 833,518,046 operations/sec for ES5/6 and 452,602 operations/sec for Babel. Chrome is 80,841,415 vs. 7,336,055 so these potentially fall into the "good enough, just don't use on the hot path" category of code.

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