changeset 53753:0040f89feb78

8217289: compiler/graalunit/HotspotTest.java failed with InvalidInstalledCodeException Reviewed-by: thartmann, neliasso
author phedlin
date Wed, 13 Feb 2019 14:42:20 +0100
parents e44c436f2447
children bc8fb1fa55b5
files src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/BigIntegerIntrinsicsTest.java test/hotspot/jtreg/ProblemList-graal.txt
diffstat 2 files changed, 30 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/BigIntegerIntrinsicsTest.java	Thu Feb 14 14:31:32 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/BigIntegerIntrinsicsTest.java	Wed Feb 13 14:42:20 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, 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
@@ -21,22 +21,23 @@
  * questions.
  */
 
-
 package org.graalvm.compiler.hotspot.test;
 
+import java.lang.reflect.InvocationTargetException;
 import java.math.BigInteger;
 import java.util.Random;
 
 import org.graalvm.compiler.api.test.Graal;
+import org.graalvm.compiler.core.test.GraalCompilerTest;
 import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig;
 import org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider;
-import org.graalvm.compiler.replacements.test.MethodSubstitutionTest;
 import org.graalvm.compiler.runtime.RuntimeProvider;
 
 import org.junit.Test;
 
 import jdk.vm.ci.amd64.AMD64;
 import jdk.vm.ci.code.InstalledCode;
+import jdk.vm.ci.code.InvalidInstalledCodeException;
 import jdk.vm.ci.meta.ResolvedJavaMethod;
 
 /*
@@ -52,7 +53,7 @@
  * is not tested per se (only execution based on admissible intrinsics).
  *
  */
-public final class BigIntegerIntrinsicsTest extends MethodSubstitutionTest {
+public final class BigIntegerIntrinsicsTest extends GraalCompilerTest {
 
     static final int N = 100;
 
@@ -149,8 +150,8 @@
 
             assertDeepEquals(res1, res2);
 
-            // Invoke BigInteger testMontgomeryAux(BigInteger, BigExp, BigInteger) through code
-            // handle.
+            // Invoke BigInteger testMontgomeryAux(BigInteger, BigExp, BigInteger)
+            // through code handle.
             BigInteger res3 = (BigInteger) tin.invokeCode(big1, bigTwo, big2);
 
             assertDeepEquals(res1, res3);
@@ -168,7 +169,6 @@
     private class TestIntrinsic {
 
         TestIntrinsic(String testmname, Class<?> javaclass, String javamname, Class<?>... params) {
-
             javamethod = getResolvedJavaMethod(javaclass, javamname, params);
             testmethod = getResolvedJavaMethod(testmname);
 
@@ -179,21 +179,39 @@
             testcode = getCode(testmethod);
 
             assert testcode != null;
+            assert testcode.isValid();
         }
 
         Object invokeJava(BigInteger big, Object... args) {
-
             return invokeSafe(javamethod, big, args);
         }
 
         Object invokeTest(Object... args) {
-
             return invokeSafe(testmethod, null, args);
         }
 
         Object invokeCode(Object... args) {
+            try {
+                return testcode.executeVarargs(args);
+            }
+            catch (InvalidInstalledCodeException e) {
+                // Ensure the installed code is valid, possibly recompiled.
+                testcode = getCode(testmethod);
 
-            return executeVarargsSafe(testcode, args);
+                assert testcode != null;
+                assert testcode.isValid();
+
+                return invokeCode(args);
+            }
+        }
+
+        private Object invokeSafe(ResolvedJavaMethod method, Object receiver, Object... args) {
+            try {
+                return invoke(method, receiver, args);
+            } catch (IllegalAccessException   | InvocationTargetException |
+                     IllegalArgumentException | InstantiationException e) {
+                throw new RuntimeException(e);
+            }
         }
 
         // Private data section:
@@ -202,7 +220,8 @@
         private InstalledCode testcode;
     }
 
-    private static GraalHotSpotVMConfig config = ((HotSpotGraalRuntimeProvider) Graal.getRequiredCapability(RuntimeProvider.class)).getVMConfig();
+    private static GraalHotSpotVMConfig config =
+        ((HotSpotGraalRuntimeProvider) Graal.getRequiredCapability(RuntimeProvider.class)).getVMConfig();
 
     private static BigInteger bigTwo = BigInteger.valueOf(2);
     private static Random rnd = new Random(17);
--- a/test/hotspot/jtreg/ProblemList-graal.txt	Thu Feb 14 14:31:32 2019 +0100
+++ b/test/hotspot/jtreg/ProblemList-graal.txt	Wed Feb 13 14:42:20 2019 +0100
@@ -228,6 +228,4 @@
 
 org.graalvm.compiler.replacements.test.StringCompressInflateTest 8214947
 
-org.graalvm.compiler.hotspot.test.BigIntegerIntrinsicsTest       8217289
-
 org.graalvm.compiler.hotspot.test.CheckGraalIntrinsics           8218698