Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java @ 21556:48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 27 May 2015 00:36:16 +0200 |
parents | b1530a6cce8c |
children | d71b0cbe7016 |
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; |
10727
9d079661cbcd
fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents:
10711
diff
changeset
|
27 import static com.oracle.graal.compiler.GraalDebugConfig.*; |
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.*; |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9650
diff
changeset
|
29 |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
30 import java.io.*; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
31 import java.net.*; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
32 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
|
33 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
|
34 import java.text.*; |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
35 import java.util.*; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
36 |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
37 import com.oracle.graal.graph.*; |
7869
cb7bab0fd666
use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents:
7785
diff
changeset
|
38 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
|
39 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
|
40 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
|
41 |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
42 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7153
diff
changeset
|
43 * 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
|
44 * 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
|
45 * Visualizer</a>. |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
46 */ |
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
|
47 public class GraphPrinterDumpHandler implements DebugDumpHandler { |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
48 |
13145
3e5555577ebc
improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10727
diff
changeset
|
49 protected GraphPrinter printer; |
5817
74eb5feba8dc
Make sure the right port is used for dumping
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5815
diff
changeset
|
50 private List<String> previousInlineContext; |
10711
68d4d5457546
add sequential id prefixes to IGV graphs
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
51 private int[] dumpIds = {}; |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
52 private int failuresCount; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
53 |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
54 /** |
5817
74eb5feba8dc
Make sure the right port is used for dumping
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5815
diff
changeset
|
55 * Creates a new {@link GraphPrinterDumpHandler}. |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
56 */ |
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
|
57 public GraphPrinterDumpHandler() { |
5817
74eb5feba8dc
Make sure the right port is used for dumping
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5815
diff
changeset
|
58 previousInlineContext = new ArrayList<>(); |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
59 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
60 |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
61 private void ensureInitialized() { |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
62 if (printer == null) { |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
63 if (failuresCount > 8) { |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
64 return; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
65 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
66 previousInlineContext.clear(); |
13145
3e5555577ebc
improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10727
diff
changeset
|
67 createPrinter(); |
3e5555577ebc
improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10727
diff
changeset
|
68 } |
3e5555577ebc
improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10727
diff
changeset
|
69 } |
3e5555577ebc
improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10727
diff
changeset
|
70 |
3e5555577ebc
improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10727
diff
changeset
|
71 protected void createPrinter() { |
3e5555577ebc
improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10727
diff
changeset
|
72 if (PrintIdealGraphFile.getValue()) { |
3e5555577ebc
improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10727
diff
changeset
|
73 initializeFilePrinter(); |
3e5555577ebc
improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10727
diff
changeset
|
74 } else { |
3e5555577ebc
improve graph printer API for better suppport of derived classes
Erik Eckstein <erik.eckstein@oracle.com>
parents:
10727
diff
changeset
|
75 initializeNetworkPrinter(); |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
76 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
77 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
78 |
10711
68d4d5457546
add sequential id prefixes to IGV graphs
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
79 private int nextDumpId() { |
68d4d5457546
add sequential id prefixes to IGV graphs
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
80 int depth = previousInlineContext.size(); |
68d4d5457546
add sequential id prefixes to IGV graphs
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
81 if (dumpIds.length < depth) { |
68d4d5457546
add sequential id prefixes to IGV graphs
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
82 dumpIds = Arrays.copyOf(dumpIds, depth); |
68d4d5457546
add sequential id prefixes to IGV graphs
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
83 } |
68d4d5457546
add sequential id prefixes to IGV graphs
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
84 return dumpIds[depth - 1]++; |
68d4d5457546
add sequential id prefixes to IGV graphs
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
85 } |
68d4d5457546
add sequential id prefixes to IGV graphs
Doug Simon <doug.simon@oracle.com>
parents:
9864
diff
changeset
|
86 |
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
|
87 // 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
|
88 // 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
|
89 // are online. |
14157 | 90 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
|
91 |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
92 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
|
93 String ext; |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9650
diff
changeset
|
94 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
|
95 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
|
96 } else { |
8fd81d0e3acf
Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5817
diff
changeset
|
97 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
|
98 } |
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
|
99 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
|
100 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
|
101 } |
14157 | 102 |
103 // DateFormats are inherently unsafe for multi-threaded use. Use a synchronized block. | |
104 String prefix; | |
105 synchronized (sdf) { | |
106 prefix = "Graphs-" + Thread.currentThread().getName() + "-" + sdf.format(new Date()); | |
107 } | |
108 | |
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
|
109 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
|
110 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
|
111 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
|
112 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
|
113 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
|
114 } |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
115 try { |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9650
diff
changeset
|
116 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
|
117 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
|
118 } else { |
14757
91c88fc2157c
make scheduling in IdealGraphPrinter optional
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14580
diff
changeset
|
119 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
|
120 } |
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
|
121 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
|
122 } 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
|
123 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
|
124 failuresCount++; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
125 printer = null; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
126 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
127 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
128 |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
129 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
|
130 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
|
131 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
|
132 try { |
9864
063a712fe8d8
converted remaining options in GraalOptions to new system (GRAAL-27)
Doug Simon <doug.simon@oracle.com>
parents:
9650
diff
changeset
|
133 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
|
134 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
|
135 } else { |
14757
91c88fc2157c
make scheduling in IdealGraphPrinter optional
Erik Eckstein <erik.eckstein@oracle.com>
parents:
14580
diff
changeset
|
136 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
|
137 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
|
138 } |
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
|
139 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
|
140 } 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
|
141 /* |
b5fed092083f
Socket interrupts should not be treated as errors in GraphPrinterDumpHandler.
Christian Humer <christian.humer@gmail.com>
parents:
14757
diff
changeset
|
142 * 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
|
143 * 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
|
144 * 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
|
145 */ |
b5fed092083f
Socket interrupts should not be treated as errors in GraphPrinterDumpHandler.
Christian Humer <christian.humer@gmail.com>
parents:
14757
diff
changeset
|
146 printer = null; |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
147 } 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
|
148 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
|
149 failuresCount++; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
150 printer = null; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
151 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
152 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
153 |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
154 @Override |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
155 public void dump(Object object, final String message) { |
18886
9afe8fbe088c
Add -G:[-/+]PrintIdealGraph option.
Josef Eisl <josef.eisl@jku.at>
parents:
18642
diff
changeset
|
156 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
|
157 ensureInitialized(); |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
158 if (printer == null) { |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
159 return; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
160 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
161 final Graph graph = (Graph) object; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
162 |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
163 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
|
164 // 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
|
165 List<String> inlineContext = getInlineContext(); |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
166 |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
167 // 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
|
168 Collections.reverse(inlineContext); |
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 // 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
|
171 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
|
172 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
|
173 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
|
174 closeScope(inlineDepth); |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
175 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
176 break; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
177 } |
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 |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
180 // 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
|
181 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
|
182 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
|
183 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
|
184 openScope(inlineContext.get(inlineDepth), inlineDepth); |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
185 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
186 break; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
187 } |
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 |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
190 // Save inline context for next dump. |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
191 previousInlineContext = inlineContext; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
192 |
7869
cb7bab0fd666
use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents:
7785
diff
changeset
|
193 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
|
194 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
|
195 // 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
|
196 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
|
197 } 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
|
198 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
|
199 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
|
200 } 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
|
201 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
|
202 } |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
203 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
204 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
205 } |
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 private static List<String> getInlineContext() { |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
208 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
|
209 Object lastMethodOrGraph = null; |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
210 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
|
211 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
|
212 if (method != null) { |
14580
a15776cb4e6c
small additional null check in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14158
diff
changeset
|
213 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
|
214 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
|
215 } 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
|
216 // 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
|
217 // 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
|
218 // 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
|
219 // 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
|
220 } |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
221 } else if (o instanceof DebugDumpScope) { |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
222 DebugDumpScope debugDumpScope = (DebugDumpScope) o; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
223 if (debugDumpScope.decorator && !result.isEmpty()) { |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
224 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
|
225 } else { |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
226 result.add(debugDumpScope.name); |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
227 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
228 } |
10727
9d079661cbcd
fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents:
10711
diff
changeset
|
229 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
|
230 lastMethodOrGraph = o; |
9d079661cbcd
fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents:
10711
diff
changeset
|
231 } |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
232 } |
7785
f180d2a1c3a4
support graph dumping with being nested in a DebugScope
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
233 if (result.isEmpty()) { |
f180d2a1c3a4
support graph dumping with being nested in a DebugScope
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
234 result.add("Top Scope"); |
f180d2a1c3a4
support graph dumping with being nested in a DebugScope
Doug Simon <doug.simon@oracle.com>
parents:
7530
diff
changeset
|
235 } |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
236 return result; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
237 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
238 |
7869
cb7bab0fd666
use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents:
7785
diff
changeset
|
239 private static SchedulePhase getPredefinedSchedule() { |
cb7bab0fd666
use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents:
7785
diff
changeset
|
240 SchedulePhase result = null; |
cb7bab0fd666
use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents:
7785
diff
changeset
|
241 for (Object o : Debug.context()) { |
cb7bab0fd666
use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents:
7785
diff
changeset
|
242 if (o instanceof SchedulePhase) { |
cb7bab0fd666
use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents:
7785
diff
changeset
|
243 result = (SchedulePhase) o; |
cb7bab0fd666
use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents:
7785
diff
changeset
|
244 } |
cb7bab0fd666
use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents:
7785
diff
changeset
|
245 } |
cb7bab0fd666
use predefined schedule in GraphPrinterDumpHandler
Lukas Stadler <lukas.stadler@jku.at>
parents:
7785
diff
changeset
|
246 return result; |
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 |
10727
9d079661cbcd
fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents:
10711
diff
changeset
|
249 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
|
250 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
|
251 try { |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
252 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
|
253 } catch (IOException e) { |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
254 failuresCount++; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
255 printer = null; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
256 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
257 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
258 |
10727
9d079661cbcd
fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents:
10711
diff
changeset
|
259 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
|
260 dumpIds[inlineDepth] = 0; |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
261 try { |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
262 printer.endGroup(); |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
263 } catch (IOException e) { |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
264 failuresCount++; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
265 printer = null; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
266 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
267 } |
5819
8fd81d0e3acf
Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5817
diff
changeset
|
268 |
8fd81d0e3acf
Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5817
diff
changeset
|
269 @Override |
7032
5a1f6e96e163
close() method for dump handlers should not throw IOException
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6695
diff
changeset
|
270 public void close() { |
10727
9d079661cbcd
fixed generation of sequential id prefixes for IGV graphs
Doug Simon <doug.simon@oracle.com>
parents:
10711
diff
changeset
|
271 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
|
272 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
|
273 } |
6695
dc7cd6885f07
Avoid NullPointerException
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6525
diff
changeset
|
274 if (printer != null) { |
dc7cd6885f07
Avoid NullPointerException
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6525
diff
changeset
|
275 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
|
276 printer = null; |
6695
dc7cd6885f07
Avoid NullPointerException
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6525
diff
changeset
|
277 } |
5819
8fd81d0e3acf
Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5817
diff
changeset
|
278 } |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
279 } |