JDK-8075231 : Typed array setters are very slow when index exceeds capacity
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 8u40
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2015-03-16
  • Updated: 2015-09-29
  • Resolved: 2015-03-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u60 b10Fixed 9Fixed
Description
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();

Comments
Adding noreg-perf label. Fix can be verified by running the script in the bug description.
26-03-2015

Very good find, Hannes!
16-03-2015