Mercurial > hg > truffle
annotate src/share/vm/c1/c1_InstructionPrinter.cpp @ 7666:31540ca73e81
Remove ControlFlowException in SimpleLanguage.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 01 Feb 2013 19:53:52 +0100 |
parents | 203f64878aab |
children | 46f6f063b272 |
rev | line source |
---|---|
0 | 1 /* |
7623
203f64878aab
7102489: RFE: cleanup jlong typedef on __APPLE__and _LLP64 systems.
hseigel
parents:
6795
diff
changeset
|
2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
989
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
989
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:
989
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "c1/c1_InstructionPrinter.hpp" | |
27 #include "c1/c1_ValueStack.hpp" | |
28 #include "ci/ciArray.hpp" | |
29 #include "ci/ciInstance.hpp" | |
30 #include "ci/ciObject.hpp" | |
0 | 31 |
32 | |
33 #ifndef PRODUCT | |
34 | |
35 const char* InstructionPrinter::basic_type_name(BasicType type) { | |
36 switch (type) { | |
37 case T_BOOLEAN: return "boolean"; | |
38 case T_BYTE : return "byte"; | |
39 case T_CHAR : return "char"; | |
40 case T_SHORT : return "short"; | |
41 case T_INT : return "int"; | |
42 case T_LONG : return "long"; | |
43 case T_FLOAT : return "float"; | |
44 case T_DOUBLE : return "double"; | |
45 case T_ARRAY : return "array"; | |
46 case T_OBJECT : return "object"; | |
47 default : return "???"; | |
48 } | |
49 } | |
50 | |
51 | |
52 const char* InstructionPrinter::cond_name(If::Condition cond) { | |
53 switch (cond) { | |
54 case If::eql: return "=="; | |
55 case If::neq: return "!="; | |
56 case If::lss: return "<"; | |
57 case If::leq: return "<="; | |
58 case If::gtr: return ">"; | |
59 case If::geq: return ">="; | |
60 } | |
61 ShouldNotReachHere(); | |
62 return NULL; | |
63 } | |
64 | |
65 | |
66 const char* InstructionPrinter::op_name(Bytecodes::Code op) { | |
67 switch (op) { | |
68 // arithmetic ops | |
69 case Bytecodes::_iadd : // fall through | |
70 case Bytecodes::_ladd : // fall through | |
71 case Bytecodes::_fadd : // fall through | |
72 case Bytecodes::_dadd : return "+"; | |
73 case Bytecodes::_isub : // fall through | |
74 case Bytecodes::_lsub : // fall through | |
75 case Bytecodes::_fsub : // fall through | |
76 case Bytecodes::_dsub : return "-"; | |
77 case Bytecodes::_imul : // fall through | |
78 case Bytecodes::_lmul : // fall through | |
79 case Bytecodes::_fmul : // fall through | |
80 case Bytecodes::_dmul : return "*"; | |
81 case Bytecodes::_idiv : // fall through | |
82 case Bytecodes::_ldiv : // fall through | |
83 case Bytecodes::_fdiv : // fall through | |
84 case Bytecodes::_ddiv : return "/"; | |
85 case Bytecodes::_irem : // fall through | |
86 case Bytecodes::_lrem : // fall through | |
87 case Bytecodes::_frem : // fall through | |
88 case Bytecodes::_drem : return "%"; | |
89 // shift ops | |
90 case Bytecodes::_ishl : // fall through | |
91 case Bytecodes::_lshl : return "<<"; | |
92 case Bytecodes::_ishr : // fall through | |
93 case Bytecodes::_lshr : return ">>"; | |
94 case Bytecodes::_iushr: // fall through | |
95 case Bytecodes::_lushr: return ">>>"; | |
96 // logic ops | |
97 case Bytecodes::_iand : // fall through | |
98 case Bytecodes::_land : return "&"; | |
99 case Bytecodes::_ior : // fall through | |
100 case Bytecodes::_lor : return "|"; | |
101 case Bytecodes::_ixor : // fall through | |
102 case Bytecodes::_lxor : return "^"; | |
103 } | |
104 return Bytecodes::name(op); | |
105 } | |
106 | |
107 | |
108 bool InstructionPrinter::is_illegal_phi(Value v) { | |
109 Phi* phi = v ? v->as_Phi() : NULL; | |
110 if (phi && phi->is_illegal()) { | |
111 return true; | |
112 } | |
113 return false; | |
114 } | |
115 | |
116 | |
117 bool InstructionPrinter::is_phi_of_block(Value v, BlockBegin* b) { | |
118 Phi* phi = v ? v->as_Phi() : NULL; | |
119 return phi && phi->block() == b; | |
120 } | |
121 | |
122 | |
123 void InstructionPrinter::print_klass(ciKlass* klass) { | |
124 klass->name()->print_symbol_on(output()); | |
125 } | |
126 | |
127 | |
128 void InstructionPrinter::print_object(Value obj) { | |
129 ValueType* type = obj->type(); | |
130 if (type->as_ObjectConstant() != NULL) { | |
131 ciObject* value = type->as_ObjectConstant()->value(); | |
132 if (value->is_null_object()) { | |
133 output()->print("null"); | |
134 } else if (!value->is_loaded()) { | |
3362
d4c1fbc3de95
7042153: guarantee(x_compare_res != Constant::not_comparable) failed: incomparable constants in IfOp
iveresov
parents:
2166
diff
changeset
|
135 output()->print("<unloaded object " PTR_FORMAT ">", value); |
0 | 136 } else { |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4966
diff
changeset
|
137 output()->print("<object " PTR_FORMAT " klass=", value->constant_encoding()); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4966
diff
changeset
|
138 print_klass(value->klass()); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4966
diff
changeset
|
139 output()->print(">"); |
0 | 140 } |
141 } else if (type->as_InstanceConstant() != NULL) { | |
3362
d4c1fbc3de95
7042153: guarantee(x_compare_res != Constant::not_comparable) failed: incomparable constants in IfOp
iveresov
parents:
2166
diff
changeset
|
142 ciInstance* value = type->as_InstanceConstant()->value(); |
d4c1fbc3de95
7042153: guarantee(x_compare_res != Constant::not_comparable) failed: incomparable constants in IfOp
iveresov
parents:
2166
diff
changeset
|
143 if (value->is_loaded()) { |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4966
diff
changeset
|
144 output()->print("<instance " PTR_FORMAT " klass=", value->constant_encoding()); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4966
diff
changeset
|
145 print_klass(value->klass()); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4966
diff
changeset
|
146 output()->print(">"); |
3362
d4c1fbc3de95
7042153: guarantee(x_compare_res != Constant::not_comparable) failed: incomparable constants in IfOp
iveresov
parents:
2166
diff
changeset
|
147 } else { |
d4c1fbc3de95
7042153: guarantee(x_compare_res != Constant::not_comparable) failed: incomparable constants in IfOp
iveresov
parents:
2166
diff
changeset
|
148 output()->print("<unloaded instance " PTR_FORMAT ">", value); |
d4c1fbc3de95
7042153: guarantee(x_compare_res != Constant::not_comparable) failed: incomparable constants in IfOp
iveresov
parents:
2166
diff
changeset
|
149 } |
0 | 150 } else if (type->as_ArrayConstant() != NULL) { |
3362
d4c1fbc3de95
7042153: guarantee(x_compare_res != Constant::not_comparable) failed: incomparable constants in IfOp
iveresov
parents:
2166
diff
changeset
|
151 output()->print("<array " PTR_FORMAT ">", type->as_ArrayConstant()->value()->constant_encoding()); |
0 | 152 } else if (type->as_ClassConstant() != NULL) { |
153 ciInstanceKlass* klass = type->as_ClassConstant()->value(); | |
154 if (!klass->is_loaded()) { | |
155 output()->print("<unloaded> "); | |
156 } | |
157 output()->print("class "); | |
158 print_klass(klass); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
159 } else if (type->as_MethodConstant() != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
160 ciMethod* m = type->as_MethodConstant()->value(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
161 output()->print("<method %s.%s>", m->holder()->name()->as_utf8(), m->name()->as_utf8()); |
0 | 162 } else { |
163 output()->print("???"); | |
164 } | |
165 } | |
166 | |
167 | |
168 void InstructionPrinter::print_temp(Value value) { | |
169 output()->print("%c%d", value->type()->tchar(), value->id()); | |
170 } | |
171 | |
172 | |
173 void InstructionPrinter::print_field(AccessField* field) { | |
174 print_value(field->obj()); | |
175 output()->print("._%d", field->offset()); | |
176 } | |
177 | |
178 | |
179 void InstructionPrinter::print_indexed(AccessIndexed* indexed) { | |
180 print_value(indexed->array()); | |
181 output()->put('['); | |
182 print_value(indexed->index()); | |
183 output()->put(']'); | |
184 } | |
185 | |
186 | |
187 void InstructionPrinter::print_monitor(AccessMonitor* monitor) { | |
188 output()->print("monitor[%d](", monitor->monitor_no()); | |
189 print_value(monitor->obj()); | |
190 output()->put(')'); | |
191 } | |
192 | |
193 | |
194 void InstructionPrinter::print_op2(Op2* instr) { | |
195 print_value(instr->x()); | |
196 output()->print(" %s ", op_name(instr->op())); | |
197 print_value(instr->y()); | |
198 } | |
199 | |
200 | |
201 void InstructionPrinter::print_value(Value value) { | |
202 if (value == NULL) { | |
203 output()->print("NULL"); | |
204 } else { | |
205 print_temp(value); | |
206 } | |
207 } | |
208 | |
209 | |
210 void InstructionPrinter::print_instr(Instruction* instr) { | |
211 instr->visit(this); | |
212 } | |
213 | |
214 | |
215 void InstructionPrinter::print_stack(ValueStack* stack) { | |
216 int start_position = output()->position(); | |
217 if (stack->stack_is_empty()) { | |
218 output()->print("empty stack"); | |
219 } else { | |
220 output()->print("stack ["); | |
221 for (int i = 0; i < stack->stack_size();) { | |
222 if (i > 0) output()->print(", "); | |
223 output()->print("%d:", i); | |
224 Value value = stack->stack_at_inc(i); | |
225 print_value(value); | |
226 Phi* phi = value->as_Phi(); | |
227 if (phi != NULL) { | |
228 if (phi->operand()->is_valid()) { | |
229 output()->print(" "); | |
230 phi->operand()->print(output()); | |
231 } | |
232 } | |
233 } | |
234 output()->put(']'); | |
235 } | |
236 if (!stack->no_active_locks()) { | |
237 // print out the lines on the line below this | |
238 // one at the same indentation level. | |
239 output()->cr(); | |
240 fill_to(start_position, ' '); | |
241 output()->print("locks ["); | |
242 for (int i = i = 0; i < stack->locks_size(); i++) { | |
243 Value t = stack->lock_at(i); | |
244 if (i > 0) output()->print(", "); | |
245 output()->print("%d:", i); | |
246 if (t == NULL) { | |
247 // synchronized methods push null on the lock stack | |
248 output()->print("this"); | |
249 } else { | |
250 print_value(t); | |
251 } | |
252 } | |
253 output()->print("]"); | |
254 } | |
255 } | |
256 | |
257 | |
258 void InstructionPrinter::print_inline_level(BlockBegin* block) { | |
259 output()->print_cr("inlining depth %d", block->scope()->level()); | |
260 } | |
261 | |
262 | |
263 void InstructionPrinter::print_unsafe_op(UnsafeOp* op, const char* name) { | |
264 output()->print(name); | |
265 output()->print(".("); | |
266 } | |
267 | |
268 void InstructionPrinter::print_unsafe_raw_op(UnsafeRawOp* op, const char* name) { | |
269 print_unsafe_op(op, name); | |
270 output()->print("base "); | |
271 print_value(op->base()); | |
272 if (op->has_index()) { | |
273 output()->print(", index "); print_value(op->index()); | |
274 output()->print(", log2_scale %d", op->log2_scale()); | |
275 } | |
276 } | |
277 | |
278 | |
279 void InstructionPrinter::print_unsafe_object_op(UnsafeObjectOp* op, const char* name) { | |
280 print_unsafe_op(op, name); | |
281 print_value(op->object()); | |
282 output()->print(", "); | |
283 print_value(op->offset()); | |
284 } | |
285 | |
286 | |
287 void InstructionPrinter::print_phi(int i, Value v, BlockBegin* b) { | |
288 Phi* phi = v->as_Phi(); | |
289 output()->print("%2d ", i); | |
290 print_value(v); | |
291 // print phi operands | |
292 if (phi && phi->block() == b) { | |
293 output()->print(" ["); | |
294 for (int j = 0; j < phi->operand_count(); j ++) { | |
295 output()->print(" "); | |
296 Value opd = phi->operand_at(j); | |
297 if (opd) print_value(opd); | |
298 else output()->print("NULL"); | |
299 } | |
300 output()->print("] "); | |
301 } | |
302 print_alias(v); | |
303 } | |
304 | |
305 | |
306 void InstructionPrinter::print_alias(Value v) { | |
307 if (v != v->subst()) { | |
308 output()->print("alias "); print_value(v->subst()); | |
309 } | |
310 } | |
311 | |
312 | |
313 void InstructionPrinter::fill_to(int pos, char filler) { | |
314 while (output()->position() < pos) output()->put(filler); | |
315 } | |
316 | |
317 | |
318 void InstructionPrinter::print_head() { | |
319 const char filler = '_'; | |
320 fill_to(bci_pos , filler); output()->print("bci" ); | |
321 fill_to(use_pos , filler); output()->print("use" ); | |
322 fill_to(temp_pos , filler); output()->print("tid" ); | |
323 fill_to(instr_pos, filler); output()->print("instr"); | |
324 fill_to(end_pos , filler); | |
325 output()->cr(); | |
326 } | |
327 | |
328 | |
329 void InstructionPrinter::print_line(Instruction* instr) { | |
330 // print instruction data on one line | |
331 if (instr->is_pinned()) output()->put('.'); | |
1819 | 332 fill_to(bci_pos ); output()->print("%d", instr->printable_bci()); |
0 | 333 fill_to(use_pos ); output()->print("%d", instr->use_count()); |
334 fill_to(temp_pos ); print_temp(instr); | |
335 fill_to(instr_pos); print_instr(instr); | |
336 output()->cr(); | |
337 // add a line for StateSplit instructions w/ non-empty stacks | |
338 // (make it robust so we can print incomplete instructions) | |
339 StateSplit* split = instr->as_StateSplit(); | |
340 if (split != NULL && split->state() != NULL && !split->state()->stack_is_empty()) { | |
341 fill_to(instr_pos); print_stack(split->state()); | |
342 output()->cr(); | |
343 } | |
344 } | |
345 | |
346 | |
347 void InstructionPrinter::do_Phi(Phi* x) { | |
348 output()->print("phi function"); // make that more detailed later | |
349 if (x->is_illegal()) | |
350 output()->print(" (illegal)"); | |
351 } | |
352 | |
353 | |
354 void InstructionPrinter::do_Local(Local* x) { | |
355 output()->print("local[index %d]", x->java_index()); | |
356 } | |
357 | |
358 | |
359 void InstructionPrinter::do_Constant(Constant* x) { | |
360 ValueType* t = x->type(); | |
361 switch (t->tag()) { | |
362 case intTag : output()->print("%d" , t->as_IntConstant ()->value()); break; | |
7623
203f64878aab
7102489: RFE: cleanup jlong typedef on __APPLE__and _LLP64 systems.
hseigel
parents:
6795
diff
changeset
|
363 case longTag : output()->print(JLONG_FORMAT, t->as_LongConstant()->value()); output()->print("L"); break; |
0 | 364 case floatTag : output()->print("%g" , t->as_FloatConstant ()->value()); break; |
365 case doubleTag : output()->print("%gD" , t->as_DoubleConstant()->value()); break; | |
366 case objectTag : print_object(x); break; | |
367 case addressTag: output()->print("bci:%d", t->as_AddressConstant()->value()); break; | |
368 default : output()->print("???"); break; | |
369 } | |
370 } | |
371 | |
372 | |
373 void InstructionPrinter::do_LoadField(LoadField* x) { | |
374 print_field(x); | |
375 output()->print(" (%c)", type2char(x->field()->type()->basic_type())); | |
376 } | |
377 | |
378 | |
379 void InstructionPrinter::do_StoreField(StoreField* x) { | |
380 print_field(x); | |
381 output()->print(" := "); | |
382 print_value(x->value()); | |
383 output()->print(" (%c)", type2char(x->field()->type()->basic_type())); | |
384 } | |
385 | |
386 | |
387 void InstructionPrinter::do_ArrayLength(ArrayLength* x) { | |
388 print_value(x->array()); | |
389 output()->print(".length"); | |
390 } | |
391 | |
392 | |
393 void InstructionPrinter::do_LoadIndexed(LoadIndexed* x) { | |
394 print_indexed(x); | |
395 output()->print(" (%c)", type2char(x->elt_type())); | |
396 } | |
397 | |
398 | |
399 void InstructionPrinter::do_StoreIndexed(StoreIndexed* x) { | |
400 print_indexed(x); | |
401 output()->print(" := "); | |
402 print_value(x->value()); | |
403 output()->print(" (%c)", type2char(x->elt_type())); | |
404 } | |
405 | |
406 void InstructionPrinter::do_NegateOp(NegateOp* x) { | |
407 output()->put('-'); | |
408 print_value(x->x()); | |
409 } | |
410 | |
411 | |
412 void InstructionPrinter::do_ArithmeticOp(ArithmeticOp* x) { | |
413 print_op2(x); | |
414 } | |
415 | |
416 | |
417 void InstructionPrinter::do_ShiftOp(ShiftOp* x) { | |
418 print_op2(x); | |
419 } | |
420 | |
421 | |
422 void InstructionPrinter::do_LogicOp(LogicOp* x) { | |
423 print_op2(x); | |
424 } | |
425 | |
426 | |
427 void InstructionPrinter::do_CompareOp(CompareOp* x) { | |
428 print_op2(x); | |
429 } | |
430 | |
431 | |
432 void InstructionPrinter::do_IfOp(IfOp* x) { | |
433 print_value(x->x()); | |
434 output()->print(" %s ", cond_name(x->cond())); | |
435 print_value(x->y()); | |
436 output()->print(" ? "); | |
437 print_value(x->tval()); | |
438 output()->print(" : "); | |
439 print_value(x->fval()); | |
440 } | |
441 | |
442 | |
443 void InstructionPrinter::do_Convert(Convert* x) { | |
444 output()->print("%s(", Bytecodes::name(x->op())); | |
445 print_value(x->value()); | |
446 output()->put(')'); | |
447 } | |
448 | |
449 | |
450 void InstructionPrinter::do_NullCheck(NullCheck* x) { | |
451 output()->print("null_check("); | |
452 print_value(x->obj()); | |
453 output()->put(')'); | |
454 if (!x->can_trap()) { | |
455 output()->print(" (eliminated)"); | |
456 } | |
457 } | |
458 | |
459 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4966
diff
changeset
|
460 void InstructionPrinter::do_TypeCast(TypeCast* x) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4966
diff
changeset
|
461 output()->print("type_cast("); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4966
diff
changeset
|
462 print_value(x->obj()); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4966
diff
changeset
|
463 output()->print(") "); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
464 if (x->declared_type()->is_klass()) |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
465 print_klass(x->declared_type()->as_klass()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
466 else |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
467 output()->print(type2name(x->declared_type()->basic_type())); |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4966
diff
changeset
|
468 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4966
diff
changeset
|
469 |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4966
diff
changeset
|
470 |
0 | 471 void InstructionPrinter::do_Invoke(Invoke* x) { |
472 if (x->receiver() != NULL) { | |
473 print_value(x->receiver()); | |
474 output()->print("."); | |
475 } | |
476 | |
477 output()->print("%s(", Bytecodes::name(x->code())); | |
478 for (int i = 0; i < x->number_of_arguments(); i++) { | |
479 if (i > 0) output()->print(", "); | |
480 print_value(x->argument_at(i)); | |
481 } | |
482 output()->print_cr(")"); | |
483 fill_to(instr_pos); | |
484 output()->print("%s.%s%s", | |
485 x->target()->holder()->name()->as_utf8(), | |
486 x->target()->name()->as_utf8(), | |
487 x->target()->signature()->as_symbol()->as_utf8()); | |
488 } | |
489 | |
490 | |
491 void InstructionPrinter::do_NewInstance(NewInstance* x) { | |
492 output()->print("new instance "); | |
493 print_klass(x->klass()); | |
494 } | |
495 | |
496 | |
497 void InstructionPrinter::do_NewTypeArray(NewTypeArray* x) { | |
498 output()->print("new %s array [", basic_type_name(x->elt_type())); | |
499 print_value(x->length()); | |
500 output()->put(']'); | |
501 } | |
502 | |
503 | |
504 void InstructionPrinter::do_NewObjectArray(NewObjectArray* x) { | |
505 output()->print("new object array ["); | |
506 print_value(x->length()); | |
507 output()->print("] "); | |
508 print_klass(x->klass()); | |
509 } | |
510 | |
511 | |
512 void InstructionPrinter::do_NewMultiArray(NewMultiArray* x) { | |
513 output()->print("new multi array ["); | |
514 Values* dims = x->dims(); | |
515 for (int i = 0; i < dims->length(); i++) { | |
516 if (i > 0) output()->print(", "); | |
517 print_value(dims->at(i)); | |
518 } | |
519 output()->print("] "); | |
520 print_klass(x->klass()); | |
521 } | |
522 | |
523 | |
524 void InstructionPrinter::do_MonitorEnter(MonitorEnter* x) { | |
525 output()->print("enter "); | |
526 print_monitor(x); | |
527 } | |
528 | |
529 | |
530 void InstructionPrinter::do_MonitorExit(MonitorExit* x) { | |
531 output()->print("exit "); | |
532 print_monitor(x); | |
533 } | |
534 | |
535 | |
536 void InstructionPrinter::do_Intrinsic(Intrinsic* x) { | |
537 const char* name = vmIntrinsics::name_at(x->id()); | |
538 if (name[0] == '_') name++; // strip leading bug from _hashCode, etc. | |
539 const char* kname = vmSymbols::name_for(vmIntrinsics::class_for(x->id())); | |
540 if (strchr(name, '_') == NULL) { | |
541 kname = NULL; | |
542 } else { | |
543 const char* kptr = strrchr(kname, '/'); | |
544 if (kptr != NULL) kname = kptr + 1; | |
545 } | |
546 if (kname == NULL) | |
547 output()->print("%s(", name); | |
548 else | |
549 output()->print("%s.%s(", kname, name); | |
550 for (int i = 0; i < x->number_of_arguments(); i++) { | |
551 if (i > 0) output()->print(", "); | |
552 print_value(x->argument_at(i)); | |
553 } | |
554 output()->put(')'); | |
555 } | |
556 | |
557 | |
558 void InstructionPrinter::do_BlockBegin(BlockBegin* x) { | |
559 // print block id | |
560 BlockEnd* end = x->end(); | |
561 output()->print("B%d ", x->block_id()); | |
562 | |
563 // print flags | |
564 bool printed_flag = false; | |
565 if (x->is_set(BlockBegin::std_entry_flag)) { | |
566 if (!printed_flag) output()->print("("); | |
567 output()->print("S"); printed_flag = true; | |
568 } | |
569 if (x->is_set(BlockBegin::osr_entry_flag)) { | |
570 if (!printed_flag) output()->print("("); | |
571 output()->print("O"); printed_flag = true; | |
572 } | |
573 if (x->is_set(BlockBegin::exception_entry_flag)) { | |
574 if (!printed_flag) output()->print("("); | |
575 output()->print("E"); printed_flag = true; | |
576 } | |
577 if (x->is_set(BlockBegin::subroutine_entry_flag)) { | |
578 if (!printed_flag) output()->print("("); | |
579 output()->print("s"); printed_flag = true; | |
580 } | |
581 if (x->is_set(BlockBegin::parser_loop_header_flag)) { | |
582 if (!printed_flag) output()->print("("); | |
583 output()->print("LH"); printed_flag = true; | |
584 } | |
585 if (x->is_set(BlockBegin::backward_branch_target_flag)) { | |
586 if (!printed_flag) output()->print("("); | |
587 output()->print("b"); printed_flag = true; | |
588 } | |
589 if (x->is_set(BlockBegin::was_visited_flag)) { | |
590 if (!printed_flag) output()->print("("); | |
591 output()->print("V"); printed_flag = true; | |
592 } | |
593 if (printed_flag) output()->print(") "); | |
594 | |
595 // print block bci range | |
1819 | 596 output()->print("[%d, %d]", x->bci(), (end == NULL ? -1 : end->printable_bci())); |
0 | 597 |
598 // print block successors | |
599 if (end != NULL && end->number_of_sux() > 0) { | |
600 output()->print(" ->"); | |
601 for (int i = 0; i < end->number_of_sux(); i++) { | |
602 output()->print(" B%d", end->sux_at(i)->block_id()); | |
603 } | |
604 } | |
605 // print exception handlers | |
606 if (x->number_of_exception_handlers() > 0) { | |
607 output()->print(" (xhandlers "); | |
608 for (int i = 0; i < x->number_of_exception_handlers(); i++) { | |
609 if (i > 0) output()->print(" "); | |
610 output()->print("B%d", x->exception_handler_at(i)->block_id()); | |
611 } | |
612 output()->put(')'); | |
613 } | |
614 | |
615 // print dominator block | |
616 if (x->dominator() != NULL) { | |
617 output()->print(" dom B%d", x->dominator()->block_id()); | |
618 } | |
619 | |
620 // print predecessors and successors | |
621 if (x->successors()->length() > 0) { | |
622 output()->print(" sux:"); | |
623 for (int i = 0; i < x->successors()->length(); i ++) { | |
624 output()->print(" B%d", x->successors()->at(i)->block_id()); | |
625 } | |
626 } | |
627 | |
628 if (x->number_of_preds() > 0) { | |
629 output()->print(" pred:"); | |
630 for (int i = 0; i < x->number_of_preds(); i ++) { | |
631 output()->print(" B%d", x->pred_at(i)->block_id()); | |
632 } | |
633 } | |
634 | |
635 if (!_print_phis) { | |
636 return; | |
637 } | |
638 | |
639 // print phi functions | |
640 bool has_phis_in_locals = false; | |
641 bool has_phis_on_stack = false; | |
642 | |
643 if (x->end() && x->end()->state()) { | |
644 ValueStack* state = x->state(); | |
645 | |
646 int i = 0; | |
647 while (!has_phis_on_stack && i < state->stack_size()) { | |
648 Value v = state->stack_at_inc(i); | |
649 has_phis_on_stack = is_phi_of_block(v, x); | |
650 } | |
651 | |
652 do { | |
653 for (i = 0; !has_phis_in_locals && i < state->locals_size();) { | |
654 Value v = state->local_at(i); | |
655 has_phis_in_locals = is_phi_of_block(v, x); | |
656 // also ignore illegal HiWords | |
657 if (v && !v->type()->is_illegal()) i += v->type()->size(); else i ++; | |
658 } | |
659 state = state->caller_state(); | |
660 } while (state != NULL); | |
661 | |
662 } | |
663 | |
664 // print values in locals | |
665 if (has_phis_in_locals) { | |
666 output()->cr(); output()->print_cr("Locals:"); | |
667 | |
668 ValueStack* state = x->state(); | |
669 do { | |
670 for (int i = 0; i < state->locals_size();) { | |
671 Value v = state->local_at(i); | |
672 if (v) { | |
673 print_phi(i, v, x); output()->cr(); | |
674 // also ignore illegal HiWords | |
675 i += (v->type()->is_illegal() ? 1 : v->type()->size()); | |
676 } else { | |
677 i ++; | |
678 } | |
679 } | |
680 output()->cr(); | |
681 state = state->caller_state(); | |
682 } while (state != NULL); | |
683 } | |
684 | |
685 // print values on stack | |
686 if (has_phis_on_stack) { | |
687 output()->print_cr("Stack:"); | |
688 int i = 0; | |
689 while (i < x->state()->stack_size()) { | |
690 int o = i; | |
691 Value v = x->state()->stack_at_inc(i); | |
692 if (v) { | |
693 print_phi(o, v, x); output()->cr(); | |
694 } | |
695 } | |
696 } | |
697 } | |
698 | |
699 | |
700 void InstructionPrinter::do_CheckCast(CheckCast* x) { | |
701 output()->print("checkcast("); | |
702 print_value(x->obj()); | |
703 output()->print(") "); | |
704 print_klass(x->klass()); | |
705 } | |
706 | |
707 | |
708 void InstructionPrinter::do_InstanceOf(InstanceOf* x) { | |
709 output()->print("instanceof("); | |
710 print_value(x->obj()); | |
711 output()->print(") "); | |
712 print_klass(x->klass()); | |
713 } | |
714 | |
715 | |
716 void InstructionPrinter::do_Goto(Goto* x) { | |
717 output()->print("goto B%d", x->default_sux()->block_id()); | |
718 if (x->is_safepoint()) output()->print(" (safepoint)"); | |
719 } | |
720 | |
721 | |
722 void InstructionPrinter::do_If(If* x) { | |
723 output()->print("if "); | |
724 print_value(x->x()); | |
725 output()->print(" %s ", cond_name(x->cond())); | |
726 print_value(x->y()); | |
727 output()->print(" then B%d else B%d", x->sux_at(0)->block_id(), x->sux_at(1)->block_id()); | |
728 if (x->is_safepoint()) output()->print(" (safepoint)"); | |
729 } | |
730 | |
731 | |
732 void InstructionPrinter::do_IfInstanceOf(IfInstanceOf* x) { | |
733 output()->print("<IfInstanceOf>"); | |
734 } | |
735 | |
736 | |
737 void InstructionPrinter::do_TableSwitch(TableSwitch* x) { | |
738 output()->print("tableswitch "); | |
739 if (x->is_safepoint()) output()->print("(safepoint) "); | |
740 print_value(x->tag()); | |
741 output()->cr(); | |
742 int l = x->length(); | |
743 for (int i = 0; i < l; i++) { | |
744 fill_to(instr_pos); | |
745 output()->print_cr("case %5d: B%d", x->lo_key() + i, x->sux_at(i)->block_id()); | |
746 } | |
747 fill_to(instr_pos); | |
748 output()->print("default : B%d", x->default_sux()->block_id()); | |
749 } | |
750 | |
751 | |
752 void InstructionPrinter::do_LookupSwitch(LookupSwitch* x) { | |
753 output()->print("lookupswitch "); | |
754 if (x->is_safepoint()) output()->print("(safepoint) "); | |
755 print_value(x->tag()); | |
756 output()->cr(); | |
757 int l = x->length(); | |
758 for (int i = 0; i < l; i++) { | |
759 fill_to(instr_pos); | |
760 output()->print_cr("case %5d: B%d", x->key_at(i), x->sux_at(i)->block_id()); | |
761 } | |
762 fill_to(instr_pos); | |
763 output()->print("default : B%d", x->default_sux()->block_id()); | |
764 } | |
765 | |
766 | |
767 void InstructionPrinter::do_Return(Return* x) { | |
768 if (x->result() == NULL) { | |
769 output()->print("return"); | |
770 } else { | |
771 output()->print("%creturn ", x->type()->tchar()); | |
772 print_value(x->result()); | |
773 } | |
774 } | |
775 | |
776 | |
777 void InstructionPrinter::do_Throw(Throw* x) { | |
778 output()->print("throw "); | |
779 print_value(x->exception()); | |
780 } | |
781 | |
782 | |
783 void InstructionPrinter::do_Base(Base* x) { | |
784 output()->print("std entry B%d", x->std_entry()->block_id()); | |
785 if (x->number_of_sux() > 1) { | |
786 output()->print(" osr entry B%d", x->osr_entry()->block_id()); | |
787 } | |
788 } | |
789 | |
790 | |
791 void InstructionPrinter::do_OsrEntry(OsrEntry* x) { | |
792 output()->print("osr entry"); | |
793 } | |
794 | |
795 | |
796 void InstructionPrinter::do_ExceptionObject(ExceptionObject* x) { | |
797 output()->print("incoming exception"); | |
798 } | |
799 | |
800 | |
801 void InstructionPrinter::do_RoundFP(RoundFP* x) { | |
802 output()->print("round_fp "); | |
803 print_value(x->input()); | |
804 } | |
805 | |
806 | |
807 void InstructionPrinter::do_UnsafeGetRaw(UnsafeGetRaw* x) { | |
808 print_unsafe_raw_op(x, "UnsafeGetRaw"); | |
809 output()->put(')'); | |
810 } | |
811 | |
812 | |
813 void InstructionPrinter::do_UnsafePutRaw(UnsafePutRaw* x) { | |
814 print_unsafe_raw_op(x, "UnsafePutRaw"); | |
815 output()->print(", value "); | |
816 print_value(x->value()); | |
817 output()->put(')'); | |
818 } | |
819 | |
820 | |
821 void InstructionPrinter::do_UnsafeGetObject(UnsafeGetObject* x) { | |
822 print_unsafe_object_op(x, "UnsafeGetObject"); | |
823 output()->put(')'); | |
824 } | |
825 | |
826 | |
827 void InstructionPrinter::do_UnsafePutObject(UnsafePutObject* x) { | |
828 print_unsafe_object_op(x, "UnsafePutObject"); | |
829 output()->print(", value "); | |
830 print_value(x->value()); | |
831 output()->put(')'); | |
832 } | |
833 | |
6795
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6725
diff
changeset
|
834 void InstructionPrinter::do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) { |
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6725
diff
changeset
|
835 print_unsafe_object_op(x, x->is_add()?"UnsafeGetAndSetObject (add)":"UnsafeGetAndSetObject"); |
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6725
diff
changeset
|
836 output()->print(", value "); |
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6725
diff
changeset
|
837 print_value(x->value()); |
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6725
diff
changeset
|
838 output()->put(')'); |
7eca5de9e0b6
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
6725
diff
changeset
|
839 } |
0 | 840 |
841 void InstructionPrinter::do_UnsafePrefetchRead(UnsafePrefetchRead* x) { | |
842 print_unsafe_object_op(x, "UnsafePrefetchRead"); | |
843 output()->put(')'); | |
844 } | |
845 | |
846 | |
847 void InstructionPrinter::do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) { | |
848 print_unsafe_object_op(x, "UnsafePrefetchWrite"); | |
849 output()->put(')'); | |
850 } | |
851 | |
852 void InstructionPrinter::do_ProfileCall(ProfileCall* x) { | |
853 output()->print("profile "); | |
854 print_value(x->recv()); | |
855 output()->print(" %s.%s", x->method()->holder()->name()->as_utf8(), x->method()->name()->as_utf8()); | |
856 if (x->known_holder() != NULL) { | |
857 output()->print(", "); | |
858 print_klass(x->known_holder()); | |
859 } | |
860 output()->put(')'); | |
861 } | |
862 | |
1783 | 863 void InstructionPrinter::do_ProfileInvoke(ProfileInvoke* x) { |
864 output()->print("profile_invoke "); | |
865 output()->print(" %s.%s", x->inlinee()->holder()->name()->as_utf8(), x->inlinee()->name()->as_utf8()); | |
866 output()->put(')'); | |
0 | 867 |
868 } | |
869 | |
2166
403dc4c1d7f5
6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents:
1972
diff
changeset
|
870 void InstructionPrinter::do_RuntimeCall(RuntimeCall* x) { |
403dc4c1d7f5
6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents:
1972
diff
changeset
|
871 output()->print("call_rt %s(", x->entry_name()); |
403dc4c1d7f5
6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents:
1972
diff
changeset
|
872 for (int i = 0; i < x->number_of_arguments(); i++) { |
403dc4c1d7f5
6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents:
1972
diff
changeset
|
873 if (i > 0) output()->print(", "); |
403dc4c1d7f5
6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents:
1972
diff
changeset
|
874 print_value(x->argument_at(i)); |
403dc4c1d7f5
6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents:
1972
diff
changeset
|
875 } |
403dc4c1d7f5
6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents:
1972
diff
changeset
|
876 output()->put(')'); |
403dc4c1d7f5
6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents:
1972
diff
changeset
|
877 } |
403dc4c1d7f5
6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents:
1972
diff
changeset
|
878 |
4966
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3362
diff
changeset
|
879 void InstructionPrinter::do_MemBar(MemBar* x) { |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3362
diff
changeset
|
880 if (os::is_MP()) { |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3362
diff
changeset
|
881 LIR_Code code = x->code(); |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3362
diff
changeset
|
882 switch (code) { |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3362
diff
changeset
|
883 case lir_membar_acquire : output()->print("membar_acquire"); break; |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3362
diff
changeset
|
884 case lir_membar_release : output()->print("membar_release"); break; |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3362
diff
changeset
|
885 case lir_membar : output()->print("membar"); break; |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3362
diff
changeset
|
886 case lir_membar_loadload : output()->print("membar_loadload"); break; |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3362
diff
changeset
|
887 case lir_membar_storestore: output()->print("membar_storestore"); break; |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3362
diff
changeset
|
888 case lir_membar_loadstore : output()->print("membar_loadstore"); break; |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3362
diff
changeset
|
889 case lir_membar_storeload : output()->print("membar_storeload"); break; |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3362
diff
changeset
|
890 default : ShouldNotReachHere(); break; |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3362
diff
changeset
|
891 } |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3362
diff
changeset
|
892 } |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3362
diff
changeset
|
893 } |
701a83c86f28
7120481: storeStore barrier in constructor with final field
jiangli
parents:
3362
diff
changeset
|
894 |
0 | 895 #endif // PRODUCT |