< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.printer/src/org/graalvm/compiler/printer/CanonicalStringGraphPrinter.java
Print this page
*** 24,34 ****
import static org.graalvm.compiler.debug.DebugOptions.CanonicalGraphStringsCheckConstants;
import static org.graalvm.compiler.debug.DebugOptions.CanonicalGraphStringsExcludeVirtuals;
import static org.graalvm.compiler.debug.DebugOptions.CanonicalGraphStringsRemoveIdentities;
import static org.graalvm.compiler.debug.DebugOptions.PrintCanonicalGraphStringFlavor;
- import static org.graalvm.compiler.printer.GraalDebugHandlersFactory.sanitizedFileName;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
--- 24,33 ----
*** 42,51 ****
--- 41,51 ----
import java.util.regex.Pattern;
import org.graalvm.compiler.api.replacements.SnippetReflectionProvider;
import org.graalvm.compiler.core.common.Fields;
import org.graalvm.compiler.debug.DebugContext;
+ import org.graalvm.compiler.debug.PathUtilities;
import org.graalvm.compiler.graph.Graph;
import org.graalvm.compiler.graph.Node;
import org.graalvm.compiler.graph.NodeMap;
import org.graalvm.compiler.graph.Position;
import org.graalvm.compiler.nodeinfo.Verbosity;
*** 258,284 ****
}
private StructuredGraph currentGraph;
private Path currentDirectory;
! private Path getDirectory(StructuredGraph graph) throws IOException {
if (graph == currentGraph) {
return currentDirectory;
}
! currentDirectory = GraalDebugHandlersFactory.createDumpPath(graph.getOptions(), graph, "graph-strings", true);
currentGraph = graph;
return currentDirectory;
}
@Override
public void print(DebugContext debug, Graph graph, Map<Object, Object> properties, int id, String format, Object... args) throws IOException {
if (graph instanceof StructuredGraph) {
OptionValues options = graph.getOptions();
StructuredGraph structuredGraph = (StructuredGraph) graph;
! Path outDirectory = getDirectory(structuredGraph);
String title = String.format("%03d-%s.txt", id, String.format(format, simplifyClassArgs(args)));
! Path filePath = outDirectory.resolve(sanitizedFileName(title));
try (PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(filePath.toFile())))) {
switch (PrintCanonicalGraphStringFlavor.getValue(options)) {
case 1:
writeCanonicalExpressionCFGString(structuredGraph, CanonicalGraphStringsCheckConstants.getValue(options), CanonicalGraphStringsRemoveIdentities.getValue(options), writer);
break;
--- 258,284 ----
}
private StructuredGraph currentGraph;
private Path currentDirectory;
! private Path getDirectory(DebugContext debug, StructuredGraph graph) {
if (graph == currentGraph) {
return currentDirectory;
}
! currentDirectory = debug.getDumpPath(".graph-strings", true);
currentGraph = graph;
return currentDirectory;
}
@Override
public void print(DebugContext debug, Graph graph, Map<Object, Object> properties, int id, String format, Object... args) throws IOException {
if (graph instanceof StructuredGraph) {
OptionValues options = graph.getOptions();
StructuredGraph structuredGraph = (StructuredGraph) graph;
! Path outDirectory = getDirectory(debug, structuredGraph);
String title = String.format("%03d-%s.txt", id, String.format(format, simplifyClassArgs(args)));
! Path filePath = outDirectory.resolve(PathUtilities.sanitizeFileName(title));
try (PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(filePath.toFile())))) {
switch (PrintCanonicalGraphStringFlavor.getValue(options)) {
case 1:
writeCanonicalExpressionCFGString(structuredGraph, CanonicalGraphStringsCheckConstants.getValue(options), CanonicalGraphStringsRemoveIdentities.getValue(options), writer);
break;
< prev index next >