hotspot/test/compiler/arraycopy/TestLoadBypassArrayCopy.java
author thartmann
Thu, 04 Aug 2016 10:34:34 +0200
changeset 40365 3791c1b34e36
parent 40059 c2304140ed64
permissions -rw-r--r--
8136818: Test compiler/arraycopy/TestEliminatedArrayCopyDeopt.java fails with "m1 failed" Summary: Added missing Op_StoreB check to ArrayCopyNode::may_modify_helper(). Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31231
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
     1
/*
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
     4
 *
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
     8
 *
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    13
 * accompanied this code).
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    14
 *
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    18
 *
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    21
 * questions.
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    22
 */
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    23
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    24
/*
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    25
 * @test
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    26
 * @bug 8086046
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    27
 * @summary load bypasses arraycopy that sets the value after the ArrayCopyNode is expanded
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    28
 *
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 31231
diff changeset
    29
 * @run main/othervm -XX:-BackgroundCompilation  -XX:-UseOnStackReplacement
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 31231
diff changeset
    30
 *                   -XX:CompileCommand=dontinline,compiler.arraycopy.TestLoadBypassArrayCopy::test_helper
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 31231
diff changeset
    31
 *                   -XX:-TieredCompilation
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 31231
diff changeset
    32
 *                   compiler.arraycopy.TestLoadBypassArrayCopy
31231
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    33
 */
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    34
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 31231
diff changeset
    35
package compiler.arraycopy;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 31231
diff changeset
    36
31231
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    37
public class TestLoadBypassArrayCopy {
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    38
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    39
    static long i;
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    40
    static boolean test_helper() {
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    41
        i++;
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    42
        if ((i%10) == 0) {
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    43
            return false;
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    44
        }
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    45
        return true;
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    46
    }
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    47
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    48
    static int test(int[] src, int len, boolean flag) {
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    49
        int[] dest = new int[10];
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    50
        int res = 0;
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    51
        while (test_helper()) {
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    52
            System.arraycopy(src, 0, dest, 0, len);
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    53
            // predicate moved out of loop so control of following
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    54
            // load is not the ArrayCopyNode. Otherwise, if the memory
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    55
            // of the load is changed and the control is set to the
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    56
            // ArrayCopyNode the graph is unschedulable and the test
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    57
            // doesn't fail.
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    58
            if (flag) {
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    59
            }
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    60
            // The memory of this load shouldn't bypass the arraycopy
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    61
            res = dest[0];
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    62
        }
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    63
        return res;
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    64
    }
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    65
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    66
    static public void main(String[] args) {
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    67
        int[] src = new int[10];
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    68
        src[0] = 0x42;
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    69
        for (int i = 0; i < 20000; i++) {
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    70
            int res = test(src, 10, false);
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    71
            if (res != src[0]) {
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    72
                throw new RuntimeException("test failed");
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    73
            }
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    74
        }
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    75
    }
068d1f94b3bf 8086046: escape analysis generates incorrect code as of B67
roland
parents:
diff changeset
    76
}