hotspot/test/compiler/types/TestMeetTopArrayExactConstantArray.java
author stuefe
Thu, 28 Apr 2016 15:40:45 +0200
changeset 38215 fe1677e95252
parent 23208 4c37d91b8b09
child 40059 c2304140ed64
permissions -rw-r--r--
8155639: Remove STEP numbers from error reporting Reviewed-by: coleenp, twisti
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22239
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
     1
/*
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
     4
 *
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
     8
 *
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    13
 * accompanied this code).
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    14
 *
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    18
 *
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    21
 * questions.
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    22
 */
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    23
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    24
/*
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    25
 * @test
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    26
 * @bug 8027571
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    27
 * @summary meet of TopPTR exact array with constant array is not symmetric
23208
4c37d91b8b09 8032633: Enable type speculation by default
roland
parents: 22239
diff changeset
    28
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseOnStackReplacement -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation -XX:-BackgroundCompilation TestMeetTopArrayExactConstantArray
22239
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    29
 *
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    30
 */
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    31
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    32
public class TestMeetTopArrayExactConstantArray {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    33
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    34
    static class A {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    35
    }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    36
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    37
    static class B {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    38
    }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    39
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    40
    static class C extends A {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    41
    }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    42
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    43
    static class D extends C {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    44
    }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    45
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    46
    final static B[] b = new B[10];
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    47
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    48
    static void m0(Object[] o) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    49
        if (o.getClass() ==  Object[].class) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    50
        }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    51
    }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    52
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    53
    static void m1(Object[] o, boolean cond) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    54
        if (cond) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    55
            o = b;
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    56
        }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    57
        m0(o);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    58
    }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    59
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    60
    static void m2(Object[] o, boolean cond1, boolean cond2) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    61
        if (cond1) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    62
            m1(o, cond2);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    63
        }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    64
    }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    65
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    66
    static void m3(C[] o, boolean cond1, boolean cond2, boolean cond3) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    67
        if (cond1) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    68
            m2(o, cond2, cond3);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    69
        }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    70
    }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    71
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    72
    static public void main(String[] args) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    73
        A[] a = new A[10];
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    74
        D[] d = new D[10];
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    75
        Object[] o = new Object[10];
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    76
        for (int i = 0; i < 5000; i++) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    77
            // record in profiling that the if in m0 succeeds
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    78
            m0(o);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    79
            // record some profiling for m2 and m1
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    80
            m2(a, true, (i%2) == 0);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    81
            // record some profiling for m3 and conflicting profile for m2
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    82
            m3(d, true, false, (i%2) == 0);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    83
        }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    84
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    85
        // get m3 compiled. The if in m0 will be optimized because of argument profiling in m3
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    86
        C[] c = new C[10];
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    87
        for (int i = 0; i < 20000; i++) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    88
            m3(c, true, false, (i%2) == 0);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    89
        }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    90
        // make m3 not entrant and the if in m0 fail
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    91
        m3(c, true, true, false);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    92
        m3(c, true, true, false);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    93
        m3(c, true, true, false);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    94
        m3(c, true, true, false);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    95
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    96
        // make m3 recompile, this time with if the not optimized
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    97
        // on entry to m3, argument o is of type C[], profiled C[]
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    98
        // on entry to m1, argument o is of type C[], speculative C[] exact, profiled A[]. Speculative becomes AnyNull
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    99
        // after the if in m1, speculative type of o becomes constant from final field b
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
   100
        // the true if branch in m0 does a join between the type of o of speculative type constant from final field b and exact klass Object[]
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
   101
        for (int i = 0; i < 20000; i++) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
   102
            m3(c, true, false, (i%2) == 0);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
   103
        }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
   104
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
   105
        System.out.println("TEST PASSED");
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
   106
    }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
   107
}