Mercurial > hg > truffle
annotate graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java @ 18937:ff232ff8d028
Add utility Node#hasNoUsages.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 23 Jan 2015 11:52:36 +0100 |
parents | ade7699e160e |
children | c943ba97b2a7 |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
15534
diff
changeset
|
2 * Copyright (c) 2009, 2014, 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 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
25 import static com.oracle.graal.api.code.ValueUtil.*; |
4183
9e0c1b4cfef5
Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4169
diff
changeset
|
26 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 import java.io.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 import java.util.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 |
5510
426c605c9d3c
Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
30 import com.oracle.graal.api.code.*; |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5506
diff
changeset
|
31 import com.oracle.graal.api.meta.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
32 import com.oracle.graal.compiler.alloc.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
33 import com.oracle.graal.compiler.alloc.Interval.UsePosList; |
15192
644dfe49c0f4
Move packages com.oracle.graal.cfg to com.oracle.graal.compiler.common.cfg.
Josef Eisl <josef.eisl@jku.at>
parents:
15157
diff
changeset
|
34 import com.oracle.graal.compiler.common.cfg.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
35 import com.oracle.graal.compiler.gen.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
36 import com.oracle.graal.graph.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
37 import com.oracle.graal.java.*; |
15025
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
38 import com.oracle.graal.java.BciBlockMapping.BciBlock; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
39 import com.oracle.graal.lir.*; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16796
diff
changeset
|
40 import com.oracle.graal.nodeinfo.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
41 import com.oracle.graal.nodes.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
42 import com.oracle.graal.nodes.calc.*; |
6529
2e96dc4eb8e2
renamed package: com.oracle.graal.lir.cfg -> com.oracle.graal.nodes.cfg
Doug Simon <doug.simon@oracle.com>
parents:
6436
diff
changeset
|
43 import com.oracle.graal.nodes.cfg.*; |
14594
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
44 import com.oracle.graal.phases.schedule.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 * Utility for printing Graal IR at various compilation phases. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 */ |
4200
816ac0e579fb
Move printer into separate project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4199
diff
changeset
|
49 class CFGPrinter extends CompilationPrinter { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5540
diff
changeset
|
51 protected TargetDescription target; |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
52 protected LIR lir; |
14888
f6630873316b
Rename NodeLIRGenerator (and related classes and interfaces) to NodeLIRBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
14842
diff
changeset
|
53 protected NodeLIRBuilder nodeLirGenerator; |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
54 protected ControlFlowGraph cfg; |
14594
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
55 protected SchedulePhase schedule; |
15025
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
56 protected ResolvedJavaMethod method; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 * Creates a control flow graph printer. |
15025
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
60 * |
5711
4d7175cf3526
enabled Eclipse/JDT javadoc checking and fixed resulting warnings
Doug Simon <doug.simon@oracle.com>
parents:
5552
diff
changeset
|
61 * @param out where the output generated via this printer shown be written |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 */ |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
63 public CFGPrinter(OutputStream out) { |
4522
cf13124efdd9
Restructure phi functions in LIR; Re-enabled C1Visualizer output
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4435
diff
changeset
|
64 super(out); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
65 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
66 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
67 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 * Prints the control flow graph denoted by a given block map. |
15025
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
69 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 * @param label A label describing the compilation phase that produced the control flow graph. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
71 * @param blockMap A data structure describing the blocks in a method and how they are |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
72 * connected. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 */ |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4295
diff
changeset
|
74 public void printCFG(String label, BciBlockMapping blockMap) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 begin("cfg"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 out.print("name \"").print(label).println('"'); |
18820
ade7699e160e
Calculate blocks immediately in correct order.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
17328
diff
changeset
|
77 for (BciBlockMapping.BciBlock block : blockMap.getBlocks()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 begin("block"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 printBlock(block); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
80 end("block"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
81 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 end("cfg"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
84 |
14827
2ed3233503b8
Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14826
diff
changeset
|
85 private void printBlock(BciBlockMapping.BciBlock block) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 out.print("name \"B").print(block.startBci).println('"'); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 out.print("from_bci ").println(block.startBci); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
88 out.print("to_bci ").println(block.endBci); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
89 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
90 out.println("predecessors "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
91 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
92 out.print("successors "); |
14829
8f6f63e997ba
BciBlock extends AbstractBlockBase
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14827
diff
changeset
|
93 for (BciBlockMapping.BciBlock succ : block.getSuccessors()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
94 if (!succ.isExceptionEntry) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
95 out.print("\"B").print(succ.startBci).print("\" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
96 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
97 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
98 out.println(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
99 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
100 out.print("xhandlers"); |
14829
8f6f63e997ba
BciBlock extends AbstractBlockBase
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14827
diff
changeset
|
101 for (BciBlockMapping.BciBlock succ : block.getSuccessors()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 if (succ.isExceptionEntry) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 out.print("\"B").print(succ.startBci).print("\" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
106 out.println(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
107 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
108 out.print("flags "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
109 if (block.isExceptionEntry) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
110 out.print("\"ex\" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
111 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
112 if (block.isLoopHeader) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
113 out.print("\"plh\" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
114 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
115 out.println(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
116 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 out.print("loop_depth ").println(Long.bitCount(block.loops)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
119 |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
120 private NodeMap<Block> latestScheduling; |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
121 private NodeBitMap printedNodes; |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
122 |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
123 private boolean inFixedSchedule(Node node) { |
14594
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
124 return lir != null || schedule != null || node.isDeleted() || cfg.getNodeToBlock().get(node) != null; |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
125 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
126 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 * Prints the specified list of blocks. |
15025
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
129 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
130 * @param label A label describing the compilation phase that produced the control flow graph. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
131 * @param blocks The list of blocks to be printed. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
132 */ |
14788
f0da23ee8315
Work around printCFG / AbstractBlock issue.
Josef Eisl <josef.eisl@jku.at>
parents:
14144
diff
changeset
|
133 public void printCFG(String label, List<? extends AbstractBlock<?>> blocks, boolean printNodes) { |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
134 if (lir == null) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
135 latestScheduling = new NodeMap<>(cfg.getNodeToBlock()); |
14788
f0da23ee8315
Work around printCFG / AbstractBlock issue.
Josef Eisl <josef.eisl@jku.at>
parents:
14144
diff
changeset
|
136 for (AbstractBlock<?> abstractBlock : blocks) { |
f0da23ee8315
Work around printCFG / AbstractBlock issue.
Josef Eisl <josef.eisl@jku.at>
parents:
14144
diff
changeset
|
137 Block block = (Block) abstractBlock; |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
138 Node cur = block.getBeginNode(); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
139 while (true) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
140 assert inFixedSchedule(cur) && latestScheduling.get(cur) == block; |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
141 scheduleInputs(cur, block); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
142 |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
143 if (cur == block.getEndNode()) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
144 break; |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
145 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
146 assert cur.successors().count() == 1; |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
147 cur = cur.successors().first(); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
148 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
149 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
150 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
151 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
152 begin("cfg"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
153 out.print("name \"").print(label).println('"'); |
14814
f200eb890729
Handle AbstractBlock in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
14806
diff
changeset
|
154 for (AbstractBlock<?> block : blocks) { |
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:
9436
diff
changeset
|
155 printBlock(block, printNodes); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
156 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
157 end("cfg"); |
15025
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
158 // NOTE: we do this only because the c1visualizer does not recognize the bytecode block if |
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
159 // it is proceeding the cfg blocks. Currently we have no direct influence on the emit order. |
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
160 // As a workaround we dump the bytecode after every cfg. |
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
161 if (method != null) { |
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
162 printBytecodes(new BytecodeDisassembler(false).disassemble(method)); |
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
163 } |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
164 |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
165 latestScheduling = null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
166 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
167 |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
168 private void scheduleInputs(Node node, Block nodeBlock) { |
14978
e302df8bf51c
separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14888
diff
changeset
|
169 if (node instanceof ValuePhiNode) { |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
170 PhiNode phi = (PhiNode) node; |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
171 assert nodeBlock.getBeginNode() == phi.merge(); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
172 for (Block pred : nodeBlock.getPredecessors()) { |
9434
50f02c7d1cec
Rename EndNode => AbstractEndNode and make abstract class. Introduce concrete EndNode subclass.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9336
diff
changeset
|
173 schedule(phi.valueAt((AbstractEndNode) pred.getEndNode()), pred); |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
174 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
175 |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
176 } else { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
177 for (Node input : node.inputs()) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
178 schedule(input, nodeBlock); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
179 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
180 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
181 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
182 |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
183 private void schedule(Node input, Block block) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
184 if (!inFixedSchedule(input)) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
185 Block inputBlock = block; |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
186 if (latestScheduling.get(input) != null) { |
16503
b3800429f543
Move commonDominator to AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents:
16345
diff
changeset
|
187 inputBlock = AbstractControlFlowGraph.commonDominatorTyped(inputBlock, latestScheduling.get(input)); |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
188 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
189 if (inputBlock != latestScheduling.get(input)) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
190 latestScheduling.set(input, inputBlock); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
191 scheduleInputs(input, inputBlock); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
192 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
193 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
194 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
195 |
14814
f200eb890729
Handle AbstractBlock in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
14806
diff
changeset
|
196 private void printBlock(AbstractBlock<?> block, boolean printNodes) { |
14594
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
197 printBlockProlog(block); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
198 if (printNodes) { |
14826 | 199 assert block instanceof Block; |
200 printNodes((Block) block); | |
14594
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
201 } |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
202 printBlockEpilog(block); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
203 } |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
204 |
14826 | 205 private void printBlockEpilog(AbstractBlock<?> block) { |
14594
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
206 printLIR(block); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
207 end("block"); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
208 } |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
209 |
14826 | 210 private void printBlockProlog(AbstractBlock<?> block) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
211 begin("block"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
212 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
213 out.print("name \"").print(blockToString(block)).println('"'); |
15025
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
214 if (block instanceof BciBlock) { |
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
215 out.print("from_bci ").println(((BciBlock) block).startBci); |
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
216 out.print("to_bci ").println(((BciBlock) block).endBci); |
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
217 } else { |
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
218 out.println("from_bci -1"); |
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
219 out.println("to_bci -1"); |
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
220 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
221 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
222 out.print("predecessors "); |
14814
f200eb890729
Handle AbstractBlock in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
14806
diff
changeset
|
223 for (AbstractBlock<?> pred : block.getPredecessors()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
224 out.print("\"").print(blockToString(pred)).print("\" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
225 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
226 out.println(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
227 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
228 out.print("successors "); |
14814
f200eb890729
Handle AbstractBlock in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
14806
diff
changeset
|
229 for (AbstractBlock<?> succ : block.getSuccessors()) { |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4295
diff
changeset
|
230 if (!succ.isExceptionEntry()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
231 out.print("\"").print(blockToString(succ)).print("\" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
232 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
233 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
234 out.println(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
235 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
236 out.print("xhandlers"); |
14814
f200eb890729
Handle AbstractBlock in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
14806
diff
changeset
|
237 for (AbstractBlock<?> succ : block.getSuccessors()) { |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4295
diff
changeset
|
238 if (succ.isExceptionEntry()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
239 out.print("\"").print(blockToString(succ)).print("\" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
240 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
241 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
242 out.println(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
243 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
244 out.print("flags "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
245 if (block.isLoopHeader()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
246 out.print("\"llh\" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
247 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
248 if (block.isLoopEnd()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
249 out.print("\"lle\" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
250 } |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4295
diff
changeset
|
251 if (block.isExceptionEntry()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
252 out.print("\"ex\" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
253 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
254 out.println(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
255 |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4295
diff
changeset
|
256 if (block.getLoop() != null) { |
15534
4bd6ad45ee0a
Encapsulate members of Loop.
Josef Eisl <josef.eisl@jku.at>
parents:
15241
diff
changeset
|
257 out.print("loop_index ").println(block.getLoop().getIndex()); |
4bd6ad45ee0a
Encapsulate members of Loop.
Josef Eisl <josef.eisl@jku.at>
parents:
15241
diff
changeset
|
258 out.print("loop_depth ").println(block.getLoop().getDepth()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
259 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
260 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
261 |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
262 private void printNodes(Block block) { |
14826 | 263 printedNodes = new NodeBitMap(cfg.graph); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
264 begin("IR"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
265 out.println("HIR"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
266 out.disableIndentation(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
267 |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4295
diff
changeset
|
268 if (block.getBeginNode() instanceof MergeNode) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
269 // Currently phi functions are not in the schedule, so print them separately here. |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4295
diff
changeset
|
270 for (ValueNode phi : ((MergeNode) block.getBeginNode()).phis()) { |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
271 printNode(phi, false); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
272 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
273 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
274 |
16950
559ab93c1ad6
CFGPrinter: do not print empty HIR cfgs.
Josef Eisl <josef.eisl@jku.at>
parents:
16897
diff
changeset
|
275 Node cur = block.getBeginNode(); |
559ab93c1ad6
CFGPrinter: do not print empty HIR cfgs.
Josef Eisl <josef.eisl@jku.at>
parents:
16897
diff
changeset
|
276 while (true) { |
559ab93c1ad6
CFGPrinter: do not print empty HIR cfgs.
Josef Eisl <josef.eisl@jku.at>
parents:
16897
diff
changeset
|
277 printNode(cur, false); |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
278 |
16950
559ab93c1ad6
CFGPrinter: do not print empty HIR cfgs.
Josef Eisl <josef.eisl@jku.at>
parents:
16897
diff
changeset
|
279 if (cur == block.getEndNode()) { |
559ab93c1ad6
CFGPrinter: do not print empty HIR cfgs.
Josef Eisl <josef.eisl@jku.at>
parents:
16897
diff
changeset
|
280 for (Map.Entry<Node, Block> entry : latestScheduling.entries()) { |
559ab93c1ad6
CFGPrinter: do not print empty HIR cfgs.
Josef Eisl <josef.eisl@jku.at>
parents:
16897
diff
changeset
|
281 if (entry.getValue() == block && !inFixedSchedule(entry.getKey()) && !printedNodes.isMarked(entry.getKey())) { |
559ab93c1ad6
CFGPrinter: do not print empty HIR cfgs.
Josef Eisl <josef.eisl@jku.at>
parents:
16897
diff
changeset
|
282 printNode(entry.getKey(), true); |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
283 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
284 } |
16950
559ab93c1ad6
CFGPrinter: do not print empty HIR cfgs.
Josef Eisl <josef.eisl@jku.at>
parents:
16897
diff
changeset
|
285 break; |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
286 } |
16950
559ab93c1ad6
CFGPrinter: do not print empty HIR cfgs.
Josef Eisl <josef.eisl@jku.at>
parents:
16897
diff
changeset
|
287 assert cur.successors().count() == 1; |
559ab93c1ad6
CFGPrinter: do not print empty HIR cfgs.
Josef Eisl <josef.eisl@jku.at>
parents:
16897
diff
changeset
|
288 cur = cur.successors().first(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
289 } |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
290 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
291 out.enableIndentation(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
292 end("IR"); |
14826 | 293 printedNodes = null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
294 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
295 |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
296 private void printNode(Node node, boolean unscheduled) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
297 assert !printedNodes.isMarked(node); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
298 printedNodes.mark(node); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
299 |
14978
e302df8bf51c
separate subclasses for value and guard phis and proxies
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14888
diff
changeset
|
300 if (!(node instanceof ValuePhiNode)) { |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
301 for (Node input : node.inputs()) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
302 if (!inFixedSchedule(input) && !printedNodes.isMarked(input)) { |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
303 printNode(input, true); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
304 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
305 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
306 } |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
307 |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
308 if (unscheduled) { |
14594
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
309 assert lir == null && schedule == null : "unscheduled nodes can only be present before LIR generation"; |
5011
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
310 out.print("f ").print(HOVER_START).print("u").print(HOVER_SEP).print("unscheduled").print(HOVER_END).println(COLUMN_END); |
5d0af6520f26
Do not use SchedulePhase in CFG printer
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4525
diff
changeset
|
311 } else if (node instanceof FixedWithNextNode) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
312 out.print("f ").print(HOVER_START).print("#").print(HOVER_SEP).print("fixed with next").print(HOVER_END).println(COLUMN_END); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
313 } else if (node instanceof FixedNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
314 out.print("f ").print(HOVER_START).print("*").print(HOVER_SEP).print("fixed").print(HOVER_END).println(COLUMN_END); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
315 } else if (node instanceof FloatingNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
316 out.print("f ").print(HOVER_START).print("~").print(HOVER_SEP).print("floating").print(HOVER_END).println(COLUMN_END); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
317 } |
4278
b49981617b10
Fixes after removal of GraalCompilation
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4265
diff
changeset
|
318 out.print("tid ").print(nodeToString(node)).println(COLUMN_END); |
b49981617b10
Fixes after removal of GraalCompilation
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4265
diff
changeset
|
319 |
14842
f2e61bf2a2d8
Removed nodeOperands from LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents:
14829
diff
changeset
|
320 if (nodeLirGenerator != null) { |
f2e61bf2a2d8
Removed nodeOperands from LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents:
14829
diff
changeset
|
321 Value operand = nodeLirGenerator.getNodeOperands().get(node); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
322 if (operand != null) { |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
323 out.print("result ").print(operand.toString()).println(COLUMN_END); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
324 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
325 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
326 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
327 if (node instanceof StateSplit) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
328 StateSplit stateSplit = (StateSplit) node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
329 if (stateSplit.stateAfter() != null) { |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
330 String state = stateToString(stateSplit.stateAfter()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
331 out.print("st ").print(HOVER_START).print("st").print(HOVER_SEP).print(state).print(HOVER_END).println(COLUMN_END); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
332 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
333 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
334 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
335 Map<Object, Object> props = new TreeMap<>(node.getDebugProperties()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
336 out.print("d ").print(HOVER_START).print("d").print(HOVER_SEP); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
337 out.println("=== Debug Properties ==="); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
338 for (Map.Entry<Object, Object> entry : props.entrySet()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
339 out.print(entry.getKey().toString()).print(": ").print(entry.getValue() == null ? "[null]" : entry.getValue().toString()).println(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
340 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
341 out.println("=== Inputs ==="); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
342 printNamedNodes(node, node.inputs().iterator(), "", "\n", null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
343 out.println("=== Succesors ==="); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
344 printNamedNodes(node, node.successors().iterator(), "", "\n", null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
345 out.println("=== Usages ==="); |
18937
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18820
diff
changeset
|
346 if (!node.hasNoUsages()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
347 for (Node usage : node.usages()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
348 out.print(nodeToString(usage)).print(" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
349 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
350 out.println(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
351 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
352 out.println("=== Predecessor ==="); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
353 out.print(nodeToString(node.predecessor())).print(" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
354 out.print(HOVER_END).println(COLUMN_END); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
355 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
356 out.print("instruction "); |
17272
9eb112c9337d
moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents:
17258
diff
changeset
|
357 out.print(HOVER_START).print(node.getNodeClass().shortName()).print(HOVER_SEP).print(node.getClass().getName()).print(HOVER_END).print(" "); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
358 printNamedNodes(node, node.inputs().iterator(), "", "", "#NDF"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
359 printNamedNodes(node, node.successors().iterator(), "#", "", "#NDF"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
360 for (Map.Entry<Object, Object> entry : props.entrySet()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
361 String key = entry.getKey().toString(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
362 if (key.startsWith("data.") && !key.equals("data.stamp")) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
363 out.print(key.substring("data.".length())).print(": ").print(entry.getValue() == null ? "[null]" : entry.getValue().toString()).print(" "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
364 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
365 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
366 out.print(COLUMN_END).print(' ').println(COLUMN_END); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
367 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
368 |
17008
81c9a1fc9072
select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents:
16950
diff
changeset
|
369 private void printNamedNodes(Node node, NodePosIterator iter, String prefix, String suffix, String hideSuffix) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
370 int lastIndex = -1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
371 while (iter.hasNext()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
372 Position pos = iter.nextPosition(); |
17210
ef64e2682bb6
added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents:
17194
diff
changeset
|
373 if (hideSuffix != null && pos.getName().endsWith(hideSuffix)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
374 continue; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
375 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
376 |
15241
c570c2fe9d2b
small refactoring of NodeClass.Position, remove duplicated functionality
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15192
diff
changeset
|
377 if (pos.getIndex() != lastIndex) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
378 if (lastIndex != -1) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
379 out.print(suffix); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
380 } |
17210
ef64e2682bb6
added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents:
17194
diff
changeset
|
381 out.print(prefix).print(pos.getName()).print(": "); |
15241
c570c2fe9d2b
small refactoring of NodeClass.Position, remove duplicated functionality
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15192
diff
changeset
|
382 lastIndex = pos.getIndex(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
383 } |
17210
ef64e2682bb6
added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents:
17194
diff
changeset
|
384 out.print(nodeToString(pos.get(node))).print(" "); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
385 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
386 if (lastIndex != -1) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
387 out.print(suffix); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
388 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
389 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
390 |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
391 private String stateToString(FrameState state) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
392 StringBuilder buf = new StringBuilder(); |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
393 FrameState curState = state; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
394 do { |
17328
c9bb0da795d4
Backed out of changeset 17322:655f3e6b467b
Doug Simon <doug.simon@oracle.com>
parents:
17327
diff
changeset
|
395 buf.append(MetaUtil.toLocation(curState.method(), curState.bci)).append('\n'); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
396 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
397 if (curState.stackSize() > 0) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
398 buf.append("stack: "); |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
399 for (int i = 0; i < curState.stackSize(); i++) { |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
400 buf.append(stateValueToString(curState.stackAt(i))).append(' '); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
401 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
402 buf.append("\n"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
403 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
404 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
405 buf.append("locals: "); |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
406 for (int i = 0; i < curState.localsSize(); i++) { |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
407 buf.append(stateValueToString(curState.localAt(i))).append(' '); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
408 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
409 buf.append("\n"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
410 |
6436
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6418
diff
changeset
|
411 buf.append("locks: "); |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6418
diff
changeset
|
412 for (int i = 0; i < curState.locksSize(); i++) { |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6418
diff
changeset
|
413 buf.append(stateValueToString(curState.lockAt(i))).append(' '); |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6418
diff
changeset
|
414 } |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6418
diff
changeset
|
415 buf.append("\n"); |
5395ecdfce8a
move monitors into FrameState (fixes subtle issues for tail duplication and other optimizations)
Lukas Stadler <lukas.stadler@jku.at>
parents:
6418
diff
changeset
|
416 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
417 curState = curState.outerFrameState(); |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
418 } while (curState != null); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
419 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
420 return buf.toString(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
421 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
422 |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
423 private String stateValueToString(ValueNode value) { |
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
424 String result = nodeToString(value); |
14842
f2e61bf2a2d8
Removed nodeOperands from LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents:
14829
diff
changeset
|
425 if (nodeLirGenerator != null && nodeLirGenerator.getNodeOperands() != null && value != null) { |
f2e61bf2a2d8
Removed nodeOperands from LIRGenerator.
Josef Eisl <josef.eisl@jku.at>
parents:
14829
diff
changeset
|
426 Value operand = nodeLirGenerator.getNodeOperands().get(value); |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
427 if (operand != null) { |
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
428 result += ": " + operand; |
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
429 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
430 } |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
431 return result; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
432 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
433 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
434 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
435 * Prints the LIR for each instruction in a given block. |
15025
292353f2645c
CFGPrinter: workaround for bytecode dumping.
Josef Eisl <josef.eisl@jku.at>
parents:
14978
diff
changeset
|
436 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
437 * @param block the block to print |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
438 */ |
14814
f200eb890729
Handle AbstractBlock in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
14806
diff
changeset
|
439 private void printLIR(AbstractBlock<?> block) { |
6418
aa57aa781e86
fixed small regression in CFGPrinter
Doug Simon <doug.simon@oracle.com>
parents:
6411
diff
changeset
|
440 if (lir == null) { |
aa57aa781e86
fixed small regression in CFGPrinter
Doug Simon <doug.simon@oracle.com>
parents:
6411
diff
changeset
|
441 return; |
aa57aa781e86
fixed small regression in CFGPrinter
Doug Simon <doug.simon@oracle.com>
parents:
6411
diff
changeset
|
442 } |
14806
a8723f1ff542
LIR renamed setter and getter functions.
Josef Eisl <josef.eisl@jku.at>
parents:
14796
diff
changeset
|
443 List<LIRInstruction> lirInstructions = lir.getLIRforBlock(block); |
4260
78379b4203ec
remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4233
diff
changeset
|
444 if (lirInstructions == null) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
445 return; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
446 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
447 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
448 begin("IR"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
449 out.println("LIR"); |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
450 |
4260
78379b4203ec
remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4233
diff
changeset
|
451 for (int i = 0; i < lirInstructions.size(); i++) { |
78379b4203ec
remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
Lukas Stadler <lukas.stadler@jku.at>
parents:
4233
diff
changeset
|
452 LIRInstruction inst = lirInstructions.get(i); |
17194
e92cf6db7a07
Handle deleted instructions in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
17064
diff
changeset
|
453 if (inst == null) { |
e92cf6db7a07
Handle deleted instructions in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
17064
diff
changeset
|
454 out.print("nr -1 ").print(COLUMN_END).print(" instruction ").print("<deleted>").print(COLUMN_END); |
e92cf6db7a07
Handle deleted instructions in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
17064
diff
changeset
|
455 out.println(COLUMN_END); |
e92cf6db7a07
Handle deleted instructions in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
17064
diff
changeset
|
456 } else { |
e92cf6db7a07
Handle deleted instructions in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
17064
diff
changeset
|
457 out.printf("nr %4d ", inst.id()).print(COLUMN_END); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
458 |
17194
e92cf6db7a07
Handle deleted instructions in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
17064
diff
changeset
|
459 final StringBuilder stateString = new StringBuilder(); |
17296
e03a25f5a260
Replace anonymous StateProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17279
diff
changeset
|
460 inst.forEachState(state -> { |
e03a25f5a260
Replace anonymous StateProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17279
diff
changeset
|
461 if (state.hasDebugInfo()) { |
e03a25f5a260
Replace anonymous StateProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17279
diff
changeset
|
462 DebugInfo di = state.debugInfo(); |
e03a25f5a260
Replace anonymous StateProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17279
diff
changeset
|
463 stateString.append(debugInfoToString(di.getBytecodePosition(), di.getReferenceMap(), di.getCalleeSaveInfo(), target.arch)); |
e03a25f5a260
Replace anonymous StateProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17279
diff
changeset
|
464 } else { |
e03a25f5a260
Replace anonymous StateProcedures with Lambdas.
Josef Eisl <josef.eisl@jku.at>
parents:
17279
diff
changeset
|
465 stateString.append(debugInfoToString(state.topFrame, null, null, target.arch)); |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5724
diff
changeset
|
466 } |
17194
e92cf6db7a07
Handle deleted instructions in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
17064
diff
changeset
|
467 }); |
e92cf6db7a07
Handle deleted instructions in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
17064
diff
changeset
|
468 if (stateString.length() > 0) { |
e92cf6db7a07
Handle deleted instructions in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
17064
diff
changeset
|
469 int level = out.indentationLevel(); |
e92cf6db7a07
Handle deleted instructions in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
17064
diff
changeset
|
470 out.adjustIndentation(-level); |
e92cf6db7a07
Handle deleted instructions in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
17064
diff
changeset
|
471 out.print(" st ").print(HOVER_START).print("st").print(HOVER_SEP).print(stateString.toString()).print(HOVER_END).print(COLUMN_END); |
e92cf6db7a07
Handle deleted instructions in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
17064
diff
changeset
|
472 out.adjustIndentation(level); |
5733
141b15521a39
use annotated fields for operands of LIR instructions
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5724
diff
changeset
|
473 } |
17194
e92cf6db7a07
Handle deleted instructions in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
17064
diff
changeset
|
474 |
e92cf6db7a07
Handle deleted instructions in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
17064
diff
changeset
|
475 out.print(" instruction ").print(inst.toString()).print(COLUMN_END); |
e92cf6db7a07
Handle deleted instructions in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
17064
diff
changeset
|
476 out.println(COLUMN_END); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
477 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
478 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
479 end("IR"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
480 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
481 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
482 private String nodeToString(Node node) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
483 if (node == null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
484 return "-"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
485 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
486 String prefix; |
15145
df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15025
diff
changeset
|
487 if (node instanceof BeginNode && (lir == null && schedule == null)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
488 prefix = "B"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
489 } else if (node instanceof ValueNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
490 ValueNode value = (ValueNode) node; |
14633
da2431cc1506
Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents:
14594
diff
changeset
|
491 if (value.getKind() == Kind.Illegal) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
492 prefix = "v"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
493 } else { |
14633
da2431cc1506
Rename ValueNode kind() to getKind().
Josef Eisl <josef.eisl@jku.at>
parents:
14594
diff
changeset
|
494 prefix = String.valueOf(value.getKind().getTypeChar()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
495 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
496 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
497 prefix = "?"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
498 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
499 return prefix + node.toString(Verbosity.Id); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
500 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
501 |
14814
f200eb890729
Handle AbstractBlock in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
14806
diff
changeset
|
502 private String blockToString(AbstractBlock<?> block) { |
14826 | 503 if (lir == null && schedule == null && block instanceof Block) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
504 // During all the front-end phases, the block schedule is built only for the debug |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
505 // output. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
506 // Therefore, the block numbers would be different for every CFG printed -> use the id |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
507 // of the first instruction. |
14814
f200eb890729
Handle AbstractBlock in CFGPrinter.
Josef Eisl <josef.eisl@jku.at>
parents:
14806
diff
changeset
|
508 return "B" + ((Block) block).getBeginNode().toString(Verbosity.Id); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
509 } else { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
510 // LIR instructions contain references to blocks and these blocks are printed as the |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7499
diff
changeset
|
511 // blockID -> use the blockID. |
4435
57cb8ec5f6bb
Restructure block and control flow graph data structures
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4295
diff
changeset
|
512 return "B" + block.getId(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
513 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
514 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
515 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
516 public void printIntervals(String label, Interval[] intervals) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
517 begin("intervals"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
518 out.println(String.format("name \"%s\"", label)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
519 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
520 for (Interval interval : intervals) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
521 if (interval != null) { |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
522 printInterval(interval); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
523 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
524 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
525 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
526 end("intervals"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
527 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
528 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
529 private void printInterval(Interval interval) { |
16345
d0c5f9bc7d98
Fix c1visualizer dump.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
530 out.printf("%s %s ", interval.operand, (isRegister(interval.operand) ? "fixed" : interval.kind().getPlatformKind())); |
4183
9e0c1b4cfef5
Move all isXxx and asXxx out of CiValue and into their own util class.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4169
diff
changeset
|
531 if (isRegister(interval.operand)) { |
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
|
532 out.printf("\"[%s|%c]\"", interval.operand, interval.operand.getKind().getTypeChar()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
533 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
534 if (interval.location() != null) { |
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
|
535 out.printf("\"[%s|%c]\"", interval.location(), interval.location().getKind().getTypeChar()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
536 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
537 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
538 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
539 Interval hint = interval.locationHint(false); |
4169
f5328dda9714
Initial commit of SSA-based spill-all register assignment
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents:
4142
diff
changeset
|
540 out.printf("%s %s ", interval.splitParent().operand, hint != null ? hint.operand : -1); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
541 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
542 // print ranges |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
543 Range cur = interval.first(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
544 while (cur != Range.EndMarker) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
545 out.printf("[%d, %d[", cur.from, cur.to); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
546 cur = cur.next; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
547 assert cur != null : "range list not closed with range sentinel"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
548 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
549 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
550 // print use positions |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
551 int prev = 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
552 UsePosList usePosList = interval.usePosList(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
553 for (int i = usePosList.size() - 1; i >= 0; --i) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
554 assert prev < usePosList.usePos(i) : "use positions not sorted"; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
555 out.printf("%d %s ", usePosList.usePos(i), usePosList.registerPriority(i)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
556 prev = usePosList.usePos(i); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
557 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
558 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
559 out.printf(" \"%s\"", interval.spillState()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
560 out.println(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
561 } |
14594
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
562 |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
563 public void printSchedule(String message, SchedulePhase theSchedule) { |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
564 schedule = theSchedule; |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
565 cfg = schedule.getCFG(); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
566 printedNodes = new NodeBitMap(cfg.graph); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
567 |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
568 begin("cfg"); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
569 out.print("name \"").print(message).println('"'); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
570 for (Block b : schedule.getCFG().getBlocks()) { |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
571 if (schedule.nodesFor(b) != null) { |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
572 printScheduledBlock(b, schedule.nodesFor(b)); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
573 } |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
574 } |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
575 end("cfg"); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
576 |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
577 schedule = null; |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
578 cfg = null; |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
579 printedNodes = null; |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
580 } |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
581 |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
582 private void printScheduledBlock(Block block, List<ScheduledNode> nodesFor) { |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
583 printBlockProlog(block); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
584 begin("IR"); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
585 out.println("HIR"); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
586 out.disableIndentation(); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
587 |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
588 if (block.getBeginNode() instanceof MergeNode) { |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
589 // Currently phi functions are not in the schedule, so print them separately here. |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
590 for (ValueNode phi : ((MergeNode) block.getBeginNode()).phis()) { |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
591 printNode(phi, false); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
592 } |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
593 } |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
594 |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
595 for (Node n : nodesFor) { |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
596 printNode(n, false); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
597 } |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
598 |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
599 out.enableIndentation(); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
600 end("IR"); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
601 |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
602 printBlockEpilog(block); |
3eda945af90a
dump final HIR schedule to c1visualizer
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
14159
diff
changeset
|
603 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
604 } |