• 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
objects.cc 307 KB