diff --git a/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/truffle/compiler/TruffleCompilerImpl.java b/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/truffle/compiler/TruffleCompilerImpl.java index 515a7bb0a835..ecd1c19f05f8 100644 --- a/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/truffle/compiler/TruffleCompilerImpl.java +++ b/compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/truffle/compiler/TruffleCompilerImpl.java @@ -60,6 +60,7 @@ import org.graalvm.compiler.debug.DebugContext; import org.graalvm.compiler.debug.DebugContext.Builder; import org.graalvm.compiler.debug.DebugContext.Scope; +import org.graalvm.compiler.debug.DebugDumpScope; import org.graalvm.compiler.debug.DiagnosticsOutputDirectory; import org.graalvm.compiler.debug.GraalError; import org.graalvm.compiler.debug.Indent; @@ -540,6 +541,9 @@ private StructuredGraph truffleTier(TruffleCompilationWrapper wrapper, DebugCont wrapper.compilationId, TruffleTierContext.getSpeculationLog(wrapper), wrapper.task, handler); + // Save the graph so it can dumped into the graal_diagnostics zip + wrapper.graph = context.graph; + try (Scope s = context.debug.scope("CreateGraph", context.graph); Indent indent = context.debug.logAndIndent("evaluate %s", context.graph);) { truffleTier.apply(context.graph, context); @@ -676,6 +680,7 @@ final class TruffleCompilationWrapper extends CompilationWrapper { final CompilationIdentifier compilationId; final ExpansionStatistics statistics; final OptionValues compilerOptions; + StructuredGraph graph; boolean silent; private TruffleCompilationWrapper( @@ -700,6 +705,18 @@ public String toString() { return compilable.toString(); } + @SuppressWarnings("try") + @Override + protected void dumpOnError(DebugContext errorContext, Throwable cause) { + if (graph != null) { + try (DebugContext.Scope s = errorContext.scope("DumpOnError", graph, compilationId, new DebugDumpScope("Original failure"))) { + errorContext.forceDump(graph, "Exception: %s", cause); + } catch (Throwable t) { + throw errorContext.handle(t); + } + } + } + @Override protected ExceptionAction lookupAction(OptionValues options, Throwable cause) { // Respect current action if it has been explicitly set.