hotspot/test/compiler/types/TestMeetTopArrayExactConstantArray.java
author lana
Thu, 23 Feb 2017 17:30:12 +0000
changeset 44011 5eea3031ae7b
parent 40059 c2304140ed64
permissions -rw-r--r--
Merge
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
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    28
 *
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23208
diff changeset
    29
 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseOnStackReplacement
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23208
diff changeset
    30
 *                   -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23208
diff changeset
    31
 *                   -XX:-BackgroundCompilation
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23208
diff changeset
    32
 *                   compiler.types.TestMeetTopArrayExactConstantArray
22239
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    33
 */
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    34
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23208
diff changeset
    35
package compiler.types;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 23208
diff changeset
    36
22239
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    37
public class TestMeetTopArrayExactConstantArray {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    38
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    39
    static class A {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    40
    }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    41
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    42
    static class B {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    43
    }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    44
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    45
    static class C extends A {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    46
    }
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 class D extends C {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    49
    }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    50
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    51
    final static B[] b = new B[10];
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 m0(Object[] o) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    54
        if (o.getClass() ==  Object[].class) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    55
        }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    56
    }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    57
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    58
    static void m1(Object[] o, boolean cond) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    59
        if (cond) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    60
            o = b;
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    61
        }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    62
        m0(o);
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
    static void m2(Object[] o, boolean cond1, boolean cond2) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    66
        if (cond1) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    67
            m1(o, cond2);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    68
        }
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
    static void m3(C[] o, boolean cond1, boolean cond2, boolean cond3) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    72
        if (cond1) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    73
            m2(o, cond2, cond3);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    74
        }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    75
    }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    76
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    77
    static public void main(String[] args) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    78
        A[] a = new A[10];
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    79
        D[] d = new D[10];
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    80
        Object[] o = new Object[10];
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    81
        for (int i = 0; i < 5000; i++) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    82
            // record in profiling that the if in m0 succeeds
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    83
            m0(o);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    84
            // record some profiling for m2 and m1
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    85
            m2(a, true, (i%2) == 0);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    86
            // record some profiling for m3 and conflicting profile for m2
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    87
            m3(d, true, false, (i%2) == 0);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    88
        }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    89
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    90
        // 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
    91
        C[] c = new C[10];
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    92
        for (int i = 0; i < 20000; i++) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    93
            m3(c, true, false, (i%2) == 0);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    94
        }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    95
        // make m3 not entrant and the if in m0 fail
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    96
        m3(c, true, true, false);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    97
        m3(c, true, true, false);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    98
        m3(c, true, true, false);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
    99
        m3(c, true, true, false);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
   100
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
   101
        // make m3 recompile, this time with if the not optimized
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
   102
        // on entry to m3, argument o is of type C[], profiled C[]
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
   103
        // 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
   104
        // 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
   105
        // 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
   106
        for (int i = 0; i < 20000; i++) {
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
   107
            m3(c, true, false, (i%2) == 0);
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
   108
        }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
   109
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
   110
        System.out.println("TEST PASSED");
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
   111
    }
a7ea670834f4 8027571: fatal error: meet not symmetric
roland
parents:
diff changeset
   112
}