Commit 447ebbe
committed
perf(array): add dense fast path to Array.prototype.push
Array.prototype.push was going through the generic [[Set]] machinery
for every element, which involves property descriptor validation and
prototype chain walks. This is unnecessary for dense arrays where we
can append directly to the indexed storage.
Add a fast path that mirrors the PushValueToArray opcode: check that
the array is extensible and has dense storage, then push directly via
push_dense() and update the length in-place. Falls through to the
existing slow path for sparse arrays, non-extensible arrays, and
array-like objects.
~49% improvement on a push-dominated microbenchmark, ~20% on a
realistic mixed workload (push objects + filter).1 parent f5e88de commit 447ebbe
1 file changed
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
875 | 875 | | |
876 | 876 | | |
877 | 877 | | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
878 | 907 | | |
879 | 908 | | |
880 | 909 | | |
| |||
0 commit comments