Mercurial > hg > graal-compiler
annotate test/compiler/rangechecks/TestRangeCheckSmearing.java @ 21472:c190ed6b84bf
added checkcopyrights command (from mxtool2)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 22 May 2015 23:11:17 +0200 |
parents | e3d0aaab84aa |
children |
rev | line source |
---|---|
20707
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
1 /* |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
4 * |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
8 * |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
13 * accompanied this code). |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
14 * |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
18 * |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
21 * questions. |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
22 */ |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
23 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
24 /* |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
25 * @test |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
26 * @bug 8066103 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
27 * @summary C2's range check smearing allows out of bound array accesses |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
28 * @library /testlibrary /testlibrary/whitebox /compiler/whitebox /testlibrary/com/oracle/java/testlibrary |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
29 * @build TestRangeCheckSmearing |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
30 * @run main ClassFileInstaller sun.hotspot.WhiteBox |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
31 * @run main ClassFileInstaller com.oracle.java.testlibrary.Platform |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
32 * @run main/othervm -ea -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
33 * -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestRangeCheckSmearing |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
34 * |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
35 */ |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
36 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
37 import java.lang.annotation.*; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
38 import java.lang.reflect.*; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
39 import java.util.*; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
40 import sun.hotspot.WhiteBox; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
41 import sun.hotspot.code.NMethod; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
42 import com.oracle.java.testlibrary.Platform; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
43 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
44 public class TestRangeCheckSmearing { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
45 private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
46 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
47 @Retention(RetentionPolicy.RUNTIME) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
48 @interface Args { int[] value(); } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
49 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
50 // first range check is i + max of all constants |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
51 @Args({0, 8}) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
52 static int m1(int[] array, int i, boolean allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
53 int res = 0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
54 res += array[i+9]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
55 if (allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
56 res += array[i+8]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
57 res += array[i+7]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
58 res += array[i+6]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
59 res += array[i+5]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
60 res += array[i+4]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
61 res += array[i+3]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
62 res += array[i+2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
63 res += array[i+1]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
64 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
65 return res; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
66 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
67 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
68 // first range check is i + min of all constants |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
69 @Args({0, -9}) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
70 static int m2(int[] array, int i, boolean allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
71 int res = 0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
72 res += array[i+1]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
73 if (allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
74 res += array[i+2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
75 res += array[i+3]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
76 res += array[i+4]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
77 res += array[i+5]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
78 res += array[i+6]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
79 res += array[i+7]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
80 res += array[i+8]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
81 res += array[i+9]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
82 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
83 return res; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
84 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
85 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
86 // first range check is not i + min/max of all constants |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
87 @Args({0, 8}) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
88 static int m3(int[] array, int i, boolean allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
89 int res = 0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
90 res += array[i+3]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
91 if (allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
92 res += array[i+2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
93 res += array[i+1]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
94 res += array[i+4]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
95 res += array[i+5]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
96 res += array[i+6]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
97 res += array[i+7]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
98 res += array[i+8]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
99 res += array[i+9]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
100 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
101 return res; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
102 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
103 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
104 @Args({0, -9}) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
105 static int m4(int[] array, int i, boolean allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
106 int res = 0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
107 res += array[i+3]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
108 if (allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
109 res += array[i+4]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
110 res += array[i+1]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
111 res += array[i+2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
112 res += array[i+5]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
113 res += array[i+6]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
114 res += array[i+7]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
115 res += array[i+8]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
116 res += array[i+9]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
117 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
118 return res; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
119 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
120 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
121 @Args({0, -3}) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
122 static int m5(int[] array, int i, boolean allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
123 int res = 0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
124 res += array[i+3]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
125 res += array[i+2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
126 if (allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
127 res += array[i+1]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
128 res += array[i+4]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
129 res += array[i+5]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
130 res += array[i+6]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
131 res += array[i+7]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
132 res += array[i+8]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
133 res += array[i+9]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
134 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
135 return res; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
136 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
137 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
138 @Args({0, 6}) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
139 static int m6(int[] array, int i, boolean allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
140 int res = 0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
141 res += array[i+3]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
142 res += array[i+4]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
143 if (allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
144 res += array[i+2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
145 res += array[i+1]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
146 res += array[i+5]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
147 res += array[i+6]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
148 res += array[i+7]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
149 res += array[i+8]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
150 res += array[i+9]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
151 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
152 return res; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
153 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
154 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
155 @Args({0, 6}) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
156 static int m7(int[] array, int i, boolean allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
157 int res = 0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
158 res += array[i+3]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
159 res += array[i+2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
160 res += array[i+4]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
161 if (allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
162 res += array[i+1]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
163 res += array[i+5]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
164 res += array[i+6]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
165 res += array[i+7]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
166 res += array[i+8]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
167 res += array[i+9]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
168 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
169 return res; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
170 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
171 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
172 @Args({0, -3}) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
173 static int m8(int[] array, int i, boolean allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
174 int res = 0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
175 res += array[i+3]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
176 res += array[i+4]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
177 res += array[i+2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
178 if (allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
179 res += array[i+1]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
180 res += array[i+5]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
181 res += array[i+6]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
182 res += array[i+7]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
183 res += array[i+8]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
184 res += array[i+9]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
185 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
186 return res; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
187 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
188 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
189 @Args({6, 15}) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
190 static int m9(int[] array, int i, boolean allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
191 int res = 0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
192 res += array[i+3]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
193 if (allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
194 res += array[i-2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
195 res += array[i-1]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
196 res += array[i-4]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
197 res += array[i-5]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
198 res += array[i-6]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
199 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
200 return res; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
201 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
202 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
203 @Args({3, 12}) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
204 static int m10(int[] array, int i, boolean allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
205 int res = 0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
206 res += array[i+3]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
207 if (allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
208 res += array[i-2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
209 res += array[i-1]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
210 res += array[i-3]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
211 res += array[i+4]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
212 res += array[i+5]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
213 res += array[i+6]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
214 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
215 return res; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
216 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
217 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
218 @Args({3, -3}) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
219 static int m11(int[] array, int i, boolean allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
220 int res = 0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
221 res += array[i+3]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
222 res += array[i-2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
223 if (allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
224 res += array[i+5]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
225 res += array[i+6]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
226 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
227 return res; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
228 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
229 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
230 @Args({3, 6}) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
231 static int m12(int[] array, int i, boolean allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
232 int res = 0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
233 res += array[i+3]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
234 res += array[i+6]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
235 if (allaccesses) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
236 res += array[i-2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
237 res += array[i-3]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
238 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
239 return res; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
240 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
241 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
242 // check that identical range check is replaced by dominating one |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
243 // only when correct |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
244 @Args({0}) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
245 static int m13(int[] array, int i, boolean ignore) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
246 int res = 0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
247 res += array[i+3]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
248 res += array[i+3]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
249 return res; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
250 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
251 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
252 @Args({2, 0}) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
253 static int m14(int[] array, int i, boolean ignore) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
254 int res = 0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
255 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
256 res += array[i]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
257 res += array[i-2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
258 res += array[i]; // If range check below were to be removed first this cannot be considered identical to first range check |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
259 res += array[i-1]; // range check removed so i-1 array access depends on previous check |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
260 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
261 return res; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
262 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
263 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
264 static int[] m15_dummy = new int[10]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
265 @Args({2, 0}) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
266 static int m15(int[] array, int i, boolean ignore) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
267 int res = 0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
268 res += array[i]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
269 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
270 // When the loop is optimized out we don't want the |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
271 // array[i-1] access which is dependent on array[i]'s |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
272 // range check to become dependent on the identical range |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
273 // check above. |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
274 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
275 int[] array2 = m15_dummy; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
276 int j = 0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
277 for (; j < 10; j++); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
278 if (j == 10) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
279 array2 = array; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
280 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
281 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
282 res += array2[i-2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
283 res += array2[i]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
284 res += array2[i-1]; // range check removed so i-1 array access depends on previous check |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
285 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
286 return res; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
287 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
288 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
289 @Args({2, 0}) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
290 static int m16(int[] array, int i, boolean ignore) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
291 int res = 0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
292 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
293 res += array[i]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
294 res += array[i-1]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
295 res += array[i-1]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
296 res += array[i-2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
297 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
298 return res; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
299 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
300 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
301 @Args({2, 0}) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
302 static int m17(int[] array, int i, boolean ignore) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
303 int res = 0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
304 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
305 res += array[i]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
306 res += array[i-2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
307 res += array[i-2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
308 res += array[i+2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
309 res += array[i+2]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
310 res += array[i-1]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
311 res += array[i-1]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
312 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
313 return res; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
314 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
315 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
316 static public void main(String[] args) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
317 if (WHITE_BOX.getBooleanVMFlag("BackgroundCompilation")) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
318 throw new AssertionError("Background compilation enabled"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
319 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
320 new TestRangeCheckSmearing().doTests(); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
321 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
322 boolean success = true; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
323 boolean exception = false; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
324 final int[] array = new int[10]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
325 final HashMap<String,Method> tests = new HashMap<>(); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
326 { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
327 final Class<?> TEST_PARAM_TYPES[] = { int[].class, int.class, boolean.class }; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
328 for (Method m : this.getClass().getDeclaredMethods()) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
329 if (m.getName().matches("m[0-9]+")) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
330 assert(Modifier.isStatic(m.getModifiers())) : m; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
331 assert(m.getReturnType() == int.class) : m; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
332 assert(Arrays.equals(m.getParameterTypes(), TEST_PARAM_TYPES)) : m; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
333 tests.put(m.getName(), m); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
334 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
335 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
336 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
337 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
338 void invokeTest(Method m, int[] array, int index, boolean z) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
339 try { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
340 m.invoke(null, array, index, z); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
341 } catch (ReflectiveOperationException roe) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
342 Throwable ex = roe.getCause(); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
343 if (ex instanceof ArrayIndexOutOfBoundsException) |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
344 throw (ArrayIndexOutOfBoundsException) ex; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
345 throw new AssertionError(roe); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
346 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
347 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
348 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
349 void doTest(String name) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
350 Method m = tests.get(name); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
351 tests.remove(name); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
352 int[] args = m.getAnnotation(Args.class).value(); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
353 int index0 = args[0], index1; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
354 boolean exceptionRequired = true; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
355 if (args.length == 2) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
356 index1 = args[1]; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
357 } else { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
358 // no negative test for this one |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
359 assert(args.length == 1); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
360 assert(name.equals("m13")); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
361 exceptionRequired = false; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
362 index1 = index0; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
363 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
364 // Get the method compiled. |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
365 if (!WHITE_BOX.isMethodCompiled(m)) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
366 // If not, try to compile it with C2 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
367 if(!WHITE_BOX.enqueueMethodForCompilation(m, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION)) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
368 // C2 compiler not available, try to compile with C1 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
369 WHITE_BOX.enqueueMethodForCompilation(m, CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
370 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
371 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
372 if (!WHITE_BOX.isMethodCompiled(m)) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
373 throw new RuntimeException(m + " not compiled"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
374 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
375 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
376 // valid access |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
377 invokeTest(m, array, index0, true); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
378 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
379 if (!WHITE_BOX.isMethodCompiled(m)) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
380 throw new RuntimeException(m + " deoptimized on valid array access"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
381 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
382 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
383 exception = false; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
384 boolean test_success = true; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
385 try { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
386 invokeTest(m, array, index1, false); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
387 } catch(ArrayIndexOutOfBoundsException aioob) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
388 exception = true; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
389 System.out.println("ArrayIndexOutOfBoundsException thrown in "+name); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
390 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
391 if (!exception) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
392 System.out.println("ArrayIndexOutOfBoundsException was not thrown in "+name); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
393 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
394 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
395 if (Platform.isServer()) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
396 if (exceptionRequired == WHITE_BOX.isMethodCompiled(m)) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
397 System.out.println((exceptionRequired?"Didn't deoptimized":"deoptimized") + " in "+name); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
398 test_success = false; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
399 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
400 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
401 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
402 if (exception != exceptionRequired) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
403 System.out.println((exceptionRequired?"exception required but not thrown":"not exception required but thrown") + " in "+name); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
404 test_success = false; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
405 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
406 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
407 if (!test_success) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
408 success = false; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
409 System.out.println("TEST FAILED: "+name); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
410 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
411 |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
412 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
413 void doTests() { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
414 doTest("m1"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
415 doTest("m2"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
416 doTest("m3"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
417 doTest("m4"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
418 doTest("m5"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
419 doTest("m6"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
420 doTest("m7"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
421 doTest("m8"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
422 doTest("m9"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
423 doTest("m10"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
424 doTest("m11"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
425 doTest("m12"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
426 doTest("m13"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
427 doTest("m14"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
428 doTest("m15"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
429 doTest("m16"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
430 doTest("m17"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
431 if (!success) { |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
432 throw new RuntimeException("Some tests failed"); |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
433 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
434 assert(tests.isEmpty()) : tests; |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
435 } |
e3d0aaab84aa
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
436 } |