hotspot/test/compiler/8002069/Test8002069.java
changeset 14395 2395da512d6b
equal deleted inserted replaced
14394:c76096a5d82b 14395:2395da512d6b
       
     1 /*
       
     2  * Copyright (c) 2012, 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  *
       
    23  */
       
    24 
       
    25 /**
       
    26  * @test
       
    27  * @bug 8002069
       
    28  * @summary Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
       
    29  *
       
    30  * @run main/othervm -Xmx32m -XX:+IgnoreUnrecognizedVMOptions -Xbatch -XX:CompileCommand=exclude,Test8002069.dummy Test8002069
       
    31  */
       
    32 
       
    33 abstract class O {
       
    34   int f;
       
    35   public O() { f = 5; }
       
    36   abstract void put(int i);
       
    37   public int foo(int i) {
       
    38     put(i);
       
    39     return i;
       
    40   }
       
    41 };
       
    42 
       
    43 class A extends O {
       
    44   int[] a;
       
    45   public A(int s) {
       
    46     a = new int[s];
       
    47   }
       
    48   public void put(int i) {
       
    49     a[i%a.length] = i;
       
    50   }
       
    51 }
       
    52 
       
    53 class B extends O {
       
    54   int sz;
       
    55   int[] a;
       
    56   public B(int s) {
       
    57     sz = s;
       
    58     a = new int[s];
       
    59   }
       
    60   public void put(int i) {
       
    61     a[i%sz] = i;
       
    62   }
       
    63 }
       
    64 
       
    65 public class Test8002069 {
       
    66   public static void main(String args[]) {
       
    67     int sum = 0;
       
    68     for (int i=0; i<8000; i++) {
       
    69       sum += test1(i);
       
    70     }
       
    71     for (int i=0; i<100000; i++) {
       
    72       sum += test2(i);
       
    73     }
       
    74     System.out.println("PASSED. sum = " + sum);
       
    75   }
       
    76 
       
    77   private O o;
       
    78 
       
    79   private int foo(int i) {
       
    80     return o.foo(i);
       
    81   }
       
    82   static int test1(int i) {
       
    83     Test8002069 t = new Test8002069();
       
    84     t.o = new A(5);
       
    85     return t.foo(i);
       
    86   }
       
    87   static int test2(int i) {
       
    88     Test8002069 t = new Test8002069();
       
    89     t.o = new B(5);
       
    90     dummy(i);
       
    91     return t.foo(i);
       
    92   }
       
    93 
       
    94   static int dummy(int i) {
       
    95     return i*2;
       
    96   }
       
    97 }
       
    98