test/compiler/6837094/Test.java

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

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

Added tag jdk8u20-b15 for changeset 8c785f9bde6f

kvn@1255 1 /*
never@1287 2 * Copyright 2009 Google Inc. All Rights Reserved.
kvn@1255 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
kvn@1255 4 *
kvn@1255 5 * This code is free software; you can redistribute it and/or modify it
kvn@1255 6 * under the terms of the GNU General Public License version 2 only, as
kvn@1255 7 * published by the Free Software Foundation.
kvn@1255 8 *
kvn@1255 9 * This code is distributed in the hope that it will be useful, but WITHOUT
kvn@1255 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
kvn@1255 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kvn@1255 12 * version 2 for more details (a copy is included in the LICENSE file that
kvn@1255 13 * accompanied this code).
kvn@1255 14 *
kvn@1255 15 * You should have received a copy of the GNU General Public License version
kvn@1255 16 * 2 along with this work; if not, write to the Free Software Foundation,
kvn@1255 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
kvn@1255 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
kvn@1255 22 *
kvn@1255 23 */
kvn@1255 24
kvn@1255 25 /**
kvn@1255 26 * @test
kvn@1255 27 * @bug 6837094
kvn@1255 28 * @summary False positive for "meet not symmetric" failure
kvn@1255 29 *
kvn@1255 30 * @run main/othervm -Xbatch -XX:CompileOnly=Test.collectIs,Test$Factory$1.getArray,Test$Factory$2.getArray Test
kvn@1255 31 */
kvn@1255 32
kvn@1255 33 import java.util.Set;
kvn@1255 34 import java.util.HashSet;
kvn@1255 35
kvn@1255 36 public class Test {
kvn@1255 37
kvn@1255 38 private interface Factory<M extends Interface> {
kvn@1255 39 Factory<Child0> Zero = new Factory<Child0>() {
kvn@1255 40 public Child0[] getArray() { return new Child0[1]; }
kvn@1255 41 };
kvn@1255 42
kvn@1255 43 Factory<Child1> One = new Factory<Child1>() {
kvn@1255 44 public Child1[] getArray() { return new Child1[1]; }
kvn@1255 45 };
kvn@1255 46
kvn@1255 47 M[] getArray();
kvn@1255 48 }
kvn@1255 49
kvn@1255 50 /**
kvn@1255 51 * C2 asserts when compiling this method. Bimorphic inlining happens at
kvn@1255 52 * getArray call site. A Phi in the catch block tries to join the meet type
kvn@1255 53 * from he inline site (Parent[]) with the type expected by CI (Interface[]).
kvn@1255 54 *
kvn@1255 55 * C2 throws an assert when it doesn't need to.
kvn@1255 56 */
kvn@1255 57 private static <I extends Interface> void collectIs(
kvn@1255 58 Factory<I> factory, Set<Interface> s) {
kvn@1255 59 for (I i : factory.getArray()) {
kvn@1255 60 try {
kvn@1255 61 s.add(i);
kvn@1255 62 } catch (Exception e) {
kvn@1255 63 }
kvn@1255 64 }
kvn@1255 65 }
kvn@1255 66
kvn@1255 67 static public void main(String argv[]) {
kvn@1255 68 Set<Interface> s = new HashSet();
kvn@1255 69
kvn@1255 70 for (int i = 0; i < 25000; i++) {
kvn@1255 71 collectIs(Factory.Zero, s);
kvn@1255 72 collectIs(Factory.One, s);
kvn@1255 73 }
kvn@1255 74 }
kvn@1255 75 }
kvn@1255 76
kvn@1255 77 /**
kvn@1255 78 * Establish necessary class hierarchy
kvn@1255 79 */
kvn@1255 80
kvn@1255 81 interface Interface {
kvn@1255 82 }
kvn@1255 83
kvn@1255 84 class Parent {
kvn@1255 85 }
kvn@1255 86
kvn@1255 87 class Child0 extends Parent implements Interface {
kvn@1255 88 }
kvn@1255 89
kvn@1255 90 class Child1 extends Parent implements Interface {
kvn@1255 91 }
kvn@1255 92
kvn@1255 93 class Child2 extends Parent implements Interface {
kvn@1255 94 }

mercurial