hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/CompilationTask.java
changeset 46459 7d4e637d3f21
parent 46371 0337d0617e7b
child 46536 79d8dffda212
--- a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/CompilationTask.java	Fri May 12 13:14:25 2017 -0700
+++ b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/CompilationTask.java	Fri May 12 13:56:13 2017 -0700
@@ -30,20 +30,8 @@
 import static org.graalvm.compiler.core.GraalCompilerOptions.PrintFilter;
 import static org.graalvm.compiler.core.GraalCompilerOptions.PrintStackTraceOnException;
 import static org.graalvm.compiler.core.phases.HighTier.Options.Inline;
-import static org.graalvm.compiler.debug.Debug.INFO_LEVEL;
-import static org.graalvm.compiler.debug.DelegatingDebugConfig.Feature.DUMP_METHOD;
-import static org.graalvm.compiler.debug.DelegatingDebugConfig.Level.DUMP;
-import static org.graalvm.compiler.debug.GraalDebugConfig.Options.Dump;
-import static org.graalvm.compiler.debug.GraalDebugConfig.Options.DumpPath;
-import static org.graalvm.compiler.debug.GraalDebugConfig.Options.ForceDebugEnable;
-import static org.graalvm.compiler.debug.GraalDebugConfig.Options.PrintCFGFileName;
-import static org.graalvm.compiler.debug.GraalDebugConfig.Options.PrintGraphFile;
-import static org.graalvm.compiler.debug.GraalDebugConfig.Options.PrintGraphFileName;
 import static org.graalvm.compiler.java.BytecodeParserOptions.InlineDuringParsing;
 
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 
 import org.graalvm.compiler.code.CompilationResult;
@@ -51,9 +39,7 @@
 import org.graalvm.compiler.debug.Debug.Scope;
 import org.graalvm.compiler.debug.DebugCloseable;
 import org.graalvm.compiler.debug.DebugCounter;
-import org.graalvm.compiler.debug.DebugDumpHandler;
 import org.graalvm.compiler.debug.DebugDumpScope;
-import org.graalvm.compiler.debug.DebugRetryableTask;
 import org.graalvm.compiler.debug.DebugTimer;
 import org.graalvm.compiler.debug.GraalError;
 import org.graalvm.compiler.debug.Management;
@@ -61,7 +47,6 @@
 import org.graalvm.compiler.debug.TimeSource;
 import org.graalvm.compiler.options.OptionKey;
 import org.graalvm.compiler.options.OptionValues;
-import org.graalvm.compiler.printer.GraalDebugConfigCustomizer;
 import org.graalvm.util.EconomicMap;
 
 import jdk.vm.ci.code.BailoutException;
@@ -77,8 +62,6 @@
 import jdk.vm.ci.runtime.JVMCICompiler;
 import jdk.vm.ci.services.JVMCIServiceLocator;
 
-//JaCoCo Exclude
-
 public class CompilationTask {
 
     private static final DebugCounter BAILOUTS = Debug.counter("Bailouts");
@@ -112,14 +95,20 @@
     private final boolean useProfilingInfo;
     private final OptionValues options;
 
-    final class RetryableCompilation extends DebugRetryableTask<HotSpotCompilationRequestResult> {
+    final class RetryableCompilation extends HotSpotRetryableCompilation<HotSpotCompilationRequestResult> {
         private final EventProvider.CompilationEvent compilationEvent;
         CompilationResult result;
 
         RetryableCompilation(EventProvider.CompilationEvent compilationEvent) {
+            super(compiler.getGraalRuntime(), options);
             this.compilationEvent = compilationEvent;
         }
 
+        @Override
+        public String toString() {
+            return getMethod().format("%H.%n");
+        }
+
         @SuppressWarnings("try")
         @Override
         protected HotSpotCompilationRequestResult run(Throwable retryCause) {
@@ -150,6 +139,9 @@
                 compilationEvent.begin();
                 result = compiler.compile(method, entryBCI, useProfilingInfo, compilationId, options);
             } catch (Throwable e) {
+                if (retryCause != null) {
+                    log("Exception during retry", e);
+                }
                 throw Debug.handle(e);
             } finally {
                 // End the compilation event.
@@ -185,61 +177,6 @@
             }
             return null;
         }
-
-        @Override
-        protected boolean onRetry(Throwable t) {
-            if (t instanceof BailoutException) {
-                return false;
-            }
-
-            if (!Debug.isEnabled()) {
-                TTY.printf("Error while processing %s.%nRe-run with -D%s%s=true to capture graph dumps upon a compilation failure.%n", CompilationTask.this,
-                                HotSpotGraalOptionValues.GRAAL_OPTION_PROPERTY_PREFIX, ForceDebugEnable.getName());
-                return false;
-            }
-
-            if (Dump.hasBeenSet(options)) {
-                // If dumping is explicitly enabled, Graal is being debugged
-                // so don't interfere with what the user is expecting to see.
-                return false;
-            }
-
-            String outputDirectory = compiler.getGraalRuntime().getOutputDirectory();
-            if (outputDirectory == null) {
-                return false;
-            }
-            String methodFQN = getMethod().format("%H.%n");
-            File dumpPath = new File(outputDirectory, methodFQN);
-            dumpPath.mkdirs();
-            if (!dumpPath.exists()) {
-                TTY.println("Warning: could not create dump directory " + dumpPath);
-                return false;
-            }
-
-            TTY.println("Retrying " + CompilationTask.this);
-            retryDumpHandlers = new ArrayList<>();
-            retryOptions = new OptionValues(options,
-                            PrintGraphFile, true,
-                            PrintCFGFileName, methodFQN,
-                            PrintGraphFileName, methodFQN,
-                            DumpPath, dumpPath.getPath());
-            override(DUMP, INFO_LEVEL).enable(DUMP_METHOD);
-            new GraalDebugConfigCustomizer().customize(this);
-            return true;
-        }
-
-        private Collection<DebugDumpHandler> retryDumpHandlers;
-        private OptionValues retryOptions;
-
-        @Override
-        public Collection<DebugDumpHandler> dumpHandlers() {
-            return retryDumpHandlers;
-        }
-
-        @Override
-        public OptionValues getOptions() {
-            return retryOptions;
-        }
     }
 
     static class Lazy {