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