8217678: [AOT] jck Math/IncrementExact and Math/DecrementExact tests fail when test classes are AOTed
Reviewed-by: kvn
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements.test/src/org/graalvm/compiler/replacements/test/IntegerExactExceptionTest.java Wed Jan 23 16:36:45 2019 -0800
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements.test/src/org/graalvm/compiler/replacements/test/IntegerExactExceptionTest.java Wed Jan 23 16:57:01 2019 -0800
@@ -98,6 +98,10 @@
}
}
+ public void testIntegerExactOverflowWithoutUse3() {
+ Math.addExact(Integer.MAX_VALUE, 1);
+ }
+
@Test
public void testIntegerExactWithoutUse1() throws InvalidInstalledCodeException {
ResolvedJavaMethod method = getResolvedJavaMethod("testIntegerExactOverflowWithoutUse1");
@@ -126,6 +130,20 @@
assertTrue(gotException);
}
+ @Test
+ public void testIntegerExactWithoutUse3() throws InvalidInstalledCodeException {
+ ResolvedJavaMethod method = getResolvedJavaMethod("testIntegerExactOverflowWithoutUse3");
+ InstalledCode code = getCode(method);
+
+ boolean gotException = false;
+ try {
+ code.executeVarargs(this);
+ } catch (ArithmeticException e) {
+ gotException = true;
+ }
+ assertTrue(gotException);
+ }
+
static long longCounter = 10;
public void testLongExactOverflowSnippet(long input) {
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/StandardGraphBuilderPlugins.java Wed Jan 23 16:36:45 2019 -0800
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/StandardGraphBuilderPlugins.java Wed Jan 23 16:57:01 2019 -0800
@@ -560,19 +560,14 @@
}
private static boolean createIntegerExactOperation(GraphBuilderContext b, JavaKind kind, ValueNode x, ValueNode y, IntegerExactOp op) {
- if (x.isConstant() && y.isConstant()) {
- b.addPush(kind, createIntegerExactArithmeticNode(x, y, null, op));
+ BytecodeExceptionKind exceptionKind = kind == JavaKind.Int ? BytecodeExceptionKind.INTEGER_EXACT_OVERFLOW : BytecodeExceptionKind.LONG_EXACT_OVERFLOW;
+ AbstractBeginNode exceptionEdge = b.genExplicitExceptionEdge(exceptionKind);
+ if (exceptionEdge != null) {
+ IntegerExactArithmeticSplitNode split = b.addPush(kind, createIntegerExactSplit(x, y, exceptionEdge, op));
+ split.setNext(b.add(new BeginNode()));
return true;
- } else {
- BytecodeExceptionKind exceptionKind = kind == JavaKind.Int ? BytecodeExceptionKind.INTEGER_EXACT_OVERFLOW : BytecodeExceptionKind.LONG_EXACT_OVERFLOW;
- AbstractBeginNode exceptionEdge = b.genExplicitExceptionEdge(exceptionKind);
- if (exceptionEdge != null) {
- IntegerExactArithmeticSplitNode split = b.addPush(kind, createIntegerExactSplit(x, y, exceptionEdge, op));
- split.setNext(b.add(new BeginNode()));
- return true;
- }
- return false;
}
+ return false;
}
private static void registerMathPlugins(InvocationPlugins plugins, boolean allowDeoptimization) {