< 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(RISCV64) || defined(PPC64)
 354   if (expected_type != nullptr &&
 355       ((flags & ~LIR_OpArrayCopy::get_initial_copy_flags()) == 0)) {
 356     _stub = nullptr;
 357   } else {
 358     _stub = new ArrayCopyStub(this);
 359   }
 360 #else

 395 // complete rework of LIR instruction visitor.
 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_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 

 778 
 779 
 780 // LIR_OpLock
 781     case lir_lock:
 782     case lir_unlock: {
 783       assert(op->as_OpLock() != nullptr, "must be");
 784       LIR_OpLock* opLock = (LIR_OpLock*)op;
 785 
 786       if (opLock->_info)                          do_info(opLock->_info);
 787 
 788       // TODO: check if these operands really have to be temp
 789       // (or if input is sufficient). This may have influence on the oop map!
 790       assert(opLock->_lock->is_valid(), "used");  do_temp(opLock->_lock);
 791       assert(opLock->_hdr->is_valid(),  "used");  do_temp(opLock->_hdr);
 792       assert(opLock->_obj->is_valid(),  "used");  do_temp(opLock->_obj);
 793 
 794       if (opLock->_scratch->is_valid())           do_temp(opLock->_scratch);
 795       assert(opLock->_result->is_illegal(), "unused");
 796 
 797       do_stub(opLock->_stub);

 798 
 799       break;
 800     }
 801 
 802 
 803 // LIR_OpDelay
 804     case lir_delay_slot: {
 805       assert(op->as_OpDelay() != nullptr, "must be");
 806       LIR_OpDelay* opDelay = (LIR_OpDelay*)op;
 807 
 808       visit(opDelay->delay_op());
 809       break;
 810     }
 811 
 812 // LIR_OpTypeCheck
 813     case lir_instanceof:
 814     case lir_checkcast:
 815     case lir_store_check: {
 816       assert(op->as_OpTypeCheck() != nullptr, "must be");
 817       LIR_OpTypeCheck* opTypeCheck = (LIR_OpTypeCheck*)op;
 818 
 819       if (opTypeCheck->_info_for_exception)       do_info(opTypeCheck->_info_for_exception);
 820       if (opTypeCheck->_info_for_patch)           do_info(opTypeCheck->_info_for_patch);
 821       if (opTypeCheck->_object->is_valid())       do_input(opTypeCheck->_object);
 822       if (op->code() == lir_store_check && opTypeCheck->_object->is_valid()) {
 823         do_temp(opTypeCheck->_object);
 824       }
 825       if (opTypeCheck->_array->is_valid())        do_input(opTypeCheck->_array);
 826       if (opTypeCheck->_tmp1->is_valid())         do_temp(opTypeCheck->_tmp1);
 827       if (opTypeCheck->_tmp2->is_valid())         do_temp(opTypeCheck->_tmp2);
 828       if (opTypeCheck->_tmp3->is_valid())         do_temp(opTypeCheck->_tmp3);
 829       if (opTypeCheck->_result->is_valid())       do_output(opTypeCheck->_result);
 830       if (opTypeCheck->_stub != nullptr)          do_stub(opTypeCheck->_stub);
 831       break;
 832     }
 833 















































 834 // LIR_OpCompareAndSwap
 835     case lir_cas_long:
 836     case lir_cas_obj:
 837     case lir_cas_int: {
 838       assert(op->as_OpCompareAndSwap() != nullptr, "must be");
 839       LIR_OpCompareAndSwap* opCmpAndSwap = (LIR_OpCompareAndSwap*)op;
 840 
 841       if (opCmpAndSwap->_info)                              do_info(opCmpAndSwap->_info);
 842       assert(opCmpAndSwap->_addr->is_valid(), "used");      do_input(opCmpAndSwap->_addr);
 843                                                             do_temp(opCmpAndSwap->_addr);
 844       assert(opCmpAndSwap->_cmp_value->is_valid(), "used"); do_input(opCmpAndSwap->_cmp_value);
 845                                                             do_temp(opCmpAndSwap->_cmp_value);
 846       assert(opCmpAndSwap->_new_value->is_valid(), "used"); do_input(opCmpAndSwap->_new_value);
 847                                                             do_temp(opCmpAndSwap->_new_value);
 848       if (opCmpAndSwap->_tmp1->is_valid())                  do_temp(opCmpAndSwap->_tmp1);
 849       if (opCmpAndSwap->_tmp2->is_valid())                  do_temp(opCmpAndSwap->_tmp2);
 850       if (opCmpAndSwap->_result->is_valid())                do_output(opCmpAndSwap->_result);
 851 
 852       break;
 853     }

 891     case lir_profile_call: {
 892       assert(op->as_OpProfileCall() != nullptr, "must be");
 893       LIR_OpProfileCall* opProfileCall = (LIR_OpProfileCall*)op;
 894 
 895       if (opProfileCall->_recv->is_valid())              do_temp(opProfileCall->_recv);
 896       assert(opProfileCall->_mdo->is_valid(), "used");   do_temp(opProfileCall->_mdo);
 897       assert(opProfileCall->_tmp1->is_valid(), "used");  do_temp(opProfileCall->_tmp1);
 898       break;
 899     }
 900 
 901 // LIR_OpProfileType:
 902     case lir_profile_type: {
 903       assert(op->as_OpProfileType() != nullptr, "must be");
 904       LIR_OpProfileType* opProfileType = (LIR_OpProfileType*)op;
 905 
 906       do_input(opProfileType->_mdp); do_temp(opProfileType->_mdp);
 907       do_input(opProfileType->_obj);
 908       do_temp(opProfileType->_tmp);
 909       break;
 910     }
 911   default:











 912     op->visit(this);
 913   }
 914 }
 915 
 916 void LIR_Op::visit(LIR_OpVisitState* state) {
 917   ShouldNotReachHere();
 918 }
 919 
 920 void LIR_OpVisitState::do_stub(CodeStub* stub) {
 921   if (stub != nullptr) {
 922     stub->visit(this);
 923   }
 924 }
 925 
 926 XHandlers* LIR_OpVisitState::all_xhandler() {
 927   XHandlers* result = nullptr;
 928 
 929   int i;
 930   for (i = 0; i < info_count(); i++) {
 931     if (info_at(i)->exception_handlers() != nullptr) {

 964          !has_slow_case();
 965 }
 966 #endif
 967 
 968 // LIR_OpReturn
 969 LIR_OpReturn::LIR_OpReturn(LIR_Opr opr) :
 970     LIR_Op1(lir_return, opr, (CodeEmitInfo*)nullptr /* info */),
 971     _stub(nullptr) {
 972   if (VM_Version::supports_stack_watermark_barrier()) {
 973     _stub = new C1SafepointPollStub();
 974   }
 975 }
 976 
 977 //---------------------------------------------------
 978 
 979 
 980 void LIR_OpJavaCall::emit_code(LIR_Assembler* masm) {
 981   masm->emit_call(this);
 982 }
 983 




























 984 void LIR_OpRTCall::emit_code(LIR_Assembler* masm) {
 985   masm->emit_rtcall(this);
 986 }
 987 
 988 void LIR_OpLabel::emit_code(LIR_Assembler* masm) {
 989   masm->emit_opLabel(this);
 990 }
 991 
 992 void LIR_OpArrayCopy::emit_code(LIR_Assembler* masm) {
 993   masm->emit_arraycopy(this);
 994   ArrayCopyStub* code_stub = stub();
 995   if (code_stub != nullptr) {
 996     masm->append_code_stub(code_stub);
 997   }
 998 }
 999 
1000 void LIR_OpUpdateCRC32::emit_code(LIR_Assembler* masm) {
1001   masm->emit_updatecrc32(this);
1002 }
1003 

1027     masm->append_code_stub(stub());
1028   }
1029 }
1030 
1031 void LIR_Op2::emit_code(LIR_Assembler* masm) {
1032   masm->emit_op2(this);
1033 }
1034 
1035 void LIR_OpAllocArray::emit_code(LIR_Assembler* masm) {
1036   masm->emit_alloc_array(this);
1037   masm->append_code_stub(stub());
1038 }
1039 
1040 void LIR_OpTypeCheck::emit_code(LIR_Assembler* masm) {
1041   masm->emit_opTypeCheck(this);
1042   if (stub()) {
1043     masm->append_code_stub(stub());
1044   }
1045 }
1046 


















