< prev index next >

src/hotspot/share/c1/c1_LIR.cpp

Print this page

  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/ciInstance.hpp"
  32 #include "runtime/safepointMechanism.inline.hpp"
  33 #include "runtime/sharedRuntime.hpp"
  34 #include "runtime/vm_version.hpp"
  35 
  36 Register LIR_Opr::as_register() const {
  37   return FrameMap::cpu_rnr2reg(cpu_regnr());
  38 }
  39 
  40 Register LIR_Opr::as_register_lo() const {
  41   return FrameMap::cpu_rnr2reg(cpu_regnrLo());
  42 }
  43 
  44 Register LIR_Opr::as_register_hi() const {
  45   return FrameMap::cpu_rnr2reg(cpu_regnrHi());
  46 }
  47 
  48 LIR_Opr LIR_OprFact::illegalOpr = LIR_OprFact::illegal();
  49 LIR_Opr LIR_OprFact::nullOpr = LIR_Opr();
  50 

 270   assert(_ublock != nullptr, "must have old block");
 271   _ublock = b;
 272 }
 273 
 274 void LIR_OpBranch::negate_cond() {
 275   switch (cond()) {
 276     case lir_cond_equal:        set_cond(lir_cond_notEqual);     break;
 277     case lir_cond_notEqual:     set_cond(lir_cond_equal);        break;
 278     case lir_cond_less:         set_cond(lir_cond_greaterEqual); break;
 279     case lir_cond_lessEqual:    set_cond(lir_cond_greater);      break;
 280     case lir_cond_greaterEqual: set_cond(lir_cond_less);         break;
 281     case lir_cond_greater:      set_cond(lir_cond_lessEqual);    break;
 282     default: ShouldNotReachHere();
 283   }
 284 }
 285 
 286 
 287 LIR_OpTypeCheck::LIR_OpTypeCheck(LIR_Code code, LIR_Opr result, LIR_Opr object, ciKlass* klass,
 288                                  LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3,
 289                                  bool fast_check, CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch,
 290                                  CodeStub* stub)
 291 
 292   : LIR_Op(code, result, nullptr)
 293   , _object(object)
 294   , _array(LIR_OprFact::illegalOpr)
 295   , _klass(klass)
 296   , _tmp1(tmp1)
 297   , _tmp2(tmp2)
 298   , _tmp3(tmp3)
 299   , _info_for_patch(info_for_patch)
 300   , _info_for_exception(info_for_exception)
 301   , _stub(stub)
 302   , _profiled_method(nullptr)
 303   , _profiled_bci(-1)
 304   , _should_profile(false)
 305   , _fast_check(fast_check)

 306 {
 307   if (code == lir_checkcast) {
 308     assert(info_for_exception != nullptr, "checkcast throws exceptions");
 309   } else if (code == lir_instanceof) {
 310     assert(info_for_exception == nullptr, "instanceof throws no exceptions");
 311   } else {
 312     ShouldNotReachHere();
 313   }
 314 }
 315 
 316 
 317 
 318 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)
 319   : LIR_Op(code, LIR_OprFact::illegalOpr, nullptr)
 320   , _object(object)
 321   , _array(array)
 322   , _klass(nullptr)
 323   , _tmp1(tmp1)
 324   , _tmp2(tmp2)
 325   , _tmp3(tmp3)
 326   , _info_for_patch(nullptr)
 327   , _info_for_exception(info_for_exception)
 328   , _stub(nullptr)
 329   , _profiled_method(nullptr)
 330   , _profiled_bci(-1)
 331   , _should_profile(false)
 332   , _fast_check(false)

 333 {
 334   if (code == lir_store_check) {
 335     _stub = new ArrayStoreExceptionStub(object, info_for_exception);
 336     assert(info_for_exception != nullptr, "store_check throws exceptions");
 337   } else {
 338     ShouldNotReachHere();
 339   }
 340 }
 341 































 342 
 343 LIR_OpArrayCopy::LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length,
 344                                  LIR_Opr tmp, ciArrayKlass* expected_type, int flags, CodeEmitInfo* info)
 345   : LIR_Op(lir_arraycopy, LIR_OprFact::illegalOpr, info)
 346   , _src(src)
 347   , _src_pos(src_pos)
 348   , _dst(dst)
 349   , _dst_pos(dst_pos)
 350   , _length(length)
 351   , _tmp(tmp)
 352   , _expected_type(expected_type)
 353   , _flags(flags) {
 354 #if defined(X86) || defined(AARCH64) || defined(S390) || defined(RISCV) || defined(PPC64)
 355   if (expected_type != nullptr && flags == 0) {
 356     _stub = nullptr;
 357   } else {
 358     _stub = new ArrayCopyStub(this);
 359   }
 360 #else
 361   _stub = new ArrayCopyStub(this);

 396 // The virtual call for each instruction type is replaced by a big
 397 // switch that adds the operands for each instruction
 398 
 399 void LIR_OpVisitState::visit(LIR_Op* op) {
 400   // copy information from the LIR_Op
 401   reset();
 402   set_op(op);
 403 
 404   switch (op->code()) {
 405 
 406 // LIR_Op0
 407     case lir_fpop_raw:                 // result and info always invalid
 408     case lir_breakpoint:               // result and info always invalid
 409     case lir_membar:                   // result and info always invalid
 410     case lir_membar_acquire:           // result and info always invalid
 411     case lir_membar_release:           // result and info always invalid
 412     case lir_membar_loadload:          // result and info always invalid
 413     case lir_membar_storestore:        // result and info always invalid
 414     case lir_membar_loadstore:         // result and info always invalid
 415     case lir_membar_storeload:         // result and info always invalid

 416     case lir_on_spin_wait:
 417     {
 418       assert(op->as_Op0() != nullptr, "must be");
 419       assert(op->_info == nullptr, "info not used by this instruction");
 420       assert(op->_result->is_illegal(), "not used");
 421       break;
 422     }
 423 
 424     case lir_nop:                      // may have info, result always invalid
 425     case lir_std_entry:                // may have result, info always invalid
 426     case lir_osr_entry:                // may have result, info always invalid
 427     case lir_get_thread:               // may have result, info always invalid
 428     {
 429       assert(op->as_Op0() != nullptr, "must be");
 430       if (op->_info != nullptr)           do_info(op->_info);
 431       if (op->_result->is_valid())     do_output(op->_result);
 432       break;
 433     }
 434 
 435 

 792 
 793 
 794 // LIR_OpLock
 795     case lir_lock:
 796     case lir_unlock: {
 797       assert(op->as_OpLock() != nullptr, "must be");
 798       LIR_OpLock* opLock = (LIR_OpLock*)op;
 799 
 800       if (opLock->_info)                          do_info(opLock->_info);
 801 
 802       // TODO: check if these operands really have to be temp
 803       // (or if input is sufficient). This may have influence on the oop map!
 804       assert(opLock->_lock->is_valid(), "used");  do_temp(opLock->_lock);
 805       assert(opLock->_hdr->is_valid(),  "used");  do_temp(opLock->_hdr);
 806       assert(opLock->_obj->is_valid(),  "used");  do_temp(opLock->_obj);
 807 
 808       if (opLock->_scratch->is_valid())           do_temp(opLock->_scratch);
 809       assert(opLock->_result->is_illegal(), "unused");
 810 
 811       do_stub(opLock->_stub);

 812 
 813       break;
 814     }
 815 
 816 
 817 // LIR_OpDelay
 818     case lir_delay_slot: {
 819       assert(op->as_OpDelay() != nullptr, "must be");
 820       LIR_OpDelay* opDelay = (LIR_OpDelay*)op;
 821 
 822       visit(opDelay->delay_op());
 823       break;
 824     }
 825 
 826 // LIR_OpTypeCheck
 827     case lir_instanceof:
 828     case lir_checkcast:
 829     case lir_store_check: {
 830       assert(op->as_OpTypeCheck() != nullptr, "must be");
 831       LIR_OpTypeCheck* opTypeCheck = (LIR_OpTypeCheck*)op;
 832 
 833       if (opTypeCheck->_info_for_exception)       do_info(opTypeCheck->_info_for_exception);
 834       if (opTypeCheck->_info_for_patch)           do_info(opTypeCheck->_info_for_patch);
 835       if (opTypeCheck->_object->is_valid())       do_input(opTypeCheck->_object);
 836       if (op->code() == lir_store_check && opTypeCheck->_object->is_valid()) {
 837         do_temp(opTypeCheck->_object);
 838       }
 839       if (opTypeCheck->_array->is_valid())        do_input(opTypeCheck->_array);
 840       if (opTypeCheck->_tmp1->is_valid())         do_temp(opTypeCheck->_tmp1);
 841       if (opTypeCheck->_tmp2->is_valid())         do_temp(opTypeCheck->_tmp2);
 842       if (opTypeCheck->_tmp3->is_valid())         do_temp(opTypeCheck->_tmp3);
 843       if (opTypeCheck->_result->is_valid())       do_output(opTypeCheck->_result);
 844       if (opTypeCheck->_stub != nullptr)          do_stub(opTypeCheck->_stub);
 845       break;
 846     }
 847 















































 848 // LIR_OpCompareAndSwap
 849     case lir_cas_long:
 850     case lir_cas_obj:
 851     case lir_cas_int: {
 852       assert(op->as_OpCompareAndSwap() != nullptr, "must be");
 853       LIR_OpCompareAndSwap* opCmpAndSwap = (LIR_OpCompareAndSwap*)op;
 854 
 855       if (opCmpAndSwap->_info)                              do_info(opCmpAndSwap->_info);
 856       assert(opCmpAndSwap->_addr->is_valid(), "used");      do_input(opCmpAndSwap->_addr);
 857                                                             do_temp(opCmpAndSwap->_addr);
 858       assert(opCmpAndSwap->_cmp_value->is_valid(), "used"); do_input(opCmpAndSwap->_cmp_value);
 859                                                             do_temp(opCmpAndSwap->_cmp_value);
 860       assert(opCmpAndSwap->_new_value->is_valid(), "used"); do_input(opCmpAndSwap->_new_value);
 861                                                             do_temp(opCmpAndSwap->_new_value);
 862       if (opCmpAndSwap->_tmp1->is_valid())                  do_temp(opCmpAndSwap->_tmp1);
 863       if (opCmpAndSwap->_tmp2->is_valid())                  do_temp(opCmpAndSwap->_tmp2);
 864       if (opCmpAndSwap->_result->is_valid())                do_output(opCmpAndSwap->_result);
 865 
 866       break;
 867     }

 905     case lir_profile_call: {
 906       assert(op->as_OpProfileCall() != nullptr, "must be");
 907       LIR_OpProfileCall* opProfileCall = (LIR_OpProfileCall*)op;
 908 
 909       if (opProfileCall->_recv->is_valid())              do_temp(opProfileCall->_recv);
 910       assert(opProfileCall->_mdo->is_valid(), "used");   do_temp(opProfileCall->_mdo);
 911       assert(opProfileCall->_tmp1->is_valid(), "used");  do_temp(opProfileCall->_tmp1);
 912       break;
 913     }
 914 
 915 // LIR_OpProfileType:
 916     case lir_profile_type: {
 917       assert(op->as_OpProfileType() != nullptr, "must be");
 918       LIR_OpProfileType* opProfileType = (LIR_OpProfileType*)op;
 919 
 920       do_input(opProfileType->_mdp); do_temp(opProfileType->_mdp);
 921       do_input(opProfileType->_obj);
 922       do_temp(opProfileType->_tmp);
 923       break;
 924     }
 925   default:











 926     op->visit(this);
 927   }
 928 }
 929 
 930 void LIR_Op::visit(LIR_OpVisitState* state) {
 931   ShouldNotReachHere();
 932 }
 933 
 934 void LIR_OpVisitState::do_stub(CodeStub* stub) {
 935   if (stub != nullptr) {
 936     stub->visit(this);
 937   }
 938 }
 939 
 940 XHandlers* LIR_OpVisitState::all_xhandler() {
 941   XHandlers* result = nullptr;
 942 
 943   int i;
 944   for (i = 0; i < info_count(); i++) {
 945     if (info_at(i)->exception_handlers() != nullptr) {

 978          !has_slow_case();
 979 }
 980 #endif
 981 
 982 // LIR_OpReturn
 983 LIR_OpReturn::LIR_OpReturn(LIR_Opr opr) :
 984     LIR_Op1(lir_return, opr, (CodeEmitInfo*)nullptr /* info */),
 985     _stub(nullptr) {
 986   if (VM_Version::supports_stack_watermark_barrier()) {
 987     _stub = new C1SafepointPollStub();
 988   }
 989 }
 990 
 991 //---------------------------------------------------
 992 
 993 
 994 void LIR_OpJavaCall::emit_code(LIR_Assembler* masm) {
 995   masm->emit_call(this);
 996 }
 997 




























 998 void LIR_OpRTCall::emit_code(LIR_Assembler* masm) {
 999   masm->emit_rtcall(this);
1000 }
1001 
1002 void LIR_OpLabel::emit_code(LIR_Assembler* masm) {
1003   masm->emit_opLabel(this);
1004 }
1005 
1006 void LIR_OpArrayCopy::emit_code(LIR_Assembler* masm) {
1007   masm->emit_arraycopy(this);
1008   ArrayCopyStub* code_stub = stub();
1009   if (code_stub != nullptr) {
1010     masm->append_code_stub(code_stub);
1011   }
1012 }
1013 
1014 void LIR_OpUpdateCRC32::emit_code(LIR_Assembler* masm) {
1015   masm->emit_updatecrc32(this);
1016 }
1017 

1041     masm->append_code_stub(stub());
1042   }
1043 }
1044 
1045 void LIR_Op2::emit_code(LIR_Assembler* masm) {
1046   masm->emit_op2(this);
1047 }
1048 
1049 void LIR_OpAllocArray::emit_code(LIR_Assembler* masm) {
1050   masm->emit_alloc_array(this);
1051   masm->append_code_stub(stub());
1052 }
1053 
1054 void LIR_OpTypeCheck::emit_code(LIR_Assembler* masm) {
1055   masm->emit_opTypeCheck(this);
1056   if (stub()) {
1057     masm->append_code_stub(stub());
1058   }
1059 }
1060 


















1061 void LIR_OpCompareAndSwap::emit_code(LIR_Assembler* masm) {
1062   masm->emit_compare_and_swap(this);
1063 }
1064 
1065 void LIR_Op3::emit_code(LIR_Assembler* masm) {
1066   masm->emit_op3(this);
1067 }
1068 
1069 void LIR_Op4::emit_code(LIR_Assembler* masm) {
1070   masm->emit_op4(this);
1071 }
1072 
1073 void LIR_OpLock::emit_code(LIR_Assembler* masm) {
1074   masm->emit_lock(this);
1075   if (stub()) {
1076     masm->append_code_stub(stub());
1077   }



1078 }
1079 
1080 void LIR_OpLoadKlass::emit_code(LIR_Assembler* masm) {
1081   masm->emit_load_klass(this);
1082 }
1083 
1084 #ifdef ASSERT
1085 void LIR_OpAssert::emit_code(LIR_Assembler* masm) {
1086   masm->emit_assert(this);
1087 }
1088 #endif
1089 
1090 void LIR_OpDelay::emit_code(LIR_Assembler* masm) {
1091   masm->emit_delay(this);
1092 }
1093 
1094 void LIR_OpProfileCall::emit_code(LIR_Assembler* masm) {
1095   masm->emit_profile_call(this);
1096 }
1097 
1098 void LIR_OpProfileType::emit_code(LIR_Assembler* masm) {
1099   masm->emit_profile_type(this);
1100 }
1101 




1102 // LIR_List
1103 LIR_List::LIR_List(Compilation* compilation, BlockBegin* block)
1104   : _operations(8)
1105   , _compilation(compilation)
1106 #ifndef PRODUCT
1107   , _block(block)
1108 #endif
1109 #ifdef ASSERT
1110   , _file(nullptr)
1111   , _line(0)
1112 #endif
1113 #ifdef RISCV
1114   , _cmp_opr1(LIR_OprFact::illegalOpr)
1115   , _cmp_opr2(LIR_OprFact::illegalOpr)
1116 #endif
1117 { }
1118 
1119 
1120 #ifdef ASSERT
1121 void LIR_List::set_file_and_line(const char * file, int line) {

1357                     reg,
1358                     LIR_OprFact::address(addr),
1359                     info));
1360 }
1361 
1362 void LIR_List::allocate_object(LIR_Opr dst, LIR_Opr t1, LIR_Opr t2, LIR_Opr t3, LIR_Opr t4,
1363                                int header_size, int object_size, LIR_Opr klass, bool init_check, CodeStub* stub) {
1364   append(new LIR_OpAllocObj(
1365                            klass,
1366                            dst,
1367                            t1,
1368                            t2,
1369                            t3,
1370                            t4,
1371                            header_size,
1372                            object_size,
1373                            init_check,
1374                            stub));
1375 }
1376 
1377 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, bool zero_array) {
1378   append(new LIR_OpAllocArray(
1379                            klass,
1380                            len,
1381                            dst,
1382                            t1,
1383                            t2,
1384                            t3,
1385                            t4,
1386                            type,
1387                            stub,
1388                            zero_array));

1389 }
1390 
1391 void LIR_List::shift_left(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1392  append(new LIR_Op2(
1393                     lir_shl,
1394                     value,
1395                     count,
1396                     dst,
1397                     tmp));
1398 }
1399 
1400 void LIR_List::shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1401  append(new LIR_Op2(
1402                     lir_shr,
1403                     value,
1404                     count,
1405                     dst,
1406                     tmp));
1407 }
1408 
1409 
1410 void LIR_List::unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1411  append(new LIR_Op2(
1412                     lir_ushr,
1413                     value,
1414                     count,
1415                     dst,
1416                     tmp));
1417 }
1418 
1419 void LIR_List::fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less) {
1420   append(new LIR_Op2(is_unordered_less ? lir_ucmp_fd2i : lir_cmp_fd2i,
1421                      left,
1422                      right,
1423                      dst));
1424 }
1425 
1426 void LIR_List::lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info) {
1427   append(new LIR_OpLock(
1428                     lir_lock,
1429                     hdr,
1430                     obj,
1431                     lock,
1432                     scratch,
1433                     stub,
1434                     info));

1435 }
1436 
1437 void LIR_List::unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub) {
1438   append(new LIR_OpLock(
1439                     lir_unlock,
1440                     hdr,
1441                     obj,
1442                     lock,
1443                     scratch,
1444                     stub,
1445                     nullptr));
1446 }
1447 
1448 
1449 void check_LIR() {
1450   // cannot do the proper checking as PRODUCT and other modes return different results
1451   // guarantee(sizeof(LIR_Opr) == wordSize, "may not have a v-table");
1452 }
1453 
1454 
1455 
1456 void LIR_List::checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
1457                           LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
1458                           CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
1459                           ciMethod* profiled_method, int profiled_bci) {



1460   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_checkcast, result, object, klass,
1461                                            tmp1, tmp2, tmp3, fast_check, info_for_exception, info_for_patch, stub);

