annotate graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java @ 23222:56359eb3abfa

moved @ServiceProvider mechanism from JVMCI to Graal (GRAAL-1380)
author Doug Simon <doug.simon@oracle.com>
date Wed, 30 Dec 2015 18:08:59 +0100
parents 615f3bbbb174
children e67189aa2e06
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4612
diff changeset
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
23 package com.oracle.graal.printer;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
22646
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
25 import java.io.BufferedOutputStream;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
26 import java.io.File;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
27 import java.io.FileNotFoundException;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
28 import java.io.FileOutputStream;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
29 import java.io.OutputStream;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
30 import java.nio.file.Path;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
31 import java.nio.file.Paths;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
32 import java.util.ArrayList;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
33 import java.util.Collections;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
34 import java.util.List;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
35 import java.util.concurrent.atomic.AtomicInteger;
22054
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents: 21906
diff changeset
36
22790
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
37 import jdk.vm.ci.code.CodeCacheProvider;
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
38 import jdk.vm.ci.code.CompilationResult;
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
39 import jdk.vm.ci.code.InstalledCode;
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
40 import jdk.vm.ci.common.JVMCIError;
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
41 import jdk.vm.ci.meta.JavaMethod;
615f3bbbb174 Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22646
diff changeset
42 import jdk.vm.ci.meta.ResolvedJavaMethod;
23222
56359eb3abfa moved @ServiceProvider mechanism from JVMCI to Graal (GRAAL-1380)
Doug Simon <doug.simon@oracle.com>
parents: 22790
diff changeset
43 import jdk.vm.ci.services.Services;
22646
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
44
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
45 import com.oracle.graal.code.DisassemblerProvider;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
46 import com.oracle.graal.compiler.common.GraalOptions;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
47 import com.oracle.graal.compiler.common.cfg.AbstractBlockBase;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
48 import com.oracle.graal.compiler.gen.NodeLIRBuilder;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
49 import com.oracle.graal.debug.Debug;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
50 import com.oracle.graal.debug.DebugDumpHandler;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
51 import com.oracle.graal.debug.DebugDumpScope;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
52 import com.oracle.graal.debug.TTY;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
53 import com.oracle.graal.graph.Graph;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
54 import com.oracle.graal.java.BciBlockMapping;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
55 import com.oracle.graal.java.BytecodeDisassembler;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
56 import com.oracle.graal.lir.LIR;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
57 import com.oracle.graal.lir.debug.IntervalDumper;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
58 import com.oracle.graal.nodes.StructuredGraph;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
59 import com.oracle.graal.nodes.cfg.ControlFlowGraph;
05183a084a08 updated imports to be explicit and added checkstyle rule to forbid * imports
Doug Simon <doug.simon@oracle.com>
parents: 22568
diff changeset
60 import com.oracle.graal.phases.schedule.SchedulePhase;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
63 * Observes compilation events and uses {@link CFGPrinter} to produce a control flow graph for the
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
64 * <a href="http://java.net/projects/c1visualizer/">C1 Visualizer</a>.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 */
4522
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4435
diff changeset
66 public class CFGPrinterObserver implements DebugDumpHandler {
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4435
diff changeset
67
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4435
diff changeset
68 private CFGPrinter cfgPrinter;
5763
a3d71693e0ce removed bytecode disassembly from CodeCacheRuntime into separate BytecodeDisassembler class
Doug Simon <doug.simon@oracle.com>
parents: 5557
diff changeset
69 private File cfgFile;
9658
d64083db3c11 changed CFGPrinterObserver to use JavaMethod instead of ResolvedJavaMethod for method scope
Doug Simon <doug.simon@oracle.com>
parents: 9234
diff changeset
70 private JavaMethod curMethod;
5432
50598118cd0a added support for decorator dump scopes so that the visualizers can distinguish between multiple compilations of the same method
Doug Simon <doug.simon@oracle.com>
parents: 5275
diff changeset
71 private List<String> curDecorators = Collections.emptyList();
11379
0942e34b6c7d added PrintBackendCFG option (default is true) for controlling if backend output is dumped to the C1Visualizer
Doug Simon <doug.simon@oracle.com>
parents: 9658
diff changeset
72 private final boolean dumpFrontend;
0942e34b6c7d added PrintBackendCFG option (default is true) for controlling if backend output is dumped to the C1Visualizer
Doug Simon <doug.simon@oracle.com>
parents: 9658
diff changeset
73
0942e34b6c7d added PrintBackendCFG option (default is true) for controlling if backend output is dumped to the C1Visualizer
Doug Simon <doug.simon@oracle.com>
parents: 9658
diff changeset
74 public CFGPrinterObserver(boolean dumpFrontend) {
0942e34b6c7d added PrintBackendCFG option (default is true) for controlling if backend output is dumped to the C1Visualizer
Doug Simon <doug.simon@oracle.com>
parents: 9658
diff changeset
75 this.dumpFrontend = dumpFrontend;
0942e34b6c7d added PrintBackendCFG option (default is true) for controlling if backend output is dumped to the C1Visualizer
Doug Simon <doug.simon@oracle.com>
parents: 9658
diff changeset
76 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78 @Override
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4612
diff changeset
79 public void dump(Object object, String message) {
5029
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5011
diff changeset
80 try {
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5011
diff changeset
81 dumpSandboxed(object, message);
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5011
diff changeset
82 } catch (Throwable ex) {
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5011
diff changeset
83 TTY.println("CFGPrinter: Exception during output of " + message + ": " + ex);
8150
b66f831ac5ab Fix CFG printer output. Clean up after making the compiler class all-static.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7835
diff changeset
84 ex.printStackTrace();
5029
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5011
diff changeset
85 }
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5011
diff changeset
86 }
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5011
diff changeset
87
5432
50598118cd0a added support for decorator dump scopes so that the visualizers can distinguish between multiple compilations of the same method
Doug Simon <doug.simon@oracle.com>
parents: 5275
diff changeset
88 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
89 * Looks for the outer most method and its {@link DebugDumpScope#decorator}s in the current
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
90 * debug scope and opens a new compilation scope if this pair does not match the current method
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
91 * and decorator pair.
5432
50598118cd0a added support for decorator dump scopes so that the visualizers can distinguish between multiple compilations of the same method
Doug Simon <doug.simon@oracle.com>
parents: 5275
diff changeset
92 */
5763
a3d71693e0ce removed bytecode disassembly from CodeCacheRuntime into separate BytecodeDisassembler class
Doug Simon <doug.simon@oracle.com>
parents: 5557
diff changeset
93 private boolean checkMethodScope() {
9658
d64083db3c11 changed CFGPrinterObserver to use JavaMethod instead of ResolvedJavaMethod for method scope
Doug Simon <doug.simon@oracle.com>
parents: 9234
diff changeset
94 JavaMethod method = null;
5432
50598118cd0a added support for decorator dump scopes so that the visualizers can distinguish between multiple compilations of the same method
Doug Simon <doug.simon@oracle.com>
parents: 5275
diff changeset
95 ArrayList<String> decorators = new ArrayList<>();
50598118cd0a added support for decorator dump scopes so that the visualizers can distinguish between multiple compilations of the same method
Doug Simon <doug.simon@oracle.com>
parents: 5275
diff changeset
96 for (Object o : Debug.context()) {
9658
d64083db3c11 changed CFGPrinterObserver to use JavaMethod instead of ResolvedJavaMethod for method scope
Doug Simon <doug.simon@oracle.com>
parents: 9234
diff changeset
97 if (o instanceof JavaMethod) {
d64083db3c11 changed CFGPrinterObserver to use JavaMethod instead of ResolvedJavaMethod for method scope
Doug Simon <doug.simon@oracle.com>
parents: 9234
diff changeset
98 method = (JavaMethod) o;
5432
50598118cd0a added support for decorator dump scopes so that the visualizers can distinguish between multiple compilations of the same method
Doug Simon <doug.simon@oracle.com>
parents: 5275
diff changeset
99 decorators.clear();
50598118cd0a added support for decorator dump scopes so that the visualizers can distinguish between multiple compilations of the same method
Doug Simon <doug.simon@oracle.com>
parents: 5275
diff changeset
100 } else if (o instanceof StructuredGraph) {
50598118cd0a added support for decorator dump scopes so that the visualizers can distinguish between multiple compilations of the same method
Doug Simon <doug.simon@oracle.com>
parents: 5275
diff changeset
101 StructuredGraph graph = (StructuredGraph) o;
9658
d64083db3c11 changed CFGPrinterObserver to use JavaMethod instead of ResolvedJavaMethod for method scope
Doug Simon <doug.simon@oracle.com>
parents: 9234
diff changeset
102 if (graph.method() != null) {
d64083db3c11 changed CFGPrinterObserver to use JavaMethod instead of ResolvedJavaMethod for method scope
Doug Simon <doug.simon@oracle.com>
parents: 9234
diff changeset
103 method = graph.method();
d64083db3c11 changed CFGPrinterObserver to use JavaMethod instead of ResolvedJavaMethod for method scope
Doug Simon <doug.simon@oracle.com>
parents: 9234
diff changeset
104 decorators.clear();
d64083db3c11 changed CFGPrinterObserver to use JavaMethod instead of ResolvedJavaMethod for method scope
Doug Simon <doug.simon@oracle.com>
parents: 9234
diff changeset
105 }
5432
50598118cd0a added support for decorator dump scopes so that the visualizers can distinguish between multiple compilations of the same method
Doug Simon <doug.simon@oracle.com>
parents: 5275
diff changeset
106 } else if (o instanceof DebugDumpScope) {
50598118cd0a added support for decorator dump scopes so that the visualizers can distinguish between multiple compilations of the same method
Doug Simon <doug.simon@oracle.com>
parents: 5275
diff changeset
107 DebugDumpScope debugDumpScope = (DebugDumpScope) o;
50598118cd0a added support for decorator dump scopes so that the visualizers can distinguish between multiple compilations of the same method
Doug Simon <doug.simon@oracle.com>
parents: 5275
diff changeset
108 if (debugDumpScope.decorator) {
50598118cd0a added support for decorator dump scopes so that the visualizers can distinguish between multiple compilations of the same method
Doug Simon <doug.simon@oracle.com>
parents: 5275
diff changeset
109 decorators.add(debugDumpScope.name);
50598118cd0a added support for decorator dump scopes so that the visualizers can distinguish between multiple compilations of the same method
Doug Simon <doug.simon@oracle.com>
parents: 5275
diff changeset
110 }
50598118cd0a added support for decorator dump scopes so that the visualizers can distinguish between multiple compilations of the same method
Doug Simon <doug.simon@oracle.com>
parents: 5275
diff changeset
111 }
5275
290b3025b66f added support for disassembling code after installation (so that the result of patching and relocation can be seen)
Doug Simon <doug.simon@oracle.com>
parents: 5249
diff changeset
112 }
5432
50598118cd0a added support for decorator dump scopes so that the visualizers can distinguish between multiple compilations of the same method
Doug Simon <doug.simon@oracle.com>
parents: 5275
diff changeset
113
5763
a3d71693e0ce removed bytecode disassembly from CodeCacheRuntime into separate BytecodeDisassembler class
Doug Simon <doug.simon@oracle.com>
parents: 5557
diff changeset
114 if (method == null) {
a3d71693e0ce removed bytecode disassembly from CodeCacheRuntime into separate BytecodeDisassembler class
Doug Simon <doug.simon@oracle.com>
parents: 5557
diff changeset
115 return false;
a3d71693e0ce removed bytecode disassembly from CodeCacheRuntime into separate BytecodeDisassembler class
Doug Simon <doug.simon@oracle.com>
parents: 5557
diff changeset
116 }
a3d71693e0ce removed bytecode disassembly from CodeCacheRuntime into separate BytecodeDisassembler class
Doug Simon <doug.simon@oracle.com>
parents: 5557
diff changeset
117
12570
af39ea2dc39d made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12045
diff changeset
118 if (!method.equals(curMethod) || !curDecorators.equals(decorators)) {
5432
50598118cd0a added support for decorator dump scopes so that the visualizers can distinguish between multiple compilations of the same method
Doug Simon <doug.simon@oracle.com>
parents: 5275
diff changeset
119 cfgPrinter.printCompilation(method);
21906
e26913e5bc3c print absolute file names from CFGPrinterObserver
Doug Simon <doug.simon@oracle.com>
parents: 21780
diff changeset
120 TTY.println("CFGPrinter: Dumping method %s to %s", method, cfgFile.getAbsolutePath());
5432
50598118cd0a added support for decorator dump scopes so that the visualizers can distinguish between multiple compilations of the same method
Doug Simon <doug.simon@oracle.com>
parents: 5275
diff changeset
121 }
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: 16950
diff changeset
122 curMethod = method;
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: 16950
diff changeset
123 curDecorators = decorators;
5763
a3d71693e0ce removed bytecode disassembly from CodeCacheRuntime into separate BytecodeDisassembler class
Doug Simon <doug.simon@oracle.com>
parents: 5557
diff changeset
124 return true;
5275
290b3025b66f added support for disassembling code after installation (so that the result of patching and relocation can be seen)
Doug Simon <doug.simon@oracle.com>
parents: 5249
diff changeset
125 }
290b3025b66f added support for disassembling code after installation (so that the result of patching and relocation can be seen)
Doug Simon <doug.simon@oracle.com>
parents: 5249
diff changeset
126
11379
0942e34b6c7d added PrintBackendCFG option (default is true) for controlling if backend output is dumped to the C1Visualizer
Doug Simon <doug.simon@oracle.com>
parents: 9658
diff changeset
127 private static boolean isFrontendObject(Object object) {
0942e34b6c7d added PrintBackendCFG option (default is true) for controlling if backend output is dumped to the C1Visualizer
Doug Simon <doug.simon@oracle.com>
parents: 9658
diff changeset
128 return object instanceof Graph || object instanceof BciBlockMapping;
0942e34b6c7d added PrintBackendCFG option (default is true) for controlling if backend output is dumped to the C1Visualizer
Doug Simon <doug.simon@oracle.com>
parents: 9658
diff changeset
129 }
0942e34b6c7d added PrintBackendCFG option (default is true) for controlling if backend output is dumped to the C1Visualizer
Doug Simon <doug.simon@oracle.com>
parents: 9658
diff changeset
130
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21725
diff changeset
131 private LIR lastLIR = null;
22568
3714119dfbc0 CFGPrinter: introduce IntervalDumper to abstract LSRA interval dumping.
Josef Eisl <josef.eisl@jku.at>
parents: 22516
diff changeset
132 private IntervalDumper delayedIntervals = null;
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21725
diff changeset
133
5029
74f47ef37394 Fix and enable liveness analysis to prune unnecessary frame state entries
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 5011
diff changeset
134 public void dumpSandboxed(Object object, String message) {
4535
10f300ba182f Make CFGObserver handle the case without GraalCompiler silently without NPE.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4525
diff changeset
135
11379
0942e34b6c7d added PrintBackendCFG option (default is true) for controlling if backend output is dumped to the C1Visualizer
Doug Simon <doug.simon@oracle.com>
parents: 9658
diff changeset
136 if (!dumpFrontend && isFrontendObject(object)) {
0942e34b6c7d added PrintBackendCFG option (default is true) for controlling if backend output is dumped to the C1Visualizer
Doug Simon <doug.simon@oracle.com>
parents: 9658
diff changeset
137 return;
0942e34b6c7d added PrintBackendCFG option (default is true) for controlling if backend output is dumped to the C1Visualizer
Doug Simon <doug.simon@oracle.com>
parents: 9658
diff changeset
138 }
0942e34b6c7d added PrintBackendCFG option (default is true) for controlling if backend output is dumped to the C1Visualizer
Doug Simon <doug.simon@oracle.com>
parents: 9658
diff changeset
139
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
140 if (cfgPrinter == null) {
22516
8cf9fa4368de Add option DumpPath to specify directory for IGV and C1Visualizer dump files; simplify file name construction for IGV files
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22489
diff changeset
141 cfgFile = getCFGPath().toFile();
4522
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4435
diff changeset
142 try {
5763
a3d71693e0ce removed bytecode disassembly from CodeCacheRuntime into separate BytecodeDisassembler class
Doug Simon <doug.simon@oracle.com>
parents: 5557
diff changeset
143 OutputStream out = new BufferedOutputStream(new FileOutputStream(cfgFile));
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4612
diff changeset
144 cfgPrinter = new CFGPrinter(out);
4522
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4435
diff changeset
145 } catch (FileNotFoundException e) {
21543
93c50cefb9e8 moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19168
diff changeset
146 throw new JVMCIError("Could not open " + cfgFile.getAbsolutePath());
4522
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4435
diff changeset
147 }
21906
e26913e5bc3c print absolute file names from CFGPrinterObserver
Doug Simon <doug.simon@oracle.com>
parents: 21780
diff changeset
148 TTY.println("CFGPrinter: Output to file %s", cfgFile.getAbsolutePath());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
149 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
150
5763
a3d71693e0ce removed bytecode disassembly from CodeCacheRuntime into separate BytecodeDisassembler class
Doug Simon <doug.simon@oracle.com>
parents: 5557
diff changeset
151 if (!checkMethodScope()) {
a3d71693e0ce removed bytecode disassembly from CodeCacheRuntime into separate BytecodeDisassembler class
Doug Simon <doug.simon@oracle.com>
parents: 5557
diff changeset
152 return;
a3d71693e0ce removed bytecode disassembly from CodeCacheRuntime into separate BytecodeDisassembler class
Doug Simon <doug.simon@oracle.com>
parents: 5557
diff changeset
153 }
15025
292353f2645c CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents: 14888
diff changeset
154 if (curMethod instanceof ResolvedJavaMethod) {
292353f2645c CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents: 14888
diff changeset
155 cfgPrinter.method = (ResolvedJavaMethod) curMethod;
292353f2645c CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents: 14888
diff changeset
156 }
4522
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4435
diff changeset
157
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4612
diff changeset
158 if (object instanceof LIR) {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4612
diff changeset
159 cfgPrinter.lir = (LIR) object;
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4612
diff changeset
160 } else {
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4612
diff changeset
161 cfgPrinter.lir = Debug.contextLookup(LIR.class);
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4612
diff changeset
162 }
14888
f6630873316b Rename NodeLIRGenerator (and related classes and interfaces) to NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents: 14842
diff changeset
163 cfgPrinter.nodeLirGenerator = Debug.contextLookup(NodeLIRBuilder.class);
14842
f2e61bf2a2d8 Removed nodeOperands from LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14826
diff changeset
164 if (cfgPrinter.nodeLirGenerator != null) {
f2e61bf2a2d8 Removed nodeOperands from LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14826
diff changeset
165 cfgPrinter.target = cfgPrinter.nodeLirGenerator.getLIRGeneratorTool().target();
8150
b66f831ac5ab Fix CFG printer output. Clean up after making the compiler class all-static.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7835
diff changeset
166 }
14814
f200eb890729 Handle AbstractBlock in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents: 14791
diff changeset
167 if (cfgPrinter.lir != null && cfgPrinter.lir.getControlFlowGraph() instanceof ControlFlowGraph) {
14791
be2be30c653d Introduce AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents: 14788
diff changeset
168 cfgPrinter.cfg = (ControlFlowGraph) cfgPrinter.lir.getControlFlowGraph();
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4612
diff changeset
169 }
4522
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4435
diff changeset
170
12045
0fc653a9e019 made GraalCodeCacheProvider independent of CodeCacheProvider and renamed the former to LoweringProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11379
diff changeset
171 CodeCacheProvider codeCache = Debug.contextLookup(CodeCacheProvider.class);
0fc653a9e019 made GraalCodeCacheProvider independent of CodeCacheProvider and renamed the former to LoweringProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11379
diff changeset
172 if (codeCache != null) {
0fc653a9e019 made GraalCodeCacheProvider independent of CodeCacheProvider and renamed the former to LoweringProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents: 11379
diff changeset
173 cfgPrinter.target = codeCache.getTarget();
8150
b66f831ac5ab Fix CFG printer output. Clean up after making the compiler class all-static.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7835
diff changeset
174 }
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4612
diff changeset
175
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4612
diff changeset
176 if (object instanceof BciBlockMapping) {
4522
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4435
diff changeset
177 BciBlockMapping blockMap = (BciBlockMapping) object;
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4435
diff changeset
178 cfgPrinter.printCFG(message, blockMap);
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6529
diff changeset
179 if (blockMap.method.getCode() != null) {
5763
a3d71693e0ce removed bytecode disassembly from CodeCacheRuntime into separate BytecodeDisassembler class
Doug Simon <doug.simon@oracle.com>
parents: 5557
diff changeset
180 cfgPrinter.printBytecodes(new BytecodeDisassembler(false).disassemble(blockMap.method));
a3d71693e0ce removed bytecode disassembly from CodeCacheRuntime into separate BytecodeDisassembler class
Doug Simon <doug.simon@oracle.com>
parents: 5557
diff changeset
181 }
4522
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4435
diff changeset
182
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4435
diff changeset
183 } else if (object instanceof LIR) {
16950
559ab93c1ad6 CFGPrinter: do not print empty HIR cfgs.
Josef Eisl <josef.eisl@jku.at>
parents: 15537
diff changeset
184 // Currently no node printing for lir
559ab93c1ad6 CFGPrinter: do not print empty HIR cfgs.
Josef Eisl <josef.eisl@jku.at>
parents: 15537
diff changeset
185 cfgPrinter.printCFG(message, cfgPrinter.lir.codeEmittingOrder(), false);
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21725
diff changeset
186 lastLIR = (LIR) object;
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21725
diff changeset
187 if (delayedIntervals != null) {
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21725
diff changeset
188 cfgPrinter.printIntervals(message, delayedIntervals);
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21725
diff changeset
189 delayedIntervals = null;
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21725
diff changeset
190 }
14594
3eda945af90a dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14145
diff changeset
191 } else if (object instanceof SchedulePhase) {
3eda945af90a dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14145
diff changeset
192 cfgPrinter.printSchedule(message, (SchedulePhase) object);
4522
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4435
diff changeset
193 } else if (object instanceof StructuredGraph) {
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4612
diff changeset
194 if (cfgPrinter.cfg == null) {
9234
b9cf7d0b598e removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents: 8349
diff changeset
195 StructuredGraph graph = (StructuredGraph) object;
b9cf7d0b598e removal of FixedNode.probability (draft)
Christian Haeubl <haeubl@ssw.jku.at>
parents: 8349
diff changeset
196 cfgPrinter.cfg = ControlFlowGraph.compute(graph, true, true, true, false);
4522
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4435
diff changeset
197 }
15537
8117e9cadb48 Use List instead of an array in AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents: 15193
diff changeset
198 cfgPrinter.printCFG(message, cfgPrinter.cfg.getBlocks(), true);
4522
cf13124efdd9 Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4435
diff changeset
199
5546
e42c0df7212a Rename CiTargetMethod => CompilationResult.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
200 } else if (object instanceof CompilationResult) {
8349
8d6ea1915d42 merged CodeInfo into InstalledCode (GRAAL-156)
Doug Simon <doug.simon@oracle.com>
parents: 8150
diff changeset
201 final CompilationResult compResult = (CompilationResult) object;
21706
4c00096fc415 moved CodeCacheProvider.disassemble(...) from API to CFGPrinterObserver
Doug Simon <doug.simon@oracle.com>
parents: 21556
diff changeset
202 cfgPrinter.printMachineCode(disassemble(codeCache, compResult, null), message);
8349
8d6ea1915d42 merged CodeInfo into InstalledCode (GRAAL-156)
Doug Simon <doug.simon@oracle.com>
parents: 8150
diff changeset
203 } else if (isCompilationResultAndInstalledCode(object)) {
5557
2e2a77f091f2 re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents: 5546
diff changeset
204 Object[] tuple = (Object[]) object;
21706
4c00096fc415 moved CodeCacheProvider.disassemble(...) from API to CFGPrinterObserver
Doug Simon <doug.simon@oracle.com>
parents: 21556
diff changeset
205 cfgPrinter.printMachineCode(disassemble(codeCache, (CompilationResult) tuple[0], (InstalledCode) tuple[1]), message);
22568
3714119dfbc0 CFGPrinter: introduce IntervalDumper to abstract LSRA interval dumping.
Josef Eisl <josef.eisl@jku.at>
parents: 22516
diff changeset
206 } else if (object instanceof IntervalDumper) {
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21725
diff changeset
207 if (lastLIR == cfgPrinter.lir) {
22568
3714119dfbc0 CFGPrinter: introduce IntervalDumper to abstract LSRA interval dumping.
Josef Eisl <josef.eisl@jku.at>
parents: 22516
diff changeset
208 cfgPrinter.printIntervals(message, (IntervalDumper) object);
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21725
diff changeset
209 } else {
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21725
diff changeset
210 if (delayedIntervals != null) {
22568
3714119dfbc0 CFGPrinter: introduce IntervalDumper to abstract LSRA interval dumping.
Josef Eisl <josef.eisl@jku.at>
parents: 22516
diff changeset
211 Debug.log("Some delayed intervals were dropped (%s)", delayedIntervals);
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21725
diff changeset
212 }
22568
3714119dfbc0 CFGPrinter: introduce IntervalDumper to abstract LSRA interval dumping.
Josef Eisl <josef.eisl@jku.at>
parents: 22516
diff changeset
213 delayedIntervals = (IntervalDumper) object;
21780
3d15183f3c93 Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21725
diff changeset
214 }
22339
ba6a5a66fa18 CFGPrinterObserver: add support for dumping a subset of blocks.
Josef Eisl <josef.eisl@jku.at>
parents: 22300
diff changeset
215 } else if (isBlockList(object)) {
ba6a5a66fa18 CFGPrinterObserver: add support for dumping a subset of blocks.
Josef Eisl <josef.eisl@jku.at>
parents: 22300
diff changeset
216 cfgPrinter.printCFG(message, getBlockList(object), false);
4278
b49981617b10 Fixes after removal of GraalCompilation
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
217 }
b49981617b10 Fixes after removal of GraalCompilation
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4265
diff changeset
218
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4612
diff changeset
219 cfgPrinter.target = null;
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4612
diff changeset
220 cfgPrinter.lir = null;
14842
f2e61bf2a2d8 Removed nodeOperands from LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents: 14826
diff changeset
221 cfgPrinter.nodeLirGenerator = null;
5011
5d0af6520f26 Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 4612
diff changeset
222 cfgPrinter.cfg = null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
223 cfgPrinter.flush();
11379
0942e34b6c7d added PrintBackendCFG option (default is true) for controlling if backend output is dumped to the C1Visualizer
Doug Simon <doug.simon@oracle.com>
parents: 9658
diff changeset
224
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
225 }
5557
2e2a77f091f2 re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents: 5546
diff changeset
226
22339
ba6a5a66fa18 CFGPrinterObserver: add support for dumping a subset of blocks.
Josef Eisl <josef.eisl@jku.at>
parents: 22300
diff changeset
227 @SuppressWarnings("unchecked")
ba6a5a66fa18 CFGPrinterObserver: add support for dumping a subset of blocks.
Josef Eisl <josef.eisl@jku.at>
parents: 22300
diff changeset
228 private static List<? extends AbstractBlockBase<?>> getBlockList(Object object) {
ba6a5a66fa18 CFGPrinterObserver: add support for dumping a subset of blocks.
Josef Eisl <josef.eisl@jku.at>
parents: 22300
diff changeset
229 return (List<? extends AbstractBlockBase<?>>) object;
ba6a5a66fa18 CFGPrinterObserver: add support for dumping a subset of blocks.
Josef Eisl <josef.eisl@jku.at>
parents: 22300
diff changeset
230 }
ba6a5a66fa18 CFGPrinterObserver: add support for dumping a subset of blocks.
Josef Eisl <josef.eisl@jku.at>
parents: 22300
diff changeset
231
ba6a5a66fa18 CFGPrinterObserver: add support for dumping a subset of blocks.
Josef Eisl <josef.eisl@jku.at>
parents: 22300
diff changeset
232 private static boolean isBlockList(Object object) {
ba6a5a66fa18 CFGPrinterObserver: add support for dumping a subset of blocks.
Josef Eisl <josef.eisl@jku.at>
parents: 22300
diff changeset
233 return object instanceof List<?> && ((List<?>) object).size() > 0 && ((List<?>) object).get(0) instanceof AbstractBlockBase<?>;
ba6a5a66fa18 CFGPrinterObserver: add support for dumping a subset of blocks.
Josef Eisl <josef.eisl@jku.at>
parents: 22300
diff changeset
234 }
ba6a5a66fa18 CFGPrinterObserver: add support for dumping a subset of blocks.
Josef Eisl <josef.eisl@jku.at>
parents: 22300
diff changeset
235
22516
8cf9fa4368de Add option DumpPath to specify directory for IGV and C1Visualizer dump files; simplify file name construction for IGV files
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22489
diff changeset
236 private static long timestamp;
8cf9fa4368de Add option DumpPath to specify directory for IGV and C1Visualizer dump files; simplify file name construction for IGV files
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22489
diff changeset
237 private static final AtomicInteger uniqueId = new AtomicInteger();
8cf9fa4368de Add option DumpPath to specify directory for IGV and C1Visualizer dump files; simplify file name construction for IGV files
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22489
diff changeset
238
8cf9fa4368de Add option DumpPath to specify directory for IGV and C1Visualizer dump files; simplify file name construction for IGV files
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22489
diff changeset
239 private static Path getCFGPath() {
8cf9fa4368de Add option DumpPath to specify directory for IGV and C1Visualizer dump files; simplify file name construction for IGV files
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22489
diff changeset
240 if (timestamp == 0) {
8cf9fa4368de Add option DumpPath to specify directory for IGV and C1Visualizer dump files; simplify file name construction for IGV files
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22489
diff changeset
241 timestamp = System.currentTimeMillis();
8cf9fa4368de Add option DumpPath to specify directory for IGV and C1Visualizer dump files; simplify file name construction for IGV files
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22489
diff changeset
242 }
8cf9fa4368de Add option DumpPath to specify directory for IGV and C1Visualizer dump files; simplify file name construction for IGV files
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22489
diff changeset
243 return Paths.get(GraalOptions.DumpPath.getValue(), "compilations-" + timestamp + "_" + uniqueId.incrementAndGet() + ".cfg");
8cf9fa4368de Add option DumpPath to specify directory for IGV and C1Visualizer dump files; simplify file name construction for IGV files
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22489
diff changeset
244 }
8cf9fa4368de Add option DumpPath to specify directory for IGV and C1Visualizer dump files; simplify file name construction for IGV files
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22489
diff changeset
245
22489
8b24fab0a573 Move reflection and service lookups only in static initializers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22367
diff changeset
246 /** Lazy initialization to delay service lookup until disassembler is actually needed. */
8b24fab0a573 Move reflection and service lookups only in static initializers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22367
diff changeset
247 static class DisassemblerHolder {
8b24fab0a573 Move reflection and service lookups only in static initializers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22367
diff changeset
248 private static final DisassemblerProvider disassembler;
21725
edafbaef3059 unified the DisassemblerProvider service interface to support both the hsdis and HexCodeFile based disassemblers
Doug Simon <doug.simon@oracle.com>
parents: 21706
diff changeset
249
22489
8b24fab0a573 Move reflection and service lookups only in static initializers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22367
diff changeset
250 static {
8b24fab0a573 Move reflection and service lookups only in static initializers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22367
diff changeset
251 DisassemblerProvider selected = null;
21725
edafbaef3059 unified the DisassemblerProvider service interface to support both the hsdis and HexCodeFile based disassemblers
Doug Simon <doug.simon@oracle.com>
parents: 21706
diff changeset
252 for (DisassemblerProvider d : Services.load(DisassemblerProvider.class)) {
edafbaef3059 unified the DisassemblerProvider service interface to support both the hsdis and HexCodeFile based disassemblers
Doug Simon <doug.simon@oracle.com>
parents: 21706
diff changeset
253 String name = d.getName().toLowerCase();
edafbaef3059 unified the DisassemblerProvider service interface to support both the hsdis and HexCodeFile based disassemblers
Doug Simon <doug.simon@oracle.com>
parents: 21706
diff changeset
254 if (name.contains("hcf") || name.contains("hexcodefile")) {
edafbaef3059 unified the DisassemblerProvider service interface to support both the hsdis and HexCodeFile based disassemblers
Doug Simon <doug.simon@oracle.com>
parents: 21706
diff changeset
255 selected = d;
edafbaef3059 unified the DisassemblerProvider service interface to support both the hsdis and HexCodeFile based disassemblers
Doug Simon <doug.simon@oracle.com>
parents: 21706
diff changeset
256 break;
21706
4c00096fc415 moved CodeCacheProvider.disassemble(...) from API to CFGPrinterObserver
Doug Simon <doug.simon@oracle.com>
parents: 21556
diff changeset
257 }
4c00096fc415 moved CodeCacheProvider.disassemble(...) from API to CFGPrinterObserver
Doug Simon <doug.simon@oracle.com>
parents: 21556
diff changeset
258 }
22489
8b24fab0a573 Move reflection and service lookups only in static initializers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22367
diff changeset
259 if (selected == null) {
8b24fab0a573 Move reflection and service lookups only in static initializers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22367
diff changeset
260 selected = new DisassemblerProvider() {
8b24fab0a573 Move reflection and service lookups only in static initializers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22367
diff changeset
261 public String getName() {
8b24fab0a573 Move reflection and service lookups only in static initializers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22367
diff changeset
262 return "nop";
8b24fab0a573 Move reflection and service lookups only in static initializers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22367
diff changeset
263 }
8b24fab0a573 Move reflection and service lookups only in static initializers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22367
diff changeset
264 };
8b24fab0a573 Move reflection and service lookups only in static initializers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22367
diff changeset
265 }
21725
edafbaef3059 unified the DisassemblerProvider service interface to support both the hsdis and HexCodeFile based disassemblers
Doug Simon <doug.simon@oracle.com>
parents: 21706
diff changeset
266 disassembler = selected;
21706
4c00096fc415 moved CodeCacheProvider.disassemble(...) from API to CFGPrinterObserver
Doug Simon <doug.simon@oracle.com>
parents: 21556
diff changeset
267 }
4c00096fc415 moved CodeCacheProvider.disassemble(...) from API to CFGPrinterObserver
Doug Simon <doug.simon@oracle.com>
parents: 21556
diff changeset
268 }
4c00096fc415 moved CodeCacheProvider.disassemble(...) from API to CFGPrinterObserver
Doug Simon <doug.simon@oracle.com>
parents: 21556
diff changeset
269
21725
edafbaef3059 unified the DisassemblerProvider service interface to support both the hsdis and HexCodeFile based disassemblers
Doug Simon <doug.simon@oracle.com>
parents: 21706
diff changeset
270 private static String disassemble(CodeCacheProvider codeCache, CompilationResult compResult, InstalledCode installedCode) {
22489
8b24fab0a573 Move reflection and service lookups only in static initializers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22367
diff changeset
271 DisassemblerProvider dis = DisassemblerHolder.disassembler;
21725
edafbaef3059 unified the DisassemblerProvider service interface to support both the hsdis and HexCodeFile based disassemblers
Doug Simon <doug.simon@oracle.com>
parents: 21706
diff changeset
272 if (installedCode != null) {
edafbaef3059 unified the DisassemblerProvider service interface to support both the hsdis and HexCodeFile based disassemblers
Doug Simon <doug.simon@oracle.com>
parents: 21706
diff changeset
273 return dis.disassembleInstalledCode(codeCache, compResult, installedCode);
21706
4c00096fc415 moved CodeCacheProvider.disassemble(...) from API to CFGPrinterObserver
Doug Simon <doug.simon@oracle.com>
parents: 21556
diff changeset
274 }
21725
edafbaef3059 unified the DisassemblerProvider service interface to support both the hsdis and HexCodeFile based disassemblers
Doug Simon <doug.simon@oracle.com>
parents: 21706
diff changeset
275 return dis.disassembleCompiledCode(codeCache, compResult);
21706
4c00096fc415 moved CodeCacheProvider.disassemble(...) from API to CFGPrinterObserver
Doug Simon <doug.simon@oracle.com>
parents: 21556
diff changeset
276 }
4c00096fc415 moved CodeCacheProvider.disassemble(...) from API to CFGPrinterObserver
Doug Simon <doug.simon@oracle.com>
parents: 21556
diff changeset
277
8349
8d6ea1915d42 merged CodeInfo into InstalledCode (GRAAL-156)
Doug Simon <doug.simon@oracle.com>
parents: 8150
diff changeset
278 private static boolean isCompilationResultAndInstalledCode(Object object) {
5557
2e2a77f091f2 re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents: 5546
diff changeset
279 if (object instanceof Object[]) {
2e2a77f091f2 re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents: 5546
diff changeset
280 Object[] tuple = (Object[]) object;
8349
8d6ea1915d42 merged CodeInfo into InstalledCode (GRAAL-156)
Doug Simon <doug.simon@oracle.com>
parents: 8150
diff changeset
281 if (tuple.length == 2 && tuple[0] instanceof CompilationResult && tuple[1] instanceof InstalledCode) {
5557
2e2a77f091f2 re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents: 5546
diff changeset
282 return true;
2e2a77f091f2 re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents: 5546
diff changeset
283 }
2e2a77f091f2 re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents: 5546
diff changeset
284 }
2e2a77f091f2 re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents: 5546
diff changeset
285 return false;
2e2a77f091f2 re-enabled disassembler output to C1Visualizer after code installation
Doug Simon <doug.simon@oracle.com>
parents: 5546
diff changeset
286 }
5819
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5763
diff changeset
287
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5763
diff changeset
288 @Override
7032
5a1f6e96e163 close() method for dump handlers should not throw IOException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6960
diff changeset
289 public void close() {
5819
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5763
diff changeset
290 if (cfgPrinter != null) {
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5763
diff changeset
291 cfgPrinter.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: 16950
diff changeset
292 cfgPrinter = null;
18665
96861e3f8cc5 made CFGPrinterObserver reset (upon close) properly
Doug Simon <doug.simon@oracle.com>
parents: 18642
diff changeset
293 curDecorators = Collections.emptyList();
96861e3f8cc5 made CFGPrinterObserver reset (upon close) properly
Doug Simon <doug.simon@oracle.com>
parents: 18642
diff changeset
294 curMethod = null;
5819
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5763
diff changeset
295 }
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5763
diff changeset
296 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
297 }