1047 void LIR_OpCompareAndSwap::emit_code(LIR_Assembler* masm) {
1048   masm->emit_compare_and_swap(this);
1049 }
1050 
1051 void LIR_Op3::emit_code(LIR_Assembler* masm) {
1052   masm->emit_op3(this);
1053 }
1054 
1055 void LIR_Op4::emit_code(LIR_Assembler* masm) {
1056   masm->emit_op4(this);
1057 }
1058 
1059 void LIR_OpLock::emit_code(LIR_Assembler* masm) {
1060   masm->emit_lock(this);
1061   if (stub()) {
1062     masm->append_code_stub(stub());
1063   }



1064 }
1065 
1066 void LIR_OpLoadKlass::emit_code(LIR_Assembler* masm) {
1067   masm->emit_load_klass(this);
1068 }
1069 
1070 #ifdef ASSERT
1071 void LIR_OpAssert::emit_code(LIR_Assembler* masm) {
1072   masm->emit_assert(this);
1073 }
1074 #endif
1075 
1076 void LIR_OpDelay::emit_code(LIR_Assembler* masm) {
1077   masm->emit_delay(this);
1078 }
1079 
1080 void LIR_OpProfileCall::emit_code(LIR_Assembler* masm) {
1081   masm->emit_profile_call(this);
1082 }
1083 
1084 void LIR_OpProfileType::emit_code(LIR_Assembler* masm) {
1085   masm->emit_profile_type(this);
1086 }
1087 




1088 // LIR_List
1089 LIR_List::LIR_List(Compilation* compilation, BlockBegin* block)
1090   : _operations(8)
1091   , _compilation(compilation)
1092 #ifndef PRODUCT
1093   , _block(block)
1094 #endif
1095 #ifdef ASSERT
1096   , _file(nullptr)
1097   , _line(0)
1098 #endif
1099 #ifdef RISCV
1100   , _cmp_opr1(LIR_OprFact::illegalOpr)
1101   , _cmp_opr2(LIR_OprFact::illegalOpr)
1102 #endif
1103 { }
1104 
1105 
1106 #ifdef ASSERT
1107 void LIR_List::set_file_and_line(const char * file, int line) {

1343                     reg,
1344                     LIR_OprFact::address(addr),
1345                     info));
1346 }
1347 
1348 void LIR_List::allocate_object(LIR_Opr dst, LIR_Opr t1, LIR_Opr t2, LIR_Opr t3, LIR_Opr t4,
1349                                int header_size, int object_size, LIR_Opr klass, bool init_check, CodeStub* stub) {
1350   append(new LIR_OpAllocObj(
1351                            klass,
1352                            dst,
1353                            t1,
1354                            t2,
1355                            t3,
1356                            t4,
1357                            header_size,
1358                            object_size,
1359                            init_check,
1360                            stub));
1361 }
1362 
1363 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) {
1364   append(new LIR_OpAllocArray(
1365                            klass,
1366                            len,
1367                            dst,
1368                            t1,
1369                            t2,
1370                            t3,
1371                            t4,
1372                            type,
1373                            stub,
1374                            zero_array));

1375 }
1376 
1377 void LIR_List::shift_left(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1378  append(new LIR_Op2(
1379                     lir_shl,
1380                     value,
1381                     count,
1382                     dst,
1383                     tmp));
1384 }
1385 
1386 void LIR_List::shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1387  append(new LIR_Op2(
1388                     lir_shr,
1389                     value,
1390                     count,
1391                     dst,
1392                     tmp));
1393 }
1394 
1395 
1396 void LIR_List::unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1397  append(new LIR_Op2(
1398                     lir_ushr,
1399                     value,
1400                     count,
1401                     dst,
1402                     tmp));
1403 }
1404 
1405 void LIR_List::fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less) {
1406   append(new LIR_Op2(is_unordered_less ? lir_ucmp_fd2i : lir_cmp_fd2i,
1407                      left,
1408                      right,
1409                      dst));
1410 }
1411 
1412 void LIR_List::lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info) {
1413   append(new LIR_OpLock(
1414                     lir_lock,
1415                     hdr,
1416                     obj,
1417                     lock,
1418                     scratch,
1419                     stub,
1420                     info));

1421 }
1422 
1423 void LIR_List::unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub) {
1424   append(new LIR_OpLock(
1425                     lir_unlock,
1426                     hdr,
1427                     obj,
1428                     lock,
1429                     scratch,
1430                     stub,
1431                     nullptr));
1432 }
1433 
1434 
1435 void check_LIR() {
1436   // cannot do the proper checking as PRODUCT and other modes return different results
1437   // guarantee(sizeof(LIR_Opr) == wordSize, "may not have a v-table");
1438 }
1439 
1440 
1441 
1442 void LIR_List::checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
1443                           LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
1444                           CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
1445                           ciMethod* profiled_method, int profiled_bci) {



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

1448   if (profiled_method != nullptr && TypeProfileCasts) {
1449     c->set_profiled_method(profiled_method);
1450     c->set_profiled_bci(profiled_bci);
1451     c->set_should_profile(true);
1452   }
1453   append(c);
1454 }
1455 
1456 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) {
1457   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_instanceof, result, object, klass, tmp1, tmp2, tmp3, fast_check, nullptr, info_for_patch, nullptr);
1458   if (profiled_method != nullptr && TypeProfileCasts) {
1459     c->set_profiled_method(profiled_method);
1460     c->set_profiled_bci(profiled_bci);
1461     c->set_should_profile(true);
1462   }
1463   append(c);
1464 }
1465 
1466 
1467 void LIR_List::store_check(LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3,
1468                            CodeEmitInfo* info_for_exception, ciMethod* profiled_method, int profiled_bci) {

1469   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_store_check, object, array, tmp1, tmp2, tmp3, info_for_exception);
1470   if (profiled_method != nullptr && TypeProfileCasts) {
1471     c->set_profiled_method(profiled_method);
1472     c->set_profiled_bci(profiled_bci);
1473     c->set_should_profile(true);
1474   }
1475   append(c);
1476 }
1477 
1478 void LIR_List::null_check(LIR_Opr opr, CodeEmitInfo* info, bool deoptimize_on_null) {
1479   if (deoptimize_on_null) {
1480     // Emit an explicit null check and deoptimize if opr is null
1481     CodeStub* deopt = new DeoptimizeStub(info, Deoptimization::Reason_null_check, Deoptimization::Action_none);
1482     cmp(lir_cond_equal, opr, LIR_OprFact::oopConst(nullptr));
1483     branch(lir_cond_equal, deopt);
1484   } else {
1485     // Emit an implicit null check
1486     append(new LIR_Op1(lir_null_check, opr, info));
1487   }
1488 }
1489 





















