• 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...
build_overrides Loading commit data...
docs Loading commit data...
gni Loading commit data...
gypfiles Loading commit data...
include Loading commit data...
infra Loading commit data...
samples Loading commit data...
src Loading commit data...
test Loading commit data...
testing Loading commit data...
third_party Loading commit data...
tools Loading commit data...
.clang-format Loading commit data...
.editorconfig Loading commit data...
.git-blame-ignore-revs Loading commit data...
.gitignore Loading commit data...
.gn Loading commit data...
.ycm_extra_conf.py Loading commit data...
AUTHORS Loading commit data...
BUILD.gn Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
ChangeLog Loading commit data...
DEPS Loading commit data...
LICENSE Loading commit data...
LICENSE.fdlibm Loading commit data...
LICENSE.strongtalk Loading commit data...
LICENSE.v8 Loading commit data...
LICENSE.valgrind Loading commit data...
Makefile Loading commit data...
Makefile.android Loading commit data...
OWNERS Loading commit data...
PRESUBMIT.py Loading commit data...
README.md Loading commit data...
WATCHLISTS Loading commit data...
codereview.settings Loading commit data...
snapshot_toolchain.gni Loading commit data...