hotspot/test/compiler/arraycopy/TestArrayCopyBadReexec.java
author tpivovarova
Tue, 12 Jul 2016 18:24:48 +0300
changeset 40059 c2304140ed64
parent 30185 4b08d63ac105
permissions -rw-r--r--
8132919: Put compiler tests in packages Reviewed-by: vlivanov, dpochepk Contributed-by: igor.ignatyev@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30185
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
     1
/*
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
     4
 *
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
     8
 *
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    13
 * accompanied this code).
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    14
 *
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    18
 *
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    21
 * questions.
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    22
 */
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    23
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    24
/*
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    25
 * @test
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    26
 * @bug 8073866
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    27
 * @summary Fix for 8064703 may also cause stores between the allocation and arraycopy to be rexecuted after a deoptimization
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    28
 *
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 30185
diff changeset
    29
 * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 30185
diff changeset
    30
 *                   compiler.arraycopy.TestArrayCopyBadReexec
30185
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    31
 */
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    32
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 30185
diff changeset
    33
package compiler.arraycopy;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 30185
diff changeset
    34
30185
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    35
public class TestArrayCopyBadReexec {
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    36
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    37
    static int val;
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    38
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    39
    static int[] m1(int[] src, int l) {
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    40
        if (src == null) {
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    41
            return null;
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    42
        }
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    43
        int[] dest = new int[10];
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    44
        val++;
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    45
        try {
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    46
            System.arraycopy(src, 0, dest, 0, l);
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    47
        } catch (IndexOutOfBoundsException npe) {
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    48
        }
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    49
        return dest;
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    50
    }
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    51
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    52
    static public void main(String[] args) {
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    53
        int[] src = new int[10];
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    54
        int[] res = null;
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    55
        boolean success = true;
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    56
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    57
        for (int i = 0; i < 20000; i++) {
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    58
            m1(src, 10);
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    59
        }
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    60
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    61
        int val_before = val;
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    62
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    63
        m1(src, -1);
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    64
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    65
        if (val - val_before != 1) {
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    66
            System.out.println("Bad increment: " + (val - val_before));
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    67
            throw new RuntimeException("Test failed");
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    68
        }
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    69
    }
4b08d63ac105 8073866: Fix for 8064703 is not sufficient
roland
parents:
diff changeset
    70
}