test/hotspot/jtreg/compiler/c2/TestDominatingDeadCheckCast.java
author iignatyev
Mon, 18 Feb 2019 09:31:07 -0800
changeset 53791 bec6c8739833
parent 47216 71c04702a3d5
permissions -rw-r--r--
8219157: vm/mlvm/mixed/stress/java/findDeadlock should be problem-listed only on mac Reviewed-by: thartmann
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36311
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
     1
/*
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
     4
 *
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
     8
 *
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    13
 * accompanied this code).
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    14
 *
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    18
 *
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    21
 * questions.
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    22
 */
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    23
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    24
/**
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    25
 * @test
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    26
 * @bug 8149797
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    27
 * @summary node replaced by dominating dead cast during parsing
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    28
 *
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36311
diff changeset
    29
 * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36311
diff changeset
    30
 *      -XX:TypeProfileLevel=200
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36311
diff changeset
    31
 *      -XX:CompileCommand=dontinline,compiler.c2.TestDominatingDeadCheckCast::not_inlined
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36311
diff changeset
    32
 *      compiler.c2.TestDominatingDeadCheckCast
36311
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    33
 */
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    34
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36311
diff changeset
    35
package compiler.c2;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36311
diff changeset
    36
36311
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    37
public class TestDominatingDeadCheckCast {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    38
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    39
    static class A {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    40
        int f;
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    41
    }
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    42
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    43
    static class B extends A {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    44
    }
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    45
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    46
    static A not_inlined() {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    47
        return new A();
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    48
    }
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    49
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    50
    static void inlined(A param) {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    51
        param.f = 42;
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    52
    }
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    53
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    54
    static A field;
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    55
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    56
    static void test(boolean flag1, boolean flag2, boolean flag3, boolean flag4, boolean flag5) {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    57
        // Go through memory rather than through a local to defeat C2's replace_in_map
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    58
        field = not_inlined();
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    59
        // Speculation adds a CheckCast on entry of this inlined
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    60
        // method for the parameter
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    61
        inlined(field);
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    62
        // Walk up the dominators is depth limited, make the CheckCast
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    63
        // above unreachable from the last inlined call
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    64
        if (flag1) {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    65
            if (flag2) {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    66
                if (flag3) {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    67
                    // Speculation adds a CheckCast on entry of this
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    68
                    // inlined method for the parameter. This
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    69
                    // CheckCast is replaced by the CheckCast of the
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    70
                    // first inlined method call but the replaced
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    71
                    // CheckCast is still around during parsing.
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    72
                    inlined(field);
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    73
                    // Same as above, some useless control
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    74
                    if (flag4) {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    75
                        if (flag5) {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    76
                            // Speculation adds a CheckCast on entry
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    77
                            // of this inlined method for the
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    78
                            // parameter. This CheckCast is replaced
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    79
                            // by the dead CheckCast of the previous
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    80
                            // inlined() call.
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    81
                            inlined(field);
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    82
                        }
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    83
                    }
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    84
                }
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    85
            }
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    86
        }
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    87
    }
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    88
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    89
    static public void main(String[] args) {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    90
        field = new A();
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    91
        for (int i = 0; i < 20000; i++) {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    92
            test(true, true, true, true, true);
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    93
        }
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    94
    }
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    95
}