1462   if (profiled_method != nullptr) {
1463     c->set_profiled_method(profiled_method);
1464     c->set_profiled_bci(profiled_bci);
1465     c->set_should_profile(true);
1466   }
1467   append(c);
1468 }
1469 
1470 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) {
1471   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_instanceof, result, object, klass, tmp1, tmp2, tmp3, fast_check, nullptr, info_for_patch, nullptr);
1472   if (profiled_method != nullptr) {
1473     c->set_profiled_method(profiled_method);
1474     c->set_profiled_bci(profiled_bci);
1475     c->set_should_profile(true);
1476   }
1477   append(c);
1478 }
1479 
1480 
1481 void LIR_List::store_check(LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3,
1482                            CodeEmitInfo* info_for_exception, ciMethod* profiled_method, int profiled_bci) {

1483   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_store_check, object, array, tmp1, tmp2, tmp3, info_for_exception);
1484   if (profiled_method != nullptr) {
1485     c->set_profiled_method(profiled_method);
1486     c->set_profiled_bci(profiled_bci);
1487     c->set_should_profile(true);
1488   }
1489   append(c);
1490 }
1491 
1492 void LIR_List::null_check(LIR_Opr opr, CodeEmitInfo* info, bool deoptimize_on_null) {
1493   if (deoptimize_on_null) {
1494     // Emit an explicit null check and deoptimize if opr is null
1495     CodeStub* deopt = new DeoptimizeStub(info, Deoptimization::Reason_null_check, Deoptimization::Action_none);
1496     cmp(lir_cond_equal, opr, LIR_OprFact::oopConst(nullptr));
1497     branch(lir_cond_equal, deopt);
1498   } else {
1499     // Emit an implicit null check
1500     append(new LIR_Op1(lir_null_check, opr, info));
1501   }
1502 }
1503 





















