src/share/vm/c1/c1_InstructionPrinter.cpp

Wed, 31 Aug 2011 16:46:11 -0700

author
never
date
Wed, 31 Aug 2011 16:46:11 -0700
changeset 3099
c124e2e7463e
parent 2894
d4c1fbc3de95
child 3592
701a83c86f28
permissions
-rw-r--r--

7083786: dead various dead chunks of code
Reviewed-by: iveresov, kvn

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

mercurial