src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotRetryableCompilation.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Cdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotRetryableCompilation.java

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotRetryableCompilation.java

Print this page

        

*** 20,136 **** * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.compiler.hotspot; ! import static org.graalvm.compiler.debug.Debug.VERBOSE_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.PrintGraphFileName; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; - import java.nio.file.InvalidPathException; - import java.nio.file.Paths; - import java.util.ArrayList; - import java.util.Collection; ! import org.graalvm.compiler.debug.Debug; ! import org.graalvm.compiler.debug.DebugDumpHandler; import org.graalvm.compiler.debug.DebugRetryableTask; import org.graalvm.compiler.debug.TTY; import org.graalvm.compiler.options.OptionValues; ! import org.graalvm.compiler.printer.GraalDebugConfigCustomizer; import jdk.vm.ci.code.BailoutException; /** * Utility for retrying a compilation that throws an exception where the retry enables extra logging * for subsequently diagnosing the failure. */ public abstract class HotSpotRetryableCompilation<T> extends DebugRetryableTask<T> { - protected final OptionValues originalOptions; protected final HotSpotGraalRuntimeProvider runtime; ! public HotSpotRetryableCompilation(HotSpotGraalRuntimeProvider runtime, OptionValues options) { this.runtime = runtime; - this.originalOptions = options; } /** * Gets a value that represents the compilation unit being compiled. */ @Override public abstract String toString(); - private static String sanitizedFileName(String name) { - StringBuilder buf = new StringBuilder(name.length()); - for (int i = 0; i < name.length(); i++) { - char c = name.charAt(i); - try { - Paths.get(String.valueOf(c)); - } catch (InvalidPathException e) { - buf.append('_'); - } - buf.append(c); - } - return buf.toString(); - } - @Override ! protected boolean onRetry(Throwable t) { if (t instanceof BailoutException) { ! return false; ! } ! ! if (!Debug.isEnabled()) { ! TTY.printf("Error while compiling %s due to %s.%nRe-run with -D%s%s=true to capture graph dumps upon a compilation failure.%n", this, ! t, HotSpotGraalOptionValues.GRAAL_OPTION_PROPERTY_PREFIX, ForceDebugEnable.getName()); ! return false; } ! if (Dump.hasBeenSet(originalOptions)) { // 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 = runtime.getOutputDirectory(); if (outputDirectory == null) { ! return false; } ! String dumpName = sanitizedFileName(toString()); File dumpPath = new File(outputDirectory, dumpName); dumpPath.mkdirs(); if (!dumpPath.exists()) { TTY.println("Warning: could not create dump directory " + dumpPath); ! return false; } TTY.println("Retrying compilation of " + this + " due to " + t); retryLogPath = new File(dumpPath, "retry.log").getPath(); log("Exception causing retry", t); ! retryDumpHandlers = new ArrayList<>(); ! retryOptions = new OptionValues(originalOptions, ! PrintCFGFileName, dumpName, ! PrintGraphFileName, dumpName, DumpPath, dumpPath.getPath()); ! override(DUMP, VERBOSE_LEVEL).enable(DUMP_METHOD); ! new GraalDebugConfigCustomizer().customize(this); ! return true; } - private Collection<DebugDumpHandler> retryDumpHandlers; - private OptionValues retryOptions; private String retryLogPath; /** * Prints a message to a retry log file. * --- 20,103 ---- * or visit www.oracle.com if you need additional information or have any * questions. */ package org.graalvm.compiler.hotspot; ! import static org.graalvm.compiler.debug.DebugContext.VERBOSE_LEVEL; ! import static org.graalvm.compiler.debug.DebugOptions.Dump; ! import static org.graalvm.compiler.debug.DebugOptions.DumpPath; ! import static org.graalvm.compiler.debug.DebugOptions.MethodFilter; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; ! import org.graalvm.compiler.api.replacements.SnippetReflectionProvider; ! import org.graalvm.compiler.debug.DebugContext; import org.graalvm.compiler.debug.DebugRetryableTask; import org.graalvm.compiler.debug.TTY; import org.graalvm.compiler.options.OptionValues; ! import org.graalvm.compiler.printer.GraalDebugHandlersFactory; import jdk.vm.ci.code.BailoutException; /** * Utility for retrying a compilation that throws an exception where the retry enables extra logging * for subsequently diagnosing the failure. */ public abstract class HotSpotRetryableCompilation<T> extends DebugRetryableTask<T> { protected final HotSpotGraalRuntimeProvider runtime; ! public HotSpotRetryableCompilation(HotSpotGraalRuntimeProvider runtime) { this.runtime = runtime; } /** * Gets a value that represents the compilation unit being compiled. */ @Override public abstract String toString(); @Override ! protected DebugContext getRetryContext(DebugContext initialDebug, Throwable t) { if (t instanceof BailoutException) { ! return null; } ! OptionValues initialOptions = initialDebug.getOptions(); ! if (Dump.hasBeenSet(initialOptions)) { // If dumping is explicitly enabled, Graal is being debugged // so don't interfere with what the user is expecting to see. ! return null; } String outputDirectory = runtime.getOutputDirectory(); if (outputDirectory == null) { ! return null; } ! String dumpName = GraalDebugHandlersFactory.sanitizedFileName(toString()); File dumpPath = new File(outputDirectory, dumpName); dumpPath.mkdirs(); if (!dumpPath.exists()) { TTY.println("Warning: could not create dump directory " + dumpPath); ! return null; } TTY.println("Retrying compilation of " + this + " due to " + t); retryLogPath = new File(dumpPath, "retry.log").getPath(); log("Exception causing retry", t); ! OptionValues retryOptions = new OptionValues(initialOptions, ! Dump, ":" + VERBOSE_LEVEL, ! MethodFilter, null, DumpPath, dumpPath.getPath()); ! SnippetReflectionProvider snippetReflection = runtime.getHostProviders().getSnippetReflection(); ! return DebugContext.create(retryOptions, new GraalDebugHandlersFactory(snippetReflection)); } private String retryLogPath; /** * Prints a message to a retry log file. *
*** 151,166 **** } catch (FileNotFoundException e) { TTY.println("Warning: could not open retry log file " + retryLogPath + " [" + e + "]"); } } } - - @Override - public Collection<DebugDumpHandler> dumpHandlers() { - return retryDumpHandlers; - } - - @Override - public OptionValues getOptions() { - return retryOptions; - } } --- 118,123 ----
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotRetryableCompilation.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File