< prev index next >

src/hotspot/share/c1/c1_LIR.cpp

Print this page

  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "c1/c1_CodeStubs.hpp"
  27 #include "c1/c1_InstructionPrinter.hpp"
  28 #include "c1/c1_LIR.hpp"
  29 #include "c1/c1_LIRAssembler.hpp"
  30 #include "c1/c1_ValueStack.hpp"

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

  79 //---------------------------------------------------
  80 
  81 
  82 LIR_Address::Scale LIR_Address::scale(BasicType type) {
  83   int elem_size = type2aelembytes(type);
  84   switch (elem_size) {
  85   case 1: return LIR_Address::times_1;
  86   case 2: return LIR_Address::times_2;
  87   case 4: return LIR_Address::times_4;
  88   case 8: return LIR_Address::times_8;
  89   }
  90   ShouldNotReachHere();
  91   return LIR_Address::times_1;
  92 }
  93 
  94 //---------------------------------------------------
  95 
  96 char LIR_Opr::type_char(BasicType t) {
  97   switch (t) {
  98     case T_ARRAY:

  99       t = T_OBJECT;
 100     case T_BOOLEAN:
 101     case T_CHAR:
 102     case T_FLOAT:
 103     case T_DOUBLE:
 104     case T_BYTE:
 105     case T_SHORT:
 106     case T_INT:
 107     case T_LONG:
 108     case T_OBJECT:
 109     case T_ADDRESS:
 110     case T_VOID:
 111       return ::type2char(t);
 112     case T_METADATA:
 113       return 'M';
 114     case T_ILLEGAL:
 115       return '?';
 116 
 117     default:
 118       ShouldNotReachHere();

 135       // FP return values can be also in CPU registers on ARM (softfp ABI)
 136       assert((kindfield == fpu_register || kindfield == stack_value
 137              ARM_ONLY(|| kindfield == cpu_register) ) &&
 138              size_field() == single_size, "must match");
 139       break;
 140     case T_DOUBLE:
 141       // FP return values can be also in CPU registers on ARM (softfp ABI)
 142       assert((kindfield == fpu_register || kindfield == stack_value
 143              ARM_ONLY(|| kindfield == cpu_register) ) &&
 144              size_field() == double_size, "must match");
 145       break;
 146     case T_BOOLEAN:
 147     case T_CHAR:
 148     case T_BYTE:
 149     case T_SHORT:
 150     case T_INT:
 151     case T_ADDRESS:
 152     case T_OBJECT:
 153     case T_METADATA:
 154     case T_ARRAY:

 155       assert((kindfield == cpu_register || kindfield == stack_value) &&
 156              size_field() == single_size, "must match");
 157       break;
 158 
 159     case T_ILLEGAL:
 160       // XXX TKR also means unknown right now
 161       // assert(is_illegal(), "must match");
 162       break;
 163 
 164     default:
 165       ShouldNotReachHere();
 166     }
 167   }
 168 #endif
 169 
 170 }
 171 #endif // PRODUCT
 172 
 173 
 174 bool LIR_Opr::is_oop() const {

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

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

 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 
 345 LIR_OpArrayCopy::LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length,
 346                                  LIR_Opr tmp, ciArrayKlass* expected_type, int flags, CodeEmitInfo* info)
 347   : LIR_Op(lir_arraycopy, LIR_OprFact::illegalOpr, info)
 348   , _src(src)
 349   , _src_pos(src_pos)
 350   , _dst(dst)
 351   , _dst_pos(dst_pos)
 352   , _length(length)
 353   , _tmp(tmp)
 354   , _expected_type(expected_type)
 355   , _flags(flags) {
 356   _stub = new ArrayCopyStub(this);
 357 }
 358 
 359 LIR_OpUpdateCRC32::LIR_OpUpdateCRC32(LIR_Opr crc, LIR_Opr val, LIR_Opr res)
 360   : LIR_Op(lir_updatecrc32, res, nullptr)
 361   , _crc(crc)
 362   , _val(val) {
 363 }

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

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

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

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















































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

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











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

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




























 992 void LIR_OpRTCall::emit_code(LIR_Assembler* masm) {
 993   masm->emit_rtcall(this);
 994 }
 995 
 996 void LIR_OpLabel::emit_code(LIR_Assembler* masm) {
 997   masm->emit_opLabel(this);
 998 }
 999 
1000 void LIR_OpArrayCopy::emit_code(LIR_Assembler* masm) {
1001   masm->emit_arraycopy(this);
1002   masm->append_code_stub(stub());
1003 }
1004 
1005 void LIR_OpUpdateCRC32::emit_code(LIR_Assembler* masm) {
1006   masm->emit_updatecrc32(this);
1007 }
1008 
1009 void LIR_Op0::emit_code(LIR_Assembler* masm) {
1010   masm->emit_op0(this);
1011 }

1032     masm->append_code_stub(stub());
1033   }
1034 }
1035 
1036 void LIR_Op2::emit_code(LIR_Assembler* masm) {
1037   masm->emit_op2(this);
1038 }
1039 
1040 void LIR_OpAllocArray::emit_code(LIR_Assembler* masm) {
1041   masm->emit_alloc_array(this);
1042   masm->append_code_stub(stub());
1043 }
1044 
1045 void LIR_OpTypeCheck::emit_code(LIR_Assembler* masm) {
1046   masm->emit_opTypeCheck(this);
1047   if (stub()) {
1048     masm->append_code_stub(stub());
1049   }
1050 }
1051 


















1052 void LIR_OpCompareAndSwap::emit_code(LIR_Assembler* masm) {
1053   masm->emit_compare_and_swap(this);
1054 }
1055 
1056 void LIR_Op3::emit_code(LIR_Assembler* masm) {
1057   masm->emit_op3(this);
1058 }
1059 
1060 void LIR_Op4::emit_code(LIR_Assembler* masm) {
1061   masm->emit_op4(this);
1062 }
1063 
1064 void LIR_OpLock::emit_code(LIR_Assembler* masm) {
1065   masm->emit_lock(this);
1066   if (stub()) {
1067     masm->append_code_stub(stub());
1068   }



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




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

1396                     tmp));
1397 }
1398 
1399 
1400 void LIR_List::unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1401  append(new LIR_Op2(
1402                     lir_ushr,
1403                     value,
1404                     count,
1405                     dst,
1406                     tmp));
1407 }
1408 
1409 void LIR_List::fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less) {
1410   append(new LIR_Op2(is_unordered_less ? lir_ucmp_fd2i : lir_cmp_fd2i,
1411                      left,
1412                      right,
1413                      dst));
1414 }
1415 
1416 void LIR_List::lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info) {
1417   append(new LIR_OpLock(
1418                     lir_lock,
1419                     hdr,
1420                     obj,
1421                     lock,
1422                     scratch,
1423                     stub,
1424                     info));

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



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

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

1473   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_store_check, object, array, tmp1, tmp2, tmp3, info_for_exception);
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 void LIR_List::null_check(LIR_Opr opr, CodeEmitInfo* info, bool deoptimize_on_null) {
1483   if (deoptimize_on_null) {
1484     // Emit an explicit null check and deoptimize if opr is null
1485     CodeStub* deopt = new DeoptimizeStub(info, Deoptimization::Reason_null_check, Deoptimization::Action_none);
1486     cmp(lir_cond_equal, opr, LIR_OprFact::oopConst(nullptr));
1487     branch(lir_cond_equal, deopt);
1488   } else {
1489     // Emit an implicit null check
1490     append(new LIR_Op1(lir_null_check, opr, info));
1491   }
1492 }
1493 





















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

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

1710      // LIR_Op1
1711      case lir_fxch:                  s = "fxch";          break;
1712      case lir_fld:                   s = "fld";           break;
1713      case lir_push:                  s = "push";          break;
1714      case lir_pop:                   s = "pop";           break;
1715      case lir_null_check:            s = "null_check";    break;
1716      case lir_return:                s = "return";        break;
1717      case lir_safepoint:             s = "safepoint";     break;
1718      case lir_leal:                  s = "leal";          break;
1719      case lir_branch:                s = "branch";        break;
1720      case lir_cond_float_branch:     s = "flt_cond_br";   break;
1721      case lir_move:                  s = "move";          break;
1722      case lir_roundfp:               s = "roundfp";       break;
1723      case lir_rtcall:                s = "rtcall";        break;
1724      case lir_throw:                 s = "throw";         break;
1725      case lir_unwind:                s = "unwind";        break;
1726      case lir_convert:               s = "convert";       break;
1727      case lir_alloc_object:          s = "alloc_obj";     break;
1728      case lir_monaddr:               s = "mon_addr";      break;
1729      // LIR_Op2

1758      // LIR_Op4
1759      case lir_cmove:                 s = "cmove";         break;
1760      // LIR_OpJavaCall
1761      case lir_static_call:           s = "static";        break;
1762      case lir_optvirtual_call:       s = "optvirtual";    break;
1763      case lir_icvirtual_call:        s = "icvirtual";     break;
1764      case lir_dynamic_call:          s = "dynamic";       break;
1765      // LIR_OpArrayCopy
1766      case lir_arraycopy:             s = "arraycopy";     break;
1767      // LIR_OpUpdateCRC32
1768      case lir_updatecrc32:           s = "updatecrc32";   break;
1769      // LIR_OpLock
1770      case lir_lock:                  s = "lock";          break;
1771      case lir_unlock:                s = "unlock";        break;
1772      // LIR_OpDelay
1773      case lir_delay_slot:            s = "delay";         break;
1774      // LIR_OpTypeCheck
1775      case lir_instanceof:            s = "instanceof";    break;
1776      case lir_checkcast:             s = "checkcast";     break;
1777      case lir_store_check:           s = "store_check";   break;






1778      // LIR_OpCompareAndSwap
1779      case lir_cas_long:              s = "cas_long";      break;
1780      case lir_cas_obj:               s = "cas_obj";      break;
1781      case lir_cas_int:               s = "cas_int";      break;
1782      // LIR_OpProfileCall
1783      case lir_profile_call:          s = "profile_call";  break;
1784      // LIR_OpProfileType
1785      case lir_profile_type:          s = "profile_type";  break;


1786      // LIR_OpAssert
1787 #ifdef ASSERT
1788      case lir_assert:                s = "assert";        break;
1789 #endif
1790      case lir_none:                  ShouldNotReachHere();break;
1791     default:                         s = "illegal_op";    break;
1792   }
1793   return s;
1794 }
1795 
1796 // LIR_OpJavaCall
1797 void LIR_OpJavaCall::print_instr(outputStream* out) const {
1798   out->print("call: ");
1799   out->print("[addr: " INTPTR_FORMAT "]", p2i(address()));
1800   if (receiver()->is_valid()) {
1801     out->print(" [recv: ");   receiver()->print(out);   out->print("]");
1802   }
1803   if (result_opr()->is_valid()) {
1804     out->print(" [result: "); result_opr()->print(out); out->print("]");
1805   }

1997   out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
1998 }
1999 
2000 
2001 void LIR_OpTypeCheck::print_instr(outputStream* out) const {
2002   object()->print(out);                  out->print(" ");
2003   if (code() == lir_store_check) {
2004     array()->print(out);                 out->print(" ");
2005   }
2006   if (code() != lir_store_check) {
2007     klass()->print_name_on(out);         out->print(" ");
2008     if (fast_check())                 out->print("fast_check ");
2009   }
2010   tmp1()->print(out);                    out->print(" ");
2011   tmp2()->print(out);                    out->print(" ");
2012   tmp3()->print(out);                    out->print(" ");
2013   result_opr()->print(out);              out->print(" ");
2014   if (info_for_exception() != nullptr) out->print(" [bci:%d]", info_for_exception()->stack()->bci());
2015 }
2016 






































2017 
2018 // LIR_Op3
2019 void LIR_Op3::print_instr(outputStream* out) const {
2020   in_opr1()->print(out);    out->print(" ");
2021   in_opr2()->print(out);    out->print(" ");
2022   in_opr3()->print(out);    out->print(" ");
2023   result_opr()->print(out);
2024 }
2025 
2026 // LIR_Op4
2027 void LIR_Op4::print_instr(outputStream* out) const {
2028   print_condition(out, condition()); out->print(" ");
2029   in_opr1()->print(out);             out->print(" ");
2030   in_opr2()->print(out);             out->print(" ");
2031   in_opr3()->print(out);             out->print(" ");
2032   in_opr4()->print(out);             out->print(" ");
2033   result_opr()->print(out);
2034 }
2035 
2036 void LIR_OpLock::print_instr(outputStream* out) const {

2072   mdo()->print(out);           out->print(" ");
2073   recv()->print(out);          out->print(" ");
2074   tmp1()->print(out);          out->print(" ");
2075 }
2076 
2077 // LIR_OpProfileType
2078 void LIR_OpProfileType::print_instr(outputStream* out) const {
2079   out->print("exact = ");
2080   if (exact_klass() == nullptr) {
2081     out->print("unknown");
2082   } else {
2083     exact_klass()->print_name_on(out);
2084   }
2085   out->print(" current = "); ciTypeEntries::print_ciklass(out, current_klass());
2086   out->print(" ");
2087   mdp()->print(out);          out->print(" ");
2088   obj()->print(out);          out->print(" ");
2089   tmp()->print(out);          out->print(" ");
2090 }
2091 








2092 #endif // PRODUCT
2093 
2094 // Implementation of LIR_InsertionBuffer
2095 
2096 void LIR_InsertionBuffer::append(int index, LIR_Op* op) {
2097   assert(_index_and_count.length() % 2 == 0, "must have a count for each index");
2098 
2099   int i = number_of_insertion_points() - 1;
2100   if (i < 0 || index_at(i) < index) {
2101     append_new(index, 1);
2102   } else {
2103     assert(index_at(i) == index, "can append LIR_Ops in ascending order only");
2104     assert(count_at(i) > 0, "check");
2105     set_count_at(i, count_at(i) + 1);
2106   }
2107   _ops.push(op);
2108 
2109   DEBUG_ONLY(verify());
2110 }
2111 

  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "c1/c1_CodeStubs.hpp"
  27 #include "c1/c1_InstructionPrinter.hpp"
  28 #include "c1/c1_LIR.hpp"
  29 #include "c1/c1_LIRAssembler.hpp"
  30 #include "c1/c1_ValueStack.hpp"
  31 #include "ci/ciInlineKlass.hpp"
  32 #include "ci/ciInstance.hpp"
  33 #include "runtime/safepointMechanism.inline.hpp"
  34 #include "runtime/sharedRuntime.hpp"
  35 #include "runtime/vm_version.hpp"
  36 
  37 Register LIR_Opr::as_register() const {
  38   return FrameMap::cpu_rnr2reg(cpu_regnr());
  39 }
  40 
  41 Register LIR_Opr::as_register_lo() const {
  42   return FrameMap::cpu_rnr2reg(cpu_regnrLo());
  43 }
  44 
  45 Register LIR_Opr::as_register_hi() const {
  46   return FrameMap::cpu_rnr2reg(cpu_regnrHi());
  47 }
  48 
  49 LIR_Opr LIR_OprFact::illegalOpr = LIR_OprFact::illegal();
  50 LIR_Opr LIR_OprFact::nullOpr = LIR_Opr();
  51 

  80 //---------------------------------------------------
  81 
  82 
  83 LIR_Address::Scale LIR_Address::scale(BasicType type) {
  84   int elem_size = type2aelembytes(type);
  85   switch (elem_size) {
  86   case 1: return LIR_Address::times_1;
  87   case 2: return LIR_Address::times_2;
  88   case 4: return LIR_Address::times_4;
  89   case 8: return LIR_Address::times_8;
  90   }
  91   ShouldNotReachHere();
  92   return LIR_Address::times_1;
  93 }
  94 
  95 //---------------------------------------------------
  96 
  97 char LIR_Opr::type_char(BasicType t) {
  98   switch (t) {
  99     case T_ARRAY:
 100     case T_PRIMITIVE_OBJECT:
 101       t = T_OBJECT;
 102     case T_BOOLEAN:
 103     case T_CHAR:
 104     case T_FLOAT:
 105     case T_DOUBLE:
 106     case T_BYTE:
 107     case T_SHORT:
 108     case T_INT:
 109     case T_LONG:
 110     case T_OBJECT:
 111     case T_ADDRESS:
 112     case T_VOID:
 113       return ::type2char(t);
 114     case T_METADATA:
 115       return 'M';
 116     case T_ILLEGAL:
 117       return '?';
 118 
 119     default:
 120       ShouldNotReachHere();

 137       // FP return values can be also in CPU registers on ARM (softfp ABI)
 138       assert((kindfield == fpu_register || kindfield == stack_value
 139              ARM_ONLY(|| kindfield == cpu_register) ) &&
 140              size_field() == single_size, "must match");
 141       break;
 142     case T_DOUBLE:
 143       // FP return values can be also in CPU registers on ARM (softfp ABI)
 144       assert((kindfield == fpu_register || kindfield == stack_value
 145              ARM_ONLY(|| kindfield == cpu_register) ) &&
 146              size_field() == double_size, "must match");
 147       break;
 148     case T_BOOLEAN:
 149     case T_CHAR:
 150     case T_BYTE:
 151     case T_SHORT:
 152     case T_INT:
 153     case T_ADDRESS:
 154     case T_OBJECT:
 155     case T_METADATA:
 156     case T_ARRAY:
 157     case T_PRIMITIVE_OBJECT:
 158       assert((kindfield == cpu_register || kindfield == stack_value) &&
 159              size_field() == single_size, "must match");
 160       break;
 161 
 162     case T_ILLEGAL:
 163       // XXX TKR also means unknown right now
 164       // assert(is_illegal(), "must match");
 165       break;
 166 
 167     default:
 168       ShouldNotReachHere();
 169     }
 170   }
 171 #endif
 172 
 173 }
 174 #endif // PRODUCT
 175 
 176 
 177 bool LIR_Opr::is_oop() const {

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

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

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

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

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

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

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

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

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

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

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