1 /*
   2  * Copyright (c) 2000, 2022, 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_CodeStubs.hpp"
  27 #include "c1/c1_InstructionPrinter.hpp"
  28 #include "c1/c1_LIR.hpp"
  29 #include "c1/c1_LIRAssembler.hpp"
  30 #include "c1/c1_ValueStack.hpp"
  31 #include "ci/ciInlineKlass.hpp"
  32 #include "ci/ciInstance.hpp"
  33 #include "runtime/safepointMechanism.inline.hpp"
  34 #include "runtime/sharedRuntime.hpp"
  35 #include "runtime/vm_version.hpp"
  36 
  37 Register LIR_Opr::as_register() const {
  38   return FrameMap::cpu_rnr2reg(cpu_regnr());
  39 }
  40 
  41 Register LIR_Opr::as_register_lo() const {
  42   return FrameMap::cpu_rnr2reg(cpu_regnrLo());
  43 }
  44 
  45 Register LIR_Opr::as_register_hi() const {
  46   return FrameMap::cpu_rnr2reg(cpu_regnrHi());
  47 }
  48 
  49 LIR_Opr LIR_OprFact::illegalOpr = LIR_OprFact::illegal();
  50 LIR_Opr LIR_OprFact::nullOpr = LIR_Opr();
  51 
  52 LIR_Opr LIR_OprFact::value_type(ValueType* type) {
  53   ValueTag tag = type->tag();
  54   switch (tag) {
  55   case metaDataTag : {
  56     ClassConstant* c = type->as_ClassConstant();
  57     if (c != NULL && !c->value()->is_loaded()) {
  58       return LIR_OprFact::metadataConst(NULL);
  59     } else if (c != NULL) {
  60       return LIR_OprFact::metadataConst(c->value()->constant_encoding());
  61     } else {
  62       MethodConstant* m = type->as_MethodConstant();
  63       assert (m != NULL, "not a class or a method?");
  64       return LIR_OprFact::metadataConst(m->value()->constant_encoding());
  65     }
  66   }
  67   case objectTag : {
  68       return LIR_OprFact::oopConst(type->as_ObjectType()->encoding());
  69     }
  70   case addressTag: return LIR_OprFact::addressConst(type->as_AddressConstant()->value());
  71   case intTag    : return LIR_OprFact::intConst(type->as_IntConstant()->value());
  72   case floatTag  : return LIR_OprFact::floatConst(type->as_FloatConstant()->value());
  73   case longTag   : return LIR_OprFact::longConst(type->as_LongConstant()->value());
  74   case doubleTag : return LIR_OprFact::doubleConst(type->as_DoubleConstant()->value());
  75   default: ShouldNotReachHere(); return LIR_OprFact::intConst(-1);
  76   }
  77 }
  78 
  79 
  80 //---------------------------------------------------
  81 
  82 
  83 LIR_Address::Scale LIR_Address::scale(BasicType type) {
  84   int elem_size = type2aelembytes(type);
  85   switch (elem_size) {
  86   case 1: return LIR_Address::times_1;
  87   case 2: return LIR_Address::times_2;
  88   case 4: return LIR_Address::times_4;
  89   case 8: return LIR_Address::times_8;
  90   }
  91   ShouldNotReachHere();
  92   return LIR_Address::times_1;
  93 }
  94 
  95 //---------------------------------------------------
  96 
  97 char LIR_Opr::type_char(BasicType t) {
  98   switch (t) {
  99     case T_ARRAY:
 100     case T_PRIMITIVE_OBJECT:
 101       t = T_OBJECT;
 102     case T_BOOLEAN:
 103     case T_CHAR:
 104     case T_FLOAT:
 105     case T_DOUBLE:
 106     case T_BYTE:
 107     case T_SHORT:
 108     case T_INT:
 109     case T_LONG:
 110     case T_OBJECT:
 111     case T_ADDRESS:
 112     case T_VOID:
 113       return ::type2char(t);
 114     case T_METADATA:
 115       return 'M';
 116     case T_ILLEGAL:
 117       return '?';
 118 
 119     default:
 120       ShouldNotReachHere();
 121       return '?';
 122   }
 123 }
 124 
 125 #ifndef PRODUCT
 126 void LIR_Opr::validate_type() const {
 127 
 128 #ifdef ASSERT
 129   if (!is_pointer() && !is_illegal()) {
 130     OprKind kindfield = kind_field(); // Factored out because of compiler bug, see 8002160
 131     switch (as_BasicType(type_field())) {
 132     case T_LONG:
 133       assert((kindfield == cpu_register || kindfield == stack_value) &&
 134              size_field() == double_size, "must match");
 135       break;
 136     case T_FLOAT:
 137       // FP return values can be also in CPU registers on ARM (softfp ABI)
 138       assert((kindfield == fpu_register || kindfield == stack_value
 139              ARM_ONLY(|| kindfield == cpu_register) ) &&
 140              size_field() == single_size, "must match");
 141       break;
 142     case T_DOUBLE:
 143       // FP return values can be also in CPU registers on ARM (softfp ABI)
 144       assert((kindfield == fpu_register || kindfield == stack_value
 145              ARM_ONLY(|| kindfield == cpu_register) ) &&
 146              size_field() == double_size, "must match");
 147       break;
 148     case T_BOOLEAN:
 149     case T_CHAR:
 150     case T_BYTE:
 151     case T_SHORT:
 152     case T_INT:
 153     case T_ADDRESS:
 154     case T_OBJECT:
 155     case T_METADATA:
 156     case T_ARRAY:
 157     case T_PRIMITIVE_OBJECT:
 158       assert((kindfield == cpu_register || kindfield == stack_value) &&
 159              size_field() == single_size, "must match");
 160       break;
 161 
 162     case T_ILLEGAL:
 163       // XXX TKR also means unknown right now
 164       // assert(is_illegal(), "must match");
 165       break;
 166 
 167     default:
 168       ShouldNotReachHere();
 169     }
 170   }
 171 #endif
 172 
 173 }
 174 #endif // PRODUCT
 175 
 176 
 177 bool LIR_Opr::is_oop() const {
 178   if (is_pointer()) {
 179     return pointer()->is_oop_pointer();
 180   } else {
 181     OprType t= type_field();
 182     assert(t != unknown_type, "not set");
 183     return t == object_type;
 184   }
 185 }
 186 
 187 
 188 
 189 void LIR_Op2::verify() const {
 190 #ifdef ASSERT
 191   switch (code()) {
 192     case lir_xchg:
 193       break;
 194 
 195     default:
 196       assert(!result_opr()->is_register() || !result_opr()->is_oop_register(),
 197              "can't produce oops from arith");
 198   }
 199 
 200   if (two_operand_lir_form) {
 201 
 202 #ifdef ASSERT
 203     bool threeOperandForm = false;
 204 #ifdef S390
 205     // There are 3 operand shifts on S390 (see LIR_Assembler::shift_op()).
 206     threeOperandForm =
 207       code() == lir_shl ||
 208       ((code() == lir_shr || code() == lir_ushr) && (result_opr()->is_double_cpu() || in_opr1()->type() == T_OBJECT));
 209 #endif
 210 #endif
 211 
 212     switch (code()) {
 213     case lir_add:
 214     case lir_sub:
 215     case lir_mul:
 216     case lir_div:
 217     case lir_rem:
 218     case lir_logic_and:
 219     case lir_logic_or:
 220     case lir_logic_xor:
 221     case lir_shl:
 222     case lir_shr:
 223       assert(in_opr1() == result_opr() || threeOperandForm, "opr1 and result must match");
 224       assert(in_opr1()->is_valid() && in_opr2()->is_valid(), "must be valid");
 225       break;
 226 
 227     // special handling for lir_ushr because of write barriers
 228     case lir_ushr:
 229       assert(in_opr1() == result_opr() || in_opr2()->is_constant() || threeOperandForm, "opr1 and result must match or shift count is constant");
 230       assert(in_opr1()->is_valid() && in_opr2()->is_valid(), "must be valid");
 231       break;
 232 
 233     default:
 234       break;
 235     }
 236   }
 237 #endif
 238 }
 239 
 240 
 241 LIR_OpBranch::LIR_OpBranch(LIR_Condition cond, BlockBegin* block)
 242   : LIR_Op2(lir_branch, cond, LIR_OprFact::illegalOpr, LIR_OprFact::illegalOpr, (CodeEmitInfo*)NULL)
 243   , _label(block->label())
 244   , _block(block)
 245   , _ublock(NULL)
 246   , _stub(NULL) {
 247 }
 248 
 249 LIR_OpBranch::LIR_OpBranch(LIR_Condition cond, CodeStub* stub) :
 250   LIR_Op2(lir_branch, cond, LIR_OprFact::illegalOpr, LIR_OprFact::illegalOpr, (CodeEmitInfo*)NULL)
 251   , _label(stub->entry())
 252   , _block(NULL)
 253   , _ublock(NULL)
 254   , _stub(stub) {
 255 }
 256 
 257 LIR_OpBranch::LIR_OpBranch(LIR_Condition cond, BlockBegin* block, BlockBegin* ublock)
 258   : LIR_Op2(lir_cond_float_branch, cond, LIR_OprFact::illegalOpr, LIR_OprFact::illegalOpr, (CodeEmitInfo*)NULL)
 259   , _label(block->label())
 260   , _block(block)
 261   , _ublock(ublock)
 262   , _stub(NULL)
 263 {
 264 }
 265 
 266 void LIR_OpBranch::change_block(BlockBegin* b) {
 267   assert(_block != NULL, "must have old block");
 268   assert(_block->label() == label(), "must be equal");
 269 
 270   _block = b;
 271   _label = b->label();
 272 }
 273 
 274 void LIR_OpBranch::change_ublock(BlockBegin* b) {
 275   assert(_ublock != NULL, "must have old block");
 276   _ublock = b;
 277 }
 278 
 279 void LIR_OpBranch::negate_cond() {
 280   switch (cond()) {
 281     case lir_cond_equal:        set_cond(lir_cond_notEqual);     break;
 282     case lir_cond_notEqual:     set_cond(lir_cond_equal);        break;
 283     case lir_cond_less:         set_cond(lir_cond_greaterEqual); break;
 284     case lir_cond_lessEqual:    set_cond(lir_cond_greater);      break;
 285     case lir_cond_greaterEqual: set_cond(lir_cond_less);         break;
 286     case lir_cond_greater:      set_cond(lir_cond_lessEqual);    break;
 287     default: ShouldNotReachHere();
 288   }
 289 }
 290 
 291 
 292 LIR_OpTypeCheck::LIR_OpTypeCheck(LIR_Code code, LIR_Opr result, LIR_Opr object, ciKlass* klass,
 293                                  LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3,
 294                                  bool fast_check, CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch,
 295                                  CodeStub* stub, bool need_null_check)
 296 
 297   : LIR_Op(code, result, NULL)
 298   , _object(object)
 299   , _array(LIR_OprFact::illegalOpr)
 300   , _klass(klass)
 301   , _tmp1(tmp1)
 302   , _tmp2(tmp2)
 303   , _tmp3(tmp3)
 304   , _fast_check(fast_check)
 305   , _info_for_patch(info_for_patch)
 306   , _info_for_exception(info_for_exception)
 307   , _stub(stub)
 308   , _profiled_method(NULL)
 309   , _profiled_bci(-1)
 310   , _should_profile(false)
 311   , _need_null_check(need_null_check)
 312 {
 313   if (code == lir_checkcast) {
 314     assert(info_for_exception != NULL, "checkcast throws exceptions");
 315   } else if (code == lir_instanceof) {
 316     assert(info_for_exception == NULL, "instanceof throws no exceptions");
 317   } else {
 318     ShouldNotReachHere();
 319   }
 320 }
 321 
 322 
 323 
 324 LIR_OpTypeCheck::LIR_OpTypeCheck(LIR_Code code, LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, CodeEmitInfo* info_for_exception)
 325   : LIR_Op(code, LIR_OprFact::illegalOpr, NULL)
 326   , _object(object)
 327   , _array(array)
 328   , _klass(NULL)
 329   , _tmp1(tmp1)
 330   , _tmp2(tmp2)
 331   , _tmp3(tmp3)
 332   , _fast_check(false)
 333   , _info_for_patch(NULL)
 334   , _info_for_exception(info_for_exception)
 335   , _stub(NULL)
 336   , _profiled_method(NULL)
 337   , _profiled_bci(-1)
 338   , _should_profile(false)
 339   , _need_null_check(true)
 340 {
 341   if (code == lir_store_check) {
 342     _stub = new ArrayStoreExceptionStub(object, info_for_exception);
 343     assert(info_for_exception != NULL, "store_check throws exceptions");
 344   } else {
 345     ShouldNotReachHere();
 346   }
 347 }
 348 
 349 LIR_OpFlattenedArrayCheck::LIR_OpFlattenedArrayCheck(LIR_Opr array, LIR_Opr value, LIR_Opr tmp, CodeStub* stub)
 350   : LIR_Op(lir_flattened_array_check, LIR_OprFact::illegalOpr, NULL)
 351   , _array(array)
 352   , _value(value)
 353   , _tmp(tmp)
 354   , _stub(stub) {}
 355 
 356 
 357 LIR_OpNullFreeArrayCheck::LIR_OpNullFreeArrayCheck(LIR_Opr array, LIR_Opr tmp)
 358   : LIR_Op(lir_null_free_array_check, LIR_OprFact::illegalOpr, NULL)
 359   , _array(array)
 360   , _tmp(tmp) {}
 361 
 362 
 363 LIR_OpSubstitutabilityCheck::LIR_OpSubstitutabilityCheck(LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr equal_result, LIR_Opr not_equal_result,
 364                                                          LIR_Opr tmp1, LIR_Opr tmp2,
 365                                                          ciKlass* left_klass, ciKlass* right_klass, LIR_Opr left_klass_op, LIR_Opr right_klass_op,
 366                                                          CodeEmitInfo* info, CodeStub* stub)
 367   : LIR_Op(lir_substitutability_check, result, info)
 368   , _left(left)
 369   , _right(right)
 370   , _equal_result(equal_result)
 371   , _not_equal_result(not_equal_result)
 372   , _tmp1(tmp1)
 373   , _tmp2(tmp2)
 374   , _left_klass(left_klass)
 375   , _right_klass(right_klass)
 376   , _left_klass_op(left_klass_op)
 377   , _right_klass_op(right_klass_op)
 378   , _stub(stub) {}
 379 
 380 
 381 LIR_OpArrayCopy::LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length,
 382                                  LIR_Opr tmp, ciArrayKlass* expected_type, int flags, CodeEmitInfo* info)
 383   : LIR_Op(lir_arraycopy, LIR_OprFact::illegalOpr, info)
 384   , _src(src)
 385   , _src_pos(src_pos)
 386   , _dst(dst)
 387   , _dst_pos(dst_pos)
 388   , _length(length)
 389   , _tmp(tmp)
 390   , _expected_type(expected_type)
 391   , _flags(flags) {
 392   _stub = new ArrayCopyStub(this);
 393 }
 394 
 395 LIR_OpUpdateCRC32::LIR_OpUpdateCRC32(LIR_Opr crc, LIR_Opr val, LIR_Opr res)
 396   : LIR_Op(lir_updatecrc32, res, NULL)
 397   , _crc(crc)
 398   , _val(val) {
 399 }
 400 
 401 //-------------------verify--------------------------
 402 
 403 void LIR_Op1::verify() const {
 404   switch(code()) {
 405   case lir_move:
 406     assert(in_opr()->is_valid() && result_opr()->is_valid(), "must be");
 407     break;
 408   case lir_null_check:
 409     assert(in_opr()->is_register(), "must be");
 410     break;
 411   case lir_return:
 412     assert(in_opr()->is_register() || in_opr()->is_illegal(), "must be");
 413     break;
 414   default:
 415     break;
 416   }
 417 }
 418 
 419 void LIR_OpRTCall::verify() const {
 420   assert(strcmp(Runtime1::name_for_address(addr()), "<unknown function>") != 0, "unknown function");
 421 }
 422 
 423 //-------------------visits--------------------------
 424 
 425 // complete rework of LIR instruction visitor.
 426 // The virtual call for each instruction type is replaced by a big
 427 // switch that adds the operands for each instruction
 428 
 429 void LIR_OpVisitState::visit(LIR_Op* op) {
 430   // copy information from the LIR_Op
 431   reset();
 432   set_op(op);
 433 
 434   switch (op->code()) {
 435 
 436 // LIR_Op0
 437     case lir_fpop_raw:                 // result and info always invalid
 438     case lir_breakpoint:               // result and info always invalid
 439     case lir_membar:                   // result and info always invalid
 440     case lir_membar_acquire:           // result and info always invalid
 441     case lir_membar_release:           // result and info always invalid
 442     case lir_membar_loadload:          // result and info always invalid
 443     case lir_membar_storestore:        // result and info always invalid
 444     case lir_membar_loadstore:         // result and info always invalid
 445     case lir_membar_storeload:         // result and info always invalid
 446     case lir_check_orig_pc:            // result and info always invalid
 447     case lir_on_spin_wait:
 448     {
 449       assert(op->as_Op0() != NULL, "must be");
 450       assert(op->_info == NULL, "info not used by this instruction");
 451       assert(op->_result->is_illegal(), "not used");
 452       break;
 453     }
 454 
 455     case lir_nop:                      // may have info, result always invalid
 456     case lir_std_entry:                // may have result, info always invalid
 457     case lir_osr_entry:                // may have result, info always invalid
 458     case lir_get_thread:               // may have result, info always invalid
 459     {
 460       assert(op->as_Op0() != NULL, "must be");
 461       if (op->_info != NULL)           do_info(op->_info);
 462       if (op->_result->is_valid())     do_output(op->_result);
 463       break;
 464     }
 465 
 466 
 467 // LIR_OpLabel
 468     case lir_label:                    // result and info always invalid
 469     {
 470       assert(op->as_OpLabel() != NULL, "must be");
 471       assert(op->_info == NULL, "info not used by this instruction");
 472       assert(op->_result->is_illegal(), "not used");
 473       break;
 474     }
 475 
 476 
 477 // LIR_Op1
 478     case lir_fxch:           // input always valid, result and info always invalid
 479     case lir_fld:            // input always valid, result and info always invalid
 480     case lir_push:           // input always valid, result and info always invalid
 481     case lir_pop:            // input always valid, result and info always invalid
 482     case lir_leal:           // input and result always valid, info always invalid
 483     case lir_monaddr:        // input and result always valid, info always invalid
 484     case lir_null_check:     // input and info always valid, result always invalid
 485     case lir_move:           // input and result always valid, may have info
 486     {
 487       assert(op->as_Op1() != NULL, "must be");
 488       LIR_Op1* op1 = (LIR_Op1*)op;
 489 
 490       if (op1->_info)                  do_info(op1->_info);
 491       if (op1->_opr->is_valid())       do_input(op1->_opr);
 492       if (op1->_result->is_valid())    do_output(op1->_result);
 493 
 494       break;
 495     }
 496 
 497     case lir_return:
 498     {
 499       assert(op->as_OpReturn() != NULL, "must be");
 500       LIR_OpReturn* op_ret = (LIR_OpReturn*)op;
 501 
 502       if (op_ret->_info)               do_info(op_ret->_info);
 503       if (op_ret->_opr->is_valid())    do_input(op_ret->_opr);
 504       if (op_ret->_result->is_valid()) do_output(op_ret->_result);
 505       if (op_ret->stub() != NULL)      do_stub(op_ret->stub());
 506 
 507       break;
 508     }
 509 
 510     case lir_safepoint:
 511     {
 512       assert(op->as_Op1() != NULL, "must be");
 513       LIR_Op1* op1 = (LIR_Op1*)op;
 514 
 515       assert(op1->_info != NULL, "");  do_info(op1->_info);
 516       if (op1->_opr->is_valid())       do_temp(op1->_opr); // safepoints on SPARC need temporary register
 517       assert(op1->_result->is_illegal(), "safepoint does not produce value");
 518 
 519       break;
 520     }
 521 
 522 // LIR_OpConvert;
 523     case lir_convert:        // input and result always valid, info always invalid
 524     {
 525       assert(op->as_OpConvert() != NULL, "must be");
 526       LIR_OpConvert* opConvert = (LIR_OpConvert*)op;
 527 
 528       assert(opConvert->_info == NULL, "must be");
 529       if (opConvert->_opr->is_valid())       do_input(opConvert->_opr);
 530       if (opConvert->_result->is_valid())    do_output(opConvert->_result);
 531       do_stub(opConvert->_stub);
 532 
 533       break;
 534     }
 535 
 536 // LIR_OpBranch;
 537     case lir_branch:                   // may have info, input and result register always invalid
 538     case lir_cond_float_branch:        // may have info, input and result register always invalid
 539     {
 540       assert(op->as_OpBranch() != NULL, "must be");
 541       LIR_OpBranch* opBranch = (LIR_OpBranch*)op;
 542 
 543       assert(opBranch->_tmp1->is_illegal() && opBranch->_tmp2->is_illegal() &&
 544              opBranch->_tmp3->is_illegal() && opBranch->_tmp4->is_illegal() &&
 545              opBranch->_tmp5->is_illegal(), "not used");
 546 
 547       if (opBranch->_opr1->is_valid()) do_input(opBranch->_opr1);
 548       if (opBranch->_opr2->is_valid()) do_input(opBranch->_opr2);
 549 
 550       if (opBranch->_info != NULL)     do_info(opBranch->_info);
 551       assert(opBranch->_result->is_illegal(), "not used");
 552       if (opBranch->_stub != NULL)     opBranch->stub()->visit(this);
 553 
 554       break;
 555     }
 556 
 557 
 558 // LIR_OpAllocObj
 559     case lir_alloc_object:
 560     {
 561       assert(op->as_OpAllocObj() != NULL, "must be");
 562       LIR_OpAllocObj* opAllocObj = (LIR_OpAllocObj*)op;
 563 
 564       if (opAllocObj->_info)                     do_info(opAllocObj->_info);
 565       if (opAllocObj->_opr->is_valid()) {        do_input(opAllocObj->_opr);
 566                                                  do_temp(opAllocObj->_opr);
 567                                         }
 568       if (opAllocObj->_tmp1->is_valid())         do_temp(opAllocObj->_tmp1);
 569       if (opAllocObj->_tmp2->is_valid())         do_temp(opAllocObj->_tmp2);
 570       if (opAllocObj->_tmp3->is_valid())         do_temp(opAllocObj->_tmp3);
 571       if (opAllocObj->_tmp4->is_valid())         do_temp(opAllocObj->_tmp4);
 572       if (opAllocObj->_result->is_valid())       do_output(opAllocObj->_result);
 573       if (opAllocObj->_stub != nullptr)          do_stub(opAllocObj->_stub);
 574       break;
 575     }
 576 
 577 
 578 // LIR_OpRoundFP;
 579     case lir_roundfp: {
 580       assert(op->as_OpRoundFP() != NULL, "must be");
 581       LIR_OpRoundFP* opRoundFP = (LIR_OpRoundFP*)op;
 582 
 583       assert(op->_info == NULL, "info not used by this instruction");
 584       assert(opRoundFP->_tmp->is_illegal(), "not used");
 585       do_input(opRoundFP->_opr);
 586       do_output(opRoundFP->_result);
 587 
 588       break;
 589     }
 590 
 591 
 592 // LIR_Op2
 593     case lir_cmp:
 594     case lir_cmp_l2i:
 595     case lir_ucmp_fd2i:
 596     case lir_cmp_fd2i:
 597     case lir_add:
 598     case lir_sub:
 599     case lir_rem:
 600     case lir_sqrt:
 601     case lir_abs:
 602     case lir_neg:
 603     case lir_logic_and:
 604     case lir_logic_or:
 605     case lir_logic_xor:
 606     case lir_shl:
 607     case lir_shr:
 608     case lir_ushr:
 609     case lir_xadd:
 610     case lir_xchg:
 611     case lir_assert:
 612     {
 613       assert(op->as_Op2() != NULL, "must be");
 614       LIR_Op2* op2 = (LIR_Op2*)op;
 615       assert(op2->_tmp2->is_illegal() && op2->_tmp3->is_illegal() &&
 616              op2->_tmp4->is_illegal() && op2->_tmp5->is_illegal(), "not used");
 617 
 618       if (op2->_info)                     do_info(op2->_info);
 619       if (op2->_opr1->is_valid())         do_input(op2->_opr1);
 620       if (op2->_opr2->is_valid())         do_input(op2->_opr2);
 621       if (op2->_tmp1->is_valid())         do_temp(op2->_tmp1);
 622       if (op2->_result->is_valid())       do_output(op2->_result);
 623       if (op->code() == lir_xchg || op->code() == lir_xadd) {
 624         // on ARM and PPC, return value is loaded first so could
 625         // destroy inputs. On other platforms that implement those
 626         // (x86, sparc), the extra constrainsts are harmless.
 627         if (op2->_opr1->is_valid())       do_temp(op2->_opr1);
 628         if (op2->_opr2->is_valid())       do_temp(op2->_opr2);
 629       }
 630 
 631       break;
 632     }
 633 
 634     // special handling for cmove: right input operand must not be equal
 635     // to the result operand, otherwise the backend fails
 636     case lir_cmove:
 637     {
 638       assert(op->as_Op4() != NULL, "must be");
 639       LIR_Op4* op4 = (LIR_Op4*)op;
 640 
 641       assert(op4->_info == NULL && op4->_tmp1->is_illegal() && op4->_tmp2->is_illegal() &&
 642              op4->_tmp3->is_illegal() && op4->_tmp4->is_illegal() && op4->_tmp5->is_illegal(), "not used");
 643       assert(op4->_opr1->is_valid() && op4->_opr2->is_valid() && op4->_result->is_valid(), "used");
 644 
 645       do_input(op4->_opr1);
 646       do_input(op4->_opr2);
 647       if (op4->_opr3->is_valid()) do_input(op4->_opr3);
 648       if (op4->_opr4->is_valid()) do_input(op4->_opr4);
 649       do_temp(op4->_opr2);
 650       do_output(op4->_result);
 651 
 652       break;
 653     }
 654 
 655     // vspecial handling for strict operations: register input operands
 656     // as temp to guarantee that they do not overlap with other
 657     // registers
 658     case lir_mul:
 659     case lir_div:
 660     {
 661       assert(op->as_Op2() != NULL, "must be");
 662       LIR_Op2* op2 = (LIR_Op2*)op;
 663 
 664       assert(op2->_info == NULL, "not used");
 665       assert(op2->_opr1->is_valid(), "used");
 666       assert(op2->_opr2->is_valid(), "used");
 667       assert(op2->_result->is_valid(), "used");
 668       assert(op2->_tmp2->is_illegal() && op2->_tmp3->is_illegal() &&
 669              op2->_tmp4->is_illegal() && op2->_tmp5->is_illegal(), "not used");
 670 
 671       do_input(op2->_opr1); do_temp(op2->_opr1);
 672       do_input(op2->_opr2); do_temp(op2->_opr2);
 673       if (op2->_tmp1->is_valid()) do_temp(op2->_tmp1);
 674       do_output(op2->_result);
 675 
 676       break;
 677     }
 678 
 679     case lir_throw: {
 680       assert(op->as_Op2() != NULL, "must be");
 681       LIR_Op2* op2 = (LIR_Op2*)op;
 682 
 683       if (op2->_info)                     do_info(op2->_info);
 684       if (op2->_opr1->is_valid())         do_temp(op2->_opr1);
 685       if (op2->_opr2->is_valid())         do_input(op2->_opr2); // exception object is input parameter
 686       assert(op2->_result->is_illegal(), "no result");
 687       assert(op2->_tmp2->is_illegal() && op2->_tmp3->is_illegal() &&
 688              op2->_tmp4->is_illegal() && op2->_tmp5->is_illegal(), "not used");
 689 
 690       break;
 691     }
 692 
 693     case lir_unwind: {
 694       assert(op->as_Op1() != NULL, "must be");
 695       LIR_Op1* op1 = (LIR_Op1*)op;
 696 
 697       assert(op1->_info == NULL, "no info");
 698       assert(op1->_opr->is_valid(), "exception oop");         do_input(op1->_opr);
 699       assert(op1->_result->is_illegal(), "no result");
 700 
 701       break;
 702     }
 703 
 704 // LIR_Op3
 705     case lir_idiv:
 706     case lir_irem: {
 707       assert(op->as_Op3() != NULL, "must be");
 708       LIR_Op3* op3= (LIR_Op3*)op;
 709 
 710       if (op3->_info)                     do_info(op3->_info);
 711       if (op3->_opr1->is_valid())         do_input(op3->_opr1);
 712 
 713       // second operand is input and temp, so ensure that second operand
 714       // and third operand get not the same register
 715       if (op3->_opr2->is_valid())         do_input(op3->_opr2);
 716       if (op3->_opr2->is_valid())         do_temp(op3->_opr2);
 717       if (op3->_opr3->is_valid())         do_temp(op3->_opr3);
 718 
 719       if (op3->_result->is_valid())       do_output(op3->_result);
 720 
 721       break;
 722     }
 723 
 724     case lir_fmad:
 725     case lir_fmaf: {
 726       assert(op->as_Op3() != NULL, "must be");
 727       LIR_Op3* op3= (LIR_Op3*)op;
 728       assert(op3->_info == NULL, "no info");
 729       do_input(op3->_opr1);
 730       do_input(op3->_opr2);
 731       do_input(op3->_opr3);
 732       do_output(op3->_result);
 733       break;
 734     }
 735 
 736 // LIR_OpJavaCall
 737     case lir_static_call:
 738     case lir_optvirtual_call:
 739     case lir_icvirtual_call:
 740     case lir_dynamic_call: {
 741       LIR_OpJavaCall* opJavaCall = op->as_OpJavaCall();
 742       assert(opJavaCall != NULL, "must be");
 743 
 744       if (opJavaCall->_receiver->is_valid())     do_input(opJavaCall->_receiver);
 745 
 746       // only visit register parameters
 747       int n = opJavaCall->_arguments->length();
 748       for (int i = opJavaCall->_receiver->is_valid() ? 1 : 0; i < n; i++) {
 749         if (!opJavaCall->_arguments->at(i)->is_pointer()) {
 750           do_input(*opJavaCall->_arguments->adr_at(i));
 751         }
 752       }
 753 
 754       if (opJavaCall->_info)                     do_info(opJavaCall->_info);
 755       if (FrameMap::method_handle_invoke_SP_save_opr() != LIR_OprFact::illegalOpr &&
 756           opJavaCall->is_method_handle_invoke()) {
 757         opJavaCall->_method_handle_invoke_SP_save_opr = FrameMap::method_handle_invoke_SP_save_opr();
 758         do_temp(opJavaCall->_method_handle_invoke_SP_save_opr);
 759       }
 760       do_call();
 761       if (opJavaCall->_result->is_valid())       do_output(opJavaCall->_result);
 762 
 763       break;
 764     }
 765 
 766 
 767 // LIR_OpRTCall
 768     case lir_rtcall: {
 769       assert(op->as_OpRTCall() != NULL, "must be");
 770       LIR_OpRTCall* opRTCall = (LIR_OpRTCall*)op;
 771 
 772       // only visit register parameters
 773       int n = opRTCall->_arguments->length();
 774       for (int i = 0; i < n; i++) {
 775         if (!opRTCall->_arguments->at(i)->is_pointer()) {
 776           do_input(*opRTCall->_arguments->adr_at(i));
 777         }
 778       }
 779       if (opRTCall->_info)                     do_info(opRTCall->_info);
 780       if (opRTCall->_tmp->is_valid())          do_temp(opRTCall->_tmp);
 781       do_call();
 782       if (opRTCall->_result->is_valid())       do_output(opRTCall->_result);
 783 
 784       break;
 785     }
 786 
 787 
 788 // LIR_OpArrayCopy
 789     case lir_arraycopy: {
 790       assert(op->as_OpArrayCopy() != NULL, "must be");
 791       LIR_OpArrayCopy* opArrayCopy = (LIR_OpArrayCopy*)op;
 792 
 793       assert(opArrayCopy->_result->is_illegal(), "unused");
 794       assert(opArrayCopy->_src->is_valid(), "used");          do_input(opArrayCopy->_src);     do_temp(opArrayCopy->_src);
 795       assert(opArrayCopy->_src_pos->is_valid(), "used");      do_input(opArrayCopy->_src_pos); do_temp(opArrayCopy->_src_pos);
 796       assert(opArrayCopy->_dst->is_valid(), "used");          do_input(opArrayCopy->_dst);     do_temp(opArrayCopy->_dst);
 797       assert(opArrayCopy->_dst_pos->is_valid(), "used");      do_input(opArrayCopy->_dst_pos); do_temp(opArrayCopy->_dst_pos);
 798       assert(opArrayCopy->_length->is_valid(), "used");       do_input(opArrayCopy->_length);  do_temp(opArrayCopy->_length);
 799       assert(opArrayCopy->_tmp->is_valid(), "used");          do_temp(opArrayCopy->_tmp);
 800       if (opArrayCopy->_info)                     do_info(opArrayCopy->_info);
 801 
 802       // the implementation of arraycopy always has a call into the runtime
 803       do_call();
 804 
 805       break;
 806     }
 807 
 808 
 809 // LIR_OpUpdateCRC32
 810     case lir_updatecrc32: {
 811       assert(op->as_OpUpdateCRC32() != NULL, "must be");
 812       LIR_OpUpdateCRC32* opUp = (LIR_OpUpdateCRC32*)op;
 813 
 814       assert(opUp->_crc->is_valid(), "used");          do_input(opUp->_crc);     do_temp(opUp->_crc);
 815       assert(opUp->_val->is_valid(), "used");          do_input(opUp->_val);     do_temp(opUp->_val);
 816       assert(opUp->_result->is_valid(), "used");       do_output(opUp->_result);
 817       assert(opUp->_info == NULL, "no info for LIR_OpUpdateCRC32");
 818 
 819       break;
 820     }
 821 
 822 
 823 // LIR_OpLock
 824     case lir_lock:
 825     case lir_unlock: {
 826       assert(op->as_OpLock() != NULL, "must be");
 827       LIR_OpLock* opLock = (LIR_OpLock*)op;
 828 
 829       if (opLock->_info)                          do_info(opLock->_info);
 830 
 831       // TODO: check if these operands really have to be temp
 832       // (or if input is sufficient). This may have influence on the oop map!
 833       assert(opLock->_lock->is_valid(), "used");  do_temp(opLock->_lock);
 834       assert(opLock->_hdr->is_valid(),  "used");  do_temp(opLock->_hdr);
 835       assert(opLock->_obj->is_valid(),  "used");  do_temp(opLock->_obj);
 836 
 837       if (opLock->_scratch->is_valid())           do_temp(opLock->_scratch);
 838       assert(opLock->_result->is_illegal(), "unused");
 839 
 840       do_stub(opLock->_stub);
 841       do_stub(opLock->_throw_imse_stub);
 842 
 843       break;
 844     }
 845 
 846 
 847 // LIR_OpDelay
 848     case lir_delay_slot: {
 849       assert(op->as_OpDelay() != NULL, "must be");
 850       LIR_OpDelay* opDelay = (LIR_OpDelay*)op;
 851 
 852       visit(opDelay->delay_op());
 853       break;
 854     }
 855 
 856 // LIR_OpTypeCheck
 857     case lir_instanceof:
 858     case lir_checkcast:
 859     case lir_store_check: {
 860       assert(op->as_OpTypeCheck() != NULL, "must be");
 861       LIR_OpTypeCheck* opTypeCheck = (LIR_OpTypeCheck*)op;
 862 
 863       if (opTypeCheck->_info_for_exception)       do_info(opTypeCheck->_info_for_exception);
 864       if (opTypeCheck->_info_for_patch)           do_info(opTypeCheck->_info_for_patch);
 865       if (opTypeCheck->_object->is_valid())       do_input(opTypeCheck->_object);
 866       if (op->code() == lir_store_check && opTypeCheck->_object->is_valid()) {
 867         do_temp(opTypeCheck->_object);
 868       }
 869       if (opTypeCheck->_array->is_valid())        do_input(opTypeCheck->_array);
 870       if (opTypeCheck->_tmp1->is_valid())         do_temp(opTypeCheck->_tmp1);
 871       if (opTypeCheck->_tmp2->is_valid())         do_temp(opTypeCheck->_tmp2);
 872       if (opTypeCheck->_tmp3->is_valid())         do_temp(opTypeCheck->_tmp3);
 873       if (opTypeCheck->_result->is_valid())       do_output(opTypeCheck->_result);
 874       if (opTypeCheck->_stub != nullptr)          do_stub(opTypeCheck->_stub);
 875       break;
 876     }
 877 
 878 // LIR_OpFlattenedArrayCheck
 879     case lir_flattened_array_check: {
 880       assert(op->as_OpFlattenedArrayCheck() != NULL, "must be");
 881       LIR_OpFlattenedArrayCheck* opFlattenedArrayCheck = (LIR_OpFlattenedArrayCheck*)op;
 882 
 883       if (opFlattenedArrayCheck->_array->is_valid()) do_input(opFlattenedArrayCheck->_array);
 884       if (opFlattenedArrayCheck->_value->is_valid()) do_input(opFlattenedArrayCheck->_value);
 885       if (opFlattenedArrayCheck->_tmp->is_valid())   do_temp(opFlattenedArrayCheck->_tmp);
 886 
 887       do_stub(opFlattenedArrayCheck->_stub);
 888 
 889       break;
 890     }
 891 
 892 // LIR_OpNullFreeArrayCheck
 893     case lir_null_free_array_check: {
 894       assert(op->as_OpNullFreeArrayCheck() != NULL, "must be");
 895       LIR_OpNullFreeArrayCheck* opNullFreeArrayCheck = (LIR_OpNullFreeArrayCheck*)op;
 896 
 897       if (opNullFreeArrayCheck->_array->is_valid()) do_input(opNullFreeArrayCheck->_array);
 898       if (opNullFreeArrayCheck->_tmp->is_valid())   do_temp(opNullFreeArrayCheck->_tmp);
 899       break;
 900     }
 901 
 902 // LIR_OpSubstitutabilityCheck
 903     case lir_substitutability_check: {
 904       assert(op->as_OpSubstitutabilityCheck() != NULL, "must be");
 905       LIR_OpSubstitutabilityCheck* opSubstitutabilityCheck = (LIR_OpSubstitutabilityCheck*)op;
 906                                                                 do_input(opSubstitutabilityCheck->_left);
 907                                                                 do_temp (opSubstitutabilityCheck->_left);
 908                                                                 do_input(opSubstitutabilityCheck->_right);
 909                                                                 do_temp (opSubstitutabilityCheck->_right);
 910                                                                 do_input(opSubstitutabilityCheck->_equal_result);
 911                                                                 do_temp (opSubstitutabilityCheck->_equal_result);
 912                                                                 do_input(opSubstitutabilityCheck->_not_equal_result);
 913                                                                 do_temp (opSubstitutabilityCheck->_not_equal_result);
 914       if (opSubstitutabilityCheck->_tmp1->is_valid())           do_temp(opSubstitutabilityCheck->_tmp1);
 915       if (opSubstitutabilityCheck->_tmp2->is_valid())           do_temp(opSubstitutabilityCheck->_tmp2);
 916       if (opSubstitutabilityCheck->_left_klass_op->is_valid())  do_temp(opSubstitutabilityCheck->_left_klass_op);
 917       if (opSubstitutabilityCheck->_right_klass_op->is_valid()) do_temp(opSubstitutabilityCheck->_right_klass_op);
 918       if (opSubstitutabilityCheck->_result->is_valid())         do_output(opSubstitutabilityCheck->_result);
 919 
 920       do_info(opSubstitutabilityCheck->_info);
 921       do_stub(opSubstitutabilityCheck->_stub);
 922       break;
 923     }
 924 
 925 // LIR_OpCompareAndSwap
 926     case lir_cas_long:
 927     case lir_cas_obj:
 928     case lir_cas_int: {
 929       assert(op->as_OpCompareAndSwap() != NULL, "must be");
 930       LIR_OpCompareAndSwap* opCmpAndSwap = (LIR_OpCompareAndSwap*)op;
 931 
 932       if (opCmpAndSwap->_info)                              do_info(opCmpAndSwap->_info);
 933       assert(opCmpAndSwap->_addr->is_valid(), "used");      do_input(opCmpAndSwap->_addr);
 934                                                             do_temp(opCmpAndSwap->_addr);
 935       assert(opCmpAndSwap->_cmp_value->is_valid(), "used"); do_input(opCmpAndSwap->_cmp_value);
 936                                                             do_temp(opCmpAndSwap->_cmp_value);
 937       assert(opCmpAndSwap->_new_value->is_valid(), "used"); do_input(opCmpAndSwap->_new_value);
 938                                                             do_temp(opCmpAndSwap->_new_value);
 939       if (opCmpAndSwap->_tmp1->is_valid())                  do_temp(opCmpAndSwap->_tmp1);
 940       if (opCmpAndSwap->_tmp2->is_valid())                  do_temp(opCmpAndSwap->_tmp2);
 941       if (opCmpAndSwap->_result->is_valid())                do_output(opCmpAndSwap->_result);
 942 
 943       break;
 944     }
 945 
 946 
 947 // LIR_OpAllocArray;
 948     case lir_alloc_array: {
 949       assert(op->as_OpAllocArray() != NULL, "must be");
 950       LIR_OpAllocArray* opAllocArray = (LIR_OpAllocArray*)op;
 951 
 952       if (opAllocArray->_info)                        do_info(opAllocArray->_info);
 953       if (opAllocArray->_klass->is_valid()) {         do_input(opAllocArray->_klass);
 954                                                       do_temp(opAllocArray->_klass);
 955                                             }
 956       if (opAllocArray->_len->is_valid())   {         do_input(opAllocArray->_len);
 957                                                       do_temp(opAllocArray->_len);
 958                                             }
 959       if (opAllocArray->_tmp1->is_valid())            do_temp(opAllocArray->_tmp1);
 960       if (opAllocArray->_tmp2->is_valid())            do_temp(opAllocArray->_tmp2);
 961       if (opAllocArray->_tmp3->is_valid())            do_temp(opAllocArray->_tmp3);
 962       if (opAllocArray->_tmp4->is_valid())            do_temp(opAllocArray->_tmp4);
 963       if (opAllocArray->_result->is_valid())          do_output(opAllocArray->_result);
 964       if (opAllocArray->_stub != nullptr)             do_stub(opAllocArray->_stub);
 965       break;
 966     }
 967 
 968 // LIR_OpLoadKlass
 969     case lir_load_klass:
 970     {
 971       LIR_OpLoadKlass* opLoadKlass = op->as_OpLoadKlass();
 972       assert(opLoadKlass != NULL, "must be");
 973 
 974       do_input(opLoadKlass->_obj);
 975       do_output(opLoadKlass->_result);
 976       if (opLoadKlass->_info) do_info(opLoadKlass->_info);
 977       break;
 978     }
 979 
 980 
 981 // LIR_OpProfileCall:
 982     case lir_profile_call: {
 983       assert(op->as_OpProfileCall() != NULL, "must be");
 984       LIR_OpProfileCall* opProfileCall = (LIR_OpProfileCall*)op;
 985 
 986       if (opProfileCall->_recv->is_valid())              do_temp(opProfileCall->_recv);
 987       assert(opProfileCall->_mdo->is_valid(), "used");   do_temp(opProfileCall->_mdo);
 988       assert(opProfileCall->_tmp1->is_valid(), "used");  do_temp(opProfileCall->_tmp1);
 989       break;
 990     }
 991 
 992 // LIR_OpProfileType:
 993     case lir_profile_type: {
 994       assert(op->as_OpProfileType() != NULL, "must be");
 995       LIR_OpProfileType* opProfileType = (LIR_OpProfileType*)op;
 996 
 997       do_input(opProfileType->_mdp); do_temp(opProfileType->_mdp);
 998       do_input(opProfileType->_obj);
 999       do_temp(opProfileType->_tmp);
1000       break;
1001     }
1002 
1003     // LIR_OpProfileInlineType:
1004     case lir_profile_inline_type: {
1005       assert(op->as_OpProfileInlineType() != NULL, "must be");
1006       LIR_OpProfileInlineType* opProfileInlineType = (LIR_OpProfileInlineType*)op;
1007 
1008       do_input(opProfileInlineType->_mdp); do_temp(opProfileInlineType->_mdp);
1009       do_input(opProfileInlineType->_obj);
1010       do_temp(opProfileInlineType->_tmp);
1011       break;
1012     }
1013 default:
1014     op->visit(this);
1015   }
1016 }
1017 
1018 void LIR_Op::visit(LIR_OpVisitState* state) {
1019   ShouldNotReachHere();
1020 }
1021 
1022 void LIR_OpVisitState::do_stub(CodeStub* stub) {
1023   if (stub != NULL) {
1024     stub->visit(this);
1025   }
1026 }
1027 
1028 XHandlers* LIR_OpVisitState::all_xhandler() {
1029   XHandlers* result = NULL;
1030 
1031   int i;
1032   for (i = 0; i < info_count(); i++) {
1033     if (info_at(i)->exception_handlers() != NULL) {
1034       result = info_at(i)->exception_handlers();
1035       break;
1036     }
1037   }
1038 
1039 #ifdef ASSERT
1040   for (i = 0; i < info_count(); i++) {
1041     assert(info_at(i)->exception_handlers() == NULL ||
1042            info_at(i)->exception_handlers() == result,
1043            "only one xhandler list allowed per LIR-operation");
1044   }
1045 #endif
1046 
1047   if (result != NULL) {
1048     return result;
1049   } else {
1050     return new XHandlers();
1051   }
1052 
1053   return result;
1054 }
1055 
1056 
1057 #ifdef ASSERT
1058 bool LIR_OpVisitState::no_operands(LIR_Op* op) {
1059   visit(op);
1060 
1061   return opr_count(inputMode) == 0 &&
1062          opr_count(outputMode) == 0 &&
1063          opr_count(tempMode) == 0 &&
1064          info_count() == 0 &&
1065          !has_call() &&
1066          !has_slow_case();
1067 }
1068 #endif
1069 
1070 // LIR_OpReturn
1071 LIR_OpReturn::LIR_OpReturn(LIR_Opr opr) :
1072     LIR_Op1(lir_return, opr, (CodeEmitInfo*)NULL /* info */),
1073     _stub(NULL) {
1074   if (VM_Version::supports_stack_watermark_barrier()) {
1075     _stub = new C1SafepointPollStub();
1076   }
1077 }
1078 
1079 //---------------------------------------------------
1080 
1081 
1082 void LIR_OpJavaCall::emit_code(LIR_Assembler* masm) {
1083   masm->emit_call(this);
1084 }
1085 
1086 bool LIR_OpJavaCall::maybe_return_as_fields(ciInlineKlass** vk_ret) const {
1087   ciType* return_type = method()->return_type();
1088   if (InlineTypeReturnedAsFields) {
1089     if (return_type->is_inlinetype()) {
1090       ciInlineKlass* vk = return_type->as_inline_klass();
1091       if (vk->can_be_returned_as_fields()) {
1092         if (vk_ret != NULL) {
1093           *vk_ret = vk;
1094         }
1095         return true;
1096       }
1097     } else if (return_type->is_instance_klass() &&
1098                (method()->is_method_handle_intrinsic() ||
1099                 (!return_type->is_loaded() && !method()->holder()->is_loaded()))) {
1100       // An inline type might be returned from the call but we don't know its type.
1101       // This can happen with method handle intrinsics or when both the return type
1102       // and the method holder are unloaded (and therefore the preload logic did not
1103       // get a chance to load the return type). If an inline type is returned, we
1104       // either get an oop to a buffer and nothing needs to be done or one of the
1105       // values being returned is the klass of the inline type (RAX on x64, with LSB
1106       // set to 1) and we need to allocate an inline type instance of that type and
1107       // initialize it with other values being returned (in other registers).
1108       return true;
1109     }
1110   }
1111   return false;
1112 }
1113 
1114 void LIR_OpRTCall::emit_code(LIR_Assembler* masm) {
1115   masm->emit_rtcall(this);
1116 }
1117 
1118 void LIR_OpLabel::emit_code(LIR_Assembler* masm) {
1119   masm->emit_opLabel(this);
1120 }
1121 
1122 void LIR_OpArrayCopy::emit_code(LIR_Assembler* masm) {
1123   masm->emit_arraycopy(this);
1124   masm->append_code_stub(stub());
1125 }
1126 
1127 void LIR_OpUpdateCRC32::emit_code(LIR_Assembler* masm) {
1128   masm->emit_updatecrc32(this);
1129 }
1130 
1131 void LIR_Op0::emit_code(LIR_Assembler* masm) {
1132   masm->emit_op0(this);
1133 }
1134 
1135 void LIR_Op1::emit_code(LIR_Assembler* masm) {
1136   masm->emit_op1(this);
1137 }
1138 
1139 void LIR_OpAllocObj::emit_code(LIR_Assembler* masm) {
1140   masm->emit_alloc_obj(this);
1141   masm->append_code_stub(stub());
1142 }
1143 
1144 void LIR_OpBranch::emit_code(LIR_Assembler* masm) {
1145   masm->emit_opBranch(this);
1146   if (stub()) {
1147     masm->append_code_stub(stub());
1148   }
1149 }
1150 
1151 void LIR_OpConvert::emit_code(LIR_Assembler* masm) {
1152   masm->emit_opConvert(this);
1153   if (stub() != NULL) {
1154     masm->append_code_stub(stub());
1155   }
1156 }
1157 
1158 void LIR_Op2::emit_code(LIR_Assembler* masm) {
1159   masm->emit_op2(this);
1160 }
1161 
1162 void LIR_OpAllocArray::emit_code(LIR_Assembler* masm) {
1163   masm->emit_alloc_array(this);
1164   masm->append_code_stub(stub());
1165 }
1166 
1167 void LIR_OpTypeCheck::emit_code(LIR_Assembler* masm) {
1168   masm->emit_opTypeCheck(this);
1169   if (stub()) {
1170     masm->append_code_stub(stub());
1171   }
1172 }
1173 
1174 void LIR_OpFlattenedArrayCheck::emit_code(LIR_Assembler* masm) {
1175   masm->emit_opFlattenedArrayCheck(this);
1176   if (stub() != NULL) {
1177     masm->append_code_stub(stub());
1178   }
1179 }
1180 
1181 void LIR_OpNullFreeArrayCheck::emit_code(LIR_Assembler* masm) {
1182   masm->emit_opNullFreeArrayCheck(this);
1183 }
1184 
1185 void LIR_OpSubstitutabilityCheck::emit_code(LIR_Assembler* masm) {
1186   masm->emit_opSubstitutabilityCheck(this);
1187   if (stub() != NULL) {
1188     masm->append_code_stub(stub());
1189   }
1190 }
1191 
1192 void LIR_OpCompareAndSwap::emit_code(LIR_Assembler* masm) {
1193   masm->emit_compare_and_swap(this);
1194 }
1195 
1196 void LIR_Op3::emit_code(LIR_Assembler* masm) {
1197   masm->emit_op3(this);
1198 }
1199 
1200 void LIR_Op4::emit_code(LIR_Assembler* masm) {
1201   masm->emit_op4(this);
1202 }
1203 
1204 void LIR_OpLock::emit_code(LIR_Assembler* masm) {
1205   masm->emit_lock(this);
1206   if (stub()) {
1207     masm->append_code_stub(stub());
1208   }
1209   if (throw_imse_stub()) {
1210     masm->append_code_stub(throw_imse_stub());
1211   }
1212 }
1213 
1214 void LIR_OpLoadKlass::emit_code(LIR_Assembler* masm) {
1215   masm->emit_load_klass(this);
1216 }
1217 
1218 #ifdef ASSERT
1219 void LIR_OpAssert::emit_code(LIR_Assembler* masm) {
1220   masm->emit_assert(this);
1221 }
1222 #endif
1223 
1224 void LIR_OpDelay::emit_code(LIR_Assembler* masm) {
1225   masm->emit_delay(this);
1226 }
1227 
1228 void LIR_OpProfileCall::emit_code(LIR_Assembler* masm) {
1229   masm->emit_profile_call(this);
1230 }
1231 
1232 void LIR_OpProfileType::emit_code(LIR_Assembler* masm) {
1233   masm->emit_profile_type(this);
1234 }
1235 
1236 void LIR_OpProfileInlineType::emit_code(LIR_Assembler* masm) {
1237   masm->emit_profile_inline_type(this);
1238 }
1239 
1240 // LIR_List
1241 LIR_List::LIR_List(Compilation* compilation, BlockBegin* block)
1242   : _operations(8)
1243   , _compilation(compilation)
1244 #ifndef PRODUCT
1245   , _block(block)
1246 #endif
1247 #ifdef ASSERT
1248   , _file(NULL)
1249   , _line(0)
1250 #endif
1251 #ifdef RISCV
1252   , _cmp_opr1(LIR_OprFact::illegalOpr)
1253   , _cmp_opr2(LIR_OprFact::illegalOpr)
1254 #endif
1255 { }
1256 
1257 
1258 #ifdef ASSERT
1259 void LIR_List::set_file_and_line(const char * file, int line) {
1260   const char * f = strrchr(file, '/');
1261   if (f == NULL) f = strrchr(file, '\\');
1262   if (f == NULL) {
1263     f = file;
1264   } else {
1265     f++;
1266   }
1267   _file = f;
1268   _line = line;
1269 }
1270 #endif
1271 
1272 #ifdef RISCV
1273 void LIR_List::set_cmp_oprs(LIR_Op* op) {
1274   switch (op->code()) {
1275     case lir_cmp:
1276       _cmp_opr1 = op->as_Op2()->in_opr1();
1277       _cmp_opr2 = op->as_Op2()->in_opr2();
1278       break;
1279     case lir_branch: // fall through
1280     case lir_cond_float_branch:
1281       assert(op->as_OpBranch()->cond() == lir_cond_always ||
1282             (_cmp_opr1 != LIR_OprFact::illegalOpr && _cmp_opr2 != LIR_OprFact::illegalOpr),
1283             "conditional branches must have legal operands");
1284       if (op->as_OpBranch()->cond() != lir_cond_always) {
1285         op->as_Op2()->set_in_opr1(_cmp_opr1);
1286         op->as_Op2()->set_in_opr2(_cmp_opr2);
1287       }
1288       break;
1289     case lir_cmove:
1290       op->as_Op4()->set_in_opr3(_cmp_opr1);
1291       op->as_Op4()->set_in_opr4(_cmp_opr2);
1292       break;
1293 #if INCLUDE_ZGC
1294     case lir_zloadbarrier_test:
1295       _cmp_opr1 = FrameMap::as_opr(t1);
1296       _cmp_opr2 = LIR_OprFact::intConst(0);
1297       break;
1298 #endif
1299     default:
1300       break;
1301   }
1302 }
1303 #endif
1304 
1305 void LIR_List::append(LIR_InsertionBuffer* buffer) {
1306   assert(this == buffer->lir_list(), "wrong lir list");
1307   const int n = _operations.length();
1308 
1309   if (buffer->number_of_ops() > 0) {
1310     // increase size of instructions list
1311     _operations.at_grow(n + buffer->number_of_ops() - 1, NULL);
1312     // insert ops from buffer into instructions list
1313     int op_index = buffer->number_of_ops() - 1;
1314     int ip_index = buffer->number_of_insertion_points() - 1;
1315     int from_index = n - 1;
1316     int to_index = _operations.length() - 1;
1317     for (; ip_index >= 0; ip_index --) {
1318       int index = buffer->index_at(ip_index);
1319       // make room after insertion point
1320       while (index < from_index) {
1321         _operations.at_put(to_index --, _operations.at(from_index --));
1322       }
1323       // insert ops from buffer
1324       for (int i = buffer->count_at(ip_index); i > 0; i --) {
1325         _operations.at_put(to_index --, buffer->op_at(op_index --));
1326       }
1327     }
1328   }
1329 
1330   buffer->finish();
1331 }
1332 
1333 
1334 void LIR_List::oop2reg_patch(jobject o, LIR_Opr reg, CodeEmitInfo* info) {
1335   assert(reg->type() == T_OBJECT, "bad reg");
1336   append(new LIR_Op1(lir_move, LIR_OprFact::oopConst(o),  reg, T_OBJECT, lir_patch_normal, info));
1337 }
1338 
1339 void LIR_List::klass2reg_patch(Metadata* o, LIR_Opr reg, CodeEmitInfo* info) {
1340   assert(reg->type() == T_METADATA, "bad reg");
1341   append(new LIR_Op1(lir_move, LIR_OprFact::metadataConst(o), reg, T_METADATA, lir_patch_normal, info));
1342 }
1343 
1344 void LIR_List::load(LIR_Address* addr, LIR_Opr src, CodeEmitInfo* info, LIR_PatchCode patch_code) {
1345   append(new LIR_Op1(
1346             lir_move,
1347             LIR_OprFact::address(addr),
1348             src,
1349             addr->type(),
1350             patch_code,
1351             info));
1352 }
1353 
1354 
1355 void LIR_List::volatile_load_mem_reg(LIR_Address* address, LIR_Opr dst, CodeEmitInfo* info, LIR_PatchCode patch_code) {
1356   append(new LIR_Op1(
1357             lir_move,
1358             LIR_OprFact::address(address),
1359             dst,
1360             address->type(),
1361             patch_code,
1362             info, lir_move_volatile));
1363 }
1364 
1365 void LIR_List::volatile_load_unsafe_reg(LIR_Opr base, LIR_Opr offset, LIR_Opr dst, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code) {
1366   append(new LIR_Op1(
1367             lir_move,
1368             LIR_OprFact::address(new LIR_Address(base, offset, type)),
1369             dst,
1370             type,
1371             patch_code,
1372             info, lir_move_volatile));
1373 }
1374 
1375 
1376 void LIR_List::store_mem_int(jint v, LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code) {
1377   append(new LIR_Op1(
1378             lir_move,
1379             LIR_OprFact::intConst(v),
1380             LIR_OprFact::address(new LIR_Address(base, offset_in_bytes, type)),
1381             type,
1382             patch_code,
1383             info));
1384 }
1385 
1386 
1387 void LIR_List::store_mem_oop(jobject o, LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code) {
1388   append(new LIR_Op1(
1389             lir_move,
1390             LIR_OprFact::oopConst(o),
1391             LIR_OprFact::address(new LIR_Address(base, offset_in_bytes, type)),
1392             type,
1393             patch_code,
1394             info));
1395 }
1396 
1397 
1398 void LIR_List::store(LIR_Opr src, LIR_Address* addr, CodeEmitInfo* info, LIR_PatchCode patch_code) {
1399   append(new LIR_Op1(
1400             lir_move,
1401             src,
1402             LIR_OprFact::address(addr),
1403             addr->type(),
1404             patch_code,
1405             info));
1406 }
1407 
1408 
1409 void LIR_List::volatile_store_mem_reg(LIR_Opr src, LIR_Address* addr, CodeEmitInfo* info, LIR_PatchCode patch_code) {
1410   append(new LIR_Op1(
1411             lir_move,
1412             src,
1413             LIR_OprFact::address(addr),
1414             addr->type(),
1415             patch_code,
1416             info,
1417             lir_move_volatile));
1418 }
1419 
1420 void LIR_List::volatile_store_unsafe_reg(LIR_Opr src, LIR_Opr base, LIR_Opr offset, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code) {
1421   append(new LIR_Op1(
1422             lir_move,
1423             src,
1424             LIR_OprFact::address(new LIR_Address(base, offset, type)),
1425             type,
1426             patch_code,
1427             info, lir_move_volatile));
1428 }
1429 
1430 
1431 void LIR_List::idiv(LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info) {
1432   append(new LIR_Op3(
1433                     lir_idiv,
1434                     left,
1435                     right,
1436                     tmp,
1437                     res,
1438                     info));
1439 }
1440 
1441 
1442 void LIR_List::idiv(LIR_Opr left, int right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info) {
1443   append(new LIR_Op3(
1444                     lir_idiv,
1445                     left,
1446                     LIR_OprFact::intConst(right),
1447                     tmp,
1448                     res,
1449                     info));
1450 }
1451 
1452 
1453 void LIR_List::irem(LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info) {
1454   append(new LIR_Op3(
1455                     lir_irem,
1456                     left,
1457                     right,
1458                     tmp,
1459                     res,
1460                     info));
1461 }
1462 
1463 
1464 void LIR_List::irem(LIR_Opr left, int right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info) {
1465   append(new LIR_Op3(
1466                     lir_irem,
1467                     left,
1468                     LIR_OprFact::intConst(right),
1469                     tmp,
1470                     res,
1471                     info));
1472 }
1473 
1474 
1475 void LIR_List::cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info) {
1476   append(new LIR_Op2(
1477                     lir_cmp,
1478                     condition,
1479                     LIR_OprFact::address(new LIR_Address(base, disp, T_INT)),
1480                     LIR_OprFact::intConst(c),
1481                     info));
1482 }
1483 
1484 
1485 void LIR_List::cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Address* addr, CodeEmitInfo* info) {
1486   append(new LIR_Op2(
1487                     lir_cmp,
1488                     condition,
1489                     reg,
1490                     LIR_OprFact::address(addr),
1491                     info));
1492 }
1493 
1494 void LIR_List::allocate_object(LIR_Opr dst, LIR_Opr t1, LIR_Opr t2, LIR_Opr t3, LIR_Opr t4,
1495                                int header_size, int object_size, LIR_Opr klass, bool init_check, CodeStub* stub) {
1496   append(new LIR_OpAllocObj(
1497                            klass,
1498                            dst,
1499                            t1,
1500                            t2,
1501                            t3,
1502                            t4,
1503                            header_size,
1504                            object_size,
1505                            init_check,
1506                            stub));
1507 }
1508 
1509 void LIR_List::allocate_array(LIR_Opr dst, LIR_Opr len, LIR_Opr t1,LIR_Opr t2, LIR_Opr t3,LIR_Opr t4, BasicType type, LIR_Opr klass, CodeStub* stub) {
1510   append(new LIR_OpAllocArray(
1511                            klass,
1512                            len,
1513                            dst,
1514                            t1,
1515                            t2,
1516                            t3,
1517                            t4,
1518                            type,
1519                            stub));
1520 }
1521 
1522 void LIR_List::shift_left(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1523  append(new LIR_Op2(
1524                     lir_shl,
1525                     value,
1526                     count,
1527                     dst,
1528                     tmp));
1529 }
1530 
1531 void LIR_List::shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1532  append(new LIR_Op2(
1533                     lir_shr,
1534                     value,
1535                     count,
1536                     dst,
1537                     tmp));
1538 }
1539 
1540 
1541 void LIR_List::unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1542  append(new LIR_Op2(
1543                     lir_ushr,
1544                     value,
1545                     count,
1546                     dst,
1547                     tmp));
1548 }
1549 
1550 void LIR_List::fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less) {
1551   append(new LIR_Op2(is_unordered_less ? lir_ucmp_fd2i : lir_cmp_fd2i,
1552                      left,
1553                      right,
1554                      dst));
1555 }
1556 
1557 void LIR_List::lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info, CodeStub* throw_imse_stub) {
1558   append(new LIR_OpLock(
1559                     lir_lock,
1560                     hdr,
1561                     obj,
1562                     lock,
1563                     scratch,
1564                     stub,
1565                     info,
1566                     throw_imse_stub));
1567 }
1568 
1569 void LIR_List::unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub) {
1570   append(new LIR_OpLock(
1571                     lir_unlock,
1572                     hdr,
1573                     obj,
1574                     lock,
1575                     scratch,
1576                     stub,
1577                     NULL));
1578 }
1579 
1580 
1581 void check_LIR() {
1582   // cannot do the proper checking as PRODUCT and other modes return different results
1583   // guarantee(sizeof(LIR_Opr) == wordSize, "may not have a v-table");
1584 }
1585 
1586 
1587 
1588 void LIR_List::checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
1589                           LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
1590                           CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
1591                           ciMethod* profiled_method, int profiled_bci, bool is_null_free) {
1592   // If klass is non-nullable,  LIRGenerator::do_CheckCast has already performed null-check
1593   // on the object.
1594   bool need_null_check = !is_null_free;
1595   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_checkcast, result, object, klass,
1596                                            tmp1, tmp2, tmp3, fast_check, info_for_exception, info_for_patch, stub,
1597                                            need_null_check);
1598   if (profiled_method != NULL) {
1599     c->set_profiled_method(profiled_method);
1600     c->set_profiled_bci(profiled_bci);
1601     c->set_should_profile(true);
1602   }
1603   append(c);
1604 }
1605 
1606 void LIR_List::instanceof(LIR_Opr result, LIR_Opr object, ciKlass* klass, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check, CodeEmitInfo* info_for_patch, ciMethod* profiled_method, int profiled_bci) {
1607   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_instanceof, result, object, klass, tmp1, tmp2, tmp3, fast_check, NULL, info_for_patch, NULL);
1608   if (profiled_method != NULL) {
1609     c->set_profiled_method(profiled_method);
1610     c->set_profiled_bci(profiled_bci);
1611     c->set_should_profile(true);
1612   }
1613   append(c);
1614 }
1615 
1616 
1617 void LIR_List::store_check(LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3,
1618                            CodeEmitInfo* info_for_exception, ciMethod* profiled_method, int profiled_bci) {
1619   // FIXME -- if the types of the array and/or the object are known statically, we can avoid loading the klass
1620   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_store_check, object, array, tmp1, tmp2, tmp3, info_for_exception);
1621   if (profiled_method != NULL) {
1622     c->set_profiled_method(profiled_method);
1623     c->set_profiled_bci(profiled_bci);
1624     c->set_should_profile(true);
1625   }
1626   append(c);
1627 }
1628 
1629 void LIR_List::null_check(LIR_Opr opr, CodeEmitInfo* info, bool deoptimize_on_null) {
1630   if (deoptimize_on_null) {
1631     // Emit an explicit null check and deoptimize if opr is null
1632     CodeStub* deopt = new DeoptimizeStub(info, Deoptimization::Reason_null_check, Deoptimization::Action_none);
1633     cmp(lir_cond_equal, opr, LIR_OprFact::oopConst(NULL));
1634     branch(lir_cond_equal, deopt);
1635   } else {
1636     // Emit an implicit null check
1637     append(new LIR_Op1(lir_null_check, opr, info));
1638   }
1639 }
1640 
1641 void LIR_List::check_flattened_array(LIR_Opr array, LIR_Opr value, LIR_Opr tmp, CodeStub* stub) {
1642   LIR_OpFlattenedArrayCheck* c = new LIR_OpFlattenedArrayCheck(array, value, tmp, stub);
1643   append(c);
1644 }
1645 
1646 void LIR_List::check_null_free_array(LIR_Opr array, LIR_Opr tmp) {
1647   LIR_OpNullFreeArrayCheck* c = new LIR_OpNullFreeArrayCheck(array, tmp);
1648   append(c);
1649 }
1650 
1651 void LIR_List::substitutability_check(LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr equal_result, LIR_Opr not_equal_result,
1652                                       LIR_Opr tmp1, LIR_Opr tmp2,
1653                                       ciKlass* left_klass, ciKlass* right_klass, LIR_Opr left_klass_op, LIR_Opr right_klass_op,
1654                                       CodeEmitInfo* info, CodeStub* stub) {
1655   LIR_OpSubstitutabilityCheck* c = new LIR_OpSubstitutabilityCheck(result, left, right, equal_result, not_equal_result,
1656                                                                    tmp1, tmp2,
1657                                                                    left_klass, right_klass, left_klass_op, right_klass_op,
1658                                                                    info, stub);
1659   append(c);
1660 }
1661 
1662 void LIR_List::cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1663                         LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1664   append(new LIR_OpCompareAndSwap(lir_cas_long, addr, cmp_value, new_value, t1, t2, result));
1665 }
1666 
1667 void LIR_List::cas_obj(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1668                        LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1669   append(new LIR_OpCompareAndSwap(lir_cas_obj, addr, cmp_value, new_value, t1, t2, result));
1670 }
1671 
1672 void LIR_List::cas_int(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1673                        LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1674   append(new LIR_OpCompareAndSwap(lir_cas_int, addr, cmp_value, new_value, t1, t2, result));
1675 }
1676 
1677 
1678 #ifdef PRODUCT
1679 
1680 void print_LIR(BlockList* blocks) {
1681 }
1682 
1683 #else
1684 // LIR_Opr
1685 void LIR_Opr::print() const {
1686   print(tty);
1687 }
1688 
1689 void LIR_Opr::print(outputStream* out) const {
1690   if (is_illegal()) {
1691     return;
1692   }
1693 
1694   out->print("[");
1695   if (is_pointer()) {
1696     pointer()->print_value_on(out);
1697   } else if (is_single_stack()) {
1698     out->print("stack:%d", single_stack_ix());
1699   } else if (is_double_stack()) {
1700     out->print("dbl_stack:%d",double_stack_ix());
1701   } else if (is_virtual()) {
1702     out->print("R%d", vreg_number());
1703   } else if (is_single_cpu()) {
1704     out->print("%s", as_register()->name());
1705   } else if (is_double_cpu()) {
1706     out->print("%s", as_register_hi()->name());
1707     out->print("%s", as_register_lo()->name());
1708 #if defined(X86)
1709   } else if (is_single_xmm()) {
1710     out->print("%s", as_xmm_float_reg()->name());
1711   } else if (is_double_xmm()) {
1712     out->print("%s", as_xmm_double_reg()->name());
1713   } else if (is_single_fpu()) {
1714     out->print("fpu%d", fpu_regnr());
1715   } else if (is_double_fpu()) {
1716     out->print("fpu%d", fpu_regnrLo());
1717 #elif defined(AARCH64)
1718   } else if (is_single_fpu()) {
1719     out->print("fpu%d", fpu_regnr());
1720   } else if (is_double_fpu()) {
1721     out->print("fpu%d", fpu_regnrLo());
1722 #elif defined(ARM)
1723   } else if (is_single_fpu()) {
1724     out->print("s%d", fpu_regnr());
1725   } else if (is_double_fpu()) {
1726     out->print("d%d", fpu_regnrLo() >> 1);
1727 #else
1728   } else if (is_single_fpu()) {
1729     out->print("%s", as_float_reg()->name());
1730   } else if (is_double_fpu()) {
1731     out->print("%s", as_double_reg()->name());
1732 #endif
1733 
1734   } else if (is_illegal()) {
1735     out->print("-");
1736   } else {
1737     out->print("Unknown Operand");
1738   }
1739   if (!is_illegal()) {
1740     out->print("|%c", type_char());
1741   }
1742   if (is_register() && is_last_use()) {
1743     out->print("(last_use)");
1744   }
1745   out->print("]");
1746 }
1747 
1748 
1749 // LIR_Address
1750 void LIR_Const::print_value_on(outputStream* out) const {
1751   switch (type()) {
1752     case T_ADDRESS:out->print("address:%d",as_jint());          break;
1753     case T_INT:    out->print("int:%d",   as_jint());           break;
1754     case T_LONG:   out->print("lng:" JLONG_FORMAT, as_jlong()); break;
1755     case T_FLOAT:  out->print("flt:%f",   as_jfloat());         break;
1756     case T_DOUBLE: out->print("dbl:%f",   as_jdouble());        break;
1757     case T_OBJECT: out->print("obj:" INTPTR_FORMAT, p2i(as_jobject()));        break;
1758     case T_METADATA: out->print("metadata:" INTPTR_FORMAT, p2i(as_metadata()));break;
1759     default:       out->print("%3d:" UINT64_FORMAT_X, type(), (uint64_t)as_jlong()); break;
1760   }
1761 }
1762 
1763 // LIR_Address
1764 void LIR_Address::print_value_on(outputStream* out) const {
1765   out->print("Base:"); _base->print(out);
1766   if (!_index->is_illegal()) {
1767     out->print(" Index:"); _index->print(out);
1768     switch (scale()) {
1769     case times_1: break;
1770     case times_2: out->print(" * 2"); break;
1771     case times_4: out->print(" * 4"); break;
1772     case times_8: out->print(" * 8"); break;
1773     }
1774   }
1775   out->print(" Disp: " INTX_FORMAT, _disp);
1776 }
1777 
1778 // debug output of block header without InstructionPrinter
1779 //       (because phi functions are not necessary for LIR)
1780 static void print_block(BlockBegin* x) {
1781   // print block id
1782   BlockEnd* end = x->end();
1783   tty->print("B%d ", x->block_id());
1784 
1785   // print flags
1786   if (x->is_set(BlockBegin::std_entry_flag))               tty->print("std ");
1787   if (x->is_set(BlockBegin::osr_entry_flag))               tty->print("osr ");
1788   if (x->is_set(BlockBegin::exception_entry_flag))         tty->print("ex ");
1789   if (x->is_set(BlockBegin::subroutine_entry_flag))        tty->print("jsr ");
1790   if (x->is_set(BlockBegin::backward_branch_target_flag))  tty->print("bb ");
1791   if (x->is_set(BlockBegin::linear_scan_loop_header_flag)) tty->print("lh ");
1792   if (x->is_set(BlockBegin::linear_scan_loop_end_flag))    tty->print("le ");
1793 
1794   // print block bci range
1795   tty->print("[%d, %d] ", x->bci(), (end == NULL ? -1 : end->printable_bci()));
1796 
1797   // print predecessors and successors
1798   if (x->number_of_preds() > 0) {
1799     tty->print("preds: ");
1800     for (int i = 0; i < x->number_of_preds(); i ++) {
1801       tty->print("B%d ", x->pred_at(i)->block_id());
1802     }
1803   }
1804 
1805   if (end != NULL && x->number_of_sux() > 0) {
1806     tty->print("sux: ");
1807     for (int i = 0; i < x->number_of_sux(); i ++) {
1808       tty->print("B%d ", x->sux_at(i)->block_id());
1809     }
1810   }
1811 
1812   // print exception handlers
1813   if (x->number_of_exception_handlers() > 0) {
1814     tty->print("xhandler: ");
1815     for (int i = 0; i < x->number_of_exception_handlers();  i++) {
1816       tty->print("B%d ", x->exception_handler_at(i)->block_id());
1817     }
1818   }
1819 
1820   tty->cr();
1821 }
1822 
1823 void print_LIR(BlockList* blocks) {
1824   tty->print_cr("LIR:");
1825   int i;
1826   for (i = 0; i < blocks->length(); i++) {
1827     BlockBegin* bb = blocks->at(i);
1828     print_block(bb);
1829     tty->print("__id_Instruction___________________________________________"); tty->cr();
1830     bb->lir()->print_instructions();
1831   }
1832 }
1833 
1834 void LIR_List::print_instructions() {
1835   for (int i = 0; i < _operations.length(); i++) {
1836     _operations.at(i)->print(); tty->cr();
1837   }
1838   tty->cr();
1839 }
1840 
1841 // LIR_Ops printing routines
1842 // LIR_Op
1843 void LIR_Op::print_on(outputStream* out) const {
1844   if (id() != -1 || PrintCFGToFile) {
1845     out->print("%4d ", id());
1846   } else {
1847     out->print("     ");
1848   }
1849   out->print("%s ", name());
1850   print_instr(out);
1851   if (info() != NULL) out->print(" [bci:%d]", info()->stack()->bci());
1852 #ifdef ASSERT
1853   if (Verbose && _file != NULL) {
1854     out->print(" (%s:%d)", _file, _line);
1855   }
1856 #endif
1857 }
1858 
1859 const char * LIR_Op::name() const {
1860   const char* s = NULL;
1861   switch(code()) {
1862      // LIR_Op0
1863      case lir_membar:                s = "membar";        break;
1864      case lir_membar_acquire:        s = "membar_acquire"; break;
1865      case lir_membar_release:        s = "membar_release"; break;
1866      case lir_membar_loadload:       s = "membar_loadload";   break;
1867      case lir_membar_storestore:     s = "membar_storestore"; break;
1868      case lir_membar_loadstore:      s = "membar_loadstore";  break;
1869      case lir_membar_storeload:      s = "membar_storeload";  break;
1870      case lir_label:                 s = "label";         break;
1871      case lir_nop:                   s = "nop";           break;
1872      case lir_on_spin_wait:          s = "on_spin_wait";  break;
1873      case lir_std_entry:             s = "std_entry";     break;
1874      case lir_osr_entry:             s = "osr_entry";     break;
1875      case lir_fpop_raw:              s = "fpop_raw";      break;
1876      case lir_breakpoint:            s = "breakpoint";    break;
1877      case lir_get_thread:            s = "get_thread";    break;
1878      case lir_check_orig_pc:         s = "check_orig_pc"; break;
1879      // LIR_Op1
1880      case lir_fxch:                  s = "fxch";          break;
1881      case lir_fld:                   s = "fld";           break;
1882      case lir_push:                  s = "push";          break;
1883      case lir_pop:                   s = "pop";           break;
1884      case lir_null_check:            s = "null_check";    break;
1885      case lir_return:                s = "return";        break;
1886      case lir_safepoint:             s = "safepoint";     break;
1887      case lir_leal:                  s = "leal";          break;
1888      case lir_branch:                s = "branch";        break;
1889      case lir_cond_float_branch:     s = "flt_cond_br";   break;
1890      case lir_move:                  s = "move";          break;
1891      case lir_roundfp:               s = "roundfp";       break;
1892      case lir_rtcall:                s = "rtcall";        break;
1893      case lir_throw:                 s = "throw";         break;
1894      case lir_unwind:                s = "unwind";        break;
1895      case lir_convert:               s = "convert";       break;
1896      case lir_alloc_object:          s = "alloc_obj";     break;
1897      case lir_monaddr:               s = "mon_addr";      break;
1898      // LIR_Op2
1899      case lir_cmp:                   s = "cmp";           break;
1900      case lir_cmp_l2i:               s = "cmp_l2i";       break;
1901      case lir_ucmp_fd2i:             s = "ucomp_fd2i";    break;
1902      case lir_cmp_fd2i:              s = "comp_fd2i";     break;
1903      case lir_add:                   s = "add";           break;
1904      case lir_sub:                   s = "sub";           break;
1905      case lir_mul:                   s = "mul";           break;
1906      case lir_div:                   s = "div";           break;
1907      case lir_rem:                   s = "rem";           break;
1908      case lir_abs:                   s = "abs";           break;
1909      case lir_neg:                   s = "neg";           break;
1910      case lir_sqrt:                  s = "sqrt";          break;
1911      case lir_logic_and:             s = "logic_and";     break;
1912      case lir_logic_or:              s = "logic_or";      break;
1913      case lir_logic_xor:             s = "logic_xor";     break;
1914      case lir_shl:                   s = "shift_left";    break;
1915      case lir_shr:                   s = "shift_right";   break;
1916      case lir_ushr:                  s = "ushift_right";  break;
1917      case lir_alloc_array:           s = "alloc_array";   break;
1918      case lir_xadd:                  s = "xadd";          break;
1919      case lir_xchg:                  s = "xchg";          break;
1920      // LIR_Op3
1921      case lir_idiv:                  s = "idiv";          break;
1922      case lir_irem:                  s = "irem";          break;
1923      case lir_fmad:                  s = "fmad";          break;
1924      case lir_fmaf:                  s = "fmaf";          break;
1925      // LIR_Op4
1926      case lir_cmove:                 s = "cmove";         break;
1927      // LIR_OpJavaCall
1928      case lir_static_call:           s = "static";        break;
1929      case lir_optvirtual_call:       s = "optvirtual";    break;
1930      case lir_icvirtual_call:        s = "icvirtual";     break;
1931      case lir_dynamic_call:          s = "dynamic";       break;
1932      // LIR_OpArrayCopy
1933      case lir_arraycopy:             s = "arraycopy";     break;
1934      // LIR_OpUpdateCRC32
1935      case lir_updatecrc32:           s = "updatecrc32";   break;
1936      // LIR_OpLock
1937      case lir_lock:                  s = "lock";          break;
1938      case lir_unlock:                s = "unlock";        break;
1939      // LIR_OpDelay
1940      case lir_delay_slot:            s = "delay";         break;
1941      // LIR_OpTypeCheck
1942      case lir_instanceof:            s = "instanceof";    break;
1943      case lir_checkcast:             s = "checkcast";     break;
1944      case lir_store_check:           s = "store_check";   break;
1945      // LIR_OpFlattenedArrayCheck
1946      case lir_flattened_array_check: s = "flattened_array_check"; break;
1947      // LIR_OpNullFreeArrayCheck
1948      case lir_null_free_array_check: s = "null_free_array_check"; break;
1949      // LIR_OpSubstitutabilityCheck
1950      case lir_substitutability_check: s = "substitutability_check"; break;
1951      // LIR_OpCompareAndSwap
1952      case lir_cas_long:              s = "cas_long";      break;
1953      case lir_cas_obj:               s = "cas_obj";      break;
1954      case lir_cas_int:               s = "cas_int";      break;
1955      // LIR_OpProfileCall
1956      case lir_profile_call:          s = "profile_call";  break;
1957      // LIR_OpProfileType
1958      case lir_profile_type:          s = "profile_type";  break;
1959      // LIR_OpProfileInlineType
1960      case lir_profile_inline_type:   s = "profile_inline_type"; break;
1961      // LIR_OpAssert
1962 #ifdef ASSERT
1963      case lir_assert:                s = "assert";        break;
1964 #endif
1965      case lir_none:                  ShouldNotReachHere();break;
1966     default:                         s = "illegal_op";    break;
1967   }
1968   return s;
1969 }
1970 
1971 // LIR_OpJavaCall
1972 void LIR_OpJavaCall::print_instr(outputStream* out) const {
1973   out->print("call: ");
1974   out->print("[addr: " INTPTR_FORMAT "]", p2i(address()));
1975   if (receiver()->is_valid()) {
1976     out->print(" [recv: ");   receiver()->print(out);   out->print("]");
1977   }
1978   if (result_opr()->is_valid()) {
1979     out->print(" [result: "); result_opr()->print(out); out->print("]");
1980   }
1981 }
1982 
1983 // LIR_OpLabel
1984 void LIR_OpLabel::print_instr(outputStream* out) const {
1985   out->print("[label:" INTPTR_FORMAT "]", p2i(_label));
1986 }
1987 
1988 // LIR_OpArrayCopy
1989 void LIR_OpArrayCopy::print_instr(outputStream* out) const {
1990   src()->print(out);     out->print(" ");
1991   src_pos()->print(out); out->print(" ");
1992   dst()->print(out);     out->print(" ");
1993   dst_pos()->print(out); out->print(" ");
1994   length()->print(out);  out->print(" ");
1995   tmp()->print(out);     out->print(" ");
1996 }
1997 
1998 // LIR_OpUpdateCRC32
1999 void LIR_OpUpdateCRC32::print_instr(outputStream* out) const {
2000   crc()->print(out);     out->print(" ");
2001   val()->print(out);     out->print(" ");
2002   result_opr()->print(out); out->print(" ");
2003 }
2004 
2005 // LIR_OpCompareAndSwap
2006 void LIR_OpCompareAndSwap::print_instr(outputStream* out) const {
2007   addr()->print(out);      out->print(" ");
2008   cmp_value()->print(out); out->print(" ");
2009   new_value()->print(out); out->print(" ");
2010   tmp1()->print(out);      out->print(" ");
2011   tmp2()->print(out);      out->print(" ");
2012 
2013 }
2014 
2015 // LIR_Op0
2016 void LIR_Op0::print_instr(outputStream* out) const {
2017   result_opr()->print(out);
2018 }
2019 
2020 // LIR_Op1
2021 const char * LIR_Op1::name() const {
2022   if (code() == lir_move) {
2023     switch (move_kind()) {
2024     case lir_move_normal:
2025       return "move";
2026     case lir_move_volatile:
2027       return "volatile_move";
2028     case lir_move_wide:
2029       return "wide_move";
2030     default:
2031       ShouldNotReachHere();
2032     return "illegal_op";
2033     }
2034   } else {
2035     return LIR_Op::name();
2036   }
2037 }
2038 
2039 
2040 void LIR_Op1::print_instr(outputStream* out) const {
2041   _opr->print(out);         out->print(" ");
2042   result_opr()->print(out); out->print(" ");
2043   print_patch_code(out, patch_code());
2044 }
2045 
2046 
2047 // LIR_Op1
2048 void LIR_OpRTCall::print_instr(outputStream* out) const {
2049   intx a = (intx)addr();
2050   out->print("%s", Runtime1::name_for_address(addr()));
2051   out->print(" ");
2052   tmp()->print(out);
2053 }
2054 
2055 void LIR_Op1::print_patch_code(outputStream* out, LIR_PatchCode code) {
2056   switch(code) {
2057     case lir_patch_none:                                 break;
2058     case lir_patch_low:    out->print("[patch_low]");    break;
2059     case lir_patch_high:   out->print("[patch_high]");   break;
2060     case lir_patch_normal: out->print("[patch_normal]"); break;
2061     default: ShouldNotReachHere();
2062   }
2063 }
2064 
2065 // LIR_OpBranch
2066 void LIR_OpBranch::print_instr(outputStream* out) const {
2067   print_condition(out, cond());             out->print(" ");
2068   in_opr1()->print(out); out->print(" ");
2069   in_opr2()->print(out); out->print(" ");
2070   if (block() != NULL) {
2071     out->print("[B%d] ", block()->block_id());
2072   } else if (stub() != NULL) {
2073     out->print("[");
2074     stub()->print_name(out);
2075     out->print(": " INTPTR_FORMAT "]", p2i(stub()));
2076     if (stub()->info() != NULL) out->print(" [bci:%d]", stub()->info()->stack()->bci());
2077   } else {
2078     out->print("[label:" INTPTR_FORMAT "] ", p2i(label()));
2079   }
2080   if (ublock() != NULL) {
2081     out->print("unordered: [B%d] ", ublock()->block_id());
2082   }
2083 }
2084 
2085 void LIR_Op::print_condition(outputStream* out, LIR_Condition cond) {
2086   switch(cond) {
2087     case lir_cond_equal:           out->print("[EQ]");      break;
2088     case lir_cond_notEqual:        out->print("[NE]");      break;
2089     case lir_cond_less:            out->print("[LT]");      break;
2090     case lir_cond_lessEqual:       out->print("[LE]");      break;
2091     case lir_cond_greaterEqual:    out->print("[GE]");      break;
2092     case lir_cond_greater:         out->print("[GT]");      break;
2093     case lir_cond_belowEqual:      out->print("[BE]");      break;
2094     case lir_cond_aboveEqual:      out->print("[AE]");      break;
2095     case lir_cond_always:          out->print("[AL]");      break;
2096     default:                       out->print("[%d]",cond); break;
2097   }
2098 }
2099 
2100 // LIR_OpConvert
2101 void LIR_OpConvert::print_instr(outputStream* out) const {
2102   print_bytecode(out, bytecode());
2103   in_opr()->print(out);                  out->print(" ");
2104   result_opr()->print(out);              out->print(" ");
2105 }
2106 
2107 void LIR_OpConvert::print_bytecode(outputStream* out, Bytecodes::Code code) {
2108   switch(code) {
2109     case Bytecodes::_d2f: out->print("[d2f] "); break;
2110     case Bytecodes::_d2i: out->print("[d2i] "); break;
2111     case Bytecodes::_d2l: out->print("[d2l] "); break;
2112     case Bytecodes::_f2d: out->print("[f2d] "); break;
2113     case Bytecodes::_f2i: out->print("[f2i] "); break;
2114     case Bytecodes::_f2l: out->print("[f2l] "); break;
2115     case Bytecodes::_i2b: out->print("[i2b] "); break;
2116     case Bytecodes::_i2c: out->print("[i2c] "); break;
2117     case Bytecodes::_i2d: out->print("[i2d] "); break;
2118     case Bytecodes::_i2f: out->print("[i2f] "); break;
2119     case Bytecodes::_i2l: out->print("[i2l] "); break;
2120     case Bytecodes::_i2s: out->print("[i2s] "); break;
2121     case Bytecodes::_l2i: out->print("[l2i] "); break;
2122     case Bytecodes::_l2f: out->print("[l2f] "); break;
2123     case Bytecodes::_l2d: out->print("[l2d] "); break;
2124     default:
2125       out->print("[?%d]",code);
2126     break;
2127   }
2128 }
2129 
2130 void LIR_OpAllocObj::print_instr(outputStream* out) const {
2131   klass()->print(out);                      out->print(" ");
2132   obj()->print(out);                        out->print(" ");
2133   tmp1()->print(out);                       out->print(" ");
2134   tmp2()->print(out);                       out->print(" ");
2135   tmp3()->print(out);                       out->print(" ");
2136   tmp4()->print(out);                       out->print(" ");
2137   out->print("[hdr:%d]", header_size()); out->print(" ");
2138   out->print("[obj:%d]", object_size()); out->print(" ");
2139   out->print("[lbl:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2140 }
2141 
2142 void LIR_OpRoundFP::print_instr(outputStream* out) const {
2143   _opr->print(out);         out->print(" ");
2144   tmp()->print(out);        out->print(" ");
2145   result_opr()->print(out); out->print(" ");
2146 }
2147 
2148 // LIR_Op2
2149 void LIR_Op2::print_instr(outputStream* out) const {
2150   if (code() == lir_cmp || code() == lir_branch || code() == lir_cond_float_branch) {
2151     print_condition(out, condition());         out->print(" ");
2152   }
2153   in_opr1()->print(out);    out->print(" ");
2154   in_opr2()->print(out);    out->print(" ");
2155   if (tmp1_opr()->is_valid()) { tmp1_opr()->print(out);    out->print(" "); }
2156   if (tmp2_opr()->is_valid()) { tmp2_opr()->print(out);    out->print(" "); }
2157   if (tmp3_opr()->is_valid()) { tmp3_opr()->print(out);    out->print(" "); }
2158   if (tmp4_opr()->is_valid()) { tmp4_opr()->print(out);    out->print(" "); }
2159   if (tmp5_opr()->is_valid()) { tmp5_opr()->print(out);    out->print(" "); }
2160   result_opr()->print(out);
2161 }
2162 
2163 void LIR_OpAllocArray::print_instr(outputStream* out) const {
2164   klass()->print(out);                   out->print(" ");
2165   len()->print(out);                     out->print(" ");
2166   obj()->print(out);                     out->print(" ");
2167   tmp1()->print(out);                    out->print(" ");
2168   tmp2()->print(out);                    out->print(" ");
2169   tmp3()->print(out);                    out->print(" ");
2170   tmp4()->print(out);                    out->print(" ");
2171   out->print("[type:0x%x]", type());     out->print(" ");
2172   out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2173 }
2174 
2175 
2176 void LIR_OpTypeCheck::print_instr(outputStream* out) const {
2177   object()->print(out);                  out->print(" ");
2178   if (code() == lir_store_check) {
2179     array()->print(out);                 out->print(" ");
2180   }
2181   if (code() != lir_store_check) {
2182     klass()->print_name_on(out);         out->print(" ");
2183     if (fast_check())                 out->print("fast_check ");
2184   }
2185   tmp1()->print(out);                    out->print(" ");
2186   tmp2()->print(out);                    out->print(" ");
2187   tmp3()->print(out);                    out->print(" ");
2188   result_opr()->print(out);              out->print(" ");
2189   if (info_for_exception() != NULL) out->print(" [bci:%d]", info_for_exception()->stack()->bci());
2190 }
2191 
2192 void LIR_OpFlattenedArrayCheck::print_instr(outputStream* out) const {
2193   array()->print(out);                   out->print(" ");
2194   value()->print(out);                   out->print(" ");
2195   tmp()->print(out);                     out->print(" ");
2196   if (stub() != NULL) {
2197     out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2198   }
2199 }
2200 
2201 void LIR_OpNullFreeArrayCheck::print_instr(outputStream* out) const {
2202   array()->print(out);                   out->print(" ");
2203   tmp()->print(out);                     out->print(" ");
2204 }
2205 
2206 void LIR_OpSubstitutabilityCheck::print_instr(outputStream* out) const {
2207   result_opr()->print(out);              out->print(" ");
2208   left()->print(out);                    out->print(" ");
2209   right()->print(out);                   out->print(" ");
2210   equal_result()->print(out);            out->print(" ");
2211   not_equal_result()->print(out);        out->print(" ");
2212   tmp1()->print(out);                    out->print(" ");
2213   tmp2()->print(out);                    out->print(" ");
2214   if (left_klass() == NULL) {
2215     out->print("unknown ");
2216   } else {
2217     left_klass()->print(out);            out->print(" ");
2218   }
2219   if (right_klass() == NULL) {
2220     out->print("unknown ");
2221   } else {
2222     right_klass()->print(out);           out->print(" ");
2223   }
2224   left_klass_op()->print(out);           out->print(" ");
2225   right_klass_op()->print(out);          out->print(" ");
2226   if (stub() != NULL) {
2227     out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2228   }
2229 }
2230 
2231 // LIR_Op3
2232 void LIR_Op3::print_instr(outputStream* out) const {
2233   in_opr1()->print(out);    out->print(" ");
2234   in_opr2()->print(out);    out->print(" ");
2235   in_opr3()->print(out);    out->print(" ");
2236   result_opr()->print(out);
2237 }
2238 
2239 // LIR_Op4
2240 void LIR_Op4::print_instr(outputStream* out) const {
2241   print_condition(out, condition()); out->print(" ");
2242   in_opr1()->print(out);             out->print(" ");
2243   in_opr2()->print(out);             out->print(" ");
2244   in_opr3()->print(out);             out->print(" ");
2245   in_opr4()->print(out);             out->print(" ");
2246   result_opr()->print(out);
2247 }
2248 
2249 void LIR_OpLock::print_instr(outputStream* out) const {
2250   hdr_opr()->print(out);   out->print(" ");
2251   obj_opr()->print(out);   out->print(" ");
2252   lock_opr()->print(out);  out->print(" ");
2253   if (_scratch->is_valid()) {
2254     _scratch->print(out);  out->print(" ");
2255   }
2256   out->print("[lbl:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2257 }
2258 
2259 void LIR_OpLoadKlass::print_instr(outputStream* out) const {
2260   obj()->print(out);        out->print(" ");
2261   result_opr()->print(out); out->print(" ");
2262 }
2263 
2264 #ifdef ASSERT
2265 void LIR_OpAssert::print_instr(outputStream* out) const {
2266   print_condition(out, condition()); out->print(" ");
2267   in_opr1()->print(out);             out->print(" ");
2268   in_opr2()->print(out);             out->print(", \"");
2269   out->print("%s", msg());          out->print("\"");
2270 }
2271 #endif
2272 
2273 
2274 void LIR_OpDelay::print_instr(outputStream* out) const {
2275   _op->print_on(out);
2276 }
2277 
2278 
2279 // LIR_OpProfileCall
2280 void LIR_OpProfileCall::print_instr(outputStream* out) const {
2281   profiled_method()->name()->print_symbol_on(out);
2282   out->print(".");
2283   profiled_method()->holder()->name()->print_symbol_on(out);
2284   out->print(" @ %d ", profiled_bci());
2285   mdo()->print(out);           out->print(" ");
2286   recv()->print(out);          out->print(" ");
2287   tmp1()->print(out);          out->print(" ");
2288 }
2289 
2290 // LIR_OpProfileType
2291 void LIR_OpProfileType::print_instr(outputStream* out) const {
2292   out->print("exact = ");
2293   if  (exact_klass() == NULL) {
2294     out->print("unknown");
2295   } else {
2296     exact_klass()->print_name_on(out);
2297   }
2298   out->print(" current = "); ciTypeEntries::print_ciklass(out, current_klass());
2299   out->print(" ");
2300   mdp()->print(out);          out->print(" ");
2301   obj()->print(out);          out->print(" ");
2302   tmp()->print(out);          out->print(" ");
2303 }
2304 
2305 // LIR_OpProfileInlineType
2306 void LIR_OpProfileInlineType::print_instr(outputStream* out) const {
2307   out->print(" flag = %x ", flag());
2308   mdp()->print(out);          out->print(" ");
2309   obj()->print(out);          out->print(" ");
2310   tmp()->print(out);          out->print(" ");
2311 }
2312 
2313 #endif // PRODUCT
2314 
2315 // Implementation of LIR_InsertionBuffer
2316 
2317 void LIR_InsertionBuffer::append(int index, LIR_Op* op) {
2318   assert(_index_and_count.length() % 2 == 0, "must have a count for each index");
2319 
2320   int i = number_of_insertion_points() - 1;
2321   if (i < 0 || index_at(i) < index) {
2322     append_new(index, 1);
2323   } else {
2324     assert(index_at(i) == index, "can append LIR_Ops in ascending order only");
2325     assert(count_at(i) > 0, "check");
2326     set_count_at(i, count_at(i) + 1);
2327   }
2328   _ops.push(op);
2329 
2330   DEBUG_ONLY(verify());
2331 }
2332 
2333 #ifdef ASSERT
2334 void LIR_InsertionBuffer::verify() {
2335   int sum = 0;
2336   int prev_idx = -1;
2337 
2338   for (int i = 0; i < number_of_insertion_points(); i++) {
2339     assert(prev_idx < index_at(i), "index must be ordered ascending");
2340     sum += count_at(i);
2341   }
2342   assert(sum == number_of_ops(), "wrong total sum");
2343 }
2344 #endif