Repository navigation
Better handling of splat func arguments #857
Description
Activity
- added 2 commits that reference this issue
on Feb 21, 2016 I did a patch (summivox/LiveScript@e6591cf) but it currently relies on #859 being merged. It can be done without #859 but I'm too lazy 😉
This patch itself does not change any semantics -- the only change is inlining slicing of
arguments. Therefore I did not add/change any tests.It works by inlining
slice$as a list comprehension. Above example compiles to:f = function(a){ var i$, b, res$, j$, c; res$ = []; for (j$ = 1 < (i$ = arguments.length - 1) ? 1 : (i$ = 1); j$ < i$; ++j$) { res$.push(arguments[j$]); } b = res$; c = arguments[i$]; };
According to http://jsperf.com/arguments-to-array/43
- prealloc-assign is the fastest on Chrome
- ES6 varargs (native splat) is the fastest on Firefox, followed by empty-push then prealloc-assign
slice$.call(arguments)is universally slow
However, as long as we get rid of deoptimization, the cost of a single slice should be negligible. Prealloc-assign is much harder to implement than list comprehension/empty-push.
Ping @gkz (Babel and TypeScript do this by default, and CoffeeScript has been annoying people with the slow progress)
@isiahmeadows : currently @vendethiel is in charge (and yes he did comment on that issue too).
BTW: #859 has been merged, so I can actually make a pull request now.
- added a commit that references this issue
on Mar 21, 2016 @summivox Okay. I didn't know this.
(I don't keep up with this as much as I used to. LS 2.0 does seem pretty interesting, though.)
- added a commit that references this issue
on Mar 22, 2016
According to Petka, calling
slice$onargumentskills v8 optimization. He suggested to do a naive indexed for loop onargumentsinstead.Currently:
compiles to: