Mercurial > hg > graal-compiler
comparison test/compiler/7052494/Test7052494.java @ 3456:782e2bb60c41
7052494: Eclipse test fails on JDK 7 b142
Summary: Keep 'ne' test in Counted loop when we can't guarantee during compilation that init < limit.
Reviewed-by: never
author | kvn |
---|---|
date | Mon, 20 Jun 2011 16:45:35 -0700 |
parents | |
children | 3fbb609d9e96 |
comparison
equal
deleted
inserted
replaced
3455:49d1ee0f1f0c | 3456:782e2bb60c41 |
---|---|
1 /* | |
2 * Copyright (c) 2011, 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 7052494 | |
28 * @summary Eclipse test fails on JDK 7 b142 | |
29 * | |
30 * @run main/othervm -Xbatch Test7052494 | |
31 */ | |
32 | |
33 | |
34 public class Test7052494 { | |
35 | |
36 static int test1(int i, int limit) { | |
37 int result = 0; | |
38 while (i++ != 0) { | |
39 if (result >= limit) | |
40 break; | |
41 result = i*2; | |
42 } | |
43 return result; | |
44 } | |
45 | |
46 static int test2(int i, int limit) { | |
47 int result = 0; | |
48 while (i-- != 0) { | |
49 if (result <= limit) | |
50 break; | |
51 result = i*2; | |
52 } | |
53 return result; | |
54 } | |
55 | |
56 static void test3(int i, int limit, int arr[]) { | |
57 while (i++ != 0) { | |
58 if (arr[i-1] >= limit) | |
59 break; | |
60 arr[i] = i*2; | |
61 } | |
62 } | |
63 | |
64 static void test4(int i, int limit, int arr[]) { | |
65 while (i-- != 0) { | |
66 if (arr[arr.length + i + 1] <= limit) | |
67 break; | |
68 arr[arr.length + i] = i*2; | |
69 } | |
70 } | |
71 | |
72 // Empty loop rolls through MAXINT if i > 0 | |
73 static int test5(int i) { | |
74 int result = 0; | |
75 while (i++ != 0) { | |
76 result = i*2; | |
77 } | |
78 return result; | |
79 } | |
80 | |
81 // Empty loop rolls through MININT if i < 0 | |
82 static int test6(int i) { | |
83 int result = 0; | |
84 while (i-- != 0) { | |
85 result = i*2; | |
86 } | |
87 return result; | |
88 } | |
89 | |
90 public static void main(String [] args) { | |
91 boolean failed = false; | |
92 int[] arr = new int[8]; | |
93 int[] ar3 = { 0, 0, 4, 6, 8, 10, 0, 0 }; | |
94 int[] ar4 = { 0, 0, 0, -10, -8, -6, -4, 0 }; | |
95 for (int i = 0; i < 11000; i++) { | |
96 int k = test1(1, 10); | |
97 if (k != 10) { | |
98 System.out.println("FAILED: " + k + " != 10"); | |
99 failed = true; | |
100 break; | |
101 } | |
102 } | |
103 for (int i = 0; i < 11000; i++) { | |
104 int k = test2(-1, -10); | |
105 if (k != -10) { | |
106 System.out.println("FAILED: " + k + " != -10"); | |
107 failed = true; | |
108 break; | |
109 } | |
110 } | |
111 for (int i = 0; i < 11000; i++) { | |
112 java.util.Arrays.fill(arr, 0); | |
113 test3(1, 10, arr); | |
114 if (!java.util.Arrays.equals(arr,ar3)) { | |
115 System.out.println("FAILED: arr = { " + arr[0] + ", " | |
116 + arr[1] + ", " | |
117 + arr[2] + ", " | |
118 + arr[3] + ", " | |
119 + arr[4] + ", " | |
120 + arr[5] + ", " | |
121 + arr[6] + ", " | |
122 + arr[7] + " }"); | |
123 failed = true; | |
124 break; | |
125 } | |
126 } | |
127 for (int i = 0; i < 11000; i++) { | |
128 java.util.Arrays.fill(arr, 0); | |
129 test4(-1, -10, arr); | |
130 if (!java.util.Arrays.equals(arr,ar4)) { | |
131 System.out.println("FAILED: arr = { " + arr[0] + ", " | |
132 + arr[1] + ", " | |
133 + arr[2] + ", " | |
134 + arr[3] + ", " | |
135 + arr[4] + ", " | |
136 + arr[5] + ", " | |
137 + arr[6] + ", " | |
138 + arr[7] + " }"); | |
139 failed = true; | |
140 break; | |
141 } | |
142 } | |
143 for (int i = 0; i < 11000; i++) { | |
144 int k = test5(1); | |
145 if (k != 0) { | |
146 System.out.println("FAILED: " + k + " != 0"); | |
147 failed = true; | |
148 break; | |
149 } | |
150 } | |
151 for (int i = 0; i < 11000; i++) { | |
152 int k = test6(-1); | |
153 if (k != 0) { | |
154 System.out.println("FAILED: " + k + " != 0"); | |
155 failed = true; | |
156 break; | |
157 } | |
158 } | |
159 if (failed) | |
160 System.exit(97); | |
161 } | |
162 } |