Typed array element setters are very slow when the index value is a valid index but exceeds the array capacity. This is because the setter throws an ArrayIndexOutOfBoundsException internally but does not propagate it (and thus does not cause relinking of fast array access). This makes the Octane gameboy benchmark in (older) revision v20 very slow. It can be reproduced with the following script: var buffer = new ArrayBuffer(16); var view = new Uint8Array(buffer); function bench() { var start = Date.now(); for (var i = 0; i < 1000000; i++) { for (var j = 0; j < 18; j++) { view[j] = 1; } } print("done: " + (Date.now() - start)); } bench();
|