hotspot/test/compiler/c2/TestDominatingDeadCheckCast.java
author tpivovarova
Tue, 12 Jul 2016 18:24:48 +0300
changeset 40059 c2304140ed64
parent 36311 635900f4df95
child 41705 332239c052cc
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:
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
/**
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    26
 * @test
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    27
 * @bug 8149797
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    28
 * @summary node replaced by dominating dead cast during parsing
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    29
 *
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36311
diff changeset
    30
 * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36311
diff changeset
    31
 *      -XX:TypeProfileLevel=200
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36311
diff changeset
    32
 *      -XX:CompileCommand=dontinline,compiler.c2.TestDominatingDeadCheckCast::not_inlined
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36311
diff changeset
    33
 *      compiler.c2.TestDominatingDeadCheckCast
36311
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    34
 */
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    35
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36311
diff changeset
    36
package compiler.c2;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36311
diff changeset
    37
36311
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    38
public class TestDominatingDeadCheckCast {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    39
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    40
    static class A {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    41
        int f;
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    42
    }
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    43
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    44
    static class B extends A {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    45
    }
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    46
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    47
    static A not_inlined() {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    48
        return new A();
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    49
    }
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    50
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    51
    static void inlined(A param) {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    52
        param.f = 42;
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    53
    }
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    54
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    55
    static A field;
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    56
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    57
    static void test(boolean flag1, boolean flag2, boolean flag3, boolean flag4, boolean flag5) {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    58
        // 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
    59
        field = not_inlined();
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    60
        // Speculation adds a CheckCast on entry of this inlined
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    61
        // method for the parameter
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    62
        inlined(field);
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    63
        // Walk up the dominators is depth limited, make the CheckCast
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    64
        // above unreachable from the last inlined call
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    65
        if (flag1) {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    66
            if (flag2) {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    67
                if (flag3) {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    68
                    // Speculation adds a CheckCast on entry of this
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    69
                    // inlined method for the parameter. This
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    70
                    // CheckCast is replaced by the CheckCast of the
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    71
                    // first inlined method call but the replaced
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    72
                    // CheckCast is still around during parsing.
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    73
                    inlined(field);
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    74
                    // Same as above, some useless control
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    75
                    if (flag4) {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    76
                        if (flag5) {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    77
                            // Speculation adds a CheckCast on entry
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    78
                            // of this inlined method for the
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    79
                            // parameter. This CheckCast is replaced
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    80
                            // by the dead CheckCast of the previous
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    81
                            // inlined() call.
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    82
                            inlined(field);
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
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    90
    static public void main(String[] args) {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    91
        field = new A();
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    92
        for (int i = 0; i < 20000; i++) {
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    93
            test(true, true, true, true, true);
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    94
        }
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    95
    }
635900f4df95 8149916: Test case for 8149797
roland
parents:
diff changeset
    96
}