src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.printer/src/org/graalvm/compiler/printer/GraphPrinterDumpHandler.java
--- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.printer/src/org/graalvm/compiler/printer/GraphPrinterDumpHandler.java Thu Oct 17 20:27:44 2019 +0100
+++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.printer/src/org/graalvm/compiler/printer/GraphPrinterDumpHandler.java Thu Oct 17 20:53:35 2019 +0100
@@ -37,13 +37,14 @@
import java.util.Map;
import java.util.WeakHashMap;
+import org.graalvm.compiler.core.common.CompilationIdentifier;
import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.debug.DebugDumpHandler;
import org.graalvm.compiler.debug.DebugDumpScope;
import org.graalvm.compiler.debug.DebugOptions;
+import org.graalvm.compiler.debug.DebugOptions.PrintGraphTarget;
import org.graalvm.compiler.debug.GraalError;
import org.graalvm.compiler.debug.TTY;
-import org.graalvm.compiler.debug.DebugOptions.PrintGraphTarget;
import org.graalvm.compiler.graph.Graph;
import org.graalvm.compiler.nodes.StructuredGraph;
import org.graalvm.compiler.options.OptionValues;
@@ -66,6 +67,7 @@
private final GraphPrinterSupplier printerSupplier;
protected GraphPrinter printer;
private List<String> previousInlineContext;
+ private CompilationIdentifier previousCompilationID = CompilationIdentifier.INVALID_COMPILATION_ID;
private int[] dumpIds = {};
private int failuresCount;
private Map<Graph, List<String>> inlineContextMap;
@@ -136,36 +138,42 @@
// Get all current JavaMethod instances in the context.
List<String> inlineContext = getInlineContext(graph);
- if (inlineContext != previousInlineContext) {
+ if (graph instanceof StructuredGraph) {
+ CompilationIdentifier compilationID = ((StructuredGraph) graph).compilationId();
+ // If the graph to be dumped is with an invalid compilation id, it is likely derived
+ // from inlining.
+ if (compilationID != CompilationIdentifier.INVALID_COMPILATION_ID) {
+ if (previousCompilationID != CompilationIdentifier.INVALID_COMPILATION_ID && !compilationID.equals(previousCompilationID)) {
+ // Compilation ID does not match, close existing scopes.
+ for (int inlineDepth = previousInlineContext.size() - 1; inlineDepth >= 0; --inlineDepth) {
+ closeScope(debug, inlineDepth);
+ }
+ previousInlineContext = new ArrayList<>();
+ }
+ previousCompilationID = compilationID;
+ }
+ }
+
+ if (!inlineContext.equals(previousInlineContext)) {
Map<Object, Object> properties = new HashMap<>();
properties.put("graph", graph.toString());
addCompilationId(properties, graph);
- if (inlineContext.equals(previousInlineContext)) {
- /*
- * two different graphs have the same inline context, so make sure they appear
- * in different folders by closing and reopening the top scope.
- */
- int inlineDepth = previousInlineContext.size() - 1;
- closeScope(debug, inlineDepth);
- openScope(debug, inlineContext.get(inlineDepth), inlineDepth, properties);
- } else {
- // Check for method scopes that must be closed since the previous dump.
- for (int i = 0; i < previousInlineContext.size(); ++i) {
- if (i >= inlineContext.size() || !inlineContext.get(i).equals(previousInlineContext.get(i))) {
- for (int inlineDepth = previousInlineContext.size() - 1; inlineDepth >= i; --inlineDepth) {
- closeScope(debug, inlineDepth);
- }
- break;
+ // Check for method scopes that must be closed since the previous dump.
+ for (int i = 0; i < previousInlineContext.size(); ++i) {
+ if (i >= inlineContext.size() || !inlineContext.get(i).equals(previousInlineContext.get(i))) {
+ for (int inlineDepth = previousInlineContext.size() - 1; inlineDepth >= i; --inlineDepth) {
+ closeScope(debug, inlineDepth);
}
+ break;
}
- // Check for method scopes that must be opened since the previous dump.
- for (int i = 0; i < inlineContext.size(); ++i) {
- if (i >= previousInlineContext.size() || !inlineContext.get(i).equals(previousInlineContext.get(i))) {
- for (int inlineDepth = i; inlineDepth < inlineContext.size(); ++inlineDepth) {
- openScope(debug, inlineContext.get(inlineDepth), inlineDepth, inlineDepth == inlineContext.size() - 1 ? properties : null);
- }
- break;
+ }
+ // Check for method scopes that must be opened since the previous dump.
+ for (int i = 0; i < inlineContext.size(); ++i) {
+ if (i >= previousInlineContext.size() || !inlineContext.get(i).equals(previousInlineContext.get(i))) {
+ for (int inlineDepth = i; inlineDepth < inlineContext.size(); ++inlineDepth) {
+ openScope(debug, inlineContext.get(inlineDepth), inlineDepth, inlineDepth == inlineContext.size() - 1 ? properties : null);
}
+ break;
}
}
}