test/compiler/types/TestMeetTopArrayExactConstantArray.java

Wed, 21 May 2014 10:56:41 -0700

author
katleman
date
Wed, 21 May 2014 10:56:41 -0700
changeset 6672
fb9d124d9192
parent 6384
8f28240318a2
child 6876
710a3c8b516e
permissions
-rw-r--r--

Added tag jdk8u20-b15 for changeset 8c785f9bde6f

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

mercurial