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