New issue
Advanced search Search tips

Issue 6978 link

Starred by 2 users

Issue metadata

Status: Assigned
HW: All
NextAction: ----
OS: All
Priority: 2
Type: Bug

issue 6936

Sign in to add a comment

High overhead of C++ Array builtins in CoffeeScript

Project Member Reported by, Oct 23 2017

Issue description

The coffeescript test in the web-tooling-benchmark shows a high percentage of time spent in C++ Array code, specifically Array#slice and Array#concat. There are probably a couple of low hanging fruits to pick here.

7.3 MB View Download
3.0 MB View Download
256 KB View Download
Project Member

Comment 1 by, Oct 24 2017

The following revision refers to this bug:

commit 6452b26a4bd746928937124d674e6dc3b9031396
Author: Daniel Clifford <>
Date: Tue Oct 24 06:39:47 2017

Reimplement Array.prototype.slice in CSA and C++

Previously, V8's slice was implemented in a combination of C++ and a 
Javascript fallback. The disadvantage of this approach was that the
fast-path required a call through the CEntryStub, which introduced
considerable overhead for small arrays with fast elements kinds.

Now the implementation primarily uses the CSA to generate both the
full spec-complaint implementation as well as fast paths for argument
objects and arrays with fast elements kinds. The CSA implementation
uses a C++ implementation fallback in select situations where the the
complexity of a CSA implementation would be too great and the
CEntryStub overhead is not decisive (e.g. slices of dictionary
elements arrays).

Performance results on semi-random arrays with small number of
elements (old vs. new):

smi copy: 48.7 ms vs. 12 ms
smi slice: 43.5 ms 14.8 ms
object copy: 35.5 ms 7.7 ms
object slice: 38.7 ms 8.8 ms
dictionary slice: 2398.3 ms vs. 5.4 ms
fast sloppy arguments slice: 9.6 ms vs. 7.2 ms
slow sloppy arguments slice: 28.9 ms vs. 8.5 ms

As a bonus, the new implementation is fully spec-compliant and fixes
at least one existing bug.

The design document for Array.prototype builtin rework can be found

Bug: v8:1956,v8:6601,v8:6710,v8:6978
Change-Id: Ia0155bedcf39b4577605ff754f416c2af938efb7
Commit-Queue: Daniel Clifford <>
Reviewed-by: Benedikt Meurer <>
Cr-Commit-Position: refs/heads/master@{#48853}

The CL by danno@ improves the coffeescript test by around 4%, so roughly half the overhead of Array#slice is gone.

Now Array#concat and Array#push are dominating wrt. Array builtins.
323 KB View Download

Sign in to add a comment