changeset 59131:2ca886fd1d52

8230402: Allocation of compile task fails with assert: "Leaking compilation tasks?" Summary: Remove assert that is only hit with hand written edge case tests. Reviewed-by: kvn, thartmann
author chagedorn
date Mon, 04 May 2020 10:23:23 +0200
parents 4198213fc371
children c985a2c84933
files src/hotspot/share/compiler/compileTask.cpp src/hotspot/share/compiler/compileTask.hpp test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java
diffstat 3 files changed, 84 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/compiler/compileTask.cpp	Sun May 03 10:00:36 2020 -0400
+++ b/src/hotspot/share/compiler/compileTask.cpp	Mon May 04 10:23:23 2020 +0200
@@ -33,9 +33,6 @@
 #include "runtime/handles.inline.hpp"
 
 CompileTask*  CompileTask::_task_free_list = NULL;
-#ifdef ASSERT
-int CompileTask::_num_allocated_tasks = 0;
-#endif
 
 /**
  * Allocate a CompileTask, from the free list if possible.
@@ -50,8 +47,6 @@
     task->set_next(NULL);
   } else {
     task = new CompileTask();
-    DEBUG_ONLY(_num_allocated_tasks++;)
-    assert (WhiteBoxAPI || JVMCI_ONLY(UseJVMCICompiler ||) _num_allocated_tasks < 10000, "Leaking compilation tasks?");
     task->set_next(NULL);
     task->set_is_free(true);
   }
--- a/src/hotspot/share/compiler/compileTask.hpp	Sun May 03 10:00:36 2020 -0400
+++ b/src/hotspot/share/compiler/compileTask.hpp	Mon May 04 10:23:23 2020 +0200
@@ -75,10 +75,6 @@
 
  private:
   static CompileTask* _task_free_list;
-#ifdef ASSERT
-  static int          _num_allocated_tasks;
-#endif
-
   Monitor*     _lock;
   uint         _compile_id;
   Method*      _method;
--- a/test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java	Sun May 03 10:00:36 2020 -0400
+++ b/test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java	Mon May 04 10:23:23 2020 +0200
@@ -23,12 +23,12 @@
 
 /*
  * @test TestOverloadCompileQueues
- * @bug 8163511
+ * @bug 8163511 8230402
  * @summary Test overloading the C1 and C2 compile queues with tasks.
  * @requires !vm.graal.enabled
- * @run main/othervm -XX:-TieredCompilation -XX:CompileThreshold=2 -XX:CICompilerCount=1
+ * @run main/othervm/timeout=300 -XX:-TieredCompilation -XX:CompileThreshold=2 -XX:CICompilerCount=1
  *                   compiler.classUnloading.methodUnloading.TestOverloadCompileQueues
- * @run main/othervm -XX:TieredCompileTaskTimeout=1000 -XX:CompileThresholdScaling=0.001 -XX:CICompilerCount=2
+ * @run main/othervm/timeout=300 -XX:TieredCompileTaskTimeout=1000 -XX:CompileThresholdScaling=0.001 -XX:CICompilerCount=2
  *                   compiler.classUnloading.methodUnloading.TestOverloadCompileQueues
  */
 
