changeset 5367:7cf71c7961c6

if -G:Dump option is used, the compiler queues are given 5 seconds to finish any pending tasks (including graph dumping) before the VM exits
author Doug Simon <doug.simon@oracle.com>
date Wed, 09 May 2012 16:21:03 +0200
parents 67e63e8dcbd2
children a4218dd1b157
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java
diffstat 1 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Tue May 08 22:51:36 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Wed May 09 16:21:03 2012 +0200
@@ -160,8 +160,6 @@
         }
     }
 
-
-
     /**
      * This method is the first method compiled during bootstrapping. Put any code in there that warms up compiler paths
      * that are otherwise not exercised during bootstrapping and lead to later deoptimization when application code is
@@ -237,18 +235,27 @@
         compileMethod((HotSpotMethodResolved) riMethod, 0, false, 10);
     }
 
+    private static void shutdownCompileQueue(ThreadPoolExecutor queue) throws InterruptedException {
+        if (queue != null) {
+            queue.shutdown();
+            if (Debug.isEnabled() && GraalOptions.Dump != null) {
+                // Wait 5 seconds to try and flush out all graph dumps
+                queue.awaitTermination(5, TimeUnit.SECONDS);
+            }
+        }
+    }
+
     public void shutdownCompiler() throws Throwable {
         try {
             assert !CompilationTask.withinEnqueue.get();
             CompilationTask.withinEnqueue.set(Boolean.TRUE);
-            compileQueue.shutdown();
-            if (slowCompileQueue != null) {
-                slowCompileQueue.shutdown();
-            }
+            shutdownCompileQueue(compileQueue);
+            shutdownCompileQueue(slowCompileQueue);
         } finally {
             CompilationTask.withinEnqueue.set(Boolean.FALSE);
         }
 
+
         if (Debug.isEnabled()) {
             List<DebugValueMap> topLevelMaps = DebugValueMap.getTopLevelMaps();
             List<DebugValue> debugValues = KeyRegistry.getDebugValues();