annotate src/share/vm/c1/c1_CFGPrinter.cpp @ 1819:f02a8bbe6ed4

6986046: C1 valuestack cleanup Summary: fixes an historical oddity in C1 with inlining where all of the expression stacks are kept in the topmost ValueStack instead of being in their respective ValueStacks. Reviewed-by: never Contributed-by: Christian Wimmer <cwimmer@uci.edu>
author roland
date Tue, 29 Dec 2009 19:08:54 +0100
parents c18cbe5936b8
children f95d63e2154a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_c1_CFGPrinter.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 class CFGPrinterOutput : public CHeapObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
32 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
33 outputStream* _output;
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 Compilation* _compilation;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 bool _do_print_HIR;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 bool _do_print_LIR;
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 class PrintBlockClosure: public BlockClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 void block_do(BlockBegin* block) { if (block != NULL) CFGPrinter::output()->print_block(block); }
a61af66fc99e Initial load
duke
parents:
diff changeset
41 };
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 outputStream* output() { assert(_output != NULL, ""); return _output; }
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 void inc_indent();
a61af66fc99e Initial load
duke
parents:
diff changeset
47 void dec_indent();
a61af66fc99e Initial load
duke
parents:
diff changeset
48 void print(const char* format, ...);
a61af66fc99e Initial load
duke
parents:
diff changeset
49 void print_begin(const char* tag);
a61af66fc99e Initial load
duke
parents:
diff changeset
50 void print_end(const char* tag);
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 char* method_name(ciMethod* method, bool short_name = false);
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
55 CFGPrinterOutput();
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 void set_compilation(Compilation* compilation) { _compilation = compilation; }
a61af66fc99e Initial load
duke
parents:
diff changeset
58 void set_print_flags(bool do_print_HIR, bool do_print_LIR) { _do_print_HIR = do_print_HIR; _do_print_LIR = do_print_LIR; }
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 void print_compilation();
a61af66fc99e Initial load
duke
parents:
diff changeset
61 void print_intervals(IntervalList* intervals, const char* name);
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 void print_state(BlockBegin* block);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 void print_operand(Value instr);
a61af66fc99e Initial load
duke
parents:
diff changeset
65 void print_HIR(Value instr);
a61af66fc99e Initial load
duke
parents:
diff changeset
66 void print_HIR(BlockBegin* block);
a61af66fc99e Initial load
duke
parents:
diff changeset
67 void print_LIR(BlockBegin* block);
a61af66fc99e Initial load
duke
parents:
diff changeset
68 void print_block(BlockBegin* block);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 void print_cfg(BlockList* blocks, const char* name);
a61af66fc99e Initial load
duke
parents:
diff changeset
70 void print_cfg(IR* blocks, const char* name);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 };
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 CFGPrinterOutput* CFGPrinter::_output = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 void CFGPrinter::print_compilation(Compilation* compilation) {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 if (_output == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 _output = new CFGPrinterOutput();
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82 output()->set_compilation(compilation);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 output()->print_compilation();
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 void CFGPrinter::print_cfg(BlockList* blocks, const char* name, bool do_print_HIR, bool do_print_LIR) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 output()->set_print_flags(do_print_HIR, do_print_LIR);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 output()->print_cfg(blocks, name);
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 void CFGPrinter::print_cfg(IR* blocks, const char* name, bool do_print_HIR, bool do_print_LIR) {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 output()->set_print_flags(do_print_HIR, do_print_LIR);
a61af66fc99e Initial load
duke
parents:
diff changeset
93 output()->print_cfg(blocks, name);
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 void CFGPrinter::print_intervals(IntervalList* intervals, const char* name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 output()->print_intervals(intervals, name);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 CFGPrinterOutput::CFGPrinterOutput()
a61af66fc99e Initial load
duke
parents:
diff changeset
104 : _output(new(ResourceObj::C_HEAP) fileStream("output.cfg"))
a61af66fc99e Initial load
duke
parents:
diff changeset
105 {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 void CFGPrinterOutput::inc_indent() {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 output()->inc();
a61af66fc99e Initial load
duke
parents:
diff changeset
112 output()->inc();
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 void CFGPrinterOutput::dec_indent() {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 output()->dec();
a61af66fc99e Initial load
duke
parents:
diff changeset
117 output()->dec();
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 void CFGPrinterOutput::print(const char* format, ...) {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 output()->indent();
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 va_list ap;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 va_start(ap, format);
a61af66fc99e Initial load
duke
parents:
diff changeset
125 output()->vprint_cr(format, ap);
a61af66fc99e Initial load
duke
parents:
diff changeset
126 va_end(ap);
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 void CFGPrinterOutput::print_begin(const char* tag) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 output()->indent();
a61af66fc99e Initial load
duke
parents:
diff changeset
131 output()->print_cr("begin_%s", tag);
a61af66fc99e Initial load
duke
parents:
diff changeset
132 inc_indent();
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 void CFGPrinterOutput::print_end(const char* tag) {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 dec_indent();
a61af66fc99e Initial load
duke
parents:
diff changeset
137 output()->indent();
a61af66fc99e Initial load
duke
parents:
diff changeset
138 output()->print_cr("end_%s", tag);
a61af66fc99e Initial load
duke
parents:
diff changeset
139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 char* CFGPrinterOutput::method_name(ciMethod* method, bool short_name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 stringStream name;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 if (short_name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 method->print_short_name(&name);
a61af66fc99e Initial load
duke
parents:
diff changeset
146 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 method->print_name(&name);
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149 return name.as_string();
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 void CFGPrinterOutput::print_compilation() {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 print_begin("compilation");
a61af66fc99e Initial load
duke
parents:
diff changeset
156
a61af66fc99e Initial load
duke
parents:
diff changeset
157 print("name \"%s\"", method_name(_compilation->method(), true));
a61af66fc99e Initial load
duke
parents:
diff changeset
158 print("method \"%s\"", method_name(_compilation->method()));
a61af66fc99e Initial load
duke
parents:
diff changeset
159 print("date "INT64_FORMAT, os::javaTimeMillis());
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 print_end("compilation");
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 void CFGPrinterOutput::print_state(BlockBegin* block) {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 print_begin("states");
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 InstructionPrinter ip(true, output());
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 ValueStack* state = block->state();
a61af66fc99e Initial load
duke
parents:
diff changeset
174 int index;
a61af66fc99e Initial load
duke
parents:
diff changeset
175 Value value;
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 for_each_state(state) {
a61af66fc99e Initial load
duke
parents:
diff changeset
178 print_begin("locals");
a61af66fc99e Initial load
duke
parents:
diff changeset
179 print("size %d", state->locals_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
180 print("method \"%s\"", method_name(state->scope()->method()));
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 for_each_local_value(state, index, value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 ip.print_phi(index, value, block);
a61af66fc99e Initial load
duke
parents:
diff changeset
184 print_operand(value);
a61af66fc99e Initial load
duke
parents:
diff changeset
185 output()->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187 print_end("locals");
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
188
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
189 if (state->stack_size() > 0) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
190 print_begin("stack");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
191 print("size %d", state->stack_size());
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
192 print("method \"%s\"", method_name(state->scope()->method()));
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
193
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
194 for_each_stack_value(state, index, value) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
195 ip.print_phi(index, value, block);
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
196 print_operand(value);
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
197 output()->cr();
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
198 }
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
199
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
200 print_end("stack");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
201 }
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
202
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
203 if (state->locks_size() > 0) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
204 print_begin("locks");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
205 print("size %d", state->locks_size());
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
206 print("method \"%s\"", method_name(state->scope()->method()));
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
207
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
208 for_each_lock_value(state, index, value) {
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
209 ip.print_phi(index, value, block);
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
210 print_operand(value);
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
211 output()->cr();
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
212 }
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
213 print_end("locks");
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
214 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
215 }
a61af66fc99e Initial load
duke
parents:
diff changeset
216
a61af66fc99e Initial load
duke
parents:
diff changeset
217 print_end("states");
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 void CFGPrinterOutput::print_operand(Value instr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 if (instr->operand()->is_virtual()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 output()->print(" \"");
a61af66fc99e Initial load
duke
parents:
diff changeset
224 instr->operand()->print(output());
a61af66fc99e Initial load
duke
parents:
diff changeset
225 output()->print("\" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 void CFGPrinterOutput::print_HIR(Value instr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 InstructionPrinter ip(true, output());
a61af66fc99e Initial load
duke
parents:
diff changeset
231
a61af66fc99e Initial load
duke
parents:
diff changeset
232 if (instr->is_pinned()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 output()->put('.');
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
235
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
236 output()->print("%d %d ", instr->printable_bci(), instr->use_count());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238 print_operand(instr);
a61af66fc99e Initial load
duke
parents:
diff changeset
239
a61af66fc99e Initial load
duke
parents:
diff changeset
240 ip.print_temp(instr);
a61af66fc99e Initial load
duke
parents:
diff changeset
241 output()->print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
242 ip.print_instr(instr);
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 output()->print_cr(" <|@");
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 void CFGPrinterOutput::print_HIR(BlockBegin* block) {
a61af66fc99e Initial load
duke
parents:
diff changeset
248 print_begin("HIR");
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 Value cur = block->next();
a61af66fc99e Initial load
duke
parents:
diff changeset
251 while (cur != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
252 print_HIR(cur);
a61af66fc99e Initial load
duke
parents:
diff changeset
253 cur = cur->next();
a61af66fc99e Initial load
duke
parents:
diff changeset
254 }
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 print_end("HIR");
a61af66fc99e Initial load
duke
parents:
diff changeset
257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 void CFGPrinterOutput::print_LIR(BlockBegin* block) {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 print_begin("LIR");
a61af66fc99e Initial load
duke
parents:
diff changeset
261
a61af66fc99e Initial load
duke
parents:
diff changeset
262 for (int i = 0; i < block->lir()->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
263 block->lir()->at(i)->print_on(output());
a61af66fc99e Initial load
duke
parents:
diff changeset
264 output()->print_cr(" <|@ ");
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 print_end("LIR");
a61af66fc99e Initial load
duke
parents:
diff changeset
268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270
a61af66fc99e Initial load
duke
parents:
diff changeset
271 void CFGPrinterOutput::print_block(BlockBegin* block) {
a61af66fc99e Initial load
duke
parents:
diff changeset
272 print_begin("block");
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274 print("name \"B%d\"", block->block_id());
a61af66fc99e Initial load
duke
parents:
diff changeset
275
a61af66fc99e Initial load
duke
parents:
diff changeset
276 print("from_bci %d", block->bci());
1819
f02a8bbe6ed4 6986046: C1 valuestack cleanup
roland
parents: 1552
diff changeset
277 print("to_bci %d", (block->end() == NULL ? -1 : block->end()->printable_bci()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 output()->indent();
a61af66fc99e Initial load
duke
parents:
diff changeset
280 output()->print("predecessors ");
a61af66fc99e Initial load
duke
parents:
diff changeset
281 int i;
a61af66fc99e Initial load
duke
parents:
diff changeset
282 for (i = 0; i < block->number_of_preds(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 output()->print("\"B%d\" ", block->pred_at(i)->block_id());
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285 output()->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 output()->indent();
a61af66fc99e Initial load
duke
parents:
diff changeset
288 output()->print("successors ");
a61af66fc99e Initial load
duke
parents:
diff changeset
289 for (i = 0; i < block->number_of_sux(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
290 output()->print("\"B%d\" ", block->sux_at(i)->block_id());
a61af66fc99e Initial load
duke
parents:
diff changeset
291 }
a61af66fc99e Initial load
duke
parents:
diff changeset
292 output()->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 output()->indent();
a61af66fc99e Initial load
duke
parents:
diff changeset
295 output()->print("xhandlers");
a61af66fc99e Initial load
duke
parents:
diff changeset
296 for (i = 0; i < block->number_of_exception_handlers(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
297 output()->print("\"B%d\" ", block->exception_handler_at(i)->block_id());
a61af66fc99e Initial load
duke
parents:
diff changeset
298 }
a61af66fc99e Initial load
duke
parents:
diff changeset
299 output()->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301 output()->indent();
a61af66fc99e Initial load
duke
parents:
diff changeset
302 output()->print("flags ");
a61af66fc99e Initial load
duke
parents:
diff changeset
303 if (block->is_set(BlockBegin::std_entry_flag)) output()->print("\"std\" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
304 if (block->is_set(BlockBegin::osr_entry_flag)) output()->print("\"osr\" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
305 if (block->is_set(BlockBegin::exception_entry_flag)) output()->print("\"ex\" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
306 if (block->is_set(BlockBegin::subroutine_entry_flag)) output()->print("\"sr\" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
307 if (block->is_set(BlockBegin::backward_branch_target_flag)) output()->print("\"bb\" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
308 if (block->is_set(BlockBegin::parser_loop_header_flag)) output()->print("\"plh\" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
309 if (block->is_set(BlockBegin::critical_edge_split_flag)) output()->print("\"ces\" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
310 if (block->is_set(BlockBegin::linear_scan_loop_header_flag)) output()->print("\"llh\" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
311 if (block->is_set(BlockBegin::linear_scan_loop_end_flag)) output()->print("\"lle\" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
312 output()->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
313
a61af66fc99e Initial load
duke
parents:
diff changeset
314 if (block->dominator() != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
315 print("dominator \"B%d\"", block->dominator()->block_id());
a61af66fc99e Initial load
duke
parents:
diff changeset
316 }
a61af66fc99e Initial load
duke
parents:
diff changeset
317 if (block->loop_index() != -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
318 print("loop_index %d", block->loop_index());
a61af66fc99e Initial load
duke
parents:
diff changeset
319 print("loop_depth %d", block->loop_depth());
a61af66fc99e Initial load
duke
parents:
diff changeset
320 }
a61af66fc99e Initial load
duke
parents:
diff changeset
321
a61af66fc99e Initial load
duke
parents:
diff changeset
322 if (block->first_lir_instruction_id() != -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
323 print("first_lir_id %d", block->first_lir_instruction_id());
a61af66fc99e Initial load
duke
parents:
diff changeset
324 print("last_lir_id %d", block->last_lir_instruction_id());
a61af66fc99e Initial load
duke
parents:
diff changeset
325 }
a61af66fc99e Initial load
duke
parents:
diff changeset
326
a61af66fc99e Initial load
duke
parents:
diff changeset
327 if (_do_print_HIR) {
a61af66fc99e Initial load
duke
parents:
diff changeset
328 print_state(block);
a61af66fc99e Initial load
duke
parents:
diff changeset
329 print_HIR(block);
a61af66fc99e Initial load
duke
parents:
diff changeset
330 }
a61af66fc99e Initial load
duke
parents:
diff changeset
331
a61af66fc99e Initial load
duke
parents:
diff changeset
332 if (_do_print_LIR) {
a61af66fc99e Initial load
duke
parents:
diff changeset
333 print_LIR(block);
a61af66fc99e Initial load
duke
parents:
diff changeset
334 }
a61af66fc99e Initial load
duke
parents:
diff changeset
335
a61af66fc99e Initial load
duke
parents:
diff changeset
336 print_end("block");
a61af66fc99e Initial load
duke
parents:
diff changeset
337 }
a61af66fc99e Initial load
duke
parents:
diff changeset
338
a61af66fc99e Initial load
duke
parents:
diff changeset
339
a61af66fc99e Initial load
duke
parents:
diff changeset
340
a61af66fc99e Initial load
duke
parents:
diff changeset
341 void CFGPrinterOutput::print_cfg(BlockList* blocks, const char* name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
342 print_begin("cfg");
a61af66fc99e Initial load
duke
parents:
diff changeset
343 print("name \"%s\"", name);
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345 PrintBlockClosure print_block;
a61af66fc99e Initial load
duke
parents:
diff changeset
346 blocks->iterate_forward(&print_block);
a61af66fc99e Initial load
duke
parents:
diff changeset
347
a61af66fc99e Initial load
duke
parents:
diff changeset
348 print_end("cfg");
a61af66fc99e Initial load
duke
parents:
diff changeset
349 output()->flush();
a61af66fc99e Initial load
duke
parents:
diff changeset
350 }
a61af66fc99e Initial load
duke
parents:
diff changeset
351
a61af66fc99e Initial load
duke
parents:
diff changeset
352 void CFGPrinterOutput::print_cfg(IR* blocks, const char* name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
353 print_begin("cfg");
a61af66fc99e Initial load
duke
parents:
diff changeset
354 print("name \"%s\"", name);
a61af66fc99e Initial load
duke
parents:
diff changeset
355
a61af66fc99e Initial load
duke
parents:
diff changeset
356 PrintBlockClosure print_block;
a61af66fc99e Initial load
duke
parents:
diff changeset
357 blocks->iterate_preorder(&print_block);
a61af66fc99e Initial load
duke
parents:
diff changeset
358
a61af66fc99e Initial load
duke
parents:
diff changeset
359 print_end("cfg");
a61af66fc99e Initial load
duke
parents:
diff changeset
360 output()->flush();
a61af66fc99e Initial load
duke
parents:
diff changeset
361 }
a61af66fc99e Initial load
duke
parents:
diff changeset
362
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364
a61af66fc99e Initial load
duke
parents:
diff changeset
365
a61af66fc99e Initial load
duke
parents:
diff changeset
366 void CFGPrinterOutput::print_intervals(IntervalList* intervals, const char* name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
367 print_begin("intervals");
a61af66fc99e Initial load
duke
parents:
diff changeset
368 print("name \"%s\"", name);
a61af66fc99e Initial load
duke
parents:
diff changeset
369
a61af66fc99e Initial load
duke
parents:
diff changeset
370 for (int i = 0; i < intervals->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
371 if (intervals->at(i) != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
372 intervals->at(i)->print(output());
a61af66fc99e Initial load
duke
parents:
diff changeset
373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
374 }
a61af66fc99e Initial load
duke
parents:
diff changeset
375
a61af66fc99e Initial load
duke
parents:
diff changeset
376 print_end("intervals");
a61af66fc99e Initial load
duke
parents:
diff changeset
377 output()->flush();
a61af66fc99e Initial load
duke
parents:
diff changeset
378 }
a61af66fc99e Initial load
duke
parents:
diff changeset
379
a61af66fc99e Initial load
duke
parents:
diff changeset
380
a61af66fc99e Initial load
duke
parents:
diff changeset
381 #endif