annotate test/compiler/intrinsics/hashcode/TestHashCode.java @ 17968:dbf0d88d867d

8011646: SEGV in compiled code with loop predication Summary: Remove control edge of load node to ensure that castPP removal sets the control edge correctly Reviewed-by: kvn, roland
author anoll
date Fri, 30 May 2014 06:50:38 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17968
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
1 /*
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
4 *
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
7 * published by the Free Software Foundation.
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
8 *
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
13 * accompanied this code).
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
14 *
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
18 *
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
21 * questions.
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
22 */
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
23
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
24 /*
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
25 * @test
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
26 * @bug 8011646
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
27 * @summary SEGV in compiled code with loop predication
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
28 * @run main/othervm -XX:-TieredCompilation -XX:CompileOnly=TestHashCode.m1,Object.hashCode TestHashCode
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
29 *
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
30 */
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
31
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
32 public class TestHashCode {
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
33 static class A {
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
34 int i;
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
35 }
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
36
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
37 static class B extends A {
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
38 }
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
39
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
40 static boolean crash = false;
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
41
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
42 static A m2() {
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
43 if (crash) {
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
44 return null;
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
45 }
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
46 return new A();
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
47 }
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
48
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
49 static int m1(A aa) {
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
50 int res = 0;
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
51 for (int i = 0; i < 10; i++) {
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
52 A a = m2();
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
53 int j = a.i;
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
54 if (aa instanceof B) {
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
55 }
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
56 res += a.hashCode();
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
57 }
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
58 return res;
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
59 }
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
60
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
61 public static void main(String[] args) {
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
62 A a = new A();
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
63 for (int i = 0; i < 20000; i++) {
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
64 m1(a);
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
65 }
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
66 crash = true;
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
67 try {
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
68 m1(a);
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
69 } catch (NullPointerException e) {
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
70 System.out.println("Test passed");
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
71 }
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
72 }
dbf0d88d867d 8011646: SEGV in compiled code with loop predication
anoll
parents:
diff changeset
73 }