Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8075231

Typed array setters are very slow when index exceeds capacity

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8u60
    • 8u40
    • core-libs
    • b10
    • generic
    • generic

        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();

              hannesw Hannes Wallnoefer
              hannesw Hannes Wallnoefer
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: