duktape
duktape copied to clipboard
A possible performance problem about Array.prototype.unshift
Description
When calling Array.prototype.unshift, the execution speed of duktape is much slower than other JavaScript engines. In terms of memory allocation strategy, can duktape be optimized?
Version
Testcase
var foo = function(v) {
for(var t = [], r = 0; r < 10000; r++) {
t.unshift(1);
}
}
var res = foo();
Execution time
duktape: 2572ms JerryScript: 29ms XS: 79ms
Build setp
make -f Makefile.cmdline
CPU
Intel(R) Core(TM) i9-9940X CPU @ 3.30GHzz
Array methods must work on Array instances but also on any object that is "Array-like". Some functions have a fast path for the Array case and a slow path for the generic case (e.g. push()). At present unshift() has no fast path so it falls back to very generic processing which probably explains the performance.