author | aeriksso |
Thu, 18 Feb 2016 16:15:28 +0100 | |
changeset 36353 | 28b633a6919d |
parent 34185 | ee71c590a456 |
child 36851 | 03e2f4d0a421 |
permissions | -rw-r--r-- |
28044
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
1 |
/* |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28201
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, 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 |
34185 | 28 |
* @library /testlibrary /test/lib /compiler/whitebox / |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28201
diff
changeset
|
29 |
* @modules java.base/sun.misc |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28201
diff
changeset
|
30 |
* java.management |
28044
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
31 |
* @build TestRangeCheckSmearing |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
32 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
33 |
* @run main ClassFileInstaller jdk.test.lib.Platform |
28044
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
34 |
* @run main/othervm -ea -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
35 |
* -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestRangeCheckSmearing |
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 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
39 |
import java.lang.annotation.*; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
40 |
import java.lang.reflect.*; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
41 |
import java.util.*; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
42 |
import sun.hotspot.WhiteBox; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
43 |
import sun.hotspot.code.NMethod; |
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
44 |
import jdk.test.lib.Platform; |
34155
8d9e0cbf93a2
8138689: use package for /compiler/whitebox common classes
dpochepk
parents:
30604
diff
changeset
|
45 |
import compiler.whitebox.CompilerWhiteBoxTest; |
28044
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
46 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
47 |
public class TestRangeCheckSmearing { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
48 |
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
|
49 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
50 |
@Retention(RetentionPolicy.RUNTIME) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
51 |
@interface Args { int[] value(); } |
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 |
// 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
|
54 |
@Args({0, 8}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
55 |
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
|
56 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
57 |
res += array[i+9]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
58 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
59 |
res += array[i+8]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
60 |
res += array[i+7]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
61 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
62 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
63 |
res += array[i+4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
64 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
65 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
66 |
res += array[i+1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
67 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
68 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
69 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
70 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
71 |
// 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
|
72 |
@Args({0, -9}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
73 |
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
|
74 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
75 |
res += array[i+1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
76 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
77 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
78 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
79 |
res += array[i+4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
80 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
81 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
82 |
res += array[i+7]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
83 |
res += array[i+8]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
84 |
res += array[i+9]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
85 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
86 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
87 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
88 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
89 |
// 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
|
90 |
@Args({0, 8}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
91 |
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
|
92 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
93 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
94 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
95 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
96 |
res += array[i+1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
97 |
res += array[i+4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
98 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
99 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
100 |
res += array[i+7]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
101 |
res += array[i+8]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
102 |
res += array[i+9]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
103 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
104 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
105 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
106 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
107 |
@Args({0, -9}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
108 |
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
|
109 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
110 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
111 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
112 |
res += array[i+4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
113 |
res += array[i+1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
114 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
115 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
116 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
117 |
res += array[i+7]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
118 |
res += array[i+8]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
119 |
res += array[i+9]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
120 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
121 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
122 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
123 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
124 |
@Args({0, -3}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
125 |
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
|
126 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
127 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
128 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
129 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
130 |
res += array[i+1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
131 |
res += array[i+4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
132 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
133 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
134 |
res += array[i+7]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
135 |
res += array[i+8]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
136 |
res += array[i+9]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
137 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
138 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
139 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
140 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
141 |
@Args({0, 6}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
142 |
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
|
143 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
144 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
145 |
res += array[i+4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
146 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
147 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
148 |
res += array[i+1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
149 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
150 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
151 |
res += array[i+7]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
152 |
res += array[i+8]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
153 |
res += array[i+9]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
154 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
155 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
156 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
157 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
158 |
@Args({0, 6}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
159 |
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
|
160 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
161 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
162 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
163 |
res += array[i+4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
164 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
165 |
res += array[i+1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
166 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
167 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
168 |
res += array[i+7]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
169 |
res += array[i+8]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
170 |
res += array[i+9]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
171 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
172 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
173 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
174 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
175 |
@Args({0, -3}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
176 |
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
|
177 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
178 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
179 |
res += array[i+4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
180 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
181 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
182 |
res += array[i+1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
183 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
184 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
185 |
res += array[i+7]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
186 |
res += array[i+8]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
187 |
res += array[i+9]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
188 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
189 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
190 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
191 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
192 |
@Args({6, 15}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
193 |
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
|
194 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
195 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
196 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
197 |
res += array[i-2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
198 |
res += array[i-1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
199 |
res += array[i-4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
200 |
res += array[i-5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
201 |
res += array[i-6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
202 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
203 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
204 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
205 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
206 |
@Args({3, 12}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
207 |
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
|
208 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
209 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
210 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
211 |
res += array[i-2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
212 |
res += array[i-1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
213 |
res += array[i-3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
214 |
res += array[i+4]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
215 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
216 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
217 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
218 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
219 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
220 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
221 |
@Args({3, -3}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
222 |
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
|
223 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
224 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
225 |
res += array[i-2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
226 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
227 |
res += array[i+5]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
228 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
229 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
230 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
231 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
232 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
233 |
@Args({3, 6}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
234 |
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
|
235 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
236 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
237 |
res += array[i+6]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
238 |
if (allaccesses) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
239 |
res += array[i-2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
240 |
res += array[i-3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
241 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
242 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
243 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
244 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
245 |
// 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
|
246 |
// only when correct |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
247 |
@Args({0}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
248 |
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
|
249 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
250 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
251 |
res += array[i+3]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
252 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
253 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
254 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
255 |
@Args({2, 0}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
256 |
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
|
257 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
258 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
259 |
res += array[i]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
260 |
res += array[i-2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
261 |
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
|
262 |
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
|
263 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
264 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
265 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
266 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
267 |
static int[] m15_dummy = new int[10]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
268 |
@Args({2, 0}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
269 |
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
|
270 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
271 |
res += array[i]; |
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 |
// 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
|
274 |
// 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
|
275 |
// 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
|
276 |
// check above. |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
277 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
278 |
int[] array2 = m15_dummy; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
279 |
int j = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
280 |
for (; j < 10; j++); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
281 |
if (j == 10) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
282 |
array2 = array; |
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 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
285 |
res += array2[i-2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
286 |
res += array2[i]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
287 |
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
|
288 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
289 |
return res; |
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 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
292 |
@Args({2, 0}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
293 |
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
|
294 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
295 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
296 |
res += array[i]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
297 |
res += array[i-1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
298 |
res += array[i-1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
299 |
res += array[i-2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
300 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
301 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
302 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
303 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
304 |
@Args({2, 0}) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
305 |
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
|
306 |
int res = 0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
307 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
308 |
res += array[i]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
309 |
res += array[i-2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
310 |
res += array[i-2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
311 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
312 |
res += array[i+2]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
313 |
res += array[i-1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
314 |
res += array[i-1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
315 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
316 |
return res; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
317 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
318 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
319 |
static public void main(String[] args) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
320 |
if (WHITE_BOX.getBooleanVMFlag("BackgroundCompilation")) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
321 |
throw new AssertionError("Background compilation enabled"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
322 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
323 |
new TestRangeCheckSmearing().doTests(); |
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 |
boolean success = true; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
326 |
boolean exception = false; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
327 |
final int[] array = new int[10]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
328 |
final HashMap<String,Method> tests = new HashMap<>(); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
329 |
{ |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
330 |
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
|
331 |
for (Method m : this.getClass().getDeclaredMethods()) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
332 |
if (m.getName().matches("m[0-9]+")) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
333 |
assert(Modifier.isStatic(m.getModifiers())) : m; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
334 |
assert(m.getReturnType() == int.class) : m; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
335 |
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
|
336 |
tests.put(m.getName(), m); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
337 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
338 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
339 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
340 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
341 |
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
|
342 |
try { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
343 |
m.invoke(null, array, index, z); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
344 |
} catch (ReflectiveOperationException roe) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
345 |
Throwable ex = roe.getCause(); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
346 |
if (ex instanceof ArrayIndexOutOfBoundsException) |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
347 |
throw (ArrayIndexOutOfBoundsException) ex; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
348 |
throw new AssertionError(roe); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
349 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
350 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
351 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
352 |
void doTest(String name) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
353 |
Method m = tests.get(name); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
354 |
tests.remove(name); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
355 |
int[] args = m.getAnnotation(Args.class).value(); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
356 |
int index0 = args[0], index1; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
357 |
boolean exceptionRequired = true; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
358 |
if (args.length == 2) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
359 |
index1 = args[1]; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
360 |
} else { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
361 |
// no negative test for this one |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
362 |
assert(args.length == 1); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
363 |
assert(name.equals("m13")); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
364 |
exceptionRequired = false; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
365 |
index1 = index0; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
366 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
367 |
// Get the method compiled. |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
368 |
if (!WHITE_BOX.isMethodCompiled(m)) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
369 |
// 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
|
370 |
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
|
371 |
// 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
|
372 |
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
|
373 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
374 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
375 |
if (!WHITE_BOX.isMethodCompiled(m)) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
376 |
throw new RuntimeException(m + " not compiled"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
377 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
378 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
379 |
// valid access |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
380 |
invokeTest(m, array, index0, true); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
381 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
382 |
if (!WHITE_BOX.isMethodCompiled(m)) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
383 |
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
|
384 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
385 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
386 |
exception = false; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
387 |
boolean test_success = true; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
388 |
try { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
389 |
invokeTest(m, array, index1, false); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
390 |
} catch(ArrayIndexOutOfBoundsException aioob) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
391 |
exception = true; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
392 |
System.out.println("ArrayIndexOutOfBoundsException thrown in "+name); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
393 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
394 |
if (!exception) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
395 |
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
|
396 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
397 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
398 |
if (Platform.isServer()) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
399 |
if (exceptionRequired == WHITE_BOX.isMethodCompiled(m)) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
400 |
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
|
401 |
test_success = false; |
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 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
404 |
|
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
405 |
if (exception != exceptionRequired) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
406 |
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
|
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 |
if (!test_success) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
411 |
success = false; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
412 |
System.out.println("TEST FAILED: "+name); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
413 |
} |
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 |
void doTests() { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
417 |
doTest("m1"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
418 |
doTest("m2"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
419 |
doTest("m3"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
420 |
doTest("m4"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
421 |
doTest("m5"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
422 |
doTest("m6"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
423 |
doTest("m7"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
424 |
doTest("m8"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
425 |
doTest("m9"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
426 |
doTest("m10"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
427 |
doTest("m11"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
428 |
doTest("m12"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
429 |
doTest("m13"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
430 |
doTest("m14"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
431 |
doTest("m15"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
432 |
doTest("m16"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
433 |
doTest("m17"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
434 |
if (!success) { |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
435 |
throw new RuntimeException("Some tests failed"); |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
436 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
437 |
assert(tests.isEmpty()) : tests; |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
438 |
} |
ede40159fd3b
8066103: C2's range check smearing allows out of bound array accesses
roland
parents:
diff
changeset
|
439 |
} |