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 /**
26 * @test
27 * @bug 8003585
28 * @summary strength reduce or eliminate range checks for power-of-two sized arrays
29 * @run main/othervm -XX:CompileCommand=compileonly,PowerOf2SizedArraysChecks::test* -XX:-BackgroundCompilation PowerOf2SizedArraysChecks
30 *
31 */
32
33 import java.util.function.*;
34
35 public class PowerOf2SizedArraysChecks {
36
37 static void check_result(String name, int x, int m, boolean expected, boolean res) {
38 if (expected != res) {
39 throw new RuntimeException("Bad result in " + name + " for x = " + x + " m = " + m + " expected " + expected + " got " + res);
40 }
41 }
42
43 static void helper(String name, BiFunction<Integer, int[], Boolean> test, int[] x_values, int[] m_values, boolean[][] expected) {
44 for (int i = 0; i < x_values.length; i++) {
45 int x = x_values[i];
46 for (int j = 0; j < m_values.length; j++) {
47 int m = m_values[j];
48 int[] array = new int[m];
49 boolean res = test.apply(x, array);
50 check_result(name, x, m, expected[i][j], res);
51 }
52 }
53 }
54
|
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 /**
26 * @test
27 * @bug 8003585
28 * @summary strength reduce or eliminate range checks for power-of-two sized arrays
29 *
30 * @run main/othervm -XX:CompileCommand=compileonly,compiler.rangechecks.PowerOf2SizedArraysChecks::test*
31 * -XX:-BackgroundCompilation
32 * compiler.rangechecks.PowerOf2SizedArraysChecks
33 */
34
35 package compiler.rangechecks;
36
37 import java.util.function.BiFunction;
38 import java.util.function.Function;
39
40 public class PowerOf2SizedArraysChecks {
41
42 static void check_result(String name, int x, int m, boolean expected, boolean res) {
43 if (expected != res) {
44 throw new RuntimeException("Bad result in " + name + " for x = " + x + " m = " + m + " expected " + expected + " got " + res);
45 }
46 }
47
48 static void helper(String name, BiFunction<Integer, int[], Boolean> test, int[] x_values, int[] m_values, boolean[][] expected) {
49 for (int i = 0; i < x_values.length; i++) {
50 int x = x_values[i];
51 for (int j = 0; j < m_values.length; j++) {
52 int m = m_values[j];
53 int[] array = new int[m];
54 boolean res = test.apply(x, array);
55 check_result(name, x, m, expected[i][j], res);
56 }
57 }
58 }
59
|