hotspot/test/compiler/8002069/Test8002069.java
author ccheung
Fri, 04 Oct 2013 21:00:43 -0700
changeset 20384 49bfb2ec8f8f
parent 14395 2395da512d6b
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14395
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
     1
/*
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
     4
 *
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
     8
 *
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    13
 * accompanied this code).
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    14
 *
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    18
 *
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    21
 * questions.
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    22
 *
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    23
 */
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    24
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    25
/**
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    26
 * @test
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    27
 * @bug 8002069
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    28
 * @summary Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    29
 *
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    30
 * @run main/othervm -Xmx32m -XX:+IgnoreUnrecognizedVMOptions -Xbatch -XX:CompileCommand=exclude,Test8002069.dummy Test8002069
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    31
 */
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    32
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    33
abstract class O {
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    34
  int f;
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    35
  public O() { f = 5; }
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    36
  abstract void put(int i);
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    37
  public int foo(int i) {
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    38
    put(i);
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    39
    return i;
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    40
  }
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    41
};
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    42
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    43
class A extends O {
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    44
  int[] a;
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    45
  public A(int s) {
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    46
    a = new int[s];
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    47
  }
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    48
  public void put(int i) {
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    49
    a[i%a.length] = i;
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    50
  }
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    51
}
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    52
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    53
class B extends O {
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    54
  int sz;
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    55
  int[] a;
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    56
  public B(int s) {
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    57
    sz = s;
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    58
    a = new int[s];
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    59
  }
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    60
  public void put(int i) {
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    61
    a[i%sz] = i;
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    62
  }
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    63
}
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    64
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    65
public class Test8002069 {
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    66
  public static void main(String args[]) {
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    67
    int sum = 0;
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    68
    for (int i=0; i<8000; i++) {
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    69
      sum += test1(i);
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    70
    }
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    71
    for (int i=0; i<100000; i++) {
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    72
      sum += test2(i);
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    73
    }
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    74
    System.out.println("PASSED. sum = " + sum);
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    75
  }
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    76
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    77
  private O o;
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    78
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    79
  private int foo(int i) {
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    80
    return o.foo(i);
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    81
  }
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    82
  static int test1(int i) {
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    83
    Test8002069 t = new Test8002069();
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    84
    t.o = new A(5);
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    85
    return t.foo(i);
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    86
  }
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    87
  static int test2(int i) {
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    88
    Test8002069 t = new Test8002069();
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    89
    t.o = new B(5);
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    90
    dummy(i);
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    91
    return t.foo(i);
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    92
  }
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    93
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    94
  static int dummy(int i) {
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    95
    return i*2;
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    96
  }
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    97
}
2395da512d6b 8002069: Assert failed in C2: assert(field->edge_count() > 0) failed: sanity
kvn
parents:
diff changeset
    98