< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.printer/src/org/graalvm/compiler/printer/GraphPrinterDumpHandler.java
Print this page
*** 50,61 ****
import jdk.vm.ci.meta.ResolvedJavaMethod;
//JaCoCo Exclude
/**
! * Observes compilation events and uses {@link IdealGraphPrinter} to generate a graph representation
! * that can be inspected with the Graph Visualizer.
*/
public class GraphPrinterDumpHandler implements DebugDumpHandler {
private static final int FAILURE_LIMIT = 8;
private final GraphPrinterSupplier printerSupplier;
--- 50,61 ----
import jdk.vm.ci.meta.ResolvedJavaMethod;
//JaCoCo Exclude
/**
! * Observes compilation events and uses {@link BinaryGraphPrinter} to generate a graph
! * representation that can be inspected with the Graph Visualizer.
*/
public class GraphPrinterDumpHandler implements DebugDumpHandler {
private static final int FAILURE_LIMIT = 8;
private final GraphPrinterSupplier printerSupplier;
*** 67,77 ****
private final String jvmArguments;
private final String sunJavaCommand;
@FunctionalInterface
public interface GraphPrinterSupplier {
! GraphPrinter get(Graph graph) throws IOException;
}
/**
* Creates a new {@link GraphPrinterDumpHandler}.
*
--- 67,77 ----
private final String jvmArguments;
private final String sunJavaCommand;
@FunctionalInterface
public interface GraphPrinterSupplier {
! GraphPrinter get(DebugContext ctx, Graph graph) throws IOException;
}
/**
* Creates a new {@link GraphPrinterDumpHandler}.
*
*** 91,110 ****
} catch (LinkageError err) {
return "unknown";
}
}
! private void ensureInitialized(Graph graph) {
if (printer == null) {
if (failuresCount >= FAILURE_LIMIT) {
return;
}
previousInlineContext = new ArrayList<>();
inlineContextMap = new WeakHashMap<>();
DebugContext debug = graph.getDebug();
try {
! printer = printerSupplier.get(graph);
} catch (IOException e) {
handleException(debug, e);
}
}
}
--- 91,110 ----
} catch (LinkageError err) {
return "unknown";
}
}
! private void ensureInitialized(DebugContext ctx, Graph graph) {
if (printer == null) {
if (failuresCount >= FAILURE_LIMIT) {
return;
}
previousInlineContext = new ArrayList<>();
inlineContextMap = new WeakHashMap<>();
DebugContext debug = graph.getDebug();
try {
! printer = printerSupplier.get(ctx, graph);
} catch (IOException e) {
handleException(debug, e);
}
}
}
*** 121,131 ****
@SuppressWarnings("try")
public void dump(DebugContext debug, Object object, final String format, Object... arguments) {
OptionValues options = debug.getOptions();
if (object instanceof Graph && DebugOptions.PrintGraph.getValue(options)) {
final Graph graph = (Graph) object;
! ensureInitialized(graph);
if (printer == null) {
return;
}
// Get all current JavaMethod instances in the context.
--- 121,131 ----
@SuppressWarnings("try")
public void dump(DebugContext debug, Object object, final String format, Object... arguments) {
OptionValues options = debug.getOptions();
if (object instanceof Graph && DebugOptions.PrintGraph.getValue(options)) {
final Graph graph = (Graph) object;
! ensureInitialized(debug, graph);
if (printer == null) {
return;
}
// Get all current JavaMethod instances in the context.
*** 166,180 ****
}
// Save inline context for next dump.
previousInlineContext = inlineContext;
try (DebugContext.Scope s = debug.sandbox("PrintingGraph", null)) {
// Finally, output the graph.
Map<Object, Object> properties = new HashMap<>();
properties.put("graph", graph.toString());
! properties.put("scope", debug.getCurrentScopeName());
if (graph instanceof StructuredGraph) {
properties.put("compilationIdentifier", ((StructuredGraph) graph).compilationId());
try {
int size = NodeCostUtil.computeGraphSize((StructuredGraph) graph);
properties.put("node-cost graph size", size);
--- 166,182 ----
}
// Save inline context for next dump.
previousInlineContext = inlineContext;
+ // Capture before creating the sandbox
+ String currentScopeName = debug.getCurrentScopeName();
try (DebugContext.Scope s = debug.sandbox("PrintingGraph", null)) {
// Finally, output the graph.
Map<Object, Object> properties = new HashMap<>();
properties.put("graph", graph.toString());
! properties.put("scope", currentScopeName);
if (graph instanceof StructuredGraph) {
properties.put("compilationIdentifier", ((StructuredGraph) graph).compilationId());
try {
int size = NodeCostUtil.computeGraphSize((StructuredGraph) graph);
properties.put("node-cost graph size", size);
< prev index next >