• Benedikt Meurer's avatar
    [csa] Extend TryToName to also implicitly convert Oddball keys. · 426ae426
    Benedikt Meurer authored
    Previously TryToName bailed out for Oddball keys (i.e. when passing true
    or false as the key), which meant that for example the generic
    KeyedLoadIC would always bail out to the %KeyedGetProperty runtime
    function. But handling Oddball keys is fairly easy, since every oddball
    value carries it's unique string representation. Adding just this case
    to the CodeStubAssembler::TryToName method boosts this simple
    micro-benchmark by a factor of 4x:
    
      const n = 1e7;
      const obj = {};
      const key = true;
    
      console.time('foo');
      for (let i = 0; i < n; ++i) {
        if (obj[key] === undefined) {
          obj[key] = key;
        }
      }
      console.timeEnd('foo');
    
    It also shows on the ARES-6 ML benchmark and on several Speedometer
    tests, where objects are being used as dictionaries and the developers
    rely on the implicit ToString conversions on the property accesses.
    In the ARES-6 ML benchmark, the number of calls to %KeyedGetProperty
    is reduced by 137,758.
    
    Bug: v8:6278, v8:6344, v8:6670
    Change-Id: Iaa965e30be4c247682a67ec09543655df9b761d2
    Reviewed-on: https://chromium-review.googlesource.com/599527Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
    Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#47105}
    426ae426
test-code-stub-assembler.cc 93 KB