author | thartmann |
Thu, 05 Sep 2019 13:56:17 +0200 | |
changeset 58019 | 86b95fc6ca32 |
permissions | -rw-r--r-- |
58019
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
1 |
/* |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
4 |
* |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
8 |
* |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
13 |
* accompanied this code). |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
14 |
* |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
18 |
* |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
21 |
* questions. |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
22 |
* |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
23 |
*/ |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
24 |
|
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
25 |
/* |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
26 |
* @test |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
27 |
* @bug 8229496 |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
28 |
* @summary Verify that zero check is executed before division/modulo operation. |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
29 |
* @run main/othervm -Xbatch -XX:LoopUnrollLimit=0 |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
30 |
* -XX:CompileCommand=dontinline,compiler.loopopts.TestDivZeroCheckControl::test* |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
31 |
* compiler.loopopts.TestDivZeroCheckControl |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
32 |
*/ |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
33 |
|
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
34 |
package compiler.loopopts; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
35 |
|
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
36 |
public class TestDivZeroCheckControl { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
37 |
|
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
38 |
public static int test1(int div, int array[]) { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
39 |
int res = 0; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
40 |
for (int i = 0; i < 256; i++) { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
41 |
int j = 0; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
42 |
do { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
43 |
array[i] = i; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
44 |
try { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
45 |
res = 1 % div; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
46 |
} catch (ArithmeticException ex) { } |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
47 |
} while (++j < 9); |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
48 |
} |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
49 |
return res; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
50 |
} |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
51 |
|
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
52 |
// Same as test1 but with division instead of modulo |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
53 |
public static int test2(int div, int array[]) { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
54 |
int res = 0; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
55 |
for (int i = 0; i < 256; i++) { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
56 |
int j = 0; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
57 |
do { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
58 |
array[i] = i; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
59 |
try { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
60 |
res = 1 / div; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
61 |
} catch (ArithmeticException ex) { } |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
62 |
} while (++j < 9); |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
63 |
} |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
64 |
return res; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
65 |
} |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
66 |
|
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
67 |
// Same as test1 but with long |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
68 |
public static long test3(long div, int array[]) { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
69 |
long res = 0; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
70 |
for (int i = 0; i < 256; i++) { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
71 |
int j = 0; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
72 |
do { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
73 |
array[i] = i; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
74 |
try { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
75 |
res = 1L % div; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
76 |
} catch (ArithmeticException ex) { } |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
77 |
} while (++j < 9); |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
78 |
} |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
79 |
return res; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
80 |
} |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
81 |
|
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
82 |
// Same as test2 but with long |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
83 |
public static long test4(long div, int array[]) { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
84 |
long res = 0; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
85 |
for (int i = 0; i < 256; i++) { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
86 |
int j = 0; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
87 |
do { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
88 |
array[i] = i; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
89 |
try { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
90 |
res = 1L / div; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
91 |
} catch (ArithmeticException ex) { } |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
92 |
} while (++j < 9); |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
93 |
} |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
94 |
return res; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
95 |
} |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
96 |
|
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
97 |
public static void main(String[] args) { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
98 |
int array[] = new int[256]; |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
99 |
for (int i = 0; i < 50_000; ++i) { |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
100 |
test1(0, array); |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
101 |
test2(0, array); |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
102 |
test3(0, array); |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
103 |
test4(0, array); |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
104 |
} |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
105 |
} |
86b95fc6ca32
8229496: SIGFPE (division by zero) in C2 OSR compiled method
thartmann
parents:
diff
changeset
|
106 |
} |