comparison graal/GraalCompiler/src/com/sun/c1x/debug/CFGPrinter.java @ 2564:274360f98f97

Remove inlining (2nd part) removed IRScope
author Gilles Duboscq <gilles.duboscq@oracle.com>
date Fri, 29 Apr 2011 13:19:17 +0200
parents a384fac3fd34
children cc1f1d396288
comparison
equal deleted inserted replaced
2563:491896f81cae 2564:274360f98f97
97 out.adjustIndentation(2); 97 out.adjustIndentation(2);
98 } 98 }
99 99
100 private void end(String string) { 100 private void end(String string) {
101 out.adjustIndentation(-2); 101 out.adjustIndentation(-2);
102 end("states");
103 end("states");
104 end("states");
105 end("states");
102 out.println("end_" + string); 106 out.println("end_" + string);
103 } 107 }
104 108
105 /** 109 /**
106 * Prints a compilation timestamp for a given method. 110 * Prints a compilation timestamp for a given method.
125 * @param printLIR if {@code true} the LIR for each instruction in the block will be printed 129 * @param printLIR if {@code true} the LIR for each instruction in the block will be printed
126 */ 130 */
127 void printBlock(BlockBegin block, List<BlockBegin> successors, Iterable<BlockBegin> handlers, boolean printHIR, boolean printLIR) { 131 void printBlock(BlockBegin block, List<BlockBegin> successors, Iterable<BlockBegin> handlers, boolean printHIR, boolean printLIR) {
128 begin("block"); 132 begin("block");
129 133
134 end("states");
130 out.print("name \"B").print(block.blockID).println('"'); 135 out.print("name \"B").print(block.blockID).println('"');
131 out.print("from_bci ").println(block.bci()); 136 out.print("from_bci ").println(block.bci());
132 out.print("to_bci ").println(block.end() == null ? -1 : block.end().bci()); 137 out.print("to_bci ").println(block.end() == null ? -1 : block.end().bci());
133 138
134 out.print("predecessors "); 139 out.print("predecessors ");
156 if (block.isExceptionEntry()) { 161 if (block.isExceptionEntry()) {
157 out.print("\"ex\" "); 162 out.print("\"ex\" ");
158 } 163 }
159 if (block.isSubroutineEntry()) { 164 if (block.isSubroutineEntry()) {
160 out.print("\"sr\" "); 165 out.print("\"sr\" ");
166 end("states");
167 end("states");
161 } 168 }
162 if (block.isBackwardBranchTarget()) { 169 if (block.isBackwardBranchTarget()) {
163 out.print("\"bb\" "); 170 out.print("\"bb\" ");
164 } 171 }
165 if (block.isParserLoopHeader()) { 172 if (block.isParserLoopHeader()) {
200 * Prints the JVM frame state upon entry to a given block. 207 * Prints the JVM frame state upon entry to a given block.
201 * 208 *
202 * @param block the block for which the frame state is to be printed 209 * @param block the block for which the frame state is to be printed
203 */ 210 */
204 private void printState(BlockBegin block) { 211 private void printState(BlockBegin block) {
205 begin("states"); 212 begin("state");
206 213
207 FrameState state = block.stateBefore(); 214 FrameState state = block.stateBefore();
208 215 int stackSize = state.stackSize();
209 do { 216 if (stackSize > 0) {
210 int stackSize = state.stackSize(); 217 begin("stack");
211 if (stackSize > 0) { 218 out.print("size ").println(stackSize);
212 begin("stack"); 219 out.print("method \"").print(CiUtil.toLocation(state.method, state.bci)).println('"');
213 out.print("size ").println(stackSize); 220
214 out.print("method \"").print(CiUtil.toLocation(state.scope().method, state.bci)).println('"');
215
216 int i = 0;
217 while (i < stackSize) {
218 Value value = state.stackAt(i);
219 out.disableIndentation();
220 out.print(block.stateString(i, value));
221 printOperand(value);
222 out.println();
223 out.enableIndentation();
224 if (value == null) {
225 i++;
226 } else {
227 i += value.kind.sizeInSlots();
228 }
229 }
230 end("stack");
231 }
232
233 if (state.locksSize() > 0) {
234 begin("locks");
235 out.print("size ").println(state.locksSize());
236 out.print("method \"").print(CiUtil.toLocation(state.scope().method, state.bci)).println('"');
237
238 for (int i = 0; i < state.locksSize(); ++i) {
239 Value value = state.lockAt(i);
240 out.disableIndentation();
241 out.print(block.stateString(i, value));
242 printOperand(value);
243 out.println();
244 out.enableIndentation();
245 }
246 end("locks");
247 }
248
249 begin("locals");
250 out.print("size ").println(state.localsSize());
251 out.print("method \"").print(CiUtil.toLocation(state.scope().method, state.bci)).println('"');
252 int i = 0; 221 int i = 0;
253 while (i < state.localsSize()) { 222 while (i < stackSize) {
254 Value value = state.localAt(i); 223 Value value = state.stackAt(i);
255 if (value != null) { 224 out.disableIndentation();
256 out.disableIndentation(); 225 out.print(block.stateString(i, value));
257 out.print(block.stateString(i, value)); 226 printOperand(value);
258 printOperand(value); 227 out.println();
259 out.println(); 228 out.enableIndentation();
260 out.enableIndentation(); 229 if (value == null) {
261 // also ignore illegal HiWords 230 i++;
262 i += value.isIllegal() ? 1 : value.kind.sizeInSlots();
263 } else { 231 } else {
264 i++; 232 i += value.kind.sizeInSlots();
265 } 233 }
266 } 234 }
267 state = state.callerState(); 235 end("stack");
268 end("locals"); 236 }
269 } while (state != null); 237
270 238 if (state.locksSize() > 0) {
271 end("states"); 239 begin("locks");
240 out.print("size ").println(state.locksSize());
241 out.print("method \"").print(CiUtil.toLocation(state.method, state.bci)).println('"');
242
243 for (int i = 0; i < state.locksSize(); ++i) {
244 Value value = state.lockAt(i);
245 out.disableIndentation();
246 out.print(block.stateString(i, value));
247 printOperand(value);
248 out.println();
249 out.enableIndentation();
250 }
251 end("locks");
252 }
253
254 begin("locals");
255 out.print("size ").println(state.localsSize());
256 out.print("method \"").print(CiUtil.toLocation(state.method, state.bci)).println('"');
257 int i = 0;
258 while (i < state.localsSize()) {
259 Value value = state.localAt(i);
260 if (value != null) {
261 out.disableIndentation();
262 out.print(block.stateString(i, value));
263 printOperand(value);
264 out.println();
265 out.enableIndentation();
266 // also ignore illegal HiWords
267 i += value.isIllegal() ? 1 : value.kind.sizeInSlots();
268 } else {
269 i++;
270 }
271 }
272 end("locals");
273 end("state");
272 } 274 }
273 275
274 /** 276 /**
275 * Formats a given {@linkplain FrameState JVM frame state} as a multi line string. 277 * Formats a given {@linkplain FrameState JVM frame state} as a multi line string.
276 */ 278 */
278 if (state == null) { 280 if (state == null) {
279 return null; 281 return null;
280 } 282 }
281 283
282 StringBuilder buf = new StringBuilder(); 284 StringBuilder buf = new StringBuilder();
283 285 buf.append(CiUtil.toLocation(state.method, state.bci));
284 do { 286 buf.append('\n');
285 buf.append(CiUtil.toLocation(state.scope().method, state.bci)); 287 if (state.stackSize() > 0) {
286 buf.append('\n');
287 if (state.stackSize() > 0) {
288 int i = 0;
289 buf.append("stack: ");
290 while (i < state.stackSize()) {
291 if (i == 0) {
292 buf.append(' ');
293 }
294 Value value = state.stackAt(i);
295 buf.append(stateValueToString(value, operandFmt)).append(' ');
296 i++;
297 }
298 buf.append("\n");
299 }
300
301 if (state.locksSize() > 0) {
302 buf.append("locks: ");
303 for (int i = 0; i < state.locksSize(); ++i) {
304 if (i == 0) {
305 buf.append(' ');
306 }
307 Value value = state.lockAt(i);
308 buf.append(stateValueToString(value, operandFmt)).append(' ');
309 }
310 buf.append("\n");
311 }
312
313 buf.append("locals: ");
314 int i = 0; 288 int i = 0;
315 while (i < state.localsSize()) { 289 buf.append("stack: ");
290 while (i < state.stackSize()) {
316 if (i == 0) { 291 if (i == 0) {
317 buf.append(' '); 292 buf.append(' ');
318 } 293 }
319 Value value = state.localAt(i); 294 Value value = state.stackAt(i);
320 buf.append(stateValueToString(value, operandFmt)).append(' '); 295 buf.append(stateValueToString(value, operandFmt)).append(' ');
321 i++; 296 i++;
322 } 297 }
323 buf.append("\n"); 298 buf.append("\n");
324 state = state.callerState(); 299 }
325 } while (state != null); 300
301 if (state.locksSize() > 0) {
302 buf.append("locks: ");
303 for (int i = 0; i < state.locksSize(); ++i) {
304 if (i == 0) {
305 buf.append(' ');
306 }
307 Value value = state.lockAt(i);
308 buf.append(stateValueToString(value, operandFmt)).append(' ');
309 }
310 buf.append("\n");
311 }
312
313 buf.append("locals: ");
314 int i = 0;
315 while (i < state.localsSize()) {
316 if (i == 0) {
317 buf.append(' ');
318 }
319 Value value = state.localAt(i);
320 buf.append(stateValueToString(value, operandFmt)).append(' ');
321 i++;
322 }
323 buf.append("\n");
326 return buf.toString(); 324 return buf.toString();
327 } 325 }
328 326
329 private String stateValueToString(Value value, OperandFormatter operandFmt) { 327 private String stateValueToString(Value value, OperandFormatter operandFmt) {
330 if (operandFmt == null) { 328 if (operandFmt == null) {