1 /* 2 * Copyright (c) 1999, 2023, 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 == nullptr || 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 nullptr; 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() : nullptr; 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() : nullptr; 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() != nullptr) { 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() != nullptr) { 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() != nullptr) { 148 output()->print("<array " INTPTR_FORMAT ">", p2i(type->as_ArrayConstant()->value()->constant_encoding())); 149 } else if (type->as_ClassConstant() != nullptr) { 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() != nullptr) { 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() != nullptr) { 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 == nullptr) { 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 != nullptr) { 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 == nullptr) { 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 != nullptr && split->state() != nullptr && !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() != nullptr) { 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() != nullptr) { 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_NewObjectArray(NewObjectArray* x) { 505 output()->print("new object array ["); 506 print_value(x->length()); 507 output()->print("] "); 508 print_klass(x->klass()); 509 } 510 511 512 void InstructionPrinter::do_NewMultiArray(NewMultiArray* x) { 513 output()->print("new multi array ["); 514 Values* dims = x->dims(); 515 for (int i = 0; i < dims->length(); i++) { 516 if (i > 0) output()->print(", "); 517 print_value(dims->at(i)); 518 } 519 output()->print("] "); 520 print_klass(x->klass()); 521 } 522 523 void InstructionPrinter::do_MonitorEnter(MonitorEnter* x) { 524 output()->print("enter "); 525 print_monitor(x); 526 } 527 528 529 void InstructionPrinter::do_MonitorExit(MonitorExit* x) { 530 output()->print("exit "); 531 print_monitor(x); 532 } 533 534 535 void InstructionPrinter::do_Intrinsic(Intrinsic* x) { 536 const char* name = vmIntrinsics::name_at(x->id()); 537 if (name[0] == '_') name++; // strip leading bug from _hashCode, etc. 538 const char* kname = vmSymbols::name_for(vmIntrinsics::class_for(x->id())); 539 if (strchr(name, '_') == nullptr) { 540 kname = nullptr; 541 } else { 542 const char* kptr = strrchr(kname, '/'); 543 if (kptr != nullptr) kname = kptr + 1; 544 } 545 if (kname == nullptr) 546 output()->print("%s(", name); 547 else 548 output()->print("%s.%s(", kname, name); 549 for (int i = 0; i < x->number_of_arguments(); i++) { 550 if (i > 0) output()->print(", "); 551 print_value(x->argument_at(i)); 552 } 553 output()->put(')'); 554 } 555 556 557 void InstructionPrinter::do_BlockBegin(BlockBegin* x) { 558 // print block id 559 BlockEnd* end = x->end(); 560 output()->print("B%d ", x->block_id()); 561 562 // print flags 563 bool printed_flag = false; 564 if (x->is_set(BlockBegin::std_entry_flag)) { 565 if (!printed_flag) output()->print("("); 566 output()->print("S"); printed_flag = true; 567 } 568 if (x->is_set(BlockBegin::osr_entry_flag)) { 569 if (!printed_flag) output()->print("("); 570 output()->print("O"); printed_flag = true; 571 } 572 if (x->is_set(BlockBegin::exception_entry_flag)) { 573 if (!printed_flag) output()->print("("); 574 output()->print("E"); printed_flag = true; 575 } 576 if (x->is_set(BlockBegin::subroutine_entry_flag)) { 577 if (!printed_flag) output()->print("("); 578 output()->print("s"); printed_flag = true; 579 } 580 if (x->is_set(BlockBegin::parser_loop_header_flag)) { 581 if (!printed_flag) output()->print("("); 582 output()->print("LH"); printed_flag = true; 583 } 584 if (x->is_set(BlockBegin::backward_branch_target_flag)) { 585 if (!printed_flag) output()->print("("); 586 output()->print("b"); printed_flag = true; 587 } 588 if (x->is_set(BlockBegin::was_visited_flag)) { 589 if (!printed_flag) output()->print("("); 590 output()->print("V"); printed_flag = true; 591 } 592 if (printed_flag) output()->print(") "); 593 594 // print block bci range 595 output()->print("[%d, %d]", x->bci(), (end == nullptr ? -1 : end->printable_bci())); 596 597 // print block successors 598 if (end != nullptr && end->number_of_sux() > 0) { 599 output()->print(" ->"); 600 for (int i = 0; i < end->number_of_sux(); i++) { 601 output()->print(" B%d", end->sux_at(i)->block_id()); 602 } 603 } 604 // print exception handlers 605 if (x->number_of_exception_handlers() > 0) { 606 output()->print(" (xhandlers "); 607 for (int i = 0; i < x->number_of_exception_handlers(); i++) { 608 if (i > 0) output()->print(" "); 609 output()->print("B%d", x->exception_handler_at(i)->block_id()); 610 } 611 output()->put(')'); 612 } 613 614 // print dominator block 615 if (x->dominator() != nullptr) { 616 output()->print(" dom B%d", x->dominator()->block_id()); 617 } 618 619 // print predecessors 620 if (x->number_of_preds() > 0) { 621 output()->print(" pred:"); 622 for (int i = 0; i < x->number_of_preds(); i ++) { 623 output()->print(" B%d", x->pred_at(i)->block_id()); 624 } 625 } 626 627 if (!_print_phis) { 628 return; 629 } 630 631 // print phi functions 632 bool has_phis_in_locals = false; 633 bool has_phis_on_stack = false; 634 635 if (x->end() && x->end()->state()) { 636 ValueStack* state = x->state(); 637 638 int i = 0; 639 while (!has_phis_on_stack && i < state->stack_size()) { 640 Value v = state->stack_at_inc(i); 641 has_phis_on_stack = is_phi_of_block(v, x); 642 } 643 644 do { 645 for (i = 0; !has_phis_in_locals && i < state->locals_size();) { 646 Value v = state->local_at(i); 647 has_phis_in_locals = is_phi_of_block(v, x); 648 // also ignore illegal HiWords 649 if (v && !v->type()->is_illegal()) i += v->type()->size(); else i ++; 650 } 651 state = state->caller_state(); 652 } while (state != nullptr); 653 654 } 655 656 // print values in locals 657 if (has_phis_in_locals) { 658 output()->cr(); output()->print_cr("Locals:"); 659 660 ValueStack* state = x->state(); 661 do { 662 for (int i = 0; i < state->locals_size();) { 663 Value v = state->local_at(i); 664 if (v) { 665 print_phi(i, v, x); output()->cr(); 666 // also ignore illegal HiWords 667 i += (v->type()->is_illegal() ? 1 : v->type()->size()); 668 } else { 669 i ++; 670 } 671 } 672 output()->cr(); 673 state = state->caller_state(); 674 } while (state != nullptr); 675 } 676 677 // print values on stack 678 if (has_phis_on_stack) { 679 output()->print_cr("Stack:"); 680 int i = 0; 681 while (i < x->state()->stack_size()) { 682 int o = i; 683 Value v = x->state()->stack_at_inc(i); 684 if (v) { 685 print_phi(o, v, x); output()->cr(); 686 } 687 } 688 } 689 } 690 691 692 void InstructionPrinter::do_CheckCast(CheckCast* x) { 693 output()->print("checkcast("); 694 print_value(x->obj()); 695 output()->print(") "); 696 print_klass(x->klass()); 697 } 698 699 700 void InstructionPrinter::do_InstanceOf(InstanceOf* x) { 701 output()->print("instanceof("); 702 print_value(x->obj()); 703 output()->print(") "); 704 print_klass(x->klass()); 705 } 706 707 708 void InstructionPrinter::do_Goto(Goto* x) { 709 output()->print("goto B%d", x->default_sux()->block_id()); 710 if (x->is_safepoint()) output()->print(" (safepoint)"); 711 } 712 713 714 void InstructionPrinter::do_If(If* x) { 715 output()->print("if "); 716 print_value(x->x()); 717 output()->print(" %s ", cond_name(x->cond())); 718 print_value(x->y()); 719 output()->print(" then B%d else B%d", x->sux_at(0)->block_id(), x->sux_at(1)->block_id()); 720 if (x->is_safepoint()) output()->print(" (safepoint)"); 721 } 722 723 724 void InstructionPrinter::do_TableSwitch(TableSwitch* x) { 725 output()->print("tableswitch "); 726 if (x->is_safepoint()) output()->print("(safepoint) "); 727 print_value(x->tag()); 728 output()->cr(); 729 int l = x->length(); 730 for (int i = 0; i < l; i++) { 731 fill_to(instr_pos); 732 output()->print_cr("case %5d: B%d", x->lo_key() + i, x->sux_at(i)->block_id()); 733 } 734 fill_to(instr_pos); 735 output()->print("default : B%d", x->default_sux()->block_id()); 736 } 737 738 739 void InstructionPrinter::do_LookupSwitch(LookupSwitch* x) { 740 output()->print("lookupswitch "); 741 if (x->is_safepoint()) output()->print("(safepoint) "); 742 print_value(x->tag()); 743 output()->cr(); 744 int l = x->length(); 745 for (int i = 0; i < l; i++) { 746 fill_to(instr_pos); 747 output()->print_cr("case %5d: B%d", x->key_at(i), x->sux_at(i)->block_id()); 748 } 749 fill_to(instr_pos); 750 output()->print("default : B%d", x->default_sux()->block_id()); 751 } 752 753 754 void InstructionPrinter::do_Return(Return* x) { 755 if (x->result() == nullptr) { 756 output()->print("return"); 757 } else { 758 output()->print("%creturn ", x->type()->tchar()); 759 print_value(x->result()); 760 } 761 } 762 763 764 void InstructionPrinter::do_Throw(Throw* x) { 765 output()->print("throw "); 766 print_value(x->exception()); 767 } 768 769 770 void InstructionPrinter::do_Base(Base* x) { 771 output()->print("std entry B%d", x->std_entry()->block_id()); 772 if (x->number_of_sux() > 1) { 773 output()->print(" osr entry B%d", x->osr_entry()->block_id()); 774 } 775 } 776 777 778 void InstructionPrinter::do_OsrEntry(OsrEntry* x) { 779 output()->print("osr entry"); 780 } 781 782 783 void InstructionPrinter::do_ExceptionObject(ExceptionObject* x) { 784 output()->print("incoming exception"); 785 } 786 787 788 void InstructionPrinter::do_RoundFP(RoundFP* x) { 789 output()->print("round_fp "); 790 print_value(x->input()); 791 } 792 793 void InstructionPrinter::do_UnsafeGet(UnsafeGet* x) { 794 print_unsafe_op(x, x->is_raw() ? "UnsafeGet (raw)" : "UnsafeGet"); 795 output()->put(')'); 796 } 797 798 void InstructionPrinter::do_UnsafePut(UnsafePut* x) { 799 print_unsafe_op(x, "UnsafePut"); 800 output()->print(", value "); 801 print_value(x->value()); 802 output()->put(')'); 803 } 804 805 void InstructionPrinter::do_UnsafeGetAndSet(UnsafeGetAndSet* x) { 806 print_unsafe_op(x, x->is_add()?"UnsafeGetAndSet (add)":"UnsafeGetAndSet"); 807 output()->print(", value "); 808 print_value(x->value()); 809 output()->put(')'); 810 } 811 812 void InstructionPrinter::do_RangeCheckPredicate(RangeCheckPredicate* x) { 813 814 if (x->x() != nullptr && x->y() != nullptr) { 815 output()->print("if "); 816 print_value(x->x()); 817 output()->print(" %s ", cond_name(x->cond())); 818 print_value(x->y()); 819 output()->print(" then deoptimize!"); 820 } else { 821 output()->print("always deoptimize!"); 822 } 823 } 824 825 #ifdef ASSERT 826 void InstructionPrinter::do_Assert(Assert* x) { 827 output()->print("assert "); 828 print_value(x->x()); 829 output()->print(" %s ", cond_name(x->cond())); 830 print_value(x->y()); 831 } 832 #endif 833 834 void InstructionPrinter::do_ProfileCall(ProfileCall* x) { 835 output()->print("profile "); 836 print_value(x->recv()); 837 output()->print(" %s.%s", x->method()->holder()->name()->as_utf8(), x->method()->name()->as_utf8()); 838 if (x->known_holder() != nullptr) { 839 output()->print(", "); 840 print_klass(x->known_holder()); 841 output()->print(" "); 842 } 843 for (int i = 0; i < x->nb_profiled_args(); i++) { 844 if (i > 0) output()->print(", "); 845 print_value(x->profiled_arg_at(i)); 846 if (x->arg_needs_null_check(i)) { 847 output()->print(" [NC]"); 848 } 849 } 850 output()->put(')'); 851 } 852 853 void InstructionPrinter::do_ProfileReturnType(ProfileReturnType* x) { 854 output()->print("profile ret type "); 855 print_value(x->ret()); 856 output()->print(" %s.%s", x->method()->holder()->name()->as_utf8(), x->method()->name()->as_utf8()); 857 output()->put(')'); 858 } 859 860 void InstructionPrinter::do_ProfileInvoke(ProfileInvoke* x) { 861 output()->print("profile_invoke "); 862 output()->print(" %s.%s", x->inlinee()->holder()->name()->as_utf8(), x->inlinee()->name()->as_utf8()); 863 output()->put(')'); 864 865 } 866 867 void InstructionPrinter::do_ProfileACmpTypes(ProfileACmpTypes* x) { 868 output()->print("profile acmp types "); 869 print_value(x->left()); 870 output()->print(", "); 871 print_value(x->right()); 872 } 873 874 void InstructionPrinter::do_RuntimeCall(RuntimeCall* x) { 875 output()->print("call_rt %s(", x->entry_name()); 876 for (int i = 0; i < x->number_of_arguments(); i++) { 877 if (i > 0) output()->print(", "); 878 print_value(x->argument_at(i)); 879 } 880 output()->put(')'); 881 } 882 883 void InstructionPrinter::do_MemBar(MemBar* x) { 884 LIR_Code code = x->code(); 885 switch (code) { 886 case lir_membar_acquire : output()->print("membar_acquire"); break; 887 case lir_membar_release : output()->print("membar_release"); break; 888 case lir_membar : output()->print("membar"); break; 889 case lir_membar_loadload : output()->print("membar_loadload"); break; 890 case lir_membar_storestore: output()->print("membar_storestore"); break; 891 case lir_membar_loadstore : output()->print("membar_loadstore"); break; 892 case lir_membar_storeload : output()->print("membar_storeload"); break; 893 default : ShouldNotReachHere(); break; 894 } 895 } 896 897 #endif // PRODUCT