1504 void LIR_List::cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1505                         LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1506   append(new LIR_OpCompareAndSwap(lir_cas_long, addr, cmp_value, new_value, t1, t2, result));
1507 }
1508 
1509 void LIR_List::cas_obj(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1510                        LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1511   append(new LIR_OpCompareAndSwap(lir_cas_obj, addr, cmp_value, new_value, t1, t2, result));
1512 }
1513 
1514 void LIR_List::cas_int(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1515                        LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1516   append(new LIR_OpCompareAndSwap(lir_cas_int, addr, cmp_value, new_value, t1, t2, result));
1517 }
1518 
1519 
1520 #ifdef PRODUCT
1521 
1522 void print_LIR(BlockList* blocks) {
1523 }

1700 
1701 const char * LIR_Op::name() const {
1702   const char* s = nullptr;
1703   switch(code()) {
1704      // LIR_Op0
1705      case lir_membar:                s = "membar";        break;
1706      case lir_membar_acquire:        s = "membar_acquire"; break;
1707      case lir_membar_release:        s = "membar_release"; break;
1708      case lir_membar_loadload:       s = "membar_loadload";   break;
1709      case lir_membar_storestore:     s = "membar_storestore"; break;
1710      case lir_membar_loadstore:      s = "membar_loadstore";  break;
1711      case lir_membar_storeload:      s = "membar_storeload";  break;
1712      case lir_label:                 s = "label";         break;
1713      case lir_nop:                   s = "nop";           break;
1714      case lir_on_spin_wait:          s = "on_spin_wait";  break;
1715      case lir_std_entry:             s = "std_entry";     break;
1716      case lir_osr_entry:             s = "osr_entry";     break;
1717      case lir_fpop_raw:              s = "fpop_raw";      break;
1718      case lir_breakpoint:            s = "breakpoint";    break;
1719      case lir_get_thread:            s = "get_thread";    break;

1720      // LIR_Op1
1721      case lir_fxch:                  s = "fxch";          break;
1722      case lir_fld:                   s = "fld";           break;
1723      case lir_push:                  s = "push";          break;
1724      case lir_pop:                   s = "pop";           break;
1725      case lir_null_check:            s = "null_check";    break;
1726      case lir_return:                s = "return";        break;
1727      case lir_safepoint:             s = "safepoint";     break;
1728      case lir_leal:                  s = "leal";          break;
1729      case lir_branch:                s = "branch";        break;
1730      case lir_cond_float_branch:     s = "flt_cond_br";   break;
1731      case lir_move:                  s = "move";          break;
1732      case lir_roundfp:               s = "roundfp";       break;
1733      case lir_rtcall:                s = "rtcall";        break;
1734      case lir_throw:                 s = "throw";         break;
1735      case lir_unwind:                s = "unwind";        break;
1736      case lir_convert:               s = "convert";       break;
1737      case lir_alloc_object:          s = "alloc_obj";     break;
1738      case lir_monaddr:               s = "mon_addr";      break;
1739      // LIR_Op2

1768      // LIR_Op4
1769      case lir_cmove:                 s = "cmove";         break;
1770      // LIR_OpJavaCall
1771      case lir_static_call:           s = "static";        break;
1772      case lir_optvirtual_call:       s = "optvirtual";    break;
1773      case lir_icvirtual_call:        s = "icvirtual";     break;
1774      case lir_dynamic_call:          s = "dynamic";       break;
1775      // LIR_OpArrayCopy
1776      case lir_arraycopy:             s = "arraycopy";     break;
1777      // LIR_OpUpdateCRC32
1778      case lir_updatecrc32:           s = "updatecrc32";   break;
1779      // LIR_OpLock
1780      case lir_lock:                  s = "lock";          break;
1781      case lir_unlock:                s = "unlock";        break;
1782      // LIR_OpDelay
1783      case lir_delay_slot:            s = "delay";         break;
1784      // LIR_OpTypeCheck
1785      case lir_instanceof:            s = "instanceof";    break;
1786      case lir_checkcast:             s = "checkcast";     break;
1787      case lir_store_check:           s = "store_check";   break;






1788      // LIR_OpCompareAndSwap
1789      case lir_cas_long:              s = "cas_long";      break;
1790      case lir_cas_obj:               s = "cas_obj";      break;
1791      case lir_cas_int:               s = "cas_int";      break;
1792      // LIR_OpProfileCall
1793      case lir_profile_call:          s = "profile_call";  break;
1794      // LIR_OpProfileType
1795      case lir_profile_type:          s = "profile_type";  break;


1796      // LIR_OpAssert
1797 #ifdef ASSERT
1798      case lir_assert:                s = "assert";        break;
1799 #endif
1800      case lir_none:                  ShouldNotReachHere();break;
1801     default:                         s = "illegal_op";    break;
1802   }
1803   return s;
1804 }
1805 
1806 // LIR_OpJavaCall
1807 void LIR_OpJavaCall::print_instr(outputStream* out) const {
1808   out->print("call: ");
1809   out->print("[addr: " INTPTR_FORMAT "]", p2i(address()));
1810   if (receiver()->is_valid()) {
1811     out->print(" [recv: ");   receiver()->print(out);   out->print("]");
1812   }
1813   if (result_opr()->is_valid()) {
1814     out->print(" [result: "); result_opr()->print(out); out->print("]");
1815   }

2007   out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2008 }
2009 
2010 
2011 void LIR_OpTypeCheck::print_instr(outputStream* out) const {
2012   object()->print(out);                  out->print(" ");
2013   if (code() == lir_store_check) {
2014     array()->print(out);                 out->print(" ");
2015   }
2016   if (code() != lir_store_check) {
2017     klass()->print_name_on(out);         out->print(" ");
2018     if (fast_check())                 out->print("fast_check ");
2019   }
2020   tmp1()->print(out);                    out->print(" ");
2021   tmp2()->print(out);                    out->print(" ");
2022   tmp3()->print(out);                    out->print(" ");
2023   result_opr()->print(out);              out->print(" ");
2024   if (info_for_exception() != nullptr) out->print(" [bci:%d]", info_for_exception()->stack()->bci());
2025 }
2026 






