1490 void LIR_List::cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1491                         LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1492   append(new LIR_OpCompareAndSwap(lir_cas_long, addr, cmp_value, new_value, t1, t2, result));
1493 }
1494 
1495 void LIR_List::cas_obj(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1496                        LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1497   append(new LIR_OpCompareAndSwap(lir_cas_obj, addr, cmp_value, new_value, t1, t2, result));
1498 }
1499 
1500 void LIR_List::cas_int(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1501                        LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1502   append(new LIR_OpCompareAndSwap(lir_cas_int, addr, cmp_value, new_value, t1, t2, result));
1503 }
1504 
1505 
1506 #ifdef PRODUCT
1507 
1508 void print_LIR(BlockList* blocks) {
1509 }

1685 }
1686 
1687 const char * LIR_Op::name() const {
1688   const char* s = nullptr;
1689   switch(code()) {
1690      // LIR_Op0
1691      case lir_membar:                s = "membar";        break;
1692      case lir_membar_acquire:        s = "membar_acquire"; break;
1693      case lir_membar_release:        s = "membar_release"; break;
1694      case lir_membar_loadload:       s = "membar_loadload";   break;
1695      case lir_membar_storestore:     s = "membar_storestore"; break;
1696      case lir_membar_loadstore:      s = "membar_loadstore";  break;
1697      case lir_membar_storeload:      s = "membar_storeload";  break;
1698      case lir_label:                 s = "label";         break;
1699      case lir_nop:                   s = "nop";           break;
1700      case lir_on_spin_wait:          s = "on_spin_wait";  break;
1701      case lir_std_entry:             s = "std_entry";     break;
1702      case lir_osr_entry:             s = "osr_entry";     break;
1703      case lir_breakpoint:            s = "breakpoint";    break;
1704      case lir_get_thread:            s = "get_thread";    break;

1705      // LIR_Op1
1706      case lir_push:                  s = "push";          break;
1707      case lir_pop:                   s = "pop";           break;
1708      case lir_null_check:            s = "null_check";    break;
1709      case lir_return:                s = "return";        break;
1710      case lir_safepoint:             s = "safepoint";     break;
1711      case lir_leal:                  s = "leal";          break;
1712      case lir_branch:                s = "branch";        break;
1713      case lir_cond_float_branch:     s = "flt_cond_br";   break;
1714      case lir_move:                  s = "move";          break;
1715      case lir_abs:                   s = "abs";           break;
1716      case lir_neg:                   s = "neg";           break;
1717      case lir_sqrt:                  s = "sqrt";          break;
1718      case lir_f2hf:                  s = "f2hf";          break;
1719      case lir_hf2f:                  s = "hf2f";          break;
1720      case lir_rtcall:                s = "rtcall";        break;
1721      case lir_throw:                 s = "throw";         break;
1722      case lir_unwind:                s = "unwind";        break;
1723      case lir_convert:               s = "convert";       break;
1724      case lir_alloc_object:          s = "alloc_obj";     break;

1750      // LIR_Op4
1751      case lir_cmove:                 s = "cmove";         break;
1752      // LIR_OpJavaCall
1753      case lir_static_call:           s = "static";        break;
1754      case lir_optvirtual_call:       s = "optvirtual";    break;
1755      case lir_icvirtual_call:        s = "icvirtual";     break;
1756      case lir_dynamic_call:          s = "dynamic";       break;
1757      // LIR_OpArrayCopy
1758      case lir_arraycopy:             s = "arraycopy";     break;
1759      // LIR_OpUpdateCRC32
1760      case lir_updatecrc32:           s = "updatecrc32";   break;
1761      // LIR_OpLock
1762      case lir_lock:                  s = "lock";          break;
1763      case lir_unlock:                s = "unlock";        break;
1764      // LIR_OpDelay
1765      case lir_delay_slot:            s = "delay";         break;
1766      // LIR_OpTypeCheck
1767      case lir_instanceof:            s = "instanceof";    break;
1768      case lir_checkcast:             s = "checkcast";     break;
1769      case lir_store_check:           s = "store_check";   break;






1770      // LIR_OpCompareAndSwap
1771      case lir_cas_long:              s = "cas_long";      break;
1772      case lir_cas_obj:               s = "cas_obj";      break;
1773      case lir_cas_int:               s = "cas_int";      break;
1774      // LIR_OpProfileCall
1775      case lir_profile_call:          s = "profile_call";  break;
1776      // LIR_OpProfileType
1777      case lir_profile_type:          s = "profile_type";  break;


1778      // LIR_OpAssert
1779 #ifdef ASSERT
1780      case lir_assert:                s = "assert";        break;
1781 #endif
1782      case lir_none:                  ShouldNotReachHere();break;
1783     default:                         s = "illegal_op";    break;
1784   }
1785   return s;
1786 }
1787 
1788 // LIR_OpJavaCall
1789 void LIR_OpJavaCall::print_instr(outputStream* out) const {
1790   out->print("call: ");
1791   out->print("[addr: " INTPTR_FORMAT "]", p2i(address()));
1792   if (receiver()->is_valid()) {
1793     out->print(" [recv: ");   receiver()->print(out);   out->print("]");
1794   }
1795   if (result_opr()->is_valid()) {
1796     out->print(" [result: "); result_opr()->print(out); out->print("]");
1797   }

1983   out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
1984 }
1985 
1986 
1987 void LIR_OpTypeCheck::print_instr(outputStream* out) const {
1988   object()->print(out);                  out->print(" ");
1989   if (code() == lir_store_check) {
1990     array()->print(out);                 out->print(" ");
1991   }
1992   if (code() != lir_store_check) {
1993     klass()->print_name_on(out);         out->print(" ");
1994     if (fast_check())                 out->print("fast_check ");
1995   }
1996   tmp1()->print(out);                    out->print(" ");
1997   tmp2()->print(out);                    out->print(" ");
1998   tmp3()->print(out);                    out->print(" ");
1999   result_opr()->print(out);              out->print(" ");
2000   if (info_for_exception() != nullptr) out->print(" [bci:%d]", info_for_exception()->stack()->bci());
2001 }
2002 






































