• Benedikt Meurer's avatar
    [runtime] Optimize general object spread. · 4995c85f
    Benedikt Meurer authored
    This adds a new %_CopyDataProperties intrinsic, that reuses most of the
    existing machinery that we already have in place for Object.assign() and
    computed property names in object literals. This speeds up the general
    case for object spread (where the spread is not the first item in an
    object literal) and brings it on par with Object.assign() at least - in
    most cases it's significantly faster than Object.assign().
    
    In the test case [1] referenced from the bug, the performance goes from
    
      objectSpreadLast: 3624 ms.
      objectAssignLast: 1938 ms.
    
    to
    
      objectSpreadLast: 646 ms.
      objectAssignLast: 1944 ms.
    
    which corresponds to a **5-6x performance boost**, making object spread
    faster than Object.assign() in general.
    
    Drive-by-fix: This refactors the Object.assign() fast-path in a way that
    it can be reused appropriately for object spread, and adds another new
    builtin SetDataProperties, which does the core of the Object.assign()
    work. We can teach TurboFan to inline Object.assign() based on the new
    SetDataProperties builtin at some later point to further optimize
    Object.assign().
    
    [1]: https://gist.github.com/bmeurer/0dae4a6b0e23f43d5a22d7c91476b6c0
    
    Bug: v8:9167
    Change-Id: I57bea7a8781c4a1e8ff3d394873c3cd4c5d73834
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1587376Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
    Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
    Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#61100}
    4995c85f
interpreter-intrinsics.h 3.01 KB