2027 
2028 // LIR_Op3
2029 void LIR_Op3::print_instr(outputStream* out) const {
2030   in_opr1()->print(out);    out->print(" ");
2031   in_opr2()->print(out);    out->print(" ");
2032   in_opr3()->print(out);    out->print(" ");
2033   result_opr()->print(out);
2034 }
2035 
2036 // LIR_Op4
2037 void LIR_Op4::print_instr(outputStream* out) const {
2038   print_condition(out, condition()); out->print(" ");
2039   in_opr1()->print(out);             out->print(" ");
2040   in_opr2()->print(out);             out->print(" ");
2041   in_opr3()->print(out);             out->print(" ");
2042   in_opr4()->print(out);             out->print(" ");
2043   result_opr()->print(out);
2044 }
2045 
2046 void LIR_OpLock::print_instr(outputStream* out) const {

2082   mdo()->print(out);           out->print(" ");
2083   recv()->print(out);          out->print(" ");
2084   tmp1()->print(out);          out->print(" ");
2085 }
2086 
2087 // LIR_OpProfileType
2088 void LIR_OpProfileType::print_instr(outputStream* out) const {
2089   out->print("exact = ");
2090   if (exact_klass() == nullptr) {
2091     out->print("unknown");
2092   } else {
2093     exact_klass()->print_name_on(out);
2094   }
2095   out->print(" current = "); ciTypeEntries::print_ciklass(out, current_klass());
2096   out->print(" ");
2097   mdp()->print(out);          out->print(" ");
2098   obj()->print(out);          out->print(" ");
2099   tmp()->print(out);          out->print(" ");
2100 }
2101 








