author | weijun |
Wed, 12 Mar 2014 14:18:01 +0800 | |
changeset 23339 | d66b18f52418 |
parent 22911 | ff49c48c887d |
child 40059 | c2304140ed64 |
permissions | -rw-r--r-- |
21208
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
1 |
/* |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
4 |
* |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
8 |
* |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
13 |
* accompanied this code). |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
14 |
* |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
18 |
* |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
21 |
* questions. |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
22 |
*/ |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
23 |
|
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
24 |
/* |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
25 |
* @test |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
26 |
* @bug 8027444 |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
27 |
* @summary Test nested loops |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
28 |
* @compile NestedMathExactTest.java |
22911
ff49c48c887d
8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents:
21920
diff
changeset
|
29 |
* @run main NestedMathExactTest |
21208
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
30 |
* |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
31 |
*/ |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
32 |
|
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
33 |
public class NestedMathExactTest { |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
34 |
public static final int LIMIT = 100; |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
35 |
public static int[] result = new int[LIMIT]; |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
36 |
public static int value = 17; |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
37 |
|
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
38 |
public static void main(String[] args) { |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
39 |
for (int i = 0; i < 100; ++i) { |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
40 |
result[i] = runTest(); |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
41 |
} |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
42 |
} |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
43 |
|
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
44 |
public static int runTest() { |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
45 |
int sum = 0; |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
46 |
for (int j = 0; j < 100000; j = Math.addExact(j, 1)) { |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
47 |
sum = 1; |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
48 |
for (int i = 0; i < 5; ++i) { |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
49 |
sum *= value; |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
50 |
} |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
51 |
} |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
52 |
return sum; |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
53 |
} |
2ae445f57ac6
8027444: mathExact: assert(i < _max) failed: oob: i=1, _max=1
rbackman
parents:
diff
changeset
|
54 |
} |