• adamk's avatar
    Optimize testing for an index's existence in packed Arrays · 6230641b
    adamk authored
    This patch introduces a new inline runtime function,
    %_HasFastPackedElements(), and uses it both in the implementation
    of the 'in' operator and in the array builtins to speed
    up testing for the existence of an index in an array.
    
    In testing with the microbenchmark on the attached bug,
    for example, the runtime goes from 326ms to 66ms.
    
    A reviewer might ask whether the HAS_INDEX macro is worthwhile,
    and I tried the same example without it, which pushed the
    microbenchmark up to 157ms. So it seems it's worth it to
    avoid the function call to IN() if we know we're dealing
    with arrays and numbers.
    
    BUG=v8:3701
    LOG=n
    
    Review URL: https://codereview.chromium.org/754863002
    
    Cr-Commit-Position: refs/heads/master@{#25665}
    6230641b
macros.py 12.8 KB