8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 8066103
27 * @summary C2's range check smearing allows out of bound array accesses
28 * @library /testlibrary /../../test/lib /compiler/whitebox
29 * @modules java.base/sun.misc
30 * java.management
31 * @build TestRangeCheckSmearing
32 * @run main ClassFileInstaller sun.hotspot.WhiteBox
33 * @run main ClassFileInstaller jdk.test.lib.Platform
34 * @run main/othervm -ea -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
35 * -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestRangeCheckSmearing
36 *
37 */
38
39 import java.lang.annotation.*;
40 import java.lang.reflect.*;
41 import java.util.*;
42 import sun.hotspot.WhiteBox;
43 import sun.hotspot.code.NMethod;
44 import jdk.test.lib.Platform;
45
46 public class TestRangeCheckSmearing {
47 private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
48
49 @Retention(RetentionPolicy.RUNTIME)
50 @interface Args { int[] value(); }
51
52 // first range check is i + max of all constants
53 @Args({0, 8})
54 static int m1(int[] array, int i, boolean allaccesses) {
55 int res = 0;
56 res += array[i+9];
57 if (allaccesses) {
58 res += array[i+8];
59 res += array[i+7];
60 res += array[i+6];
61 res += array[i+5];
62 res += array[i+4];
63 res += array[i+3];
64 res += array[i+2];
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 8066103
27 * @summary C2's range check smearing allows out of bound array accesses
28 * @library /testlibrary /../../test/lib /
29 * @modules java.base/sun.misc
30 * java.management
31 * @build TestRangeCheckSmearing
32 * @run main ClassFileInstaller sun.hotspot.WhiteBox
33 * @run main ClassFileInstaller jdk.test.lib.Platform
34 * @run main/othervm -ea -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
35 * -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestRangeCheckSmearing
36 *
37 */
38
39 import java.lang.annotation.*;
40 import java.lang.reflect.*;
41 import java.util.*;
42 import sun.hotspot.WhiteBox;
43 import sun.hotspot.code.NMethod;
44 import jdk.test.lib.Platform;
45 import compiler.whitebox.CompilerWhiteBoxTest;
46
47 public class TestRangeCheckSmearing {
48 private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
49
50 @Retention(RetentionPolicy.RUNTIME)
51 @interface Args { int[] value(); }
52
53 // first range check is i + max of all constants
54 @Args({0, 8})
55 static int m1(int[] array, int i, boolean allaccesses) {
56 int res = 0;
57 res += array[i+9];
58 if (allaccesses) {
59 res += array[i+8];
60 res += array[i+7];
61 res += array[i+6];
62 res += array[i+5];
63 res += array[i+4];
64 res += array[i+3];
65 res += array[i+2];
|