2102 #endif // PRODUCT
2103 
2104 // Implementation of LIR_InsertionBuffer
2105 
2106 void LIR_InsertionBuffer::append(int index, LIR_Op* op) {
2107   assert(_index_and_count.length() % 2 == 0, "must have a count for each index");
2108 
2109   int i = number_of_insertion_points() - 1;
2110   if (i < 0 || index_at(i) < index) {
2111     append_new(index, 1);
2112   } else {
2113     assert(index_at(i) == index, "can append LIR_Ops in ascending order only");
2114     assert(count_at(i) > 0, "check");
2115     set_count_at(i, count_at(i) + 1);
2116   }
2117   _ops.push(op);
2118 
2119   DEBUG_ONLY(verify());
2120 }
2121 

  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 

 271   assert(_ublock != nullptr, "must have old block");
 272   _ublock = b;
 273 }
 274 
 275 void LIR_OpBranch::negate_cond() {
 276   switch (cond()) {
 277     case lir_cond_equal:        set_cond(lir_cond_notEqual);     break;
 278     case lir_cond_notEqual:     set_cond(lir_cond_equal);        break;
 279     case lir_cond_less:         set_cond(lir_cond_greaterEqual); break;
 280     case lir_cond_lessEqual:    set_cond(lir_cond_greater);      break;
 281     case lir_cond_greaterEqual: set_cond(lir_cond_less);         break;
 282     case lir_cond_greater:      set_cond(lir_cond_lessEqual);    break;
 283     default: ShouldNotReachHere();
 284   }
 285 }
 286 
 287 
 288 LIR_OpTypeCheck::LIR_OpTypeCheck(LIR_Code code, LIR_Opr result, LIR_Opr object, ciKlass* klass,
 289                                  LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3,
 290                                  bool fast_check, CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch,
 291                                  CodeStub* stub, bool need_null_check)
 292 
 293   : LIR_Op(code, result, nullptr)
 294   , _object(object)
 295   , _array(LIR_OprFact::illegalOpr)
 296   , _klass(klass)
 297   , _tmp1(tmp1)
 298   , _tmp2(tmp2)
 299   , _tmp3(tmp3)
 300   , _info_for_patch(info_for_patch)
 301   , _info_for_exception(info_for_exception)
 302   , _stub(stub)
 303   , _profiled_method(nullptr)
 304   , _profiled_bci(-1)
 305   , _should_profile(false)
 306   , _fast_check(fast_check)
 307   , _need_null_check(need_null_check)
 308 {
 309   if (code == lir_checkcast) {
 310     assert(info_for_exception != nullptr, "checkcast throws exceptions");
 311   } else if (code == lir_instanceof) {
 312     assert(info_for_exception == nullptr, "instanceof throws no exceptions");
 313   } else {
 314     ShouldNotReachHere();
 315   }
 316 }
 317 
 318 
 319 
 320 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)
 321   : LIR_Op(code, LIR_OprFact::illegalOpr, nullptr)
 322   , _object(object)
 323   , _array(array)
 324   , _klass(nullptr)
 325   , _tmp1(tmp1)
 326   , _tmp2(tmp2)
 327   , _tmp3(tmp3)
 328   , _info_for_patch(nullptr)
 329   , _info_for_exception(info_for_exception)
 330   , _stub(nullptr)
 331   , _profiled_method(nullptr)
 332   , _profiled_bci(-1)
 333   , _should_profile(false)
 334   , _fast_check(false)
 335   , _need_null_check(true)
 336 {
 337   if (code == lir_store_check) {
 338     _stub = new ArrayStoreExceptionStub(object, info_for_exception);
 339     assert(info_for_exception != nullptr, "store_check throws exceptions");
 340   } else {
 341     ShouldNotReachHere();
 342   }
 343 }
 344 
 345 LIR_OpFlattenedArrayCheck::LIR_OpFlattenedArrayCheck(LIR_Opr array, LIR_Opr value, LIR_Opr tmp, CodeStub* stub)
 346   : LIR_Op(lir_flat_array_check, LIR_OprFact::illegalOpr, nullptr)
 347   , _array(array)
 348   , _value(value)
 349   , _tmp(tmp)
 350   , _stub(stub) {}
 351 
 352 
 353 LIR_OpNullFreeArrayCheck::LIR_OpNullFreeArrayCheck(LIR_Opr array, LIR_Opr tmp)
 354   : LIR_Op(lir_null_free_array_check, LIR_OprFact::illegalOpr, nullptr)
 355   , _array(array)
 356   , _tmp(tmp) {}
 357 
 358 
 359 LIR_OpSubstitutabilityCheck::LIR_OpSubstitutabilityCheck(LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr equal_result, LIR_Opr not_equal_result,
 360                                                          LIR_Opr tmp1, LIR_Opr tmp2,
 361                                                          ciKlass* left_klass, ciKlass* right_klass, LIR_Opr left_klass_op, LIR_Opr right_klass_op,
 362                                                          CodeEmitInfo* info, CodeStub* stub)
 363   : LIR_Op(lir_substitutability_check, result, info)
 364   , _left(left)
 365   , _right(right)
 366   , _equal_result(equal_result)
 367   , _not_equal_result(not_equal_result)
 368   , _tmp1(tmp1)
 369   , _tmp2(tmp2)
 370   , _left_klass(left_klass)
 371   , _right_klass(right_klass)
 372   , _left_klass_op(left_klass_op)
 373   , _right_klass_op(right_klass_op)
 374   , _stub(stub) {}
 375 
 376 
 377 LIR_OpArrayCopy::LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length,
 378                                  LIR_Opr tmp, ciArrayKlass* expected_type, int flags, CodeEmitInfo* info)
 379   : LIR_Op(lir_arraycopy, LIR_OprFact::illegalOpr, info)
 380   , _src(src)
 381   , _src_pos(src_pos)
 382   , _dst(dst)
 383   , _dst_pos(dst_pos)
 384   , _length(length)
 385   , _tmp(tmp)
 386   , _expected_type(expected_type)
 387   , _flags(flags) {
 388 #if defined(X86) || defined(AARCH64) || defined(S390) || defined(RISCV) || defined(PPC64)
 389   if (expected_type != nullptr && flags == 0) {
 390     _stub = nullptr;
 391   } else {
 392     _stub = new ArrayCopyStub(this);
 393   }
 394 #else
 395   _stub = new ArrayCopyStub(this);

 430 // The virtual call for each instruction type is replaced by a big
 431 // switch that adds the operands for each instruction
 432 
 433 void LIR_OpVisitState::visit(LIR_Op* op) {
 434   // copy information from the LIR_Op
 435   reset();
 436   set_op(op);
 437 
 438   switch (op->code()) {
 439 
 440 // LIR_Op0
 441     case lir_fpop_raw:                 // result and info always invalid
 442     case lir_breakpoint:               // result and info always invalid
 443     case lir_membar:                   // result and info always invalid
 444     case lir_membar_acquire:           // result and info always invalid
 445     case lir_membar_release:           // result and info always invalid
 446     case lir_membar_loadload:          // result and info always invalid
 447     case lir_membar_storestore:        // result and info always invalid
 448     case lir_membar_loadstore:         // result and info always invalid
 449     case lir_membar_storeload:         // result and info always invalid
 450     case lir_check_orig_pc:            // result and info always invalid
 451     case lir_on_spin_wait:
 452     {
 453       assert(op->as_Op0() != nullptr, "must be");
 454       assert(op->_info == nullptr, "info not used by this instruction");
 455       assert(op->_result->is_illegal(), "not used");
 456       break;
 457     }
 458 
 459     case lir_nop:                      // may have info, result always invalid
 460     case lir_std_entry:                // may have result, info always invalid
 461     case lir_osr_entry:                // may have result, info always invalid
 462     case lir_get_thread:               // may have result, info always invalid
 463     {
 464       assert(op->as_Op0() != nullptr, "must be");
 465       if (op->_info != nullptr)           do_info(op->_info);
 466       if (op->_result->is_valid())     do_output(op->_result);
 467       break;
 468     }
 469 
 470 

 827 
 828 
 829 // LIR_OpLock
 830     case lir_lock:
 831     case lir_unlock: {
 832       assert(op->as_OpLock() != nullptr, "must be");
 833       LIR_OpLock* opLock = (LIR_OpLock*)op;
 834 
 835       if (opLock->_info)                          do_info(opLock->_info);
 836 
 837       // TODO: check if these operands really have to be temp
 838       // (or if input is sufficient). This may have influence on the oop map!
 839       assert(opLock->_lock->is_valid(), "used");  do_temp(opLock->_lock);
 840       assert(opLock->_hdr->is_valid(),  "used");  do_temp(opLock->_hdr);
 841       assert(opLock->_obj->is_valid(),  "used");  do_temp(opLock->_obj);
 842 
 843       if (opLock->_scratch->is_valid())           do_temp(opLock->_scratch);
 844       assert(opLock->_result->is_illegal(), "unused");
 845 
 846       do_stub(opLock->_stub);
 847       do_stub(opLock->_throw_ie_stub);
 848 
 849       break;
 850     }
 851 
 852 
 853 // LIR_OpDelay
 854     case lir_delay_slot: {
 855       assert(op->as_OpDelay() != nullptr, "must be");
 856       LIR_OpDelay* opDelay = (LIR_OpDelay*)op;
 857 
 858       visit(opDelay->delay_op());
 859       break;
 860     }
 861 
 862 // LIR_OpTypeCheck
 863     case lir_instanceof:
 864     case lir_checkcast:
 865     case lir_store_check: {
 866       assert(op->as_OpTypeCheck() != nullptr, "must be");
 867       LIR_OpTypeCheck* opTypeCheck = (LIR_OpTypeCheck*)op;
 868 
 869       if (opTypeCheck->_info_for_exception)       do_info(opTypeCheck->_info_for_exception);
 870       if (opTypeCheck->_info_for_patch)           do_info(opTypeCheck->_info_for_patch);
 871       if (opTypeCheck->_object->is_valid())       do_input(opTypeCheck->_object);
 872       if (op->code() == lir_store_check && opTypeCheck->_object->is_valid()) {
 873         do_temp(opTypeCheck->_object);
 874       }
 875       if (opTypeCheck->_array->is_valid())        do_input(opTypeCheck->_array);
 876       if (opTypeCheck->_tmp1->is_valid())         do_temp(opTypeCheck->_tmp1);
 877       if (opTypeCheck->_tmp2->is_valid())         do_temp(opTypeCheck->_tmp2);
 878       if (opTypeCheck->_tmp3->is_valid())         do_temp(opTypeCheck->_tmp3);
 879       if (opTypeCheck->_result->is_valid())       do_output(opTypeCheck->_result);
 880       if (opTypeCheck->_stub != nullptr)          do_stub(opTypeCheck->_stub);
 881       break;
 882     }
 883 
 884 // LIR_OpFlattenedArrayCheck
 885     case lir_flat_array_check: {
 886       assert(op->as_OpFlattenedArrayCheck() != nullptr, "must be");
 887       LIR_OpFlattenedArrayCheck* opFlattenedArrayCheck = (LIR_OpFlattenedArrayCheck*)op;
 888 
 889       if (opFlattenedArrayCheck->_array->is_valid()) do_input(opFlattenedArrayCheck->_array);
 890       if (opFlattenedArrayCheck->_value->is_valid()) do_input(opFlattenedArrayCheck->_value);
 891       if (opFlattenedArrayCheck->_tmp->is_valid())   do_temp(opFlattenedArrayCheck->_tmp);
 892 
 893       do_stub(opFlattenedArrayCheck->_stub);
 894 
 895       break;
 896     }
 897 
 898 // LIR_OpNullFreeArrayCheck
 899     case lir_null_free_array_check: {
 900       assert(op->as_OpNullFreeArrayCheck() != nullptr, "must be");
 901       LIR_OpNullFreeArrayCheck* opNullFreeArrayCheck = (LIR_OpNullFreeArrayCheck*)op;
 902 
 903       if (opNullFreeArrayCheck->_array->is_valid()) do_input(opNullFreeArrayCheck->_array);
 904       if (opNullFreeArrayCheck->_tmp->is_valid())   do_temp(opNullFreeArrayCheck->_tmp);
 905       break;
 906     }
 907 
 908 // LIR_OpSubstitutabilityCheck
 909     case lir_substitutability_check: {
 910       assert(op->as_OpSubstitutabilityCheck() != nullptr, "must be");
 911       LIR_OpSubstitutabilityCheck* opSubstitutabilityCheck = (LIR_OpSubstitutabilityCheck*)op;
 912                                                                 do_input(opSubstitutabilityCheck->_left);
 913                                                                 do_temp (opSubstitutabilityCheck->_left);
 914                                                                 do_input(opSubstitutabilityCheck->_right);
 915                                                                 do_temp (opSubstitutabilityCheck->_right);
 916                                                                 do_input(opSubstitutabilityCheck->_equal_result);
 917                                                                 do_temp (opSubstitutabilityCheck->_equal_result);
 918                                                                 do_input(opSubstitutabilityCheck->_not_equal_result);
 919                                                                 do_temp (opSubstitutabilityCheck->_not_equal_result);
 920       if (opSubstitutabilityCheck->_tmp1->is_valid())           do_temp(opSubstitutabilityCheck->_tmp1);
 921       if (opSubstitutabilityCheck->_tmp2->is_valid())           do_temp(opSubstitutabilityCheck->_tmp2);
 922       if (opSubstitutabilityCheck->_left_klass_op->is_valid())  do_temp(opSubstitutabilityCheck->_left_klass_op);
 923       if (opSubstitutabilityCheck->_right_klass_op->is_valid()) do_temp(opSubstitutabilityCheck->_right_klass_op);
 924       if (opSubstitutabilityCheck->_result->is_valid())         do_output(opSubstitutabilityCheck->_result);
 925 
 926       do_info(opSubstitutabilityCheck->_info);
 927       do_stub(opSubstitutabilityCheck->_stub);
 928       break;
 929     }
 930 
 931 // LIR_OpCompareAndSwap
 932     case lir_cas_long:
 933     case lir_cas_obj:
 934     case lir_cas_int: {
 935       assert(op->as_OpCompareAndSwap() != nullptr, "must be");
 936       LIR_OpCompareAndSwap* opCmpAndSwap = (LIR_OpCompareAndSwap*)op;
 937 
 938       if (opCmpAndSwap->_info)                              do_info(opCmpAndSwap->_info);
 939       assert(opCmpAndSwap->_addr->is_valid(), "used");      do_input(opCmpAndSwap->_addr);
 940                                                             do_temp(opCmpAndSwap->_addr);
 941       assert(opCmpAndSwap->_cmp_value->is_valid(), "used"); do_input(opCmpAndSwap->_cmp_value);
 942                                                             do_temp(opCmpAndSwap->_cmp_value);
 943       assert(opCmpAndSwap->_new_value->is_valid(), "used"); do_input(opCmpAndSwap->_new_value);
 944                                                             do_temp(opCmpAndSwap->_new_value);
 945       if (opCmpAndSwap->_tmp1->is_valid())                  do_temp(opCmpAndSwap->_tmp1);
 946       if (opCmpAndSwap->_tmp2->is_valid())                  do_temp(opCmpAndSwap->_tmp2);
 947       if (opCmpAndSwap->_result->is_valid())                do_output(opCmpAndSwap->_result);
 948 
 949       break;
 950     }

 988     case lir_profile_call: {
 989       assert(op->as_OpProfileCall() != nullptr, "must be");
 990       LIR_OpProfileCall* opProfileCall = (LIR_OpProfileCall*)op;
 991 
 992       if (opProfileCall->_recv->is_valid())              do_temp(opProfileCall->_recv);
 993       assert(opProfileCall->_mdo->is_valid(), "used");   do_temp(opProfileCall->_mdo);
 994       assert(opProfileCall->_tmp1->is_valid(), "used");  do_temp(opProfileCall->_tmp1);
 995       break;
 996     }
 997 
 998 // LIR_OpProfileType:
 999     case lir_profile_type: {
1000       assert(op->as_OpProfileType() != nullptr, "must be");
1001       LIR_OpProfileType* opProfileType = (LIR_OpProfileType*)op;
1002 
1003       do_input(opProfileType->_mdp); do_temp(opProfileType->_mdp);
1004       do_input(opProfileType->_obj);
1005       do_temp(opProfileType->_tmp);
1006       break;
1007     }
1008 
1009     // LIR_OpProfileInlineType:
1010     case lir_profile_inline_type: {
1011       assert(op->as_OpProfileInlineType() != nullptr, "must be");
1012       LIR_OpProfileInlineType* opProfileInlineType = (LIR_OpProfileInlineType*)op;
1013 
1014       do_input(opProfileInlineType->_mdp); do_temp(opProfileInlineType->_mdp);
1015       do_input(opProfileInlineType->_obj);
1016       do_temp(opProfileInlineType->_tmp);
1017       break;
1018     }
1019 default:
1020     op->visit(this);
1021   }
1022 }
1023 
1024 void LIR_Op::visit(LIR_OpVisitState* state) {
1025   ShouldNotReachHere();
1026 }
1027 
1028 void LIR_OpVisitState::do_stub(CodeStub* stub) {
1029   if (stub != nullptr) {
1030     stub->visit(this);
1031   }
1032 }
1033 
1034 XHandlers* LIR_OpVisitState::all_xhandler() {
1035   XHandlers* result = nullptr;
1036 
1037   int i;
1038   for (i = 0; i < info_count(); i++) {
1039     if (info_at(i)->exception_handlers() != nullptr) {

1072          !has_slow_case();
1073 }
1074 #endif
1075 
1076 // LIR_OpReturn
1077 LIR_OpReturn::LIR_OpReturn(LIR_Opr opr) :
1078     LIR_Op1(lir_return, opr, (CodeEmitInfo*)nullptr /* info */),
1079     _stub(nullptr) {
1080   if (VM_Version::supports_stack_watermark_barrier()) {
1081     _stub = new C1SafepointPollStub();
1082   }
1083 }
1084 
1085 //---------------------------------------------------
1086 
1087 
1088 void LIR_OpJavaCall::emit_code(LIR_Assembler* masm) {
1089   masm->emit_call(this);
1090 }
1091 
1092 bool LIR_OpJavaCall::maybe_return_as_fields(ciInlineKlass** vk_ret) const {
1093   ciType* return_type = method()->return_type();
1094   if (InlineTypeReturnedAsFields) {
1095     if (return_type->is_inlinetype()) {
1096       ciInlineKlass* vk = return_type->as_inline_klass();
1097       if (vk->can_be_returned_as_fields()) {
1098         if (vk_ret != nullptr) {
1099           *vk_ret = vk;
1100         }
1101         return true;
1102       }
1103     } else if (return_type->is_instance_klass() &&
1104                (method()->is_method_handle_intrinsic() || !return_type->is_loaded() ||
1105                 StressCallingConvention)) {
1106       // An inline type might be returned from the call but we don't know its type.
1107       // This can happen with method handle intrinsics or when the return type is
1108       // not loaded (method holder is not loaded or preload attribute is missing).
1109       // If an inline type is returned, we either get an oop to a buffer and nothing
1110       // needs to be done or one of the values being returned is the klass of the
1111       // inline type (RAX on x64, with LSB set to 1) and we need to allocate an inline
1112       // type instance of that type and initialize it with the fields values being
1113       // returned in other registers.
1114       return true;
1115     }
1116   }
1117   return false;
1118 }
1119 
1120 void LIR_OpRTCall::emit_code(LIR_Assembler* masm) {
1121   masm->emit_rtcall(this);
1122 }
1123 
1124 void LIR_OpLabel::emit_code(LIR_Assembler* masm) {
1125   masm->emit_opLabel(this);
1126 }
1127 
1128 void LIR_OpArrayCopy::emit_code(LIR_Assembler* masm) {
1129   masm->emit_arraycopy(this);
1130   ArrayCopyStub* code_stub = stub();
1131   if (code_stub != nullptr) {
1132     masm->append_code_stub(code_stub);
1133   }
1134 }
1135 
1136 void LIR_OpUpdateCRC32::emit_code(LIR_Assembler* masm) {
1137   masm->emit_updatecrc32(this);
1138 }
1139 

1163     masm->append_code_stub(stub());
1164   }
1165 }
1166 
1167 void LIR_Op2::emit_code(LIR_Assembler* masm) {
1168   masm->emit_op2(this);
1169 }
1170 
1171 void LIR_OpAllocArray::emit_code(LIR_Assembler* masm) {
1172   masm->emit_alloc_array(this);
1173   masm->append_code_stub(stub());
1174 }
1175 
1176 void LIR_OpTypeCheck::emit_code(LIR_Assembler* masm) {
1177   masm->emit_opTypeCheck(this);
1178   if (stub()) {
1179     masm->append_code_stub(stub());
1180   }
1181 }
1182 
1183 void LIR_OpFlattenedArrayCheck::emit_code(LIR_Assembler* masm) {
1184   masm->emit_opFlattenedArrayCheck(this);
1185   if (stub() != nullptr) {
1186     masm->append_code_stub(stub());
1187   }
1188 }
1189 
1190 void LIR_OpNullFreeArrayCheck::emit_code(LIR_Assembler* masm) {
1191   masm->emit_opNullFreeArrayCheck(this);
1192 }
1193 
1194 void LIR_OpSubstitutabilityCheck::emit_code(LIR_Assembler* masm) {
1195   masm->emit_opSubstitutabilityCheck(this);
1196   if (stub() != nullptr) {
1197     masm->append_code_stub(stub());
1198   }
1199 }
1200 
1201 void LIR_OpCompareAndSwap::emit_code(LIR_Assembler* masm) {
1202   masm->emit_compare_and_swap(this);
1203 }
1204 
1205 void LIR_Op3::emit_code(LIR_Assembler* masm) {
1206   masm->emit_op3(this);
1207 }
1208 
1209 void LIR_Op4::emit_code(LIR_Assembler* masm) {
1210   masm->emit_op4(this);
1211 }
1212 
1213 void LIR_OpLock::emit_code(LIR_Assembler* masm) {
1214   masm->emit_lock(this);
1215   if (stub()) {
1216     masm->append_code_stub(stub());
1217   }
1218   if (throw_ie_stub()) {
1219     masm->append_code_stub(throw_ie_stub());
1220   }
1221 }
1222 
1223 void LIR_OpLoadKlass::emit_code(LIR_Assembler* masm) {
1224   masm->emit_load_klass(this);
1225 }
1226 
1227 #ifdef ASSERT
1228 void LIR_OpAssert::emit_code(LIR_Assembler* masm) {
1229   masm->emit_assert(this);
1230 }
1231 #endif
1232 
1233 void LIR_OpDelay::emit_code(LIR_Assembler* masm) {
1234   masm->emit_delay(this);
1235 }
1236 
1237 void LIR_OpProfileCall::emit_code(LIR_Assembler* masm) {
1238   masm->emit_profile_call(this);
1239 }
1240 
1241 void LIR_OpProfileType::emit_code(LIR_Assembler* masm) {
1242   masm->emit_profile_type(this);
1243 }
1244 
1245 void LIR_OpProfileInlineType::emit_code(LIR_Assembler* masm) {
1246   masm->emit_profile_inline_type(this);
1247 }
1248 
1249 // LIR_List
1250 LIR_List::LIR_List(Compilation* compilation, BlockBegin* block)
1251   : _operations(8)
1252   , _compilation(compilation)
1253 #ifndef PRODUCT
1254   , _block(block)
1255 #endif
1256 #ifdef ASSERT
1257   , _file(nullptr)
1258   , _line(0)
1259 #endif
1260 #ifdef RISCV
1261   , _cmp_opr1(LIR_OprFact::illegalOpr)
1262   , _cmp_opr2(LIR_OprFact::illegalOpr)
1263 #endif
1264 { }
1265 
1266 
1267 #ifdef ASSERT
1268 void LIR_List::set_file_and_line(const char * file, int line) {

1504                     reg,
1505                     LIR_OprFact::address(addr),
1506                     info));
1507 }
1508 
1509 void LIR_List::allocate_object(LIR_Opr dst, LIR_Opr t1, LIR_Opr t2, LIR_Opr t3, LIR_Opr t4,
1510                                int header_size, int object_size, LIR_Opr klass, bool init_check, CodeStub* stub) {
1511   append(new LIR_OpAllocObj(
1512                            klass,
1513                            dst,
1514                            t1,
1515                            t2,
1516                            t3,
1517                            t4,
1518                            header_size,
1519                            object_size,
1520                            init_check,
1521                            stub));
1522 }
1523 
1524 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, bool zero_array, bool is_null_free) {
1525   append(new LIR_OpAllocArray(
1526                            klass,
1527                            len,
1528                            dst,
1529                            t1,
1530                            t2,
1531                            t3,
1532                            t4,
1533                            type,
1534                            stub,
1535                            zero_array,
1536                            is_null_free));
1537 }
1538 
1539 void LIR_List::shift_left(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1540  append(new LIR_Op2(
1541                     lir_shl,
1542                     value,
1543                     count,
1544                     dst,
1545                     tmp));
1546 }
1547 
1548 void LIR_List::shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1549  append(new LIR_Op2(
1550                     lir_shr,
1551                     value,
1552                     count,
1553                     dst,
1554                     tmp));
1555 }
1556 
1557 
1558 void LIR_List::unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1559  append(new LIR_Op2(
1560                     lir_ushr,
1561                     value,
1562                     count,
1563                     dst,
1564                     tmp));
1565 }
1566 
1567 void LIR_List::fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less) {
1568   append(new LIR_Op2(is_unordered_less ? lir_ucmp_fd2i : lir_cmp_fd2i,
1569                      left,
1570                      right,
1571                      dst));
1572 }
1573 
1574 void LIR_List::lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info, CodeStub* throw_ie_stub) {
1575   append(new LIR_OpLock(
1576                     lir_lock,
1577                     hdr,
1578                     obj,
1579                     lock,
1580                     scratch,
1581                     stub,
1582                     info,
1583                     throw_ie_stub));
1584 }
1585 
1586 void LIR_List::unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub) {
1587   append(new LIR_OpLock(
1588                     lir_unlock,
1589                     hdr,
1590                     obj,
1591                     lock,
1592                     scratch,
1593                     stub,
1594                     nullptr));
1595 }
1596 
1597 
1598 void check_LIR() {
1599   // cannot do the proper checking as PRODUCT and other modes return different results
1600   // guarantee(sizeof(LIR_Opr) == wordSize, "may not have a v-table");
1601 }
1602 
1603 
1604 
1605 void LIR_List::checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
1606                           LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
1607                           CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
1608                           ciMethod* profiled_method, int profiled_bci, bool is_null_free) {
1609   // If klass is non-nullable,  LIRGenerator::do_CheckCast has already performed null-check
1610   // on the object.
1611   bool need_null_check = !is_null_free;
1612   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_checkcast, result, object, klass,
1613                                            tmp1, tmp2, tmp3, fast_check, info_for_exception, info_for_patch, stub,
1614                                            need_null_check);
1615   if (profiled_method != nullptr) {
1616     c->set_profiled_method(profiled_method);
1617     c->set_profiled_bci(profiled_bci);
1618     c->set_should_profile(true);
1619   }
1620   append(c);
1621 }
1622 
1623 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) {
1624   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_instanceof, result, object, klass, tmp1, tmp2, tmp3, fast_check, nullptr, info_for_patch, nullptr);
1625   if (profiled_method != nullptr) {
1626     c->set_profiled_method(profiled_method);
1627     c->set_profiled_bci(profiled_bci);
1628     c->set_should_profile(true);
1629   }
1630   append(c);
1631 }
1632 
1633 
1634 void LIR_List::store_check(LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3,
1635                            CodeEmitInfo* info_for_exception, ciMethod* profiled_method, int profiled_bci) {
1636   // FIXME -- if the types of the array and/or the object are known statically, we can avoid loading the klass
1637   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_store_check, object, array, tmp1, tmp2, tmp3, info_for_exception);
1638   if (profiled_method != nullptr) {
1639     c->set_profiled_method(profiled_method);
1640     c->set_profiled_bci(profiled_bci);
1641     c->set_should_profile(true);
1642   }
1643   append(c);
1644 }
1645 
1646 void LIR_List::null_check(LIR_Opr opr, CodeEmitInfo* info, bool deoptimize_on_null) {
1647   if (deoptimize_on_null) {
1648     // Emit an explicit null check and deoptimize if opr is null
1649     CodeStub* deopt = new DeoptimizeStub(info, Deoptimization::Reason_null_check, Deoptimization::Action_none);
1650     cmp(lir_cond_equal, opr, LIR_OprFact::oopConst(nullptr));
1651     branch(lir_cond_equal, deopt);
1652   } else {
1653     // Emit an implicit null check
1654     append(new LIR_Op1(lir_null_check, opr, info));
1655   }
1656 }
1657 
1658 void LIR_List::check_flat_array(LIR_Opr array, LIR_Opr value, LIR_Opr tmp, CodeStub* stub) {
1659   LIR_OpFlattenedArrayCheck* c = new LIR_OpFlattenedArrayCheck(array, value, tmp, stub);
1660   append(c);
1661 }
1662 
1663 void LIR_List::check_null_free_array(LIR_Opr array, LIR_Opr tmp) {
1664   LIR_OpNullFreeArrayCheck* c = new LIR_OpNullFreeArrayCheck(array, tmp);
1665   append(c);
1666 }
1667 
1668 void LIR_List::substitutability_check(LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr equal_result, LIR_Opr not_equal_result,
1669                                       LIR_Opr tmp1, LIR_Opr tmp2,
1670                                       ciKlass* left_klass, ciKlass* right_klass, LIR_Opr left_klass_op, LIR_Opr right_klass_op,
1671                                       CodeEmitInfo* info, CodeStub* stub) {
1672   LIR_OpSubstitutabilityCheck* c = new LIR_OpSubstitutabilityCheck(result, left, right, equal_result, not_equal_result,
1673                                                                    tmp1, tmp2,
1674                                                                    left_klass, right_klass, left_klass_op, right_klass_op,
1675                                                                    info, stub);
1676   append(c);
1677 }
1678 
1679 void LIR_List::cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1680                         LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1681   append(new LIR_OpCompareAndSwap(lir_cas_long, addr, cmp_value, new_value, t1, t2, result));
1682 }
1683 
1684 void LIR_List::cas_obj(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1685                        LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1686   append(new LIR_OpCompareAndSwap(lir_cas_obj, addr, cmp_value, new_value, t1, t2, result));
1687 }
1688 
1689 void LIR_List::cas_int(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1690                        LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1691   append(new LIR_OpCompareAndSwap(lir_cas_int, addr, cmp_value, new_value, t1, t2, result));
1692 }
1693 
1694 
1695 #ifdef PRODUCT
1696 
1697 void print_LIR(BlockList* blocks) {
1698 }

