• Benedikt Meurer's avatar
    [ic] Teach KeyedLoadICGeneric about ToName. · 923127f8
    Benedikt Meurer authored
    In the KeyedLoadICGeneric case the engine previously immediately fell
    back to the %KeyedGetProperty runtime function if the key was not a
    Name or a valid array index. This turns out to be really slow if a
    program passes for example objects as keys. Since we already have all
    the logic in place to convert an arbitrary JavaScript value to a Name,
    we can just call into ToName first and then operate on the result of
    that, which is significantly faster since C++ usually doesn't need to
    call back into JavaScript then to convert a JSReceiver into a Name.
    
    This also changes the ToName builtin to use the existing builtin for
    NonPrimitiveToPrimitive, which stays in JavaScript land completely.
    Since there's not really a point in inlining ToName into the call
    sites, the other uses were also changed to call the builtin instead,
    which saves some space and might also help with instruction cache
    utilization (especially when the ToName logic is more involved now).
    
    This improves the performance on the microbenchmark
    
    ```js
    const n = 1e7;
    const obj = {};
    const key = [1,2];
    
    const start = Date.now();
    for (let i = 0; i < n; ++i) {
      if (obj[key] === undefined) obj[key] = key;
    }
    print(`time: ${Date.now() - start} ms.`);
    ```
    
    by up to 36%. On the ARES-6 ML benchmark the steady state improves by up
    to ~7% and the overall mean for ARES-6 ML improves by up to ~6%. Further
    improvements might be possible here if the GetProperty builtin could be
    made faster for common prototype lookups like Symbol.toPrimitive and the
    "valueOf" and "toString" functions.
    
    Bug: v8:6344, v8:6670
    Change-Id: Ic3ac2bc4d4277836ef03039de4eda5c5f66a85da
    Reviewed-on: https://chromium-review.googlesource.com/1199022
    Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
    Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#55540}
    923127f8
Name
Last commit
Last update
..
OWNERS Loading commit data...
accessor-assembler.cc Loading commit data...
accessor-assembler.h Loading commit data...
binary-op-assembler.cc Loading commit data...
binary-op-assembler.h Loading commit data...
call-optimization.cc Loading commit data...
call-optimization.h Loading commit data...
handler-configuration-inl.h Loading commit data...
handler-configuration.cc Loading commit data...
handler-configuration.h Loading commit data...
ic-inl.h Loading commit data...
ic-stats.cc Loading commit data...
ic-stats.h Loading commit data...
ic.cc Loading commit data...
ic.h Loading commit data...
keyed-store-generic.cc Loading commit data...
keyed-store-generic.h Loading commit data...
stub-cache.cc Loading commit data...
stub-cache.h Loading commit data...