• Benedikt Meurer's avatar
    [es2015] Handle proxies in GetProperty builtin. · 87199f52
    Benedikt Meurer authored
    Teach the GetProperty builtin how to perform [[Get]] on JSProxy
    instances by calling into the dedicated ProxyGetProperty builtin
    that we already use for the LOAD_IC / KEYED_LOAD_IC. This is
    important when proxies are used in places were GetProperty builtin
    is used like for example as iterables in for..of loops or in spreads.
    
    On a simple micro-benchmark like the following
    
    ```js
    const proxy = new Proxy([1, 2, 3], {
      get(target, property) { return target[property]; }
    });
    const TESTS = [
        function testForOfProxy() { for (const x of proxy) {} },
        function testSpreadProxy() { return [...proxy]; }
    ];
    
    function test(fn) {
      var result;
      for (var i = 0; i < 1e6; ++i) result = fn();
      return result;
    }
    test(x => x);
    
    for (var j = 0; j < TESTS.length; ++j) test(TESTS[j]);
    for (var j = 0; j < TESTS.length; ++j) {
      var startTime = Date.now();
      test(TESTS[j]);
      print(TESTS[j].name + ':', (Date.now() - startTime), 'ms.');
    }
    ```
    
    improves from around
    
      testForOfProxy: 1672.6 ms.
      testSpreadProxy: 1956.6 ms.
    
    to
    
      testForOfProxy: 408.4 ms.
      testSpreadProxy: 530.8 ms.
    
    on average, which corresponds to a 4-5x performance improvement, even
    for small arrays. On the ARES-6 Air benchmark this completely eliminates
    all calls to the %GetProperty runtime function, and thereby improves the
    steady state mean by 2-3%.
    
    Bug: v8:6344, v8:6557, v8:6559
    Change-Id: Ifebdaff8f3ae5899a33ce408ecd54655247f3a02
    Reviewed-on: https://chromium-review.googlesource.com/1199023Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
    Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#55539}
    87199f52
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...
.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...