@@ -37,9 +37,13 @@
 import java.lang.reflect.Method;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.util.Arrays;
 
 public class TestOverloadCompileQueues {
     public static final int ITERS = 500; // Increase for longer stress testing
+    public static final int ITERS_A = 1000; // Increase for longer stress testing
+
+    public static int iArr[] = new int[100];
 
     // Some methods to fill up the compile queue
     public static void test0() { }
@@ -63,7 +67,65 @@
     public static void test18() { }
     public static void test19() { }
 
+    // More methods that do some more complex things. Therefore, the compiler needs to spend some more time compiling them.
+    // With 50 methods, a queue size of 10000 is also reached in the second run with TieredCompilation enabled.
+    public static void testA0()  { Arrays.sort(iArr); }
+    public static void testA1()  { Arrays.sort(iArr); }
+    public static void testA2()  { Arrays.sort(iArr); }
+    public static void testA3()  { Arrays.sort(iArr); }
+    public static void testA4()  { Arrays.sort(iArr); }
+    public static void testA5()  { Arrays.sort(iArr); }
+    public static void testA6()  { Arrays.sort(iArr); }
+    public static void testA7()  { Arrays.sort(iArr); }
+    public static void testA8()  { Arrays.sort(iArr); }
+    public static void testA9()  { Arrays.sort(iArr); }
+    public static void testA10() { Arrays.sort(iArr); }
+    public static void testA11() { Arrays.sort(iArr); }
+    public static void testA12() { Arrays.sort(iArr); }
+    public static void testA13() { Arrays.sort(iArr); }
+    public static void testA14() { Arrays.sort(iArr); }
+    public static void testA15() { Arrays.sort(iArr); }
+    public static void testA16() { Arrays.sort(iArr); }
+    public static void testA17() { Arrays.sort(iArr); }
+    public static void testA18() { Arrays.sort(iArr); }
+    public static void testA19() { Arrays.sort(iArr); }
+    public static void testA20() { Arrays.sort(iArr); }
+    public static void testA21() { Arrays.sort(iArr); }
+    public static void testA22() { Arrays.sort(iArr); }
+    public static void testA23() { Arrays.sort(iArr); }
+    public static void testA24() { Arrays.sort(iArr); }
+    public static void testA25() { Arrays.sort(iArr); }
+    public static void testA26() { Arrays.sort(iArr); }
+    public static void testA27() { Arrays.sort(iArr); }
+    public static void testA28() { Arrays.sort(iArr); }
+    public static void testA29() { Arrays.sort(iArr); }
+    public static void testA30() { Arrays.sort(iArr); }
+    public static void testA31() { Arrays.sort(iArr); }
+    public static void testA32() { Arrays.sort(iArr); }
+    public static void testA33() { Arrays.sort(iArr); }
+    public static void testA34() { Arrays.sort(iArr); }
+    public static void testA35() { Arrays.sort(iArr); }
+    public static void testA36() { Arrays.sort(iArr); }
+    public static void testA37() { Arrays.sort(iArr); }
+    public static void testA38() { Arrays.sort(iArr); }
+    public static void testA39() { Arrays.sort(iArr); }
+    public static void testA40() { Arrays.sort(iArr); }
+    public static void testA41() { Arrays.sort(iArr); }
+    public static void testA42() { Arrays.sort(iArr); }
+    public static void testA43() { Arrays.sort(iArr); }
+    public static void testA44() { Arrays.sort(iArr); }
+    public static void testA45() { Arrays.sort(iArr); }
+    public static void testA46() { Arrays.sort(iArr); }
+    public static void testA47() { Arrays.sort(iArr); }
+    public static void testA48() { Arrays.sort(iArr); }
+    public static void testA49() { Arrays.sort(iArr); }
+
     public static void main(String[] args) throws Throwable {
+        run();
+        runA();
+    }
+
+    public static void run() throws Throwable {
         Class<?> thisClass = TestOverloadCompileQueues.class;
         ClassLoader defaultLoader = thisClass.getClassLoader();
         URL classesDir = thisClass.getProtectionDomain().getCodeSource().getLocation();
@@ -84,4 +146,23 @@
             System.gc();
         }
     }
+
+    public static void runA() throws Throwable {
+        Class<?> thisClass = TestOverloadCompileQueues.class;
+        ClassLoader defaultLoader = thisClass.getClassLoader();
+        URL classesDir = thisClass.getProtectionDomain().getCodeSource().getLocation();
+
+        for (int i = 0; i < ITERS_A; ++i) {
+            // Load test class with own class loader
+            URLClassLoader myLoader = URLClassLoader.newInstance(new URL[] {classesDir}, defaultLoader.getParent());
+            Class<?> testClass = Class.forName(thisClass.getCanonicalName(), true, myLoader);
+
+            // Execute all test methods to trigger compilation and fill up compile queue
+            for (int j = 0; j < 50; ++j) {
+                Method method = testClass.getDeclaredMethod("testA" + j);
+                method.invoke(null);
+                method.invoke(null);
+            }
+        }
+    }
 }