1875 
1876 const char * LIR_Op::name() const {
1877   const char* s = nullptr;
1878   switch(code()) {
1879      // LIR_Op0
1880      case lir_membar:                s = "membar";        break;
1881      case lir_membar_acquire:        s = "membar_acquire"; break;
1882      case lir_membar_release:        s = "membar_release"; break;
1883      case lir_membar_loadload:       s = "membar_loadload";   break;
1884      case lir_membar_storestore:     s = "membar_storestore"; break;
1885      case lir_membar_loadstore:      s = "membar_loadstore";  break;
1886      case lir_membar_storeload:      s = "membar_storeload";  break;
1887      case lir_label:                 s = "label";         break;
1888      case lir_nop:                   s = "nop";           break;
1889      case lir_on_spin_wait:          s = "on_spin_wait";  break;
1890      case lir_std_entry:             s = "std_entry";     break;
1891      case lir_osr_entry:             s = "osr_entry";     break;
1892      case lir_fpop_raw:              s = "fpop_raw";      break;
1893      case lir_breakpoint:            s = "breakpoint";    break;
1894      case lir_get_thread:            s = "get_thread";    break;
1895      case lir_check_orig_pc:         s = "check_orig_pc"; break;
1896      // LIR_Op1
1897      case lir_fxch:                  s = "fxch";          break;
1898      case lir_fld:                   s = "fld";           break;
1899      case lir_push:                  s = "push";          break;
1900      case lir_pop:                   s = "pop";           break;
1901      case lir_null_check:            s = "null_check";    break;
1902      case lir_return:                s = "return";        break;
1903      case lir_safepoint:             s = "safepoint";     break;
1904      case lir_leal:                  s = "leal";          break;
1905      case lir_branch:                s = "branch";        break;
1906      case lir_cond_float_branch:     s = "flt_cond_br";   break;
1907      case lir_move:                  s = "move";          break;
1908      case lir_roundfp:               s = "roundfp";       break;
1909      case lir_rtcall:                s = "rtcall";        break;
1910      case lir_throw:                 s = "throw";         break;
1911      case lir_unwind:                s = "unwind";        break;
1912      case lir_convert:               s = "convert";       break;
1913      case lir_alloc_object:          s = "alloc_obj";     break;
1914      case lir_monaddr:               s = "mon_addr";      break;
1915      // LIR_Op2

1944      // LIR_Op4
1945      case lir_cmove:                 s = "cmove";         break;
1946      // LIR_OpJavaCall
1947      case lir_static_call:           s = "static";        break;
1948      case lir_optvirtual_call:       s = "optvirtual";    break;
1949      case lir_icvirtual_call:        s = "icvirtual";     break;
1950      case lir_dynamic_call:          s = "dynamic";       break;
1951      // LIR_OpArrayCopy
1952      case lir_arraycopy:             s = "arraycopy";     break;
1953      // LIR_OpUpdateCRC32
1954      case lir_updatecrc32:           s = "updatecrc32";   break;
1955      // LIR_OpLock
1956      case lir_lock:                  s = "lock";          break;
1957      case lir_unlock:                s = "unlock";        break;
1958      // LIR_OpDelay
1959      case lir_delay_slot:            s = "delay";         break;
1960      // LIR_OpTypeCheck
1961      case lir_instanceof:            s = "instanceof";    break;
1962      case lir_checkcast:             s = "checkcast";     break;
1963      case lir_store_check:           s = "store_check";   break;
1964      // LIR_OpFlattenedArrayCheck
1965      case lir_flat_array_check:      s = "flat_array_check"; break;
1966      // LIR_OpNullFreeArrayCheck
1967      case lir_null_free_array_check: s = "null_free_array_check"; break;
1968      // LIR_OpSubstitutabilityCheck
1969      case lir_substitutability_check: s = "substitutability_check"; break;
1970      // LIR_OpCompareAndSwap
1971      case lir_cas_long:              s = "cas_long";      break;
1972      case lir_cas_obj:               s = "cas_obj";      break;
1973      case lir_cas_int:               s = "cas_int";      break;
1974      // LIR_OpProfileCall
1975      case lir_profile_call:          s = "profile_call";  break;
1976      // LIR_OpProfileType
1977      case lir_profile_type:          s = "profile_type";  break;
1978      // LIR_OpProfileInlineType
1979      case lir_profile_inline_type:   s = "profile_inline_type"; break;
1980      // LIR_OpAssert
1981 #ifdef ASSERT
1982      case lir_assert:                s = "assert";        break;
1983 #endif
1984      case lir_none:                  ShouldNotReachHere();break;
1985     default:                         s = "illegal_op";    break;
1986   }
1987   return s;
1988 }
1989 
1990 // LIR_OpJavaCall
1991 void LIR_OpJavaCall::print_instr(outputStream* out) const {
1992   out->print("call: ");
1993   out->print("[addr: " INTPTR_FORMAT "]", p2i(address()));
1994   if (receiver()->is_valid()) {
1995     out->print(" [recv: ");   receiver()->print(out);   out->print("]");
1996   }
1997   if (result_opr()->is_valid()) {
1998     out->print(" [result: "); result_opr()->print(out); out->print("]");
1999   }

2191   out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2192 }
2193 
2194 
2195 void LIR_OpTypeCheck::print_instr(outputStream* out) const {
2196   object()->print(out);                  out->print(" ");
2197   if (code() == lir_store_check) {
2198     array()->print(out);                 out->print(" ");
2199   }
2200   if (code() != lir_store_check) {
2201     klass()->print_name_on(out);         out->print(" ");
2202     if (fast_check())                 out->print("fast_check ");
2203   }
2204   tmp1()->print(out);                    out->print(" ");
2205   tmp2()->print(out);                    out->print(" ");
2206   tmp3()->print(out);                    out->print(" ");
2207   result_opr()->print(out);              out->print(" ");
2208   if (info_for_exception() != nullptr) out->print(" [bci:%d]", info_for_exception()->stack()->bci());
2209 }
2210 
2211 void LIR_OpFlattenedArrayCheck::print_instr(outputStream* out) const {
2212   array()->print(out);                   out->print(" ");
2213   value()->print(out);                   out->print(" ");
2214   tmp()->print(out);                     out->print(" ");
2215   if (stub() != nullptr) {
2216     out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2217   }
2218 }
2219 
2220 void LIR_OpNullFreeArrayCheck::print_instr(outputStream* out) const {
2221   array()->print(out);                   out->print(" ");
2222   tmp()->print(out);                     out->print(" ");
2223 }
2224 
2225 void LIR_OpSubstitutabilityCheck::print_instr(outputStream* out) const {
2226   result_opr()->print(out);              out->print(" ");
2227   left()->print(out);                    out->print(" ");
2228   right()->print(out);                   out->print(" ");
2229   equal_result()->print(out);            out->print(" ");
2230   not_equal_result()->print(out);        out->print(" ");
2231   tmp1()->print(out);                    out->print(" ");
2232   tmp2()->print(out);                    out->print(" ");
2233   if (left_klass() == nullptr) {
2234     out->print("unknown ");
2235   } else {
2236     left_klass()->print(out);            out->print(" ");
2237   }
2238   if (right_klass() == nullptr) {
2239     out->print("unknown ");
2240   } else {
2241     right_klass()->print(out);           out->print(" ");
2242   }
2243   left_klass_op()->print(out);           out->print(" ");
2244   right_klass_op()->print(out);          out->print(" ");
2245   if (stub() != nullptr) {
2246     out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2247   }
2248 }
2249 
2250 // LIR_Op3
2251 void LIR_Op3::print_instr(outputStream* out) const {
2252   in_opr1()->print(out);    out->print(" ");
2253   in_opr2()->print(out);    out->print(" ");
2254   in_opr3()->print(out);    out->print(" ");
2255   result_opr()->print(out);
2256 }
2257 
2258 // LIR_Op4
2259 void LIR_Op4::print_instr(outputStream* out) const {
2260   print_condition(out, condition()); out->print(" ");
2261   in_opr1()->print(out);             out->print(" ");
2262   in_opr2()->print(out);             out->print(" ");
2263   in_opr3()->print(out);             out->print(" ");
2264   in_opr4()->print(out);             out->print(" ");
2265   result_opr()->print(out);
2266 }
2267 
2268 void LIR_OpLock::print_instr(outputStream* out) const {

2304   mdo()->print(out);           out->print(" ");
2305   recv()->print(out);          out->print(" ");
2306   tmp1()->print(out);          out->print(" ");
2307 }
2308 
2309 // LIR_OpProfileType
2310 void LIR_OpProfileType::print_instr(outputStream* out) const {
2311   out->print("exact = ");
2312   if (exact_klass() == nullptr) {
2313     out->print("unknown");
2314   } else {
2315     exact_klass()->print_name_on(out);
2316   }
2317   out->print(" current = "); ciTypeEntries::print_ciklass(out, current_klass());
2318   out->print(" ");
2319   mdp()->print(out);          out->print(" ");
2320   obj()->print(out);          out->print(" ");
2321   tmp()->print(out);          out->print(" ");
2322 }
2323 
2324 // LIR_OpProfileInlineType
2325 void LIR_OpProfileInlineType::print_instr(outputStream* out) const {
2326   out->print(" flag = %x ", flag());
2327   mdp()->print(out);          out->print(" ");
2328   obj()->print(out);          out->print(" ");
2329   tmp()->print(out);          out->print(" ");
2330 }
2331 
2332 #endif // PRODUCT
2333 
2334 // Implementation of LIR_InsertionBuffer
2335 
2336 void LIR_InsertionBuffer::append(int index, LIR_Op* op) {
2337   assert(_index_and_count.length() % 2 == 0, "must have a count for each index");
2338 
2339   int i = number_of_insertion_points() - 1;
2340   if (i < 0 || index_at(i) < index) {
2341     append_new(index, 1);
2342   } else {
2343     assert(index_at(i) == index, "can append LIR_Ops in ascending order only");
2344     assert(count_at(i) > 0, "check");
2345     set_count_at(i, count_at(i) + 1);
2346   }
2347   _ops.push(op);
2348 
2349   DEBUG_ONLY(verify());
2350 }
2351 
< prev index next >