• Benedikt Meurer's avatar
    [turbofan] Skip arguments adaptor when target cannot observe arguments. · 75629d5f
    Benedikt Meurer authored
    When calling a known function from optimized code, where the number of
    actual arguments does not match the number of expected arguments,
    TurboFan has to call indirectly via the arguments adaptor trampoline,
    which creates an argument adaptor frame underneath the activation record
    for the callee. This is done so that the callee can still get to the
    actual arguments, using either
    
    1. the arguments object, or
    2. rest parameters (to get to superfluous arguments), or
    3. the non-standard Function.arguments accessor (for sloppy mode
       functions), or
    4. direct eval(), where we don't know whether there's a use of the
       arguments object hiding somewhere in the string.
    
    However going through the arguments adaptor trampoline is quite
    expensive usually, it seems to be responsible for over 60% of the
    call overhead in those cases.
    
    So this adds a fast path for the case of calling strict mode functions
    where we have an arguments mismatch, but where we are sure that the
    callee cannot observe the actual arguments. We use a bit on the
    SharedFunctionInfo to indicate that this is safe, which is controlled
    by hints from the Parser which knows whether the callee uses either
    arguments object or rest parameters.
    
    In those cases we use a direct call from optimized code, passing the
    expected arguments instead of the actual arguments. This improves the
    benchmark on the document below by around 60-65%, which is exactly
    the overhead of the arguments adaptor trampoline that we save in this
    case.
    
    This also adds a runtime flag --fast_calls_with_arguments_mismatches,
    which can be used to turn off the new behavior. This might be handy
    for checking the performance impact via Finch.
    
    Bug: v8:8895
    Change-Id: Idea51dba7ee6cb989e86e0742eaf3516e5afe3c4
    Cq-Include-Trybots: luci.chromium.try:linux-blink-rel
    Doc: http://bit.ly/v8-faster-calls-with-arguments-mismatch
    Reviewed-on: https://chromium-review.googlesource.com/c/1482735
    Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
    Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#59825}
    75629d5f
Name
Last commit
Last update
benchmarks Loading commit data...
build_overrides Loading commit data...
custom_deps Loading commit data...
docs Loading commit data...
gni 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...
.clang-tidy Loading commit data...
.editorconfig Loading commit data...
.git-blame-ignore-revs Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.gn Loading commit data...
.vpython 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...
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...