Path: blob/master/test/hotspot/jtreg/compiler/c2/Test6837094.java
41149 views
/*1* Copyright 2009 Google Inc. All Rights Reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324/**25* @test26* @bug 683709427* @summary False positive for "meet not symmetric" failure28*29* @run main/othervm -Xbatch30* -XX:CompileCommand=compileonly,compiler.c2.Test6837094::collectIs31* -XX:CompileCommand=compileonly,compiler.c2.Test6837094$Factory$1::getArray32* -XX:CompileCommand=compileonly,compiler.c2.Test6837094$Factory$2::getArray33* compiler.c2.Test683709434*/3536package compiler.c2;3738import java.util.HashSet;39import java.util.Set;4041public class Test6837094 {4243private interface Factory<M extends Interface> {44Factory<Child0> Zero = new Factory<Child0>() {45public Child0[] getArray() { return new Child0[1]; }46};4748Factory<Child1> One = new Factory<Child1>() {49public Child1[] getArray() { return new Child1[1]; }50};5152M[] getArray();53}5455/**56* C2 asserts when compiling this method. Bimorphic inlining happens at57* getArray call site. A Phi in the catch block tries to join the meet type58* from he inline site (Parent[]) with the type expected by CI (Interface[]).59*60* C2 throws an assert when it doesn't need to.61*/62private static <I extends Interface> void collectIs(63Factory<I> factory, Set<Interface> s) {64for (I i : factory.getArray()) {65try {66s.add(i);67} catch (Exception e) {68}69}70}7172static public void main(String argv[]) {73Set<Interface> s = new HashSet();7475for (int i = 0; i < 25000; i++) {76collectIs(Factory.Zero, s);77collectIs(Factory.One, s);78}79}8081/**82* Establish necessary class hierarchy83*/8485static interface Interface {86}8788static class Parent {89}9091static class Child0 extends Parent implements Interface {92}9394static class Child1 extends Parent implements Interface {95}9697static class Child2 extends Parent implements Interface {98}99100}101102103104