< prev index next >

src/hotspot/share/c1/c1_LIR.cpp

Print this page

  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 "c1/c1_CodeStubs.hpp"
  26 #include "c1/c1_InstructionPrinter.hpp"
  27 #include "c1/c1_LIR.hpp"
  28 #include "c1/c1_LIRAssembler.hpp"
  29 #include "c1/c1_ValueStack.hpp"

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

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

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

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































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

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

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

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

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















































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

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











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

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




























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

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


















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



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




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

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

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

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



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

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

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





















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

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

1722      // LIR_Op1
1723      case lir_fxch:                  s = "fxch";          break;
1724      case lir_fld:                   s = "fld";           break;
1725      case lir_push:                  s = "push";          break;
1726      case lir_pop:                   s = "pop";           break;
1727      case lir_null_check:            s = "null_check";    break;
1728      case lir_return:                s = "return";        break;
1729      case lir_safepoint:             s = "safepoint";     break;
1730      case lir_leal:                  s = "leal";          break;
1731      case lir_branch:                s = "branch";        break;
1732      case lir_cond_float_branch:     s = "flt_cond_br";   break;
1733      case lir_move:                  s = "move";          break;
1734      case lir_roundfp:               s = "roundfp";       break;
1735      case lir_abs:                   s = "abs";           break;
1736      case lir_neg:                   s = "neg";           break;
1737      case lir_sqrt:                  s = "sqrt";          break;
1738      case lir_f2hf:                  s = "f2hf";          break;
1739      case lir_hf2f:                  s = "hf2f";          break;
1740      case lir_rtcall:                s = "rtcall";        break;
1741      case lir_throw:                 s = "throw";         break;

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






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


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

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






































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

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








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

  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 "c1/c1_CodeStubs.hpp"
  26 #include "c1/c1_InstructionPrinter.hpp"
  27 #include "c1/c1_LIR.hpp"
  28 #include "c1/c1_LIRAssembler.hpp"
  29 #include "c1/c1_ValueStack.hpp"
  30 #include "ci/ciInlineKlass.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, bool need_null_check)
 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   , _need_null_check(need_null_check)
 307 {
 308   if (code == lir_checkcast) {
 309     assert(info_for_exception != nullptr, "checkcast throws exceptions");
 310   } else if (code == lir_instanceof) {
 311     assert(info_for_exception == nullptr, "instanceof throws no exceptions");
 312   } else {
 313     ShouldNotReachHere();
 314   }
 315 }
 316 
 317 
 318 
 319 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)
 320   : LIR_Op(code, LIR_OprFact::illegalOpr, nullptr)
 321   , _object(object)
 322   , _array(array)
 323   , _klass(nullptr)
 324   , _tmp1(tmp1)
 325   , _tmp2(tmp2)
 326   , _tmp3(tmp3)
 327   , _info_for_patch(nullptr)
 328   , _info_for_exception(info_for_exception)
 329   , _stub(nullptr)
 330   , _profiled_method(nullptr)
 331   , _profiled_bci(-1)
 332   , _should_profile(false)
 333   , _fast_check(false)
 334   , _need_null_check(true)
 335 {
 336   if (code == lir_store_check) {
 337     _stub = new ArrayStoreExceptionStub(object, info_for_exception);
 338     assert(info_for_exception != nullptr, "store_check throws exceptions");
 339   } else {
 340     ShouldNotReachHere();
 341   }
 342 }
 343 
 344 LIR_OpFlattenedArrayCheck::LIR_OpFlattenedArrayCheck(LIR_Opr array, LIR_Opr value, LIR_Opr tmp, CodeStub* stub)
 345   : LIR_Op(lir_flat_array_check, LIR_OprFact::illegalOpr, nullptr)
 346   , _array(array)
 347   , _value(value)
 348   , _tmp(tmp)
 349   , _stub(stub) {}
 350 
 351 
 352 LIR_OpNullFreeArrayCheck::LIR_OpNullFreeArrayCheck(LIR_Opr array, LIR_Opr tmp)
 353   : LIR_Op(lir_null_free_array_check, LIR_OprFact::illegalOpr, nullptr)
 354   , _array(array)
 355   , _tmp(tmp) {}
 356 
 357 
 358 LIR_OpSubstitutabilityCheck::LIR_OpSubstitutabilityCheck(LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr equal_result, LIR_Opr not_equal_result,
 359                                                          LIR_Opr tmp1, LIR_Opr tmp2,
 360                                                          ciKlass* left_klass, ciKlass* right_klass, LIR_Opr left_klass_op, LIR_Opr right_klass_op,
 361                                                          CodeEmitInfo* info, CodeStub* stub)
 362   : LIR_Op(lir_substitutability_check, result, info)
 363   , _left(left)
 364   , _right(right)
 365   , _equal_result(equal_result)
 366   , _not_equal_result(not_equal_result)
 367   , _tmp1(tmp1)
 368   , _tmp2(tmp2)
 369   , _left_klass(left_klass)
 370   , _right_klass(right_klass)
 371   , _left_klass_op(left_klass_op)
 372   , _right_klass_op(right_klass_op)
 373   , _stub(stub) {}
 374 
 375 
 376 LIR_OpArrayCopy::LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length,
 377                                  LIR_Opr tmp, ciArrayKlass* expected_type, int flags, CodeEmitInfo* info)
 378   : LIR_Op(lir_arraycopy, LIR_OprFact::illegalOpr, info)
 379   , _src(src)
 380   , _src_pos(src_pos)
 381   , _dst(dst)
 382   , _dst_pos(dst_pos)
 383   , _length(length)
 384   , _tmp(tmp)
 385   , _expected_type(expected_type)
 386   , _flags(flags) {
 387 #if defined(X86) || defined(AARCH64) || defined(S390) || defined(RISCV) || defined(PPC64)
 388   if (expected_type != nullptr && flags == 0) {
 389     _stub = nullptr;
 390   } else {
 391     _stub = new ArrayCopyStub(this);
 392   }
 393 #else
 394   _stub = new ArrayCopyStub(this);

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

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

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

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

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

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

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

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

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

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