comparison test/compiler/6843752/Test.java @ 788:1851e1fb420e

6843752: missing code for an anti-dependent Phi in GCM Summary: Don't place a load below anti-dependent PHI. Reviewed-by: never, twisti
author kvn
date Wed, 27 May 2009 12:35:51 -0700
parents
children c18cbe5936b8
comparison
equal deleted inserted replaced
787:aabd393cf1ee 788:1851e1fb420e
1 /*
2 * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24 /*
25 * @test
26 * @bug 6843752
27 * @summary missing code for an anti-dependent Phi in GCM
28 * @run main/othervm -Xbatch Test
29 */
30
31 public class Test {
32
33 Item list;
34
35 static class Item {
36 public Item next;
37 public Item prev;
38 public boolean remove;
39
40 Item(boolean r) { remove = r; }
41 }
42
43 private void linkIn(Item item) {
44 Item head = list;
45 if (head == null) {
46 item.next = item;
47 item.prev = item;
48 list = item;
49 } else {
50 item.next = head;
51 item.prev = head.prev;
52 head.prev.next = item;
53 head.prev = item;
54 }
55 }
56
57 private void linkOut(Item item) {
58 Item head = list;
59 if (item.next == item) {
60 list = null;
61 } else {
62 item.prev.next = item.next;
63 item.next.prev = item.prev;
64 if (head == item) {
65 list = item.next;
66 }
67 }
68 item.next = null;
69 item.prev = null; // this is the null pointer we are seeing
70 }
71
72 private void removeItems(int numItems) {
73 Item item = list;
74 if (item == null) {
75 return;
76 }
77 Item last = item.prev;
78 boolean done = false;
79 while (!done && numItems > 1) {
80 // the original code "done = (item == last);" triggered an infinite loop
81 // and was changed slightly in order to produce an exception instead.
82 done = (item.next == last.next);
83 item = item.next;
84 if (item.prev.remove) {
85 linkOut(item.prev);
86 }
87 }
88 }
89
90 public void perform(int numItems) {
91 for (int i = 0; i < numItems; i++) {
92 linkIn(new Item(i == 0));
93 }
94 removeItems(numItems);
95 list = null;
96 }
97
98 static public void main(String[] args) {
99 int caseCnt = 0;
100 Test bj = new Test();
101 try {
102 for (; caseCnt < 500000;) {
103 int numItems = (++caseCnt % 2);
104 if ((caseCnt % 64) == 0) {
105 numItems = 5;
106 }
107 bj.perform(numItems);
108 if ((caseCnt % 100000) == 0) {
109 System.out.println("successfully performed " + caseCnt + " cases");
110 }
111 }
112 } catch (Exception e) {
113 System.out.println("ERROR: crashed during case " + caseCnt);
114 e.printStackTrace(System.out);
115 System.exit(97);
116 }
117 }
118 }
119