• Benedikt Meurer's avatar
    [turbofan] Unfold bound functions at call sites. · 99100db4
    Benedikt Meurer authored
    So far the JSCallReducer was only able to unfold constant
    JSBoundFunction targets for JSCall nodes, which is not the
    common case. With the introduction of JSCreateBoundFunction
    operator earlier, we can now also recognize calls to bound
    functions where the bind happens earlier in the function,
    i.e. as the example of
    
      a.map(f.bind(self))
    
    in https://twitter.com/BenLesh/status/920700003974123520, which
    is a handy way to use Function#bind. So this transformation
    takes a node like
    
      JSCall(JSCreateBoundFunction(bound_target_function,
                                   bound_this,
                                   a1,...,aN),
             receiver, p1,...,pM)
    
    and turns that into
    
      JSCall(bound_target_function, bound_this, a1,...,aN,p1,...,pM)
    
    allowing TurboFan to further inline the bound_target_function
    at this call site if that's also inlinable (i.e. it's a known
    constant JSFunction or the result of a JSCreateClosure call).
    
    This improves the micro-benchmark from
    
      arrowCall: 55 ms.
      boundCall: 221 ms.
      arrowMap: 181 ms.
      boundMap: 806 ms.
    
    to
    
      arrowCall: 71 ms.
      boundCall: 76 ms.
      arrowMap: 188 ms.
      boundMap: 186 ms.
    
    so that Function#bind in this case is as fast as using closures,
    which is an up to 4.3x improvement in the Array#map example.
    
    Bug: v8:5257, v8:6961
    Change-Id: Ibca650faad912bf9db1db6fbc48772e7551289a6
    Reviewed-on: https://chromium-review.googlesource.com/727799Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
    Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#48713}
    99100db4
Name
Last commit
Last update
..
benchmarks Loading commit data...
cctest Loading commit data...
common Loading commit data...
debugger Loading commit data...
fuzzer Loading commit data...
inspector Loading commit data...
intl Loading commit data...
js-perf-test Loading commit data...
memory Loading commit data...
message Loading commit data...
mjsunit Loading commit data...
mkgrokdump Loading commit data...
mozilla Loading commit data...
preparser Loading commit data...
promises-aplus Loading commit data...
test262 Loading commit data...
unittests Loading commit data...
wasm-spec-tests Loading commit data...
webkit Loading commit data...
BUILD.gn Loading commit data...
bot_default.gyp Loading commit data...
bot_default.isolate Loading commit data...
default.gyp Loading commit data...
default.isolate Loading commit data...
optimize_for_size.gyp Loading commit data...
optimize_for_size.isolate Loading commit data...
perf.gyp Loading commit data...
perf.isolate Loading commit data...