2003 
2004 // LIR_Op3
2005 void LIR_Op3::print_instr(outputStream* out) const {
2006   in_opr1()->print(out);    out->print(" ");
2007   in_opr2()->print(out);    out->print(" ");
2008   in_opr3()->print(out);    out->print(" ");
2009   result_opr()->print(out);
2010 }
2011 
2012 // LIR_Op4
2013 void LIR_Op4::print_instr(outputStream* out) const {
2014   print_condition(out, condition()); out->print(" ");
2015   in_opr1()->print(out);             out->print(" ");
2016   in_opr2()->print(out);             out->print(" ");
2017   in_opr3()->print(out);             out->print(" ");
2018   in_opr4()->print(out);             out->print(" ");
2019   result_opr()->print(out);
2020 }
2021 
2022 void LIR_OpLock::print_instr(outputStream* out) const {

2058   mdo()->print(out);           out->print(" ");
2059   recv()->print(out);          out->print(" ");
2060   tmp1()->print(out);          out->print(" ");
2061 }
2062 
2063 // LIR_OpProfileType
2064 void LIR_OpProfileType::print_instr(outputStream* out) const {
2065   out->print("exact = ");
2066   if (exact_klass() == nullptr) {
2067     out->print("unknown");
2068   } else {
2069     exact_klass()->print_name_on(out);
2070   }
2071   out->print(" current = "); ciTypeEntries::print_ciklass(out, current_klass());
2072   out->print(" ");
2073   mdp()->print(out);          out->print(" ");
2074   obj()->print(out);          out->print(" ");
2075   tmp()->print(out);          out->print(" ");
2076 }
2077 








2078 #endif // PRODUCT
2079 
2080 // Implementation of LIR_InsertionBuffer
2081 
2082 void LIR_InsertionBuffer::append(int index, LIR_Op* op) {
2083   assert(_index_and_count.length() % 2 == 0, "must have a count for each index");
2084 
2085   int i = number_of_insertion_points() - 1;
2086   if (i < 0 || index_at(i) < index) {
2087     append_new(index, 1);
2088   } else {
2089     assert(index_at(i) == index, "can append LIR_Ops in ascending order only");
2090     assert(count_at(i) > 0, "check");
2091     set_count_at(i, count_at(i) + 1);
2092   }
2093   _ops.push(op);
2094 
2095   DEBUG_ONLY(verify());
2096 }
2097 

  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(RISCV64) || defined(PPC64)
 388   if (expected_type != nullptr &&
 389       ((flags & ~LIR_OpArrayCopy::get_initial_copy_flags()) == 0)) {
 390     _stub = nullptr;
 391   } else {
 392     _stub = new ArrayCopyStub(this);
 393   }
 394 #else

 429 // complete rework of LIR instruction visitor.
 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_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 

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

 974     case lir_profile_call: {
 975       assert(op->as_OpProfileCall() != nullptr, "must be");
 976       LIR_OpProfileCall* opProfileCall = (LIR_OpProfileCall*)op;
 977 
 978       if (opProfileCall->_recv->is_valid())              do_temp(opProfileCall->_recv);
 979       assert(opProfileCall->_mdo->is_valid(), "used");   do_temp(opProfileCall->_mdo);
 980       assert(opProfileCall->_tmp1->is_valid(), "used");  do_temp(opProfileCall->_tmp1);
 981       break;
 982     }
 983 
 984 // LIR_OpProfileType:
 985     case lir_profile_type: {
 986       assert(op->as_OpProfileType() != nullptr, "must be");
 987       LIR_OpProfileType* opProfileType = (LIR_OpProfileType*)op;
 988 
 989       do_input(opProfileType->_mdp); do_temp(opProfileType->_mdp);
 990       do_input(opProfileType->_obj);
 991       do_temp(opProfileType->_tmp);
 992       break;
 993     }
 994 
 995     // LIR_OpProfileInlineType:
 996     case lir_profile_inline_type: {
 997       assert(op->as_OpProfileInlineType() != nullptr, "must be");
 998       LIR_OpProfileInlineType* opProfileInlineType = (LIR_OpProfileInlineType*)op;
 999 
1000       do_input(opProfileInlineType->_mdp); do_temp(opProfileInlineType->_mdp);
1001       do_input(opProfileInlineType->_obj);
1002       do_temp(opProfileInlineType->_tmp);
1003       break;
1004     }
1005 default:
1006     op->visit(this);
1007   }
1008 }
1009 
1010 void LIR_Op::visit(LIR_OpVisitState* state) {
1011   ShouldNotReachHere();
1012 }
1013 
1014 void LIR_OpVisitState::do_stub(CodeStub* stub) {
1015   if (stub != nullptr) {
1016     stub->visit(this);
1017   }
1018 }
1019 
1020 XHandlers* LIR_OpVisitState::all_xhandler() {
1021   XHandlers* result = nullptr;
1022 
1023   int i;
1024   for (i = 0; i < info_count(); i++) {
1025     if (info_at(i)->exception_handlers() != nullptr) {

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

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

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

1860 }
1861 
1862 const char * LIR_Op::name() const {
1863   const char* s = nullptr;
1864   switch(code()) {
1865      // LIR_Op0
1866      case lir_membar:                s = "membar";        break;
1867      case lir_membar_acquire:        s = "membar_acquire"; break;
1868      case lir_membar_release:        s = "membar_release"; break;
1869      case lir_membar_loadload:       s = "membar_loadload";   break;
1870      case lir_membar_storestore:     s = "membar_storestore"; break;
1871      case lir_membar_loadstore:      s = "membar_loadstore";  break;
1872      case lir_membar_storeload:      s = "membar_storeload";  break;
1873      case lir_label:                 s = "label";         break;
1874      case lir_nop:                   s = "nop";           break;
1875      case lir_on_spin_wait:          s = "on_spin_wait";  break;
1876      case lir_std_entry:             s = "std_entry";     break;
1877      case lir_osr_entry:             s = "osr_entry";     break;
1878      case lir_breakpoint:            s = "breakpoint";    break;
1879      case lir_get_thread:            s = "get_thread";    break;
1880      case lir_check_orig_pc:         s = "check_orig_pc"; break;
1881      // LIR_Op1
1882      case lir_push:                  s = "push";          break;
1883      case lir_pop:                   s = "pop";           break;
1884      case lir_null_check:            s = "null_check";    break;
1885      case lir_return:                s = "return";        break;
1886      case lir_safepoint:             s = "safepoint";     break;
1887      case lir_leal:                  s = "leal";          break;
1888      case lir_branch:                s = "branch";        break;
1889      case lir_cond_float_branch:     s = "flt_cond_br";   break;
1890      case lir_move:                  s = "move";          break;
1891      case lir_abs:                   s = "abs";           break;
1892      case lir_neg:                   s = "neg";           break;
1893      case lir_sqrt:                  s = "sqrt";          break;
1894      case lir_f2hf:                  s = "f2hf";          break;
1895      case lir_hf2f:                  s = "hf2f";          break;
1896      case lir_rtcall:                s = "rtcall";        break;
1897      case lir_throw:                 s = "throw";         break;
1898      case lir_unwind:                s = "unwind";        break;
1899      case lir_convert:               s = "convert";       break;
1900      case lir_alloc_object:          s = "alloc_obj";     break;

1926      // LIR_Op4
1927      case lir_cmove:                 s = "cmove";         break;
1928      // LIR_OpJavaCall
1929      case lir_static_call:           s = "static";        break;
1930      case lir_optvirtual_call:       s = "optvirtual";    break;
1931      case lir_icvirtual_call:        s = "icvirtual";     break;
1932      case lir_dynamic_call:          s = "dynamic";       break;
1933      // LIR_OpArrayCopy
1934      case lir_arraycopy:             s = "arraycopy";     break;
1935      // LIR_OpUpdateCRC32
1936      case lir_updatecrc32:           s = "updatecrc32";   break;
1937      // LIR_OpLock
1938      case lir_lock:                  s = "lock";          break;
1939      case lir_unlock:                s = "unlock";        break;
1940      // LIR_OpDelay
1941      case lir_delay_slot:            s = "delay";         break;
1942      // LIR_OpTypeCheck
1943      case lir_instanceof:            s = "instanceof";    break;
1944      case lir_checkcast:             s = "checkcast";     break;
1945      case lir_store_check:           s = "store_check";   break;
1946      // LIR_OpFlattenedArrayCheck
1947      case lir_flat_array_check:      s = "flat_array_check"; break;
1948      // LIR_OpNullFreeArrayCheck
1949      case lir_null_free_array_check: s = "null_free_array_check"; break;
1950      // LIR_OpSubstitutabilityCheck
1951      case lir_substitutability_check: s = "substitutability_check"; break;
1952      // LIR_OpCompareAndSwap
1953      case lir_cas_long:              s = "cas_long";      break;
1954      case lir_cas_obj:               s = "cas_obj";      break;
1955      case lir_cas_int:               s = "cas_int";      break;
1956      // LIR_OpProfileCall
1957      case lir_profile_call:          s = "profile_call";  break;
1958      // LIR_OpProfileType
1959      case lir_profile_type:          s = "profile_type";  break;
1960      // LIR_OpProfileInlineType
1961      case lir_profile_inline_type:   s = "profile_inline_type"; break;
1962      // LIR_OpAssert
1963 #ifdef ASSERT
1964      case lir_assert:                s = "assert";        break;
1965 #endif
1966      case lir_none:                  ShouldNotReachHere();break;
1967     default:                         s = "illegal_op";    break;
1968   }
1969   return s;
1970 }
1971 
1972 // LIR_OpJavaCall
1973 void LIR_OpJavaCall::print_instr(outputStream* out) const {
1974   out->print("call: ");
1975   out->print("[addr: " INTPTR_FORMAT "]", p2i(address()));
1976   if (receiver()->is_valid()) {
1977     out->print(" [recv: ");   receiver()->print(out);   out->print("]");
1978   }
1979   if (result_opr()->is_valid()) {
1980     out->print(" [result: "); result_opr()->print(out); out->print("]");
1981   }

2167   out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2168 }
2169 
2170 
2171 void LIR_OpTypeCheck::print_instr(outputStream* out) const {
2172   object()->print(out);                  out->print(" ");
2173   if (code() == lir_store_check) {
2174     array()->print(out);                 out->print(" ");
2175   }
2176   if (code() != lir_store_check) {
2177     klass()->print_name_on(out);         out->print(" ");
2178     if (fast_check())                 out->print("fast_check ");
2179   }
2180   tmp1()->print(out);                    out->print(" ");
2181   tmp2()->print(out);                    out->print(" ");
2182   tmp3()->print(out);                    out->print(" ");
2183   result_opr()->print(out);              out->print(" ");
2184   if (info_for_exception() != nullptr) out->print(" [bci:%d]", info_for_exception()->stack()->bci());
2185 }
2186 
2187 void LIR_OpFlattenedArrayCheck::print_instr(outputStream* out) const {
2188   array()->print(out);                   out->print(" ");
2189   value()->print(out);                   out->print(" ");
2190   tmp()->print(out);                     out->print(" ");
2191   if (stub() != nullptr) {
2192     out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2193   }
2194 }
2195 
2196 void LIR_OpNullFreeArrayCheck::print_instr(outputStream* out) const {
2197   array()->print(out);                   out->print(" ");
2198   tmp()->print(out);                     out->print(" ");
2199 }
2200 
2201 void LIR_OpSubstitutabilityCheck::print_instr(outputStream* out) const {
2202   result_opr()->print(out);              out->print(" ");
2203   left()->print(out);                    out->print(" ");
2204   right()->print(out);                   out->print(" ");
2205   equal_result()->print(out);            out->print(" ");
2206   not_equal_result()->print(out);        out->print(" ");
2207   tmp1()->print(out);                    out->print(" ");
2208   tmp2()->print(out);                    out->print(" ");
2209   if (left_klass() == nullptr) {
2210     out->print("unknown ");
2211   } else {
2212     left_klass()->print(out);            out->print(" ");
2213   }
2214   if (right_klass() == nullptr) {
2215     out->print("unknown ");
2216   } else {
2217     right_klass()->print(out);           out->print(" ");
2218   }
2219   left_klass_op()->print(out);           out->print(" ");
2220   right_klass_op()->print(out);          out->print(" ");
2221   if (stub() != nullptr) {
2222     out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2223   }
2224 }
2225 
2226 // LIR_Op3
2227 void LIR_Op3::print_instr(outputStream* out) const {
2228   in_opr1()->print(out);    out->print(" ");
2229   in_opr2()->print(out);    out->print(" ");
2230   in_opr3()->print(out);    out->print(" ");
2231   result_opr()->print(out);
2232 }
2233 
2234 // LIR_Op4
2235 void LIR_Op4::print_instr(outputStream* out) const {
2236   print_condition(out, condition()); out->print(" ");
2237   in_opr1()->print(out);             out->print(" ");
2238   in_opr2()->print(out);             out->print(" ");
2239   in_opr3()->print(out);             out->print(" ");
2240   in_opr4()->print(out);             out->print(" ");
2241   result_opr()->print(out);
2242 }
2243 
2244 void LIR_OpLock::print_instr(outputStream* out) const {

2280   mdo()->print(out);           out->print(" ");
2281   recv()->print(out);          out->print(" ");
2282   tmp1()->print(out);          out->print(" ");
2283 }
2284 
2285 // LIR_OpProfileType
2286 void LIR_OpProfileType::print_instr(outputStream* out) const {
2287   out->print("exact = ");
2288   if (exact_klass() == nullptr) {
2289     out->print("unknown");
2290   } else {
2291     exact_klass()->print_name_on(out);
2292   }
2293   out->print(" current = "); ciTypeEntries::print_ciklass(out, current_klass());
2294   out->print(" ");
2295   mdp()->print(out);          out->print(" ");
2296   obj()->print(out);          out->print(" ");
2297   tmp()->print(out);          out->print(" ");
2298 }
2299 
2300 // LIR_OpProfileInlineType
2301 void LIR_OpProfileInlineType::print_instr(outputStream* out) const {
2302   out->print(" flag = %x ", flag());
2303   mdp()->print(out);          out->print(" ");
2304   obj()->print(out);          out->print(" ");
2305   tmp()->print(out);          out->print(" ");
2306 }
2307 
2308 #endif // PRODUCT
2309 
2310 // Implementation of LIR_InsertionBuffer
2311 
2312 void LIR_InsertionBuffer::append(int index, LIR_Op* op) {
2313   assert(_index_and_count.length() % 2 == 0, "must have a count for each index");
2314 
2315   int i = number_of_insertion_points() - 1;
2316   if (i < 0 || index_at(i) < index) {
2317     append_new(index, 1);
2318   } else {
2319     assert(index_at(i) == index, "can append LIR_Ops in ascending order only");
2320     assert(count_at(i) > 0, "check");
2321     set_count_at(i, count_at(i) + 1);
2322   }
2323   _ops.push(op);
2324 
2325   DEBUG_ONLY(verify());
2326 }
2327 
< prev index next >