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