It is slow because:

a) it is very generic (take a look at the source
http://code.google.com/p/v8/source/browse/trunk/src/v8natives.js#1150);

b) not optimized for common cases (e.g. we could have provided an
optimized implementation for f.bind(this));

Bind returns a pretty complicated function (that does an allocation
per call) which optimizing code generator (aka Crankshaft) can't
optimize much.

As you've probably noticed from JSPerf results we recently improved
handling of closures in Crankshaft (so "Closure" test is almost as
fast as "Func call" test on Chrome 10.0.648).

--
Vyacheslav Egorov.



On Mon, Feb 7, 2011 at 2:03 PM, Egor Egorov <[email protected]> wrote:
>
> I discovered this problem when I was trying to figure out why my
> data-intensive code is slow. Turns out, lots of bind calls.
>
> You can test it here: http://jsperf.com/call-vs-closure-to-pass-scope/2
>
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to