test/hotspot/jtreg/compiler/arraycopy/TestArrayCopyWithBadOffset.java
author jlaskey
Thu, 14 Nov 2019 12:39:56 -0400
branchJDK-8193209-branch
changeset 59087 effb66aab08b
parent 55025 e93621d4db2c
permissions -rw-r--r--
[mq]: other
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
55003
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
     1
/*
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
     4
 *
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
     7
 * published by the Free Software Foundation.
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
     8
 *
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    13
 * accompanied this code).
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    14
 *
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    18
 *
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    21
 * questions.
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    22
 */
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    23
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    24
/*
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    25
 * @test
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    26
 * @bug 8224539
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    27
 * @summary Test arraycopy optimizations with bad src/dst array offsets.
55025
e93621d4db2c 8224723: [TESTBUG] compiler/arraycopy/TestArrayCopyWithBadOffset.java failed
thartmann
parents: 55003
diff changeset
    28
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -Xbatch -XX:+AlwaysIncrementalInline
55003
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    29
 *                   compiler.arraycopy.TestArrayCopyWithBadOffset
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    30
 */
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    31
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    32
package compiler.arraycopy;
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    33
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    34
public class TestArrayCopyWithBadOffset {
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    35
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    36
    public static byte[] getSrc() {
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    37
        return new byte[5];
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    38
    }
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    39
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    40
    // Test bad src offset
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    41
    public static void test1(byte[] dst) {
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    42
        byte[] src = getSrc();
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    43
        try {
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    44
            System.arraycopy(src, Integer.MAX_VALUE-1, dst, 0, src.length);
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    45
        } catch (Exception e) {
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    46
            // Expected
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    47
        }
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    48
    }
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    49
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    50
    public static byte[] getDst() {
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    51
        return new byte[5];
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    52
    }
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    53
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    54
    // Test bad dst offset
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    55
    public static void test2(byte[] src) {
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    56
        byte[] dst = getDst();
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    57
        try {
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    58
            System.arraycopy(src, 0, dst, Integer.MAX_VALUE-1, dst.length);
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    59
        } catch (Exception e) {
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    60
            // Expected
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    61
        }
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    62
    }
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    63
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    64
    public static void main(String[] args) {
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    65
        byte[] array = new byte[5];
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    66
        for (int i = 0; i < 10_000; ++i) {
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    67
            test1(array);
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    68
            test2(array);
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    69
        }
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    70
    }
bec1bb783c7e 8224539: C2 compilation fails during ArrayCopyNode optimizations with assert(i < _max) failed: oob: i=1, _max=1
thartmann
parents:
diff changeset
    71
}