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