Mercurial > hg > graal-jvmci-8
comparison graal/GraalCompiler/src/com/sun/c1x/C1XCompiler.java @ 2602:0c6564c254af
new node layout: BlockBegin, BlockEnd
-Dc1x.dot=regex for pdf output
escape dot graph labels (<, >, &)
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Fri, 06 May 2011 10:25:37 +0200 |
parents | 268b8eb84b6e |
children | 01c5c0443158 |
comparison
equal
deleted
inserted
replaced
2601:224e8b4007bd | 2602:0c6564c254af |
---|---|
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 package com.sun.c1x; | 23 package com.sun.c1x; |
24 | 24 |
25 import java.io.*; | |
25 import java.util.*; | 26 import java.util.*; |
26 | 27 |
28 import com.oracle.graal.graph.*; | |
29 import com.oracle.graal.graph.vis.*; | |
30 import com.oracle.graal.graph.vis.GraphvizTest.*; | |
27 import com.sun.c1x.debug.*; | 31 import com.sun.c1x.debug.*; |
28 import com.sun.c1x.globalstub.*; | 32 import com.sun.c1x.globalstub.*; |
29 import com.sun.c1x.observer.*; | 33 import com.sun.c1x.observer.*; |
30 import com.sun.c1x.target.*; | 34 import com.sun.c1x.target.*; |
31 import com.sun.cri.ci.*; | 35 import com.sun.cri.ci.*; |
123 } | 127 } |
124 | 128 |
125 if (C1XOptions.PrintCFGToFile) { | 129 if (C1XOptions.PrintCFGToFile) { |
126 addCompilationObserver(new CFGPrinterObserver()); | 130 addCompilationObserver(new CFGPrinterObserver()); |
127 } | 131 } |
132 String dot = System.getProperty("c1x.dot"); | |
133 if (dot != null && !dot.isEmpty()) { | |
134 if (!dot.endsWith("$")) { | |
135 dot = dot + ".*"; | |
136 } | |
137 if (!dot.startsWith("^")) { | |
138 dot = ".*" + dot; | |
139 } | |
140 final String dotPattern = dot; | |
141 addCompilationObserver(new CompilationObserver() { | |
142 private Graph graph; | |
143 public void compilationStarted(CompilationEvent event) { | |
144 } | |
145 public void compilationFinished(CompilationEvent event) { | |
146 String name = event.getMethod().holder().name(); | |
147 name = name.substring(1, name.length() - 1).replace('/', '.'); | |
148 name = name + "." + event.getMethod().name(); | |
149 if (name.matches(dotPattern)) { | |
150 ByteArrayOutputStream out = new ByteArrayOutputStream(); | |
151 GraphvizPrinter printer = new GraphvizPrinter(out); | |
152 printer.begin("Simple test"); | |
153 printer.print(graph); | |
154 printer.end(); | |
155 | |
156 try { | |
157 GraphvizRunner.process(GraphvizRunner.DOT_COMMAND, new ByteArrayInputStream(out.toByteArray()), | |
158 new FileOutputStream(name + ".pdf"), "pdf"); | |
159 } catch (Exception e) { | |
160 e.printStackTrace(); | |
161 } | |
162 } | |
163 } | |
164 public void compilationEvent(CompilationEvent event) { | |
165 if (event.getStartBlock() != null) { | |
166 graph = event.getStartBlock().graph(); | |
167 } | |
168 } | |
169 }); | |
170 } | |
128 } | 171 } |
129 | 172 |
130 public GlobalStub lookupGlobalStub(GlobalStub.Id id) { | 173 public GlobalStub lookupGlobalStub(GlobalStub.Id id) { |
131 GlobalStub globalStub = stubs.get(id); | 174 GlobalStub globalStub = stubs.get(id); |
132 assert globalStub != null : "no stub for global stub id: " + id; | 175 assert globalStub != null : "no stub for global stub id: " + id; |