aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorrbackman <none@none>2013-10-18 10:41:56 +0200
committerrbackman <none@none>2013-10-18 10:41:56 +0200
commit6c08e0f011e7bc279b69be5e98220beb5c1a40c2 (patch)
treed2904279e1fb7b2bca4b1250d8ea7d89d06dc01c /test
parent14b966115b76ad163048f8b303551ead03090a50 (diff)
8026844: Various Math functions needs intrinsification
Reviewed-by: kvn, twisti --HG-- rename : test/compiler/intrinsics/mathexact/CondTest.java => test/compiler/intrinsics/mathexact/AddExactICondTest.java rename : test/compiler/intrinsics/mathexact/ConstantTest.java => test/compiler/intrinsics/mathexact/AddExactIConstantTest.java rename : test/compiler/intrinsics/mathexact/LoadTest.java => test/compiler/intrinsics/mathexact/AddExactILoadTest.java rename : test/compiler/intrinsics/mathexact/LoopDependentTest.java => test/compiler/intrinsics/mathexact/AddExactILoopDependentTest.java rename : test/compiler/intrinsics/mathexact/NonConstantTest.java => test/compiler/intrinsics/mathexact/AddExactINonConstantTest.java rename : test/compiler/intrinsics/mathexact/RepeatTest.java => test/compiler/intrinsics/mathexact/AddExactIRepeatTest.java
Diffstat (limited to 'test')
-rw-r--r--test/compiler/intrinsics/mathexact/AddExactICondTest.java (renamed from test/compiler/intrinsics/mathexact/CondTest.java)8
-rw-r--r--test/compiler/intrinsics/mathexact/AddExactIConstantTest.java (renamed from test/compiler/intrinsics/mathexact/ConstantTest.java)18
-rw-r--r--test/compiler/intrinsics/mathexact/AddExactILoadTest.java (renamed from test/compiler/intrinsics/mathexact/NonConstantTest.java)20
-rw-r--r--test/compiler/intrinsics/mathexact/AddExactILoopDependentTest.java (renamed from test/compiler/intrinsics/mathexact/LoopDependentTest.java)19
-rw-r--r--test/compiler/intrinsics/mathexact/AddExactINonConstantTest.java37
-rw-r--r--test/compiler/intrinsics/mathexact/AddExactIRepeatTest.java109
-rw-r--r--test/compiler/intrinsics/mathexact/AddExactLConstantTest.java37
-rw-r--r--test/compiler/intrinsics/mathexact/AddExactLNonConstantTest.java37
-rw-r--r--test/compiler/intrinsics/mathexact/DecExactITest.java53
-rw-r--r--test/compiler/intrinsics/mathexact/DecExactLTest.java53
-rw-r--r--test/compiler/intrinsics/mathexact/IncExactITest.java51
-rw-r--r--test/compiler/intrinsics/mathexact/IncExactLTest.java (renamed from test/compiler/intrinsics/mathexact/LoadTest.java)41
-rw-r--r--test/compiler/intrinsics/mathexact/MulExactICondTest.java57
-rw-r--r--test/compiler/intrinsics/mathexact/MulExactIConstantTest.java37
-rw-r--r--test/compiler/intrinsics/mathexact/MulExactILoadTest.java38
-rw-r--r--test/compiler/intrinsics/mathexact/MulExactILoopDependentTest.java36
-rw-r--r--test/compiler/intrinsics/mathexact/MulExactINonConstantTest.java38
-rw-r--r--test/compiler/intrinsics/mathexact/MulExactIRepeatTest.java109
-rw-r--r--test/compiler/intrinsics/mathexact/MulExactLConstantTest.java37
-rw-r--r--test/compiler/intrinsics/mathexact/MulExactLNonConstantTest.java37
-rw-r--r--test/compiler/intrinsics/mathexact/NegExactIConstantTest.java37
-rw-r--r--test/compiler/intrinsics/mathexact/NegExactILoadTest.java39
-rw-r--r--test/compiler/intrinsics/mathexact/NegExactILoopDependentTest.java36
-rw-r--r--test/compiler/intrinsics/mathexact/NegExactINonConstantTest.java37
-rw-r--r--test/compiler/intrinsics/mathexact/NegExactLConstantTest.java37
-rw-r--r--test/compiler/intrinsics/mathexact/NegExactLNonConstantTest.java37
-rw-r--r--test/compiler/intrinsics/mathexact/RepeatTest.java107
-rw-r--r--test/compiler/intrinsics/mathexact/SubExactICondTest.java57
-rw-r--r--test/compiler/intrinsics/mathexact/SubExactIConstantTest.java37
-rw-r--r--test/compiler/intrinsics/mathexact/SubExactILoadTest.java38
-rw-r--r--test/compiler/intrinsics/mathexact/SubExactILoopDependentTest.java37
-rw-r--r--test/compiler/intrinsics/mathexact/SubExactINonConstantTest.java37
-rw-r--r--test/compiler/intrinsics/mathexact/SubExactIRepeatTest.java111
-rw-r--r--test/compiler/intrinsics/mathexact/SubExactLConstantTest.java37
-rw-r--r--test/compiler/intrinsics/mathexact/SubExactLNonConstantTest.java37
-rw-r--r--test/compiler/intrinsics/mathexact/Verify.java660
36 files changed, 2041 insertions, 212 deletions
diff --git a/test/compiler/intrinsics/mathexact/CondTest.java b/test/compiler/intrinsics/mathexact/AddExactICondTest.java
index a6507cf05..8862160d8 100644
--- a/test/compiler/intrinsics/mathexact/CondTest.java
+++ b/test/compiler/intrinsics/mathexact/AddExactICondTest.java
@@ -25,14 +25,12 @@
* @test
* @bug 8024924
* @summary Test non constant addExact
- * @compile CondTest.java Verify.java
- * @run main CondTest
+ * @compile AddExactICondTest.java
+ * @run main AddExactICondTest
*
*/
-import java.lang.ArithmeticException;
-
-public class CondTest {
+public class AddExactICondTest {
public static int result = 0;
public static void main(String[] args) {
diff --git a/test/compiler/intrinsics/mathexact/ConstantTest.java b/test/compiler/intrinsics/mathexact/AddExactIConstantTest.java
index b7bf93f66..77000a1d9 100644
--- a/test/compiler/intrinsics/mathexact/ConstantTest.java
+++ b/test/compiler/intrinsics/mathexact/AddExactIConstantTest.java
@@ -25,23 +25,13 @@
* @test
* @bug 8024924
* @summary Test constant addExact
- * @compile ConstantTest.java Verify.java
- * @run main ConstantTest
+ * @compile AddExactIConstantTest.java Verify.java
+ * @run main AddExactIConstantTest
*
*/
-import java.lang.ArithmeticException;
-
-public class ConstantTest {
+public class AddExactIConstantTest {
public static void main(String[] args) {
- for (int i = 0; i < 50000; ++i) {
- Verify.verify(5, 7);
- Verify.verify(Integer.MAX_VALUE, 1);
- Verify.verify(Integer.MIN_VALUE, -1);
- Verify.verify(Integer.MAX_VALUE, -1);
- Verify.verify(Integer.MIN_VALUE, 1);
- Verify.verify(Integer.MAX_VALUE / 2, Integer.MAX_VALUE / 2);
- Verify.verify(Integer.MAX_VALUE / 2, (Integer.MAX_VALUE / 2) + 3);
- }
+ Verify.ConstantTest.verify(new Verify.AddExactI());
}
}
diff --git a/test/compiler/intrinsics/mathexact/NonConstantTest.java b/test/compiler/intrinsics/mathexact/AddExactILoadTest.java
index 78c9f9d99..2d96bb8b8 100644
--- a/test/compiler/intrinsics/mathexact/NonConstantTest.java
+++ b/test/compiler/intrinsics/mathexact/AddExactILoadTest.java
@@ -25,24 +25,14 @@
* @test
* @bug 8024924
* @summary Test non constant addExact
- * @compile NonConstantTest.java Verify.java
- * @run main NonConstantTest
+ * @compile AddExactILoadTest.java Verify.java
+ * @run main AddExactILoadTest
*
*/
-import java.lang.ArithmeticException;
-
-public class NonConstantTest {
- public static java.util.Random rnd = new java.util.Random();
-
+public class AddExactILoadTest {
public static void main(String[] args) {
- for (int i = 0; i < 50000; ++i) {
- int rnd1 = rnd.nextInt(), rnd2 = rnd.nextInt();
- Verify.verify(rnd1, rnd2);
- Verify.verify(rnd1, rnd2 + 1);
- Verify.verify(rnd1 + 1, rnd2);
- Verify.verify(rnd1 - 1, rnd2);
- Verify.verify(rnd1, rnd2 - 1);
- }
+ Verify.LoadTest.init();
+ Verify.LoadTest.verify(new Verify.AddExactI());
}
}
diff --git a/test/compiler/intrinsics/mathexact/LoopDependentTest.java b/test/compiler/intrinsics/mathexact/AddExactILoopDependentTest.java
index 17f58921f..99aae0d7b 100644
--- a/test/compiler/intrinsics/mathexact/LoopDependentTest.java
+++ b/test/compiler/intrinsics/mathexact/AddExactILoopDependentTest.java
@@ -25,24 +25,13 @@
* @test
* @bug 8024924
* @summary Test non constant addExact
- * @compile LoopDependentTest.java Verify.java
- * @run main LoopDependentTest
+ * @compile AddExactILoopDependentTest.java Verify.java
+ * @run main AddExactILoopDependentTest
*
*/
-import java.lang.ArithmeticException;
-
-public class LoopDependentTest {
- public static java.util.Random rnd = new java.util.Random();
-
+public class AddExactILoopDependentTest {
public static void main(String[] args) {
- int rnd1 = rnd.nextInt(), rnd2 = rnd.nextInt();
- for (int i = 0; i < 50000; ++i) {
- Verify.verify(rnd1 + i, rnd2 + i);
- Verify.verify(rnd1 + i, rnd2 + (i & 0xff));
- Verify.verify(rnd1 - i, rnd2 - (i & 0xff));
- Verify.verify(rnd1 + i + 1, rnd2 + i + 2);
- Verify.verify(rnd1 + i * 2, rnd2 + i);
- }
+ Verify.LoopDependentTest.verify(new Verify.AddExactI());
}
}
diff --git a/test/compiler/intrinsics/mathexact/AddExactINonConstantTest.java b/test/compiler/intrinsics/mathexact/AddExactINonConstantTest.java
new file mode 100644
index 000000000..b3a247585
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/AddExactINonConstantTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8024924
+ * @summary Test non constant addExact
+ * @compile AddExactINonConstantTest.java Verify.java
+ * @run main AddExactINonConstantTest
+ *
+ */
+
+public class AddExactINonConstantTest {
+ public static void main(String[] args) {
+ Verify.NonConstantTest.verify(new Verify.AddExactI());
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/AddExactIRepeatTest.java b/test/compiler/intrinsics/mathexact/AddExactIRepeatTest.java
new file mode 100644
index 000000000..d111b66ce
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/AddExactIRepeatTest.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8025657
+ * @summary Test repeating addExact
+ * @compile AddExactIRepeatTest.java Verify.java
+ * @run main AddExactIRepeatTest
+ *
+ */
+
+public class AddExactIRepeatTest {
+ public static void main(String[] args) {
+ runTest(new Verify.AddExactI());
+ }
+
+ public static int nonExact(int x, int y, Verify.BinaryMethod method) {
+ int result = method.unchecked(x, y);
+ result += method.unchecked(x, y);
+ result += method.unchecked(x, y);
+ result += method.unchecked(x, y);
+ return result;
+ }
+
+ public static void runTest(Verify.BinaryMethod method) {
+ java.util.Random rnd = new java.util.Random();
+ for (int i = 0; i < 50000; ++i) {
+ int x = Integer.MAX_VALUE - 10;
+ int y = Integer.MAX_VALUE - 10 + rnd.nextInt(5);
+
+ int c = rnd.nextInt() / 2;
+ int d = rnd.nextInt() / 2;
+
+ int a = catchingExact(x, y, method);
+
+ if (a != 36) {
+ throw new RuntimeException("a != 36 : " + a);
+ }
+
+ int b = nonExact(c, d, method);
+ int n = exact(c, d, method);
+
+
+ if (n != b) {
+ throw new RuntimeException("n != b : " + n + " != " + b);
+ }
+ }
+ }
+
+ public static int exact(int x, int y, Verify.BinaryMethod method) {
+ int result = 0;
+ result += method.checkMethod(x, y);
+ result += method.checkMethod(x, y);
+ result += method.checkMethod(x, y);
+ result += method.checkMethod(x, y);
+ return result;
+ }
+
+ public static int catchingExact(int x, int y, Verify.BinaryMethod method) {
+ int result = 0;
+ try {
+ result += 5;
+ result = method.checkMethod(x, y);
+ } catch (ArithmeticException e) {
+ result += 1;
+ }
+ try {
+ result += 6;
+
+ result += method.checkMethod(x, y);
+ } catch (ArithmeticException e) {
+ result += 2;
+ }
+ try {
+ result += 7;
+ result += method.checkMethod(x, y);
+ } catch (ArithmeticException e) {
+ result += 3;
+ }
+ try {
+ result += 8;
+ result += method.checkMethod(x, y);
+ } catch (ArithmeticException e) {
+ result += 4;
+ }
+ return result;
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/AddExactLConstantTest.java b/test/compiler/intrinsics/mathexact/AddExactLConstantTest.java
new file mode 100644
index 000000000..dc7514061
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/AddExactLConstantTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test constant addExact
+ * @compile AddExactLConstantTest.java Verify.java
+ * @run main AddExactLConstantTest
+ *
+ */
+
+public class AddExactLConstantTest {
+ public static void main(String[] args) {
+ Verify.ConstantLongTest.verify(new Verify.AddExactL());
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/AddExactLNonConstantTest.java b/test/compiler/intrinsics/mathexact/AddExactLNonConstantTest.java
new file mode 100644
index 000000000..efd5fd7c9
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/AddExactLNonConstantTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test non constant addExact
+ * @compile AddExactLNonConstantTest.java Verify.java
+ * @run main AddExactLNonConstantTest
+ *
+ */
+
+public class AddExactLNonConstantTest {
+ public static void main(String[] args) {
+ Verify.NonConstantLongTest.verify(new Verify.AddExactL());
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/DecExactITest.java b/test/compiler/intrinsics/mathexact/DecExactITest.java
new file mode 100644
index 000000000..7e6e1ca3b
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/DecExactITest.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test decrementExact
+ * @compile DecExactITest.java Verify.java
+ * @run main DecExactITest
+ *
+ */
+
+public class DecExactITest {
+ public static int[] values = {1, 1, 1, 1};
+ public static int[] minvalues = {Integer.MIN_VALUE, Integer.MIN_VALUE};
+
+ public static void main(String[] args) {
+ runTest(new Verify.DecExactI());
+ }
+
+ public static void runTest(Verify.UnaryMethod method) {
+ for (int i = 0; i < 20000; ++i) {
+ Verify.verifyUnary(Integer.MIN_VALUE, method);
+ Verify.verifyUnary(minvalues[0], method);
+ Verify.verifyUnary(Integer.MIN_VALUE - values[2], method);
+ Verify.verifyUnary(0, method);
+ Verify.verifyUnary(values[2], method);
+ Verify.verifyUnary(Integer.MAX_VALUE, method);
+ Verify.verifyUnary(Integer.MIN_VALUE - values[0] + values[3], method);
+ Verify.verifyUnary(Integer.MIN_VALUE + 1 - values[0], method);
+ }
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/DecExactLTest.java b/test/compiler/intrinsics/mathexact/DecExactLTest.java
new file mode 100644
index 000000000..7dca00b96
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/DecExactLTest.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test decrementExact
+ * @compile DecExactITest.java Verify.java
+ * @run main DecExactITest
+ *
+ */
+
+public class DecExactLTest {
+ public static long[] values = {1, 1, 1, 1};
+ public static long[] minvalues = {Long.MIN_VALUE, Long.MIN_VALUE};
+
+ public static void main(String[] args) {
+ runTest(new Verify.DecExactL());
+ }
+
+ public static void runTest(Verify.UnaryLongMethod method) {
+ for (int i = 0; i < 20000; ++i) {
+ Verify.verifyUnary(Long.MIN_VALUE, method);
+ Verify.verifyUnary(minvalues[0], method);
+ Verify.verifyUnary(Long.MIN_VALUE - values[2], method);
+ Verify.verifyUnary(0, method);
+ Verify.verifyUnary(values[2], method);
+ Verify.verifyUnary(Long.MAX_VALUE, method);
+ Verify.verifyUnary(Long.MIN_VALUE - values[0] + values[3], method);
+ Verify.verifyUnary(Long.MIN_VALUE + 1 - values[0], method);
+ }
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/IncExactITest.java b/test/compiler/intrinsics/mathexact/IncExactITest.java
new file mode 100644
index 000000000..9f7ddbd32
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/IncExactITest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test incrementExact
+ * @compile IncExactITest.java Verify.java
+ * @run main IncExactITest
+ *
+ */
+
+
+public class IncExactITest {
+ public static int[] values = {1, 1, 1, 1};
+ public static void main(String[] args) {
+ runTest(new Verify.IncExactI());
+ }
+
+ public static void runTest(Verify.UnaryMethod method) {
+ for (int i = 0; i < 20000; ++i) {
+ Verify.verifyUnary(Integer.MIN_VALUE, method);
+ Verify.verifyUnary(Integer.MAX_VALUE - 1, method);
+ Verify.verifyUnary(0, method);
+ Verify.verifyUnary(values[1], method);
+ Verify.verifyUnary(Integer.MAX_VALUE, method);
+ Verify.verifyUnary(Integer.MAX_VALUE - values[0] + values[3], method);
+ Verify.verifyUnary(Integer.MAX_VALUE - 1 + values[0], method);
+ }
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/LoadTest.java b/test/compiler/intrinsics/mathexact/IncExactLTest.java
index c04180ba6..755d81908 100644
--- a/test/compiler/intrinsics/mathexact/LoadTest.java
+++ b/test/compiler/intrinsics/mathexact/IncExactLTest.java
@@ -23,33 +23,28 @@
/*
* @test
- * @bug 8024924
- * @summary Test non constant addExact
- * @compile LoadTest.java Verify.java
- * @run main LoadTest
+ * @bug 8026844
+ * @summary Test incrementExact
+ * @compile IncExactLTest.java Verify.java
+ * @run main IncExactLTest
*
*/
-import java.lang.ArithmeticException;
-
-public class LoadTest {
- public static java.util.Random rnd = new java.util.Random();
- public static int[] values = new int[256];
-
- public static void main(String[] args) {
- for (int i = 0; i < values.length; ++i) {
- values[i] = rnd.nextInt();
+public class IncExactLTest {
+ public static long[] values = {1, 1, 1, 1};
+ public static void main(String[] args) {
+ runTest(new Verify.IncExactL());
}
- for (int i = 0; i < 50000; ++i) {
- Verify.verify(values[i & 255], values[i & 255] - i);
- Verify.verify(values[i & 255] + i, values[i & 255] - i);
- Verify.verify(values[i & 255], values[i & 255]);
- if ((i & 1) == 1 && i > 5) {
- Verify.verify(values[i & 255] + i, values[i & 255] - i);
- } else {
- Verify.verify(values[i & 255] - i, values[i & 255] + i);
- }
+ public static void runTest(Verify.UnaryLongMethod method) {
+ for (int i = 0; i < 20000; ++i) {
+ Verify.verifyUnary(Long.MIN_VALUE, method);
+ Verify.verifyUnary(Long.MAX_VALUE - 1, method);
+ Verify.verifyUnary(0, method);
+ Verify.verifyUnary(values[1], method);
+ Verify.verifyUnary(Long.MAX_VALUE, method);
+ Verify.verifyUnary(Long.MAX_VALUE - values[0] + values[3], method);
+ Verify.verifyUnary(Long.MAX_VALUE - 1 + values[0], method);
+ }
}
- }
}
diff --git a/test/compiler/intrinsics/mathexact/MulExactICondTest.java b/test/compiler/intrinsics/mathexact/MulExactICondTest.java
new file mode 100644
index 000000000..5f3e1e645
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/MulExactICondTest.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test multiplyExact as condition
+ * @compile MulExactICondTest.java
+ * @run main MulExactICondTest
+ *
+ */
+
+public class MulExactICondTest {
+ public static int result = 0;
+
+ public static void main(String[] args) {
+ for (int i = 0; i < 50000; ++i) {
+ runTest();
+ }
+ }
+
+ public static void runTest() {
+ int i = 7;
+ while (java.lang.Math.multiplyExact(i, result) < 89361) {
+ if ((java.lang.Math.multiplyExact(i, i) & 1) == 1) {
+ i += 3;
+ } else if ((i & 5) == 4) {
+ i += 7;
+ } else if ((i & 0xf) == 6) {
+ i += 2;
+ } else {
+ i += 1;
+ }
+ result += 2;
+ }
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/MulExactIConstantTest.java b/test/compiler/intrinsics/mathexact/MulExactIConstantTest.java
new file mode 100644
index 000000000..120bef5e9
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/MulExactIConstantTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test constant multiplyExact
+ * @compile MulExactIConstantTest.java Verify.java
+ * @run main MulExactIConstantTest
+ *
+ */
+
+public class MulExactIConstantTest {
+ public static void main(String[] args) {
+ Verify.ConstantTest.verify(new Verify.MulExactI());
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/MulExactILoadTest.java b/test/compiler/intrinsics/mathexact/MulExactILoadTest.java
new file mode 100644
index 000000000..36aa3d462
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/MulExactILoadTest.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test multiplyExact
+ * @compile MulExactILoadTest.java Verify.java
+ * @run main MulExactILoadTest
+ *
+ */
+
+public class MulExactILoadTest {
+ public static void main(String[] args) {
+ Verify.LoadTest.init();
+ Verify.LoadTest.verify(new Verify.MulExactI());
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/MulExactILoopDependentTest.java b/test/compiler/intrinsics/mathexact/MulExactILoopDependentTest.java
new file mode 100644
index 000000000..5ba4ad3cf
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/MulExactILoopDependentTest.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test loop dependent multiplyExact
+ * @compile MulExactILoopDependentTest.java Verify.java
+ * @run main MulExactILoopDependentTest
+ *
+ */
+public class MulExactILoopDependentTest {
+ public static void main(String[] args) {
+ Verify.LoopDependentTest.verify(new Verify.MulExactI());
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/MulExactINonConstantTest.java b/test/compiler/intrinsics/mathexact/MulExactINonConstantTest.java
new file mode 100644
index 000000000..e10805988
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/MulExactINonConstantTest.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test non constant multiplyExact
+ * @compile MulExactINonConstantTest.java Verify.java
+ * @run main MulExactINonConstantTest
+ *
+ */
+
+public class MulExactINonConstantTest {
+ public static void main(String[] args) {
+ Verify.NonConstantTest.verify(new Verify.MulExactI());
+ Verify.LoadTest.verify(new Verify.MulExactI());
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/MulExactIRepeatTest.java b/test/compiler/intrinsics/mathexact/MulExactIRepeatTest.java
new file mode 100644
index 000000000..dd14ce21e
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/MulExactIRepeatTest.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test repeating multiplyExact
+ * @compile MulExactIRepeatTest.java Verify.java
+ * @run main MulExactIRepeatTest
+ *
+ */
+
+public class MulExactIRepeatTest {
+ public static void main(String[] args) {
+ runTest(new Verify.MulExactI());
+ }
+
+ public static int nonExact(int x, int y, Verify.BinaryMethod method) {
+ int result = method.unchecked(x, y);
+ result += method.unchecked(x, y);
+ result += method.unchecked(x, y);
+ result += method.unchecked(x, y);
+ return result;
+ }
+
+ public static void runTest(Verify.BinaryMethod method) {
+ java.util.Random rnd = new java.util.Random();
+ for (int i = 0; i < 50000; ++i) {
+ int x = Integer.MAX_VALUE - 10;
+ int y = Integer.MAX_VALUE - 10 + rnd.nextInt(5);
+
+ int c = rnd.nextInt() / 10;
+ int d = rnd.nextInt(9);
+
+ int a = catchingExact(x, y, method);
+
+ if (a != 36) {
+ throw new RuntimeException("a != 36 : " + a);
+ }
+
+ int b = nonExact(c, d, method);
+ int n = exact(c, d, method);
+
+
+ if (n != b) {
+ throw new RuntimeException("n != b : " + n + " != " + b);
+ }
+ }
+ }
+
+ public static int exact(int x, int y, Verify.BinaryMethod method) {
+ int result = 0;
+ result += method.checkMethod(x, y);
+ result += method.checkMethod(x, y);
+ result += method.checkMethod(x, y);
+ result += method.checkMethod(x, y);
+ return result;
+ }
+
+ public static int catchingExact(int x, int y, Verify.BinaryMethod method) {
+ int result = 0;
+ try {
+ result += 5;
+ result = method.checkMethod(x, y);
+ } catch (ArithmeticException e) {
+ result += 1;
+ }
+ try {
+ result += 6;
+
+ result += method.checkMethod(x, y);
+ } catch (ArithmeticException e) {
+ result += 2;
+ }
+ try {
+ result += 7;
+ result += method.checkMethod(x, y);
+ } catch (ArithmeticException e) {
+ result += 3;
+ }
+ try {
+ result += 8;
+ result += method.checkMethod(x, y);
+ } catch (ArithmeticException e) {
+ result += 4;
+ }
+ return result;
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/MulExactLConstantTest.java b/test/compiler/intrinsics/mathexact/MulExactLConstantTest.java
new file mode 100644
index 000000000..c687cc276
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/MulExactLConstantTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test constant mulExact
+ * @compile MulExactLConstantTest.java Verify.java
+ * @run main MulExactLConstantTest
+ *
+ */
+
+public class MulExactLConstantTest {
+ public static void main(String[] args) {
+ Verify.ConstantLongTest.verify(new Verify.MulExactL());
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/MulExactLNonConstantTest.java b/test/compiler/intrinsics/mathexact/MulExactLNonConstantTest.java
new file mode 100644
index 000000000..f9d82ed08
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/MulExactLNonConstantTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test non constant mulExact
+ * @compile MulExactLNonConstantTest.java Verify.java
+ * @run main MulExactLNonConstantTest
+ *
+ */
+
+public class MulExactLNonConstantTest {
+ public static void main(String[] args) {
+ Verify.NonConstantLongTest.verify(new Verify.MulExactL());
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/NegExactIConstantTest.java b/test/compiler/intrinsics/mathexact/NegExactIConstantTest.java
new file mode 100644
index 000000000..ba49d7787
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/NegExactIConstantTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test constant negExact
+ * @compile NegExactIConstantTest.java Verify.java
+ * @run main NegExactIConstantTest
+ *
+ */
+
+public class NegExactIConstantTest {
+ public static void main(String[] args) {
+ Verify.ConstantTest.verify(new Verify.UnaryToBinary(new Verify.NegExactI()));
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/NegExactILoadTest.java b/test/compiler/intrinsics/mathexact/NegExactILoadTest.java
new file mode 100644
index 000000000..371f3aedb
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/NegExactILoadTest.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test negExact
+ * @compile NegExactILoadTest.java Verify.java
+ * @run main NegExactILoadTest
+ *
+ */
+
+public class NegExactILoadTest {
+ public static void main(String[] args) {
+ Verify.LoadTest.init();
+ Verify.LoadTest.verify(new Verify.UnaryToBinary(new Verify.NegExactI()));
+ }
+
+}
diff --git a/test/compiler/intrinsics/mathexact/NegExactILoopDependentTest.java b/test/compiler/intrinsics/mathexact/NegExactILoopDependentTest.java
new file mode 100644
index 000000000..882f80b91
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/NegExactILoopDependentTest.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test negExact loop dependent
+ * @compile NegExactILoopDependentTest.java Verify.java
+ * @run main NegExactILoopDependentTest
+ *
+ */
+public class NegExactILoopDependentTest {
+ public static void main(String[] args) {
+ Verify.LoopDependentTest.verify(new Verify.UnaryToBinary(new Verify.NegExactI()));
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/NegExactINonConstantTest.java b/test/compiler/intrinsics/mathexact/NegExactINonConstantTest.java
new file mode 100644
index 000000000..6f044f0d9
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/NegExactINonConstantTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test non constant negExact
+ * @compile NegExactINonConstantTest.java Verify.java
+ * @run main NegExactINonConstantTest
+ *
+ */
+
+public class NegExactINonConstantTest {
+ public static void main(String[] args) {
+ Verify.NonConstantTest.verify(new Verify.UnaryToBinary(new Verify.NegExactI()));
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/NegExactLConstantTest.java b/test/compiler/intrinsics/mathexact/NegExactLConstantTest.java
new file mode 100644
index 000000000..382cd5c5f
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/NegExactLConstantTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test constant negExact
+ * @compile NegExactLConstantTest.java Verify.java
+ * @run main NegExactLConstantTest
+ *
+ */
+
+public class NegExactLConstantTest {
+ public static void main(String[] args) {
+ Verify.ConstantLongTest.verify(new Verify.UnaryToBinaryLong(new Verify.NegExactL()));
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/NegExactLNonConstantTest.java b/test/compiler/intrinsics/mathexact/NegExactLNonConstantTest.java
new file mode 100644
index 000000000..0bcad8b2b
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/NegExactLNonConstantTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test constant negExact
+ * @compile NegExactLNonConstantTest.java Verify.java
+ * @run main NegExactLNonConstantTest
+ *
+ */
+
+public class NegExactLNonConstantTest {
+ public static void main(String[] args) {
+ Verify.NonConstantLongTest.verify(new Verify.UnaryToBinaryLong(new Verify.NegExactL()));
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/RepeatTest.java b/test/compiler/intrinsics/mathexact/RepeatTest.java
deleted file mode 100644
index aaf63de1d..000000000
--- a/test/compiler/intrinsics/mathexact/RepeatTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 8025657
- * @summary Test repeating addExact
- * @compile RepeatTest.java
- * @run main RepeatTest
- *
- */
-
-import java.lang.ArithmeticException;
-
-public class RepeatTest {
- public static void main(String[] args) {
- java.util.Random rnd = new java.util.Random();
- for (int i = 0; i < 50000; ++i) {
- int x = Integer.MAX_VALUE - 10;
- int y = Integer.MAX_VALUE - 10 + rnd.nextInt(5); //rnd.nextInt() / 2;
-
- int c = rnd.nextInt() / 2;
- int d = rnd.nextInt() / 2;
-
- int a = addExact(x, y);
-
- if (a != 36) {
- throw new RuntimeException("a != 0 : " + a);
- }
-
- int b = nonExact(c, d);
- int n = addExact2(c, d);
-
-
- if (n != b) {
- throw new RuntimeException("n != b : " + n + " != " + b);
- }
- }
- }
-
- public static int addExact2(int x, int y) {
- int result = 0;
- result += java.lang.Math.addExact(x, y);
- result += java.lang.Math.addExact(x, y);
- result += java.lang.Math.addExact(x, y);
- result += java.lang.Math.addExact(x, y);
- return result;
- }
-
- public static int addExact(int x, int y) {
- int result = 0;
- try {
- result += 5;
- result = java.lang.Math.addExact(x, y);
- } catch (ArithmeticException e) {
- result += 1;
- }
- try {
- result += 6;
-
- result += java.lang.Math.addExact(x, y);
- } catch (ArithmeticException e) {
- result += 2;
- }
- try {
- result += 7;
- result += java.lang.Math.addExact(x, y);
- } catch (ArithmeticException e) {
- result += 3;
- }
- try {
- result += 8;
- result += java.lang.Math.addExact(x, y);
- } catch (ArithmeticException e) {
- result += 4;
- }
- return result;
- }
-
- public static int nonExact(int x, int y) {
- int result = x + y;
- result += x + y;
- result += x + y;
- result += x + y;
- return result;
- }
-}
diff --git a/test/compiler/intrinsics/mathexact/SubExactICondTest.java b/test/compiler/intrinsics/mathexact/SubExactICondTest.java
new file mode 100644
index 000000000..f539bdc7c
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/SubExactICondTest.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test subtractExact as condition
+ * @compile SubExactICondTest.java Verify.java
+ * @run main SubExactICondTest
+ *
+ */
+
+public class SubExactICondTest {
+ public static int result = 0;
+
+ public static void main(String[] args) {
+ for (int i = 0; i < 50000; ++i) {
+ runTest();
+ }
+ }
+
+ public static void runTest() {
+ int i = 7;
+ while (java.lang.Math.subtractExact(i, result) > -31361) {
+ if ((java.lang.Math.subtractExact(i, i) & 1) == 1) {
+ i -= 3;
+ } else if ((i & 5) == 4) {
+ i -= 7;
+ } else if ((i & 0xf) == 6) {
+ i -= 2;
+ } else {
+ i -= 1;
+ }
+ result += 2;
+ }
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/SubExactIConstantTest.java b/test/compiler/intrinsics/mathexact/SubExactIConstantTest.java
new file mode 100644
index 000000000..b450bd90b
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/SubExactIConstantTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test constant subtractExact
+ * @compile SubExactIConstantTest.java Verify.java
+ * @run main SubExactIConstantTest
+ *
+ */
+
+public class SubExactIConstantTest {
+ public static void main(String[] args) {
+ Verify.ConstantTest.verify(new Verify.SubExactI());
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/SubExactILoadTest.java b/test/compiler/intrinsics/mathexact/SubExactILoadTest.java
new file mode 100644
index 000000000..af2ed0182
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/SubExactILoadTest.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test non constant subtractExact
+ * @compile SubExactILoadTest.java Verify.java
+ * @run main SubExactILoadTest
+ *
+ */
+
+public class SubExactILoadTest {
+ public static void main(String[] args) {
+ Verify.LoadTest.init();
+ Verify.LoadTest.verify(new Verify.SubExactI());
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/SubExactILoopDependentTest.java b/test/compiler/intrinsics/mathexact/SubExactILoopDependentTest.java
new file mode 100644
index 000000000..67ebcbca3
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/SubExactILoopDependentTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test non constant subtractExact
+ * @compile SubExactILoopDependentTest.java Verify.java
+ * @run main SubExactILoopDependentTest
+ *
+ */
+
+public class SubExactILoopDependentTest {
+ public static void main(String[] args) {
+ Verify.LoopDependentTest.verify(new Verify.SubExactI());
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/SubExactINonConstantTest.java b/test/compiler/intrinsics/mathexact/SubExactINonConstantTest.java
new file mode 100644
index 000000000..b81538108
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/SubExactINonConstantTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test non constant subtractExact
+ * @compile SubExactINonConstantTest.java Verify.java
+ * @run main SubExactINonConstantTest
+ *
+ */
+
+public class SubExactINonConstantTest {
+ public static void main(String[] args) {
+ Verify.NonConstantTest.verify(new Verify.SubExactI());
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/SubExactIRepeatTest.java b/test/compiler/intrinsics/mathexact/SubExactIRepeatTest.java
new file mode 100644
index 000000000..3c57f6f3f
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/SubExactIRepeatTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test repeating subtractExact
+ * @compile SubExactIRepeatTest.java Verify.java
+ * @run main SubExactIRepeatTest
+ *
+ */
+
+import java.lang.ArithmeticException;
+
+public class SubExactIRepeatTest {
+ public static void main(String[] args) {
+ runTest(new Verify.SubExactI());
+ }
+
+ public static int nonExact(int x, int y, Verify.BinaryMethod method) {
+ int result = method.unchecked(x, y);
+ result += method.unchecked(x, y);
+ result += method.unchecked(x, y);
+ result += method.unchecked(x, y);
+ return result;
+ }
+
+ public static void runTest(Verify.BinaryMethod method) {
+ java.util.Random rnd = new java.util.Random();
+ for (int i = 0; i < 50000; ++i) {
+ int x = Integer.MIN_VALUE + 10;
+ int y = Integer.MAX_VALUE - 10 + rnd.nextInt(5);
+
+ int c = rnd.nextInt() / 2;
+ int d = rnd.nextInt() / 2;
+
+ int a = catchingExact(x, y, method);
+
+ if (a != 36) {
+ throw new RuntimeException("a != 36 : " + a);
+ }
+
+ int b = nonExact(c, d, method);
+ int n = exact(c, d, method);
+
+
+ if (n != b) {
+ throw new RuntimeException("n != b : " + n + " != " + b);
+ }
+ }
+ }
+
+ public static int exact(int x, int y, Verify.BinaryMethod method) {
+ int result = 0;
+ result += method.checkMethod(x, y);
+ result += method.checkMethod(x, y);
+ result += method.checkMethod(x, y);
+ result += method.checkMethod(x, y);
+ return result;
+ }
+
+ public static int catchingExact(int x, int y, Verify.BinaryMethod method) {
+ int result = 0;
+ try {
+ result += 5;
+ result = method.checkMethod(x, y);
+ } catch (ArithmeticException e) {
+ result += 1;
+ }
+ try {
+ result += 6;
+
+ result += method.checkMethod(x, y);
+ } catch (ArithmeticException e) {
+ result += 2;
+ }
+ try {
+ result += 7;
+ result += method.checkMethod(x, y);
+ } catch (ArithmeticException e) {
+ result += 3;
+ }
+ try {
+ result += 8;
+ result += method.checkMethod(x, y);
+ } catch (ArithmeticException e) {
+ result += 4;
+ }
+ return result;
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/SubExactLConstantTest.java b/test/compiler/intrinsics/mathexact/SubExactLConstantTest.java
new file mode 100644
index 000000000..46eefcd19
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/SubExactLConstantTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test constant subtractExact
+ * @compile SubExactLConstantTest.java Verify.java
+ * @run main SubExactLConstantTest
+ *
+ */
+
+public class SubExactLConstantTest {
+ public static void main(String[] args) {
+ Verify.ConstantLongTest.verify(new Verify.SubExactL());
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/SubExactLNonConstantTest.java b/test/compiler/intrinsics/mathexact/SubExactLNonConstantTest.java
new file mode 100644
index 000000000..2bd67bb0f
--- /dev/null
+++ b/test/compiler/intrinsics/mathexact/SubExactLNonConstantTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8026844
+ * @summary Test non constant subtractExact
+ * @compile SubExactLNonConstantTest.java Verify.java
+ * @run main SubExactLNonConstantTest
+ *
+ */
+
+public class SubExactLNonConstantTest {
+ public static void main(String[] args) {
+ Verify.NonConstantLongTest.verify(new Verify.SubExactL());
+ }
+}
diff --git a/test/compiler/intrinsics/mathexact/Verify.java b/test/compiler/intrinsics/mathexact/Verify.java
index de5a4cc44..a4d728bfd 100644
--- a/test/compiler/intrinsics/mathexact/Verify.java
+++ b/test/compiler/intrinsics/mathexact/Verify.java
@@ -22,47 +22,641 @@
*/
public class Verify {
- public static String throwWord(boolean threw) {
- return (threw ? "threw" : "didn't throw");
- }
+ public static String throwWord(boolean threw) {
+ return (threw ? "threw" : "didn't throw");
+ }
+
+ public static void verifyResult(UnaryMethod method, int result1, int result2, boolean exception1, boolean exception2, int value) {
+ if (exception1 != exception2) {
+ throw new RuntimeException("Intrinsic version [" + method.name() + "]" + throwWord(exception1) + " exception, NonIntrinsic version" + throwWord(exception2) + " for: " + value);
+ }
+ if (result1 != result2) {
+ throw new RuntimeException("Intrinsic version [" + method.name() + "] returned: " + result1 + " while NonIntrinsic version returned: " + result2);
+ }
+ }
+
+ public static void verifyResult(UnaryLongMethod method, long result1, long result2, boolean exception1, boolean exception2, long value) {
+ if (exception1 != exception2) {
+ throw new RuntimeException("Intrinsic version [" + method.name() + "]" + throwWord(exception1) + " exception, NonIntrinsic version" + throwWord(exception2) + " for: " + value);
+ }
+ if (result1 != result2) {
+ throw new RuntimeException("Intrinsic version [" + method.name() + "] returned: " + result1 + " while NonIntrinsic version returned: " + result2);
+ }
+ }
+
+ private static void verifyResult(BinaryMethod method, int result1, int result2, boolean exception1, boolean exception2, int a, int b) {
+ if (exception1 != exception2) {
+ throw new RuntimeException("Intrinsic version [" + method.name() + "]" + throwWord(exception1) + " exception, NonIntrinsic version " + throwWord(exception2) + " for: " + a + " + " + b);
+ }
+ if (result1 != result2) {
+ throw new RuntimeException("Intrinsic version [" + method.name() + "] returned: " + result1 + " while NonIntrinsic version returned: " + result2);
+ }
+ }
+
+ private static void verifyResult(BinaryLongMethod method, long result1, long result2, boolean exception1, boolean exception2, long a, long b) {
+ if (exception1 != exception2) {
+ throw new RuntimeException("Intrinsic version [" + method.name() + "]" + throwWord(exception1) + " exception, NonIntrinsic version " + throwWord(exception2) + " for: " + a + " + " + b);
+ }
+ if (result1 != result2) {
+ throw new RuntimeException("Intrinsic version [" + method.name() + "] returned: " + result1 + " while NonIntrinsic version returned: " + result2);
+ }
+ }
+
+
+ public static void verifyUnary(int a, UnaryMethod method) {
+ boolean exception1 = false, exception2 = false;
+ int result1 = 0, result2 = 0;
+ try {
+ result1 = method.checkMethod(a);
+ } catch (ArithmeticException e) {
+ exception1 = true;
+ }
+ try {
+ result2 = method.safeMethod(a);
+ } catch (ArithmeticException e) {
+ exception2 = true;
+ }
+
+ verifyResult(method, result1, result2, exception1, exception2, a);
+ }
+
+ public static void verifyUnary(long a, UnaryLongMethod method) {
+ boolean exception1 = false, exception2 = false;
+ long result1 = 0, result2 = 0;
+ try {
+ result1 = method.checkMethod(a);
+ } catch (ArithmeticException e) {
+ exception1 = true;
+ }
+ try {
+ result2 = method.safeMethod(a);
+ } catch (ArithmeticException e) {
+ exception2 = true;
+ }
+
+ verifyResult(method, result1, result2, exception1, exception2, a);
+ }
+
+
+ public static void verifyBinary(int a, int b, BinaryMethod method) {
+ boolean exception1 = false, exception2 = false;
+ int result1 = 0, result2 = 0;
+ try {
+ result1 = method.checkMethod(a, b);
+ } catch (ArithmeticException e) {
+ exception1 = true;
+ }
+ try {
+ result2 = method.safeMethod(a, b);
+ } catch (ArithmeticException e) {
+ exception2 = true;
+ }
+
+ verifyResult(method, result1, result2, exception1, exception2, a, b);
+ }
+
+ public static void verifyBinary(long a, long b, BinaryLongMethod method) {
+ boolean exception1 = false, exception2 = false;
+ long result1 = 0, result2 = 0;
+ try {
+ result1 = method.checkMethod(a, b);
+ } catch (ArithmeticException e) {
+ exception1 = true;
+ }
+ try {
+ result2 = method.safeMethod(a, b);
+ } catch (ArithmeticException e) {
+ exception2 = true;
+ }
+
+ verifyResult(method, result1, result2, exception1, exception2, a, b);
+ }
+
+
+ public static class LoadTest {
+ public static java.util.Random rnd = new java.util.Random();
+ public static int[] values = new int[256];
+
+ public static void init() {
+ for (int i = 0; i < values.length; ++i) {
+ values[i] = rnd.nextInt();
+ }
+ }
+
+ public static void verify(BinaryMethod method) {
+ for (int i = 0; i < 50000; ++i) {
+ Verify.verifyBinary(values[i & 255], values[i & 255] - i, method);
+ Verify.verifyBinary(values[i & 255] + i, values[i & 255] - i, method);
+ Verify.verifyBinary(values[i & 255], values[i & 255], method);
+ if ((i & 1) == 1 && i > 5) {
+ Verify.verifyBinary(values[i & 255] + i, values[i & 255] - i, method);
+ } else {
+ Verify.verifyBinary(values[i & 255] - i, values[i & 255] + i, method);
+ }
+ Verify.verifyBinary(values[i & 255], values[(i + 1) & 255], method);
+ }
+ }
+ }
+
+ public static class NonConstantTest {
+ public static java.util.Random rnd = new java.util.Random();
+
+ public static void verify(BinaryMethod method) {
+ for (int i = 0; i < 50000; ++i) {
+ int rnd1 = rnd.nextInt(), rnd2 = rnd.nextInt();
+ Verify.verifyBinary(rnd1, rnd2, method);
+ Verify.verifyBinary(rnd1, rnd2 + 1, method);
+ Verify.verifyBinary(rnd1 + 1, rnd2, method);
+ Verify.verifyBinary(rnd1 - 1, rnd2, method);
+ Verify.verifyBinary(rnd1, rnd2 - 1, method);
+ }
+ }
+ }
+
+ public static class NonConstantLongTest {
+ public static long[] values = { Long.MIN_VALUE, Long.MAX_VALUE, 0, Long.MAX_VALUE - 1831 };
+ public static java.util.Random rnd = new java.util.Random();
+
+ public static void verify(BinaryLongMethod method) {
+ for (int i = 0; i < 50000; ++i) {
+ long rnd1 = rnd.nextLong(), rnd2 = rnd.nextLong();
+ Verify.verifyBinary(rnd1, rnd2, method);
+ Verify.verifyBinary(rnd1, rnd2 + 1, method);
+ Verify.verifyBinary(rnd1 + 1, rnd2, method);
+ Verify.verifyBinary(rnd1 - 1, rnd2, method);
+ Verify.verifyBinary(rnd1, rnd2 - 1, method);
+ Verify.verifyBinary(rnd1 + Long.MAX_VALUE - rnd2, rnd2 + 1, method);
+ Verify.verifyBinary(values[0], values[2], method);
+ Verify.verifyBinary(values[1], values[2], method);
+ Verify.verifyBinary(values[3], 74L, method);
+ }
+ }
+ }
+
+ public static class LoopDependentTest {
+ public static java.util.Random rnd = new java.util.Random();
+
+ public static void verify(BinaryMethod method) {
+ int rnd1 = rnd.nextInt(), rnd2 = rnd.nextInt();
+ runTest(rnd1, rnd2, method);
+ }
+
+ private static void runTest(int rnd1, int rnd2, BinaryMethod method) {
+ for (int i = 0; i < 50000; ++i) {
+ Verify.verifyBinary(rnd1 + i, rnd2 + i, method);
+ Verify.verifyBinary(rnd1 + i, rnd2 + (i & 0xff), method);
+ Verify.verifyBinary(rnd1 - i, rnd2 - (i & 0xff), method);
+ Verify.verifyBinary(rnd1 + i + 1, rnd2 + i + 2, method);
+ Verify.verifyBinary(rnd1 + i * 2, rnd2 + i, method);
+ }
+ }
+ }
+
+ public static class ConstantTest {
+ public static void verify(BinaryMethod method) {
+ for (int i = 0; i < 50000; ++i) {
+ Verify.verifyBinary(5, 7, method);
+ Verify.verifyBinary(Integer.MAX_VALUE, 1, method);
+ Verify.verifyBinary(Integer.MIN_VALUE, -1, method);
+ Verify.verifyBinary(Integer.MAX_VALUE, -1, method);
+ Verify.verifyBinary(Integer.MIN_VALUE, 1, method);
+ Verify.verifyBinary(Integer.MAX_VALUE / 2, Integer.MAX_VALUE / 2, method);
+ Verify.verifyBinary(Integer.MAX_VALUE / 2, (Integer.MAX_VALUE / 2) + 3, method);
+ Verify.verifyBinary(Integer.MAX_VALUE, Integer.MIN_VALUE, method);
+ }
+ }
+ }
+
+ public static class ConstantLongTest {
+ public static void verify(BinaryLongMethod method) {
+ for (int i = 0; i < 50000; ++i) {
+ Verify.verifyBinary(5, 7, method);
+ Verify.verifyBinary(Long.MAX_VALUE, 1, method);
+ Verify.verifyBinary(Long.MIN_VALUE, -1, method);
+ Verify.verifyBinary(Long.MAX_VALUE, -1, method);
+ Verify.verifyBinary(Long.MIN_VALUE, 1, method);
+ Verify.verifyBinary(Long.MAX_VALUE / 2, Long.MAX_VALUE / 2, method);
+ Verify.verifyBinary(Long.MAX_VALUE / 2, (Long.MAX_VALUE / 2) + 3, method);
+ Verify.verifyBinary(Long.MAX_VALUE, Long.MIN_VALUE, method);
+ }
+ }
+ }
+
+ public static interface BinaryMethod {
+ int safeMethod(int a, int b);
+ int checkMethod(int a, int b);
+ int unchecked(int a, int b);
+ String name();
+ }
+
+ public static interface UnaryMethod {
+ int safeMethod(int value);
+ int checkMethod(int value);
+ int unchecked(int value);
+ String name();
+ }
+
+ public static interface BinaryLongMethod {
+ long safeMethod(long a, long b);
+ long checkMethod(long a, long b);
+ long unchecked(long a, long b);
+ String name();
+ }
+
+ public static interface UnaryLongMethod {
+ long safeMethod(long value);
+ long checkMethod(long value);
+ long unchecked(long value);
+ String name();
+ }
+
+ public static class UnaryToBinary implements BinaryMethod {
+ private final UnaryMethod method;
+ public UnaryToBinary(UnaryMethod method) {
+ this.method = method;
+ }
+
+ @Override
+ public int safeMethod(int a, int b) {
+ return method.safeMethod(a);
+ }
+
+ @Override
+ public int checkMethod(int a, int b) {
+ return method.checkMethod(a);
+ }
+
+ @Override
+ public int unchecked(int a, int b) {
+ return method.unchecked(a);
+
+ }
+
+ @Override
+ public String name() {
+ return method.name();
+ }
+ }
+
+ public static class UnaryToBinaryLong implements BinaryLongMethod {
+ private final UnaryLongMethod method;
+ public UnaryToBinaryLong(UnaryLongMethod method) {
+ this.method = method;
+ }
+
+ @Override
+ public long safeMethod(long a, long b) {
+ return method.safeMethod(a);
+ }
+
+ @Override
+ public long checkMethod(long a, long b) {
+ return method.checkMethod(a);
+ }
+
+ @Override
+ public long unchecked(long a, long b) {
+ return method.unchecked(a);
+
+ }
+
+ @Override
+ public String name() {
+ return method.name();
+ }
+ }
- public static void verify(int a, int b) {
- boolean exception1 = false, exception2 = false;
- int result1 = 0, result2 = 0;
- try {
- result1 = testIntrinsic(a, b);
- } catch (ArithmeticException e) {
- exception1 = true;
+
+ public static class AddExactI implements BinaryMethod {
+ @Override
+ public int safeMethod(int x, int y) {
+ int r = x + y;
+ // HD 2-12 Overflow iff both arguments have the opposite sign of the result
+ if (((x ^ r) & (y ^ r)) < 0) {
+ throw new ArithmeticException("integer overflow");
+ }
+ return r;
+
+ }
+
+ @Override
+ public int checkMethod(int a, int b) {
+ return Math.addExact(a, b);
+ }
+
+ @Override
+ public String name() {
+ return "addExact";
+ }
+
+ @Override
+ public int unchecked(int a, int b) {
+ return a + b;
+ }
+ }
+
+ public static class AddExactL implements BinaryLongMethod {
+ @Override
+ public long safeMethod(long x, long y) {
+ long r = x + y;
+ // HD 2-12 Overflow iff both arguments have the opposite sign of the result
+ if (((x ^ r) & (y ^ r)) < 0) {
+ throw new ArithmeticException("integer overflow");
+ }
+ return r;
+
+ }
+
+ @Override
+ public long checkMethod(long a, long b) {
+ return Math.addExact(a, b);
+ }
+
+ @Override
+ public String name() {
+ return "addExactLong";
+ }
+
+ @Override
+ public long unchecked(long a, long b) {
+ return a + b;
+ }
+ }
+
+ public static class MulExactI implements BinaryMethod {
+ @Override
+ public int safeMethod(int x, int y) {
+ long r = (long)x * (long)y;
+ if ((int)r != r) {
+ throw new ArithmeticException("integer overflow");
+ }
+ return (int)r;
+
+ }
+
+ @Override
+ public int checkMethod(int a, int b) {
+ return Math.multiplyExact(a, b);
+ }
+
+ @Override
+ public int unchecked(int a, int b) {
+ return a * b;
+ }
+
+ @Override
+ public String name() {
+ return "multiplyExact";
+ }
+ }
+
+ public static class MulExactL implements BinaryLongMethod {
+ @Override
+ public long safeMethod(long x, long y) {
+ long r = x * y;
+ long ax = Math.abs(x);
+ long ay = Math.abs(y);
+ if (((ax | ay) >>> 31 != 0)) {
+ // Some bits greater than 2^31 that might cause overflow
+ // Check the result using the divide operator
+ // and check for the special case of Long.MIN_VALUE * -1
+ if (((y != 0) && (r / y != x)) ||
+ (x == Long.MIN_VALUE && y == -1)) {
+ throw new ArithmeticException("long overflow");
+ }
+ }
+ return r;
+ }
+
+ @Override
+ public long checkMethod(long a, long b) {
+ return Math.multiplyExact(a, b);
+ }
+
+ @Override
+ public long unchecked(long a, long b) {
+ return a * b;
+ }
+
+ @Override
+ public String name() {
+ return "multiplyExact";
+ }
+ }
+
+ public static class NegExactL implements UnaryLongMethod {
+ @Override
+ public long safeMethod(long a) {
+ if (a == Long.MIN_VALUE) {
+ throw new ArithmeticException("long overflow");
+ }
+
+ return -a;
+
+ }
+
+ @Override
+ public long checkMethod(long value) {
+ return Math.negateExact(value);
+ }
+
+ @Override
+ public long unchecked(long value) {
+ return -value;
+ }
+
+ @Override
+ public String name() {
+ return "negateExactLong";
+ }
+ }
+
+ public static class NegExactI implements UnaryMethod {
+ @Override
+ public int safeMethod(int a) {
+ if (a == Integer.MIN_VALUE) {
+ throw new ArithmeticException("integer overflow");
+ }
+
+ return -a;
+
+ }
+
+ @Override
+ public int checkMethod(int value) {
+ return Math.negateExact(value);
+ }
+
+ @Override
+ public int unchecked(int value) {
+ return -value;
+ }
+
+ @Override
+ public String name() {
+ return "negateExact";
+ }
+ }
+
+ public static class SubExactI implements BinaryMethod {
+ @Override
+ public int safeMethod(int x, int y) {
+ int r = x - y;
+ // HD 2-12 Overflow iff the arguments have different signs and
+ // the sign of the result is different than the sign of x
+ if (((x ^ y) & (x ^ r)) < 0) {
+ throw new ArithmeticException("integer overflow");
+ }
+ return r;
+ }
+
+ @Override
+ public int checkMethod(int a, int b) {
+ return Math.subtractExact(a, b);
+ }
+
+ @Override
+ public int unchecked(int a, int b) {
+ return a - b;
+ }
+
+ @Override
+ public String name() {
+ return "subtractExact";
+ }
+ }
+
+ public static class SubExactL implements BinaryLongMethod {
+ @Override
+ public long safeMethod(long x, long y) {
+ long r = x - y;
+ // HD 2-12 Overflow iff the arguments have different signs and
+ // the sign of the result is different than the sign of x
+ if (((x ^ y) & (x ^ r)) < 0) {
+ throw new ArithmeticException("integer overflow");
+ }
+ return r;
+ }
+
+ @Override
+ public long checkMethod(long a, long b) {
+ return Math.subtractExact(a, b);
+ }
+
+ @Override
+ public long unchecked(long a, long b) {
+ return a - b;
+ }
+
+ @Override
+ public String name() {
+ return "subtractExactLong";
+ }
}
- try {
- result2 = testNonIntrinsic(a, b);
- } catch (ArithmeticException e) {
- exception2 = true;
+
+ static class IncExactL implements UnaryLongMethod {
+ @Override
+ public long safeMethod(long a) {
+ if (a == Long.MAX_VALUE) {
+ throw new ArithmeticException("long overflow");
+ }
+
+ return a + 1L;
+
+ }
+
+ @Override
+ public long checkMethod(long value) {
+ return Math.incrementExact(value);
+ }
+
+ @Override
+ public long unchecked(long value) {
+ return value + 1;
+ }
+
+ @Override
+ public String name() {
+ return "incrementExactLong";
+ }
}
- if (exception1 != exception2) {
- throw new RuntimeException("Intrinsic version " + throwWord(exception1) + " exception, NonIntrinsic version " + throwWord(exception2) + " for: " + a + " + " + b);
+ static class IncExactI implements UnaryMethod {
+ @Override
+ public int safeMethod(int a) {
+ if (a == Integer.MAX_VALUE) {
+ throw new ArithmeticException("integer overflow");
+ }
+
+ return a + 1;
+ }
+
+ @Override
+ public int checkMethod(int value) {
+ return Math.incrementExact(value);
+ }
+
+ @Override
+ public int unchecked(int value) {
+ return value + 1;
+ }
+
+ @Override
+ public String name() {
+ return "incrementExact";
+ }
}
- if (result1 != result2) {
- throw new RuntimeException("Intrinsic version returned: " + a + " while NonIntrinsic version returned: " + b);
+
+ static class DecExactL implements UnaryLongMethod {
+ @Override
+ public long safeMethod(long a) {
+ if (a == Long.MIN_VALUE) {
+ throw new ArithmeticException("long overflow");
+ }
+
+ return a - 1L;
+ }
+
+ @Override
+ public long checkMethod(long value) {
+ return Math.decrementExact(value);
+ }
+
+ @Override
+ public long unchecked(long value) {
+ return value - 1;
+ }
+
+ @Override
+ public String name() {
+ return "decExactLong";
+ }
}
- }
- public static int testIntrinsic(int a, int b) {
- return java.lang.Math.addExact(a, b);
- }
+ static class DecExactI implements UnaryMethod {
+ @Override
+ public int safeMethod(int a) {
+ if (a == Integer.MIN_VALUE) {
+ throw new ArithmeticException("integer overflow");
+ }
+
+ return a - 1;
+ }
- public static int testNonIntrinsic(int a, int b) {
- return safeAddExact(a, b);
- }
+ @Override
+ public int checkMethod(int value) {
+ return Math.decrementExact(value);
+ }
- // Copied java.lang.Math.addExact to avoid intrinsification
- public static int safeAddExact(int x, int y) {
- int r = x + y;
- // HD 2-12 Overflow iff both arguments have the opposite sign of the result
- if (((x ^ r) & (y ^ r)) < 0) {
- throw new ArithmeticException("integer overflow");
+ @Override
+ public int unchecked(int value) {
+ return value - 1;
+ }
+
+ @Override
+ public String name() {
+ return "decrementExact";
+ }
}
- return r;
- }
+
}