annotate graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java @ 21780:3d15183f3c93

Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Wed, 03 Jun 2015 15:47:54 +0200
parents d71b0cbe7016
children 0e095e2c24e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
1 /*
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
4 *
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
7 * published by the Free Software Foundation.
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
8 *
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
13 * accompanied this code).
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
14 *
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
18 *
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
21 * questions.
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
22 */
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
23 package com.oracle.graal.printer;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
24
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
25 import com.oracle.jvmci.meta.ResolvedJavaMethod;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
26 import com.oracle.jvmci.meta.JavaMethod;
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21666
diff changeset
27
15259
d90e5c22ba55 Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 14981
diff changeset
28 import static com.oracle.graal.compiler.common.GraalOptions.*;
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21666
diff changeset
29 import static com.oracle.jvmci.debug.JVMCIDebugConfig.*;
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9650
diff changeset
30
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
31 import java.io.*;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
32 import java.net.*;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
33 import java.nio.channels.*;
5819
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5817
diff changeset
34 import java.nio.file.*;
5815
272f9da7ce78 Put Binary and xml dumpers behing a common interface and use the same dumphandler for them
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
35 import java.text.*;
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
36 import java.util.*;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
37
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
38 import com.oracle.graal.graph.*;
7869
cb7bab0fd666 use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents: 7785
diff changeset
39 import com.oracle.graal.phases.schedule.*;
21554
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 18886
diff changeset
40 import com.oracle.jvmci.debug.*;
b1530a6cce8c renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 18886
diff changeset
41 import com.oracle.jvmci.debug.Debug.Scope;
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
42
21666
d71b0cbe7016 Add JaCoCo Exclude to GraphPrinterDumpHandler and BenchmarkCounters (problems with CheckGraalInvariants).
Josef Eisl <josef.eisl@jku.at>
parents: 21556
diff changeset
43 //JaCoCo Exclude
d71b0cbe7016 Add JaCoCo Exclude to GraphPrinterDumpHandler and BenchmarkCounters (problems with CheckGraalInvariants).
Josef Eisl <josef.eisl@jku.at>
parents: 21556
diff changeset
44
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
45 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7153
diff changeset
46 * Observes compilation events and uses {@link IdealGraphPrinter} to generate a graph representation
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7153
diff changeset
47 * that can be inspected with the <a href="http://kenai.com/projects/igv">Ideal Graph
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7153
diff changeset
48 * Visualizer</a>.
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
49 */
5815
272f9da7ce78 Put Binary and xml dumpers behing a common interface and use the same dumphandler for them
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
50 public class GraphPrinterDumpHandler implements DebugDumpHandler {
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
51
13145
3e5555577ebc improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10727
diff changeset
52 protected GraphPrinter printer;
5817
74eb5feba8dc Make sure the right port is used for dumping
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5815
diff changeset
53 private List<String> previousInlineContext;
10711
68d4d5457546 add sequential id prefixes to IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
54 private int[] dumpIds = {};
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
55 private int failuresCount;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
56
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
57 /**
5817
74eb5feba8dc Make sure the right port is used for dumping
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5815
diff changeset
58 * Creates a new {@link GraphPrinterDumpHandler}.
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
59 */
5815
272f9da7ce78 Put Binary and xml dumpers behing a common interface and use the same dumphandler for them
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
60 public GraphPrinterDumpHandler() {
5817
74eb5feba8dc Make sure the right port is used for dumping
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5815
diff changeset
61 previousInlineContext = new ArrayList<>();
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
62 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
63
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
64 private void ensureInitialized() {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
65 if (printer == null) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
66 if (failuresCount > 8) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
67 return;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
68 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
69 previousInlineContext.clear();
13145
3e5555577ebc improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10727
diff changeset
70 createPrinter();
3e5555577ebc improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10727
diff changeset
71 }
3e5555577ebc improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10727
diff changeset
72 }
3e5555577ebc improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10727
diff changeset
73
3e5555577ebc improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10727
diff changeset
74 protected void createPrinter() {
3e5555577ebc improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10727
diff changeset
75 if (PrintIdealGraphFile.getValue()) {
3e5555577ebc improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10727
diff changeset
76 initializeFilePrinter();
3e5555577ebc improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10727
diff changeset
77 } else {
3e5555577ebc improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents: 10727
diff changeset
78 initializeNetworkPrinter();
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
79 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
80 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
81
10711
68d4d5457546 add sequential id prefixes to IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
82 private int nextDumpId() {
68d4d5457546 add sequential id prefixes to IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
83 int depth = previousInlineContext.size();
68d4d5457546 add sequential id prefixes to IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
84 if (dumpIds.length < depth) {
68d4d5457546 add sequential id prefixes to IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
85 dumpIds = Arrays.copyOf(dumpIds, depth);
68d4d5457546 add sequential id prefixes to IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
86 }
68d4d5457546 add sequential id prefixes to IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
87 return dumpIds[depth - 1]++;
68d4d5457546 add sequential id prefixes to IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
88 }
68d4d5457546 add sequential id prefixes to IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 9864
diff changeset
89
7153
c421c19b7bf8 made initialization of GraphPrinterDumpHandler.sdf be lazy to workaround an initialization order issue during VM start up
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
90 // This field must be lazily initialized as this class may be loaded in a version
c421c19b7bf8 made initialization of GraphPrinterDumpHandler.sdf be lazy to workaround an initialization order issue during VM start up
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
91 // VM startup phase at which not all required features (such as system properties)
c421c19b7bf8 made initialization of GraphPrinterDumpHandler.sdf be lazy to workaround an initialization order issue during VM start up
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
92 // are online.
14157
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13197
diff changeset
93 private static volatile SimpleDateFormat sdf;
7153
c421c19b7bf8 made initialization of GraphPrinterDumpHandler.sdf be lazy to workaround an initialization order issue during VM start up
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
94
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
95 private void initializeFilePrinter() {
5819
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5817
diff changeset
96 String ext;
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9650
diff changeset
97 if (PrintBinaryGraphs.getValue()) {
5819
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5817
diff changeset
98 ext = ".bgv";
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5817
diff changeset
99 } else {
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5817
diff changeset
100 ext = ".gv.xml";
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5817
diff changeset
101 }
7153
c421c19b7bf8 made initialization of GraphPrinterDumpHandler.sdf be lazy to workaround an initialization order issue during VM start up
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
102 if (sdf == null) {
c421c19b7bf8 made initialization of GraphPrinterDumpHandler.sdf be lazy to workaround an initialization order issue during VM start up
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
103 sdf = new SimpleDateFormat("YYYY-MM-dd-HHmm");
c421c19b7bf8 made initialization of GraphPrinterDumpHandler.sdf be lazy to workaround an initialization order issue during VM start up
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
104 }
14157
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13197
diff changeset
105
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13197
diff changeset
106 // DateFormats are inherently unsafe for multi-threaded use. Use a synchronized block.
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13197
diff changeset
107 String prefix;
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13197
diff changeset
108 synchronized (sdf) {
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13197
diff changeset
109 prefix = "Graphs-" + Thread.currentThread().getName() + "-" + sdf.format(new Date());
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13197
diff changeset
110 }
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13197
diff changeset
111
8234
0e008317f8ed Binary dumper should try numbering output files if a file with the same name exists
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7869
diff changeset
112 String num = "";
0e008317f8ed Binary dumper should try numbering output files if a file with the same name exists
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7869
diff changeset
113 File file;
0e008317f8ed Binary dumper should try numbering output files if a file with the same name exists
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7869
diff changeset
114 int i = 0;
0e008317f8ed Binary dumper should try numbering output files if a file with the same name exists
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7869
diff changeset
115 while ((file = new File(prefix + num + ext)).exists()) {
0e008317f8ed Binary dumper should try numbering output files if a file with the same name exists
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7869
diff changeset
116 num = "-" + Integer.toString(++i);
0e008317f8ed Binary dumper should try numbering output files if a file with the same name exists
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7869
diff changeset
117 }
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
118 try {
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9650
diff changeset
119 if (PrintBinaryGraphs.getValue()) {
8234
0e008317f8ed Binary dumper should try numbering output files if a file with the same name exists
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7869
diff changeset
120 printer = new BinaryGraphPrinter(FileChannel.open(file.toPath(), StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW));
5815
272f9da7ce78 Put Binary and xml dumpers behing a common interface and use the same dumphandler for them
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
121 } else {
14757
91c88fc2157c make scheduling in IdealGraphPrinter optional
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14580
diff changeset
122 printer = new IdealGraphPrinter(new FileOutputStream(file), true);
5815
272f9da7ce78 Put Binary and xml dumpers behing a common interface and use the same dumphandler for them
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
123 }
8234
0e008317f8ed Binary dumper should try numbering output files if a file with the same name exists
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7869
diff changeset
124 TTY.println("Dumping IGV graphs to %s", file.getName());
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
125 } catch (IOException e) {
8234
0e008317f8ed Binary dumper should try numbering output files if a file with the same name exists
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7869
diff changeset
126 TTY.println("Failed to open %s to dump IGV graphs : %s", file.getName(), e);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
127 failuresCount++;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
128 printer = null;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
129 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
130 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
131
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
132 private void initializeNetworkPrinter() {
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9650
diff changeset
133 String host = PrintIdealGraphAddress.getValue();
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9650
diff changeset
134 int port = PrintBinaryGraphs.getValue() ? PrintBinaryGraphPort.getValue() : PrintIdealGraphPort.getValue();
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
135 try {
9864
063a712fe8d8 converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents: 9650
diff changeset
136 if (PrintBinaryGraphs.getValue()) {
5815
272f9da7ce78 Put Binary and xml dumpers behing a common interface and use the same dumphandler for them
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
137 printer = new BinaryGraphPrinter(SocketChannel.open(new InetSocketAddress(host, port)));
272f9da7ce78 Put Binary and xml dumpers behing a common interface and use the same dumphandler for them
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
138 } else {
14757
91c88fc2157c make scheduling in IdealGraphPrinter optional
Erik Eckstein <erik.eckstein@oracle.com>
parents: 14580
diff changeset
139 IdealGraphPrinter xmlPrinter = new IdealGraphPrinter(new Socket(host, port).getOutputStream(), true);
5815
272f9da7ce78 Put Binary and xml dumpers behing a common interface and use the same dumphandler for them
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
140 printer = xmlPrinter;
272f9da7ce78 Put Binary and xml dumpers behing a common interface and use the same dumphandler for them
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
141 }
272f9da7ce78 Put Binary and xml dumpers behing a common interface and use the same dumphandler for them
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
142 TTY.println("Connected to the IGV on %s:%d", host, port);
14981
b5fed092083f Socket interrupts should not be treated as errors in GraphPrinterDumpHandler.
Christian Humer <christian.humer@gmail.com>
parents: 14757
diff changeset
143 } catch (ClosedByInterruptException | InterruptedIOException e) {
b5fed092083f Socket interrupts should not be treated as errors in GraphPrinterDumpHandler.
Christian Humer <christian.humer@gmail.com>
parents: 14757
diff changeset
144 /*
b5fed092083f Socket interrupts should not be treated as errors in GraphPrinterDumpHandler.
Christian Humer <christian.humer@gmail.com>
parents: 14757
diff changeset
145 * Interrupts should not count as errors because they may be caused by a cancelled Graal
b5fed092083f Socket interrupts should not be treated as errors in GraphPrinterDumpHandler.
Christian Humer <christian.humer@gmail.com>
parents: 14757
diff changeset
146 * compilation. ClosedByInterruptException occurs if the SocketChannel could not be
b5fed092083f Socket interrupts should not be treated as errors in GraphPrinterDumpHandler.
Christian Humer <christian.humer@gmail.com>
parents: 14757
diff changeset
147 * opened. InterruptedIOException occurs if new Socket(..) was interrupted.
b5fed092083f Socket interrupts should not be treated as errors in GraphPrinterDumpHandler.
Christian Humer <christian.humer@gmail.com>
parents: 14757
diff changeset
148 */
b5fed092083f Socket interrupts should not be treated as errors in GraphPrinterDumpHandler.
Christian Humer <christian.humer@gmail.com>
parents: 14757
diff changeset
149 printer = null;
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
150 } catch (IOException e) {
5819
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5817
diff changeset
151 TTY.println("Could not connect to the IGV on %s:%d : %s", host, port, e);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
152 failuresCount++;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
153 printer = null;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
154 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
155 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
156
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
157 @Override
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
158 public void dump(Object object, final String message) {
18886
9afe8fbe088c Add -G:[-/+]PrintIdealGraph option.
Josef Eisl <josef.eisl@jku.at>
parents: 18642
diff changeset
159 if (object instanceof Graph && PrintIdealGraph.getValue()) {
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
160 ensureInitialized();
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
161 if (printer == null) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
162 return;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
163 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
164 final Graph graph = (Graph) object;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
165
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
166 if (printer != null) {
18642
133d5a98c547 generalized semantics of DebugDumpHandler.close() to mean reset so that closing a handler flushes and releases all its resources but leaves it operational (i.e. subsequent uses will (re)create and (re)open the required resources)
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
167 // Get all current JavaMethod instances in the context.
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
168 List<String> inlineContext = getInlineContext();
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
169
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
170 // Reverse list such that inner method comes after outer method.
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
171 Collections.reverse(inlineContext);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
172
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
173 // Check for method scopes that must be closed since the previous dump.
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
174 for (int i = 0; i < previousInlineContext.size(); ++i) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
175 if (i >= inlineContext.size() || !inlineContext.get(i).equals(previousInlineContext.get(i))) {
10727
9d079661cbcd fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 10711
diff changeset
176 for (int inlineDepth = previousInlineContext.size() - 1; inlineDepth >= i; --inlineDepth) {
9d079661cbcd fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 10711
diff changeset
177 closeScope(inlineDepth);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
178 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
179 break;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
180 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
181 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
182
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
183 // Check for method scopes that must be opened since the previous dump.
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
184 for (int i = 0; i < inlineContext.size(); ++i) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
185 if (i >= previousInlineContext.size() || !inlineContext.get(i).equals(previousInlineContext.get(i))) {
10727
9d079661cbcd fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 10711
diff changeset
186 for (int inlineDepth = i; inlineDepth < inlineContext.size(); ++inlineDepth) {
9d079661cbcd fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 10711
diff changeset
187 openScope(inlineContext.get(inlineDepth), inlineDepth);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
188 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
189 break;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
190 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
191 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
192
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
193 // Save inline context for next dump.
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
194 previousInlineContext = inlineContext;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
195
7869
cb7bab0fd666 use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents: 7785
diff changeset
196 final SchedulePhase predefinedSchedule = getPredefinedSchedule();
13197
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13145
diff changeset
197 try (Scope s = Debug.sandbox("PrintingGraph", null)) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13145
diff changeset
198 // Finally, output the graph.
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13145
diff changeset
199 printer.print(graph, nextDumpId() + ":" + message, predefinedSchedule);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13145
diff changeset
200 } catch (IOException e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13145
diff changeset
201 failuresCount++;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13145
diff changeset
202 printer = null;
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13145
diff changeset
203 } catch (Throwable e) {
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13145
diff changeset
204 throw Debug.handle(e);
8569b9e047cd change debug scopes implementation to prevent extra frames related to mechanism being added to call stack
Doug Simon <doug.simon@oracle.com>
parents: 13145
diff changeset
205 }
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
206 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
207 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
208 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
209
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
210 private static List<String> getInlineContext() {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
211 List<String> result = new ArrayList<>();
10727
9d079661cbcd fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 10711
diff changeset
212 Object lastMethodOrGraph = null;
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
213 for (Object o : Debug.context()) {
10727
9d079661cbcd fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 10711
diff changeset
214 JavaMethod method = asJavaMethod(o);
9620
0eda2b7df748 fixed debug scope processing so that -G:MethodFilter option works as expected
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
215 if (method != null) {
14580
a15776cb4e6c small additional null check in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14158
diff changeset
216 if (lastMethodOrGraph == null || asJavaMethod(lastMethodOrGraph) == null || !asJavaMethod(lastMethodOrGraph).equals(method)) {
16480
10c12d09a8d2 moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents: 15259
diff changeset
217 result.add(method.format("%H::%n(%p)"));
9650
8f9439edcf5b prevent multiple method context objects for the same method from resulting in multiple IGV tree levels unless there the method actually inlines itself
Doug Simon <doug.simon@oracle.com>
parents: 9620
diff changeset
218 } else {
8f9439edcf5b prevent multiple method context objects for the same method from resulting in multiple IGV tree levels unless there the method actually inlines itself
Doug Simon <doug.simon@oracle.com>
parents: 9620
diff changeset
219 // This prevents multiple adjacent method context objects for the same method
8f9439edcf5b prevent multiple method context objects for the same method from resulting in multiple IGV tree levels unless there the method actually inlines itself
Doug Simon <doug.simon@oracle.com>
parents: 9620
diff changeset
220 // from resulting in multiple IGV tree levels. This works on the
8f9439edcf5b prevent multiple method context objects for the same method from resulting in multiple IGV tree levels unless there the method actually inlines itself
Doug Simon <doug.simon@oracle.com>
parents: 9620
diff changeset
221 // assumption that real inlining debug scopes will have a graph
8f9439edcf5b prevent multiple method context objects for the same method from resulting in multiple IGV tree levels unless there the method actually inlines itself
Doug Simon <doug.simon@oracle.com>
parents: 9620
diff changeset
222 // context object between the inliner and inlinee context objects.
8f9439edcf5b prevent multiple method context objects for the same method from resulting in multiple IGV tree levels unless there the method actually inlines itself
Doug Simon <doug.simon@oracle.com>
parents: 9620
diff changeset
223 }
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
224 } else if (o instanceof DebugDumpScope) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
225 DebugDumpScope debugDumpScope = (DebugDumpScope) o;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
226 if (debugDumpScope.decorator && !result.isEmpty()) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
227 result.set(result.size() - 1, debugDumpScope.name + ":" + result.get(result.size() - 1));
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
228 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
229 result.add(debugDumpScope.name);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
230 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
231 }
10727
9d079661cbcd fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 10711
diff changeset
232 if (o instanceof JavaMethod || o instanceof Graph) {
9d079661cbcd fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 10711
diff changeset
233 lastMethodOrGraph = o;
9d079661cbcd fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 10711
diff changeset
234 }
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
235 }
7785
f180d2a1c3a4 support graph dumping with being nested in a DebugScope
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
236 if (result.isEmpty()) {
f180d2a1c3a4 support graph dumping with being nested in a DebugScope
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
237 result.add("Top Scope");
f180d2a1c3a4 support graph dumping with being nested in a DebugScope
Doug Simon <doug.simon@oracle.com>
parents: 7530
diff changeset
238 }
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
239 return result;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
240 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
241
7869
cb7bab0fd666 use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents: 7785
diff changeset
242 private static SchedulePhase getPredefinedSchedule() {
cb7bab0fd666 use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents: 7785
diff changeset
243 SchedulePhase result = null;
cb7bab0fd666 use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents: 7785
diff changeset
244 for (Object o : Debug.context()) {
cb7bab0fd666 use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents: 7785
diff changeset
245 if (o instanceof SchedulePhase) {
cb7bab0fd666 use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents: 7785
diff changeset
246 result = (SchedulePhase) o;
cb7bab0fd666 use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents: 7785
diff changeset
247 }
cb7bab0fd666 use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents: 7785
diff changeset
248 }
cb7bab0fd666 use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents: 7785
diff changeset
249 return result;
cb7bab0fd666 use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents: 7785
diff changeset
250 }
cb7bab0fd666 use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents: 7785
diff changeset
251
10727
9d079661cbcd fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 10711
diff changeset
252 private void openScope(String name, int inlineDepth) {
9d079661cbcd fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 10711
diff changeset
253 String prefix = inlineDepth == 0 ? Thread.currentThread().getName() + ":" : "";
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
254 try {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
255 printer.beginGroup(prefix + name, name, Debug.contextLookup(ResolvedJavaMethod.class), -1);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
256 } catch (IOException e) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
257 failuresCount++;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
258 printer = null;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
259 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
260 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
261
10727
9d079661cbcd fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 10711
diff changeset
262 private void closeScope(int inlineDepth) {
9d079661cbcd fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 10711
diff changeset
263 dumpIds[inlineDepth] = 0;
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
264 try {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
265 printer.endGroup();
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
266 } catch (IOException e) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
267 failuresCount++;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
268 printer = null;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
269 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
270 }
5819
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5817
diff changeset
271
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5817
diff changeset
272 @Override
7032
5a1f6e96e163 close() method for dump handlers should not throw IOException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6695
diff changeset
273 public void close() {
10727
9d079661cbcd fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 10711
diff changeset
274 for (int inlineDepth = 0; inlineDepth < previousInlineContext.size(); inlineDepth++) {
9d079661cbcd fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents: 10711
diff changeset
275 closeScope(inlineDepth);
5819
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5817
diff changeset
276 }
6695
dc7cd6885f07 Avoid NullPointerException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6525
diff changeset
277 if (printer != null) {
dc7cd6885f07 Avoid NullPointerException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6525
diff changeset
278 printer.close();
18642
133d5a98c547 generalized semantics of DebugDumpHandler.close() to mean reset so that closing a handler flushes and releases all its resources but leaves it operational (i.e. subsequent uses will (re)create and (re)open the required resources)
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
279 printer = null;
6695
dc7cd6885f07 Avoid NullPointerException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6525
diff changeset
280 }
5819
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5817
diff changeset
281 }
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
282 }