author | ctornqvi |
Sat, 20 Aug 2016 09:35:40 -0400 | |
changeset 40641 | 544f0108203f |
parent 40631 | ed82623d7831 |
permissions | -rw-r--r-- |
28044
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
1 |
/* |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40069
diff
changeset
|
2 |
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
28044
ede40159fd3b
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. |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
4 |
* |
ede40159fd3b
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 |
ede40159fd3b
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 |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
8 |
* |
ede40159fd3b
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 |
ede40159fd3b
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 |
ede40159fd3b
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 |
ede40159fd3b
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 |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
13 |
* accompanied this code). |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
14 |
* |
ede40159fd3b
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 |
ede40159fd3b
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, |
ede40159fd3b
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. |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
18 |
* |
ede40159fd3b
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 |
ede40159fd3b
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 |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
21 |
* questions. |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
22 |
*/ |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
23 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
24 |
/* |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
25 |
* @test |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
26 |
* @bug 8066103 |
ede40159fd3b
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 |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40069
diff
changeset
|
28 |
* @library /test/lib / |
36851 | 29 |
* @modules java.base/jdk.internal.misc |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28201
diff
changeset
|
30 |
* java.management |
40641
544f0108203f
8164521: compiler/rangechecks/TestRangeCheckSmearing.java is missing @build for sun.hotspot.WhiteBox
ctornqvi
parents:
40631
diff
changeset
|
31 |
* @build sun.hotspot.WhiteBox |
39438 | 32 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
28044
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
33 |
* @run main/othervm -ea -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
40059 | 34 |
* -XX:-BackgroundCompilation -XX:-UseOnStackReplacement |
35 |
* compiler.rangechecks.TestRangeCheckSmearing |
|
28044
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
36 |
* |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
37 |
*/ |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
38 |
|
40059 | 39 |
package compiler.rangechecks; |
40 |
||
41 |
import compiler.whitebox.CompilerWhiteBoxTest; |
|
40069
5ef5d8dd3d22
8157984: [TESTBUG] Several compiler tests fails when are executed with -XX:TieredStopAtLevel=1
dpochepk
parents:
40059
diff
changeset
|
42 |
import compiler.testlibrary.CompilerUtils; |
40059 | 43 |
import jdk.test.lib.Platform; |
28044
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
44 |
import sun.hotspot.WhiteBox; |
40059 | 45 |
|
46 |
import java.lang.annotation.Retention; |
|
47 |
import java.lang.annotation.RetentionPolicy; |
|
48 |
import java.lang.reflect.Method; |
|
49 |
import java.lang.reflect.Modifier; |
|
50 |
import java.util.Arrays; |
|
51 |
import java.util.HashMap; |
|
28044
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
52 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
53 |
public class TestRangeCheckSmearing { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
54 |
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
55 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
56 |
@Retention(RetentionPolicy.RUNTIME) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
57 |
@interface Args { int[] value(); } |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
58 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
59 |
// first range check is i + max of all constants |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
60 |
@Args({0, 8}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
61 |
static int m1(int[] array, int i, boolean allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
62 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
63 |
res += array[i+9]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
64 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
65 |
res += array[i+8]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
66 |
res += array[i+7]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
67 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
68 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
69 |
res += array[i+4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
70 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
71 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
72 |
res += array[i+1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
73 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
74 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
75 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
76 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
77 |
// first range check is i + min of all constants |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
78 |
@Args({0, -9}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
79 |
static int m2(int[] array, int i, boolean allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
80 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
81 |
res += array[i+1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
82 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
83 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
84 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
85 |
res += array[i+4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
86 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
87 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
88 |
res += array[i+7]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
89 |
res += array[i+8]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
90 |
res += array[i+9]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
91 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
92 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
93 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
94 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
95 |
// first range check is not i + min/max of all constants |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
96 |
@Args({0, 8}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
97 |
static int m3(int[] array, int i, boolean allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
98 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
99 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
100 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
101 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
102 |
res += array[i+1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
103 |
res += array[i+4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
104 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
105 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
106 |
res += array[i+7]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
107 |
res += array[i+8]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
108 |
res += array[i+9]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
109 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
110 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
111 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
112 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
113 |
@Args({0, -9}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
114 |
static int m4(int[] array, int i, boolean allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
115 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
116 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
117 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
118 |
res += array[i+4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
119 |
res += array[i+1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
120 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
121 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
122 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
123 |
res += array[i+7]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
124 |
res += array[i+8]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
125 |
res += array[i+9]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
126 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
127 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
128 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
129 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
130 |
@Args({0, -3}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
131 |
static int m5(int[] array, int i, boolean allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
132 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
133 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
134 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
135 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
136 |
res += array[i+1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
137 |
res += array[i+4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
138 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
139 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
140 |
res += array[i+7]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
141 |
res += array[i+8]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
142 |
res += array[i+9]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
143 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
144 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
145 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
146 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
147 |
@Args({0, 6}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
148 |
static int m6(int[] array, int i, boolean allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
149 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
150 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
151 |
res += array[i+4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
152 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
153 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
154 |
res += array[i+1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
155 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
156 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
157 |
res += array[i+7]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
158 |
res += array[i+8]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
159 |
res += array[i+9]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
160 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
161 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
162 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
163 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
164 |
@Args({0, 6}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
165 |
static int m7(int[] array, int i, boolean allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
166 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
167 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
168 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
169 |
res += array[i+4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
170 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
171 |
res += array[i+1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
172 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
173 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
174 |
res += array[i+7]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
175 |
res += array[i+8]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
176 |
res += array[i+9]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
177 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
178 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
179 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
180 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
181 |
@Args({0, -3}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
182 |
static int m8(int[] array, int i, boolean allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
183 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
184 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
185 |
res += array[i+4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
186 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
187 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
188 |
res += array[i+1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
189 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
190 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
191 |
res += array[i+7]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
192 |
res += array[i+8]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
193 |
res += array[i+9]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
194 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
195 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
196 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
197 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
198 |
@Args({6, 15}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
199 |
static int m9(int[] array, int i, boolean allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
200 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
201 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
202 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
203 |
res += array[i-2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
204 |
res += array[i-1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
205 |
res += array[i-4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
206 |
res += array[i-5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
207 |
res += array[i-6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
208 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
209 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
210 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
211 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
212 |
@Args({3, 12}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
213 |
static int m10(int[] array, int i, boolean allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
214 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
215 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
216 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
217 |
res += array[i-2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
218 |
res += array[i-1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
219 |
res += array[i-3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
220 |
res += array[i+4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
221 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
222 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
223 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
224 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
225 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
226 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
227 |
@Args({3, -3}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
228 |
static int m11(int[] array, int i, boolean allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
229 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
230 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
231 |
res += array[i-2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
232 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
233 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
234 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
235 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
236 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
237 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
238 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
239 |
@Args({3, 6}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
240 |
static int m12(int[] array, int i, boolean allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
241 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
242 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
243 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
244 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
245 |
res += array[i-2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
246 |
res += array[i-3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
247 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
248 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
249 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
250 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
251 |
// check that identical range check is replaced by dominating one |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
252 |
// only when correct |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
253 |
@Args({0}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
254 |
static int m13(int[] array, int i, boolean ignore) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
255 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
256 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
257 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
258 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
259 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
260 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
261 |
@Args({2, 0}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
262 |
static int m14(int[] array, int i, boolean ignore) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
263 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
264 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
265 |
res += array[i]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
266 |
res += array[i-2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
267 |
res += array[i]; // If range check below were to be removed first this cannot be considered identical to first range check |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
268 |
res += array[i-1]; // range check removed so i-1 array access depends on previous check |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
269 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
270 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
271 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
272 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
273 |
static int[] m15_dummy = new int[10]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
274 |
@Args({2, 0}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
275 |
static int m15(int[] array, int i, boolean ignore) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
276 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
277 |
res += array[i]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
278 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
279 |
// When the loop is optimized out we don't want the |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
280 |
// array[i-1] access which is dependent on array[i]'s |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
281 |
// range check to become dependent on the identical range |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
282 |
// check above. |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
283 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
284 |
int[] array2 = m15_dummy; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
285 |
int j = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
286 |
for (; j < 10; j++); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
287 |
if (j == 10) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
288 |
array2 = array; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
289 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
290 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
291 |
res += array2[i-2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
292 |
res += array2[i]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
293 |
res += array2[i-1]; // range check removed so i-1 array access depends on previous check |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
294 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
295 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
296 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
297 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
298 |
@Args({2, 0}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
299 |
static int m16(int[] array, int i, boolean ignore) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
300 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
301 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
302 |
res += array[i]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
303 |
res += array[i-1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
304 |
res += array[i-1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
305 |
res += array[i-2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
306 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
307 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
308 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
309 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
310 |
@Args({2, 0}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
311 |
static int m17(int[] array, int i, boolean ignore) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
312 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
313 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
314 |
res += array[i]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
315 |
res += array[i-2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
316 |
res += array[i-2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
317 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
318 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
319 |
res += array[i-1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
320 |
res += array[i-1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
321 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
322 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
323 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
324 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
325 |
static public void main(String[] args) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
326 |
if (WHITE_BOX.getBooleanVMFlag("BackgroundCompilation")) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
327 |
throw new AssertionError("Background compilation enabled"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
328 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
329 |
new TestRangeCheckSmearing().doTests(); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
330 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
331 |
boolean success = true; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
332 |
boolean exception = false; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
333 |
final int[] array = new int[10]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
334 |
final HashMap<String,Method> tests = new HashMap<>(); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
335 |
{ |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
336 |
final Class<?> TEST_PARAM_TYPES[] = { int[].class, int.class, boolean.class }; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
337 |
for (Method m : this.getClass().getDeclaredMethods()) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
338 |
if (m.getName().matches("m[0-9]+")) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
339 |
assert(Modifier.isStatic(m.getModifiers())) : m; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
340 |
assert(m.getReturnType() == int.class) : m; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
341 |
assert(Arrays.equals(m.getParameterTypes(), TEST_PARAM_TYPES)) : m; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
342 |
tests.put(m.getName(), m); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
343 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
344 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
345 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
346 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
347 |
void invokeTest(Method m, int[] array, int index, boolean z) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
348 |
try { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
349 |
m.invoke(null, array, index, z); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
350 |
} catch (ReflectiveOperationException roe) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
351 |
Throwable ex = roe.getCause(); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
352 |
if (ex instanceof ArrayIndexOutOfBoundsException) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
353 |
throw (ArrayIndexOutOfBoundsException) ex; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
354 |
throw new AssertionError(roe); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
355 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
356 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
357 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
358 |
void doTest(String name) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
359 |
Method m = tests.get(name); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
360 |
tests.remove(name); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
361 |
int[] args = m.getAnnotation(Args.class).value(); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
362 |
int index0 = args[0], index1; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
363 |
boolean exceptionRequired = true; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
364 |
if (args.length == 2) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
365 |
index1 = args[1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
366 |
} else { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
367 |
// no negative test for this one |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
368 |
assert(args.length == 1); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
369 |
assert(name.equals("m13")); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
370 |
exceptionRequired = false; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
371 |
index1 = index0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
372 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
373 |
// Get the method compiled. |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
374 |
if (!WHITE_BOX.isMethodCompiled(m)) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
375 |
// If not, try to compile it with C2 |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
376 |
if(!WHITE_BOX.enqueueMethodForCompilation(m, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION)) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
377 |
// C2 compiler not available, try to compile with C1 |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
378 |
WHITE_BOX.enqueueMethodForCompilation(m, CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
379 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
380 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
381 |
if (!WHITE_BOX.isMethodCompiled(m)) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
382 |
throw new RuntimeException(m + " not compiled"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
383 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
384 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
385 |
// valid access |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
386 |
invokeTest(m, array, index0, true); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
387 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
388 |
if (!WHITE_BOX.isMethodCompiled(m)) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
389 |
throw new RuntimeException(m + " deoptimized on valid array access"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
390 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
391 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
392 |
exception = false; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
393 |
boolean test_success = true; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
394 |
try { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
395 |
invokeTest(m, array, index1, false); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
396 |
} catch(ArrayIndexOutOfBoundsException aioob) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
397 |
exception = true; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
398 |
System.out.println("ArrayIndexOutOfBoundsException thrown in "+name); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
399 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
400 |
if (!exception) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
401 |
System.out.println("ArrayIndexOutOfBoundsException was not thrown in "+name); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
402 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
403 |
|
40069
5ef5d8dd3d22
8157984: [TESTBUG] Several compiler tests fails when are executed with -XX:TieredStopAtLevel=1
dpochepk
parents:
40059
diff
changeset
|
404 |
if (CompilerUtils.getMaxCompilationLevel() == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION) { |
28044
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
405 |
if (exceptionRequired == WHITE_BOX.isMethodCompiled(m)) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
406 |
System.out.println((exceptionRequired?"Didn't deoptimized":"deoptimized") + " in "+name); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
407 |
test_success = false; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
408 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
409 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
410 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
411 |
if (exception != exceptionRequired) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
412 |
System.out.println((exceptionRequired?"exception required but not thrown":"not exception required but thrown") + " in "+name); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
413 |
test_success = false; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
414 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
415 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
416 |
if (!test_success) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
417 |
success = false; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
418 |
System.out.println("TEST FAILED: "+name); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
419 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
420 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
421 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
422 |
void doTests() { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
423 |
doTest("m1"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
424 |
doTest("m2"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
425 |
doTest("m3"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
426 |
doTest("m4"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
427 |
doTest("m5"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
428 |
doTest("m6"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
429 |
doTest("m7"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
430 |
doTest("m8"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
431 |
doTest("m9"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
432 |
doTest("m10"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
433 |
doTest("m11"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
434 |
doTest("m12"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
435 |
doTest("m13"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
436 |
doTest("m14"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
437 |
doTest("m15"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
438 |
doTest("m16"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
439 |
doTest("m17"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
440 |
if (!success) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
441 |
throw new RuntimeException("Some tests failed"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
442 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
443 |
assert(tests.isEmpty()) : tests; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
444 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
445 |
} |