author | jiangli |
Fri, 02 Nov 2018 19:30:31 -0400 | |
changeset 52397 | 1322829d1501 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
10005 | 1 |
/* |
24340
30d481fc4e30
8042214: add @ignore tag to all excluded jtreg tests in test/compiler
iignatyev
parents:
10030
diff
changeset
|
2 |
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. |
10005 | 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 |
* @test |
|
26 |
* @bug 7052494 |
|
27 |
* @summary Eclipse test fails on JDK 7 b142 |
|
28 |
* |
|
40059 | 29 |
* @run main/othervm -Xbatch compiler.loopopts.Test7052494 |
10005 | 30 |
*/ |
31 |
||
40059 | 32 |
package compiler.loopopts; |
10005 | 33 |
|
34 |
public class Test7052494 { |
|
35 |
||
40059 | 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; |
|
10005 | 44 |
} |
45 |
||
40059 | 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; |
|
10005 | 54 |
} |
55 |
||
40059 | 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 |
} |
|
10005 | 62 |
} |
63 |
||
40059 | 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 |
} |
|
10005 | 70 |
} |
71 |
||
40059 | 72 |
// Empty loop rolls through MAXINT if i > 0 |
10030
5f7e29996174
7067288: compiler regression test Test7052494 timeouts with client VM
kvn
parents:
10005
diff
changeset
|
73 |
|
40059 | 74 |
static final int limit5 = Integer.MIN_VALUE + 10000; |
10030
5f7e29996174
7067288: compiler regression test Test7052494 timeouts with client VM
kvn
parents:
10005
diff
changeset
|
75 |
|
40059 | 76 |
static int test5(int i) { |
77 |
int result = 0; |
|
78 |
while (i++ != limit5) { |
|
79 |
result = i * 2; |
|
80 |
} |
|
81 |
return result; |
|
10005 | 82 |
} |
83 |
||
40059 | 84 |
// Empty loop rolls through MININT if i < 0 |
10030
5f7e29996174
7067288: compiler regression test Test7052494 timeouts with client VM
kvn
parents:
10005
diff
changeset
|
85 |
|
40059 | 86 |
static final int limit6 = Integer.MAX_VALUE - 10000; |
10030
5f7e29996174
7067288: compiler regression test Test7052494 timeouts with client VM
kvn
parents:
10005
diff
changeset
|
87 |
|
40059 | 88 |
static int test6(int i) { |
89 |
int result = 0; |
|
90 |
while (i-- != limit6) { |
|
91 |
result = i * 2; |
|
92 |
} |
|
93 |
return result; |
|
10005 | 94 |
} |
95 |
||
40059 | 96 |
public static void main(String[] args) { |
97 |
boolean failed = false; |
|
98 |
int[] arr = new int[8]; |
|
99 |
int[] ar3 = {0, 0, 4, 6, 8, 10, 0, 0}; |
|
100 |
int[] ar4 = {0, 0, 0, -10, -8, -6, -4, 0}; |
|
101 |
System.out.println("test1"); |
|
102 |
for (int i = 0; i < 11000; i++) { |
|
103 |
int k = test1(1, 10); |
|
104 |
if (k != 10) { |
|
105 |
System.out.println("FAILED: " + k + " != 10"); |
|
106 |
failed = true; |
|
107 |
break; |
|
108 |
} |
|
109 |
} |
|
110 |
System.out.println("test2"); |
|
111 |
for (int i = 0; i < 11000; i++) { |
|
112 |
int k = test2(-1, -10); |
|
113 |
if (k != -10) { |
|
114 |
System.out.println("FAILED: " + k + " != -10"); |
|
115 |
failed = true; |
|
116 |
break; |
|
117 |
} |
|
118 |
} |
|
119 |
System.out.println("test3"); |
|
120 |
for (int i = 0; i < 11000; i++) { |
|
121 |
java.util.Arrays.fill(arr, 0); |
|
122 |
test3(1, 10, arr); |
|
123 |
if (!java.util.Arrays.equals(arr, ar3)) { |
|
124 |
System.out.println("FAILED: arr = { " + arr[0] + ", " |
|
125 |
+ arr[1] + ", " |
|
126 |
+ arr[2] + ", " |
|
127 |
+ arr[3] + ", " |
|
128 |
+ arr[4] + ", " |
|
129 |
+ arr[5] + ", " |
|
130 |
+ arr[6] + ", " |
|
131 |
+ arr[7] + " }"); |
|
132 |
failed = true; |
|
133 |
break; |
|
134 |
} |
|
135 |
} |
|
136 |
System.out.println("test4"); |
|
137 |
for (int i = 0; i < 11000; i++) { |
|
138 |
java.util.Arrays.fill(arr, 0); |
|
139 |
test4(-1, -10, arr); |
|
140 |
if (!java.util.Arrays.equals(arr, ar4)) { |
|
141 |
System.out.println("FAILED: arr = { " + arr[0] + ", " |
|
142 |
+ arr[1] + ", " |
|
143 |
+ arr[2] + ", " |
|
144 |
+ arr[3] + ", " |
|
145 |
+ arr[4] + ", " |
|
146 |
+ arr[5] + ", " |
|
147 |
+ arr[6] + ", " |
|
148 |
+ arr[7] + " }"); |
|
149 |
failed = true; |
|
150 |
break; |
|
151 |
} |
|
152 |
} |
|
153 |
System.out.println("test5"); |
|
154 |
for (int i = 0; i < 11000; i++) { |
|
155 |
int k = test5(limit6); |
|
156 |
if (k != limit5 * 2) { |
|
157 |
System.out.println("FAILED: " + k + " != " + limit5 * 2); |
|
158 |
failed = true; |
|
159 |
break; |
|
160 |
} |
|
161 |
} |
|
162 |
System.out.println("test6"); |
|
163 |
for (int i = 0; i < 11000; i++) { |
|
164 |
int k = test6(limit5); |
|
165 |
if (k != limit6 * 2) { |
|
166 |
System.out.println("FAILED: " + k + " != " + limit6 * 2); |
|
167 |
failed = true; |
|
168 |
break; |
|
169 |
} |
|
170 |
} |
|
171 |
System.out.println("finish"); |
|
172 |
if (failed) { |
|
173 |
System.exit(97); |
|
174 |
} |
|
10005 | 175 |
} |
176 |
} |