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