< 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 != NULL, "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, NULL)
 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(NULL)
 306   , _profiled_bci(-1)
 307   , _should_profile(false)

 308 {
 309   if (code == lir_checkcast) {
 310     assert(info_for_exception != NULL, "checkcast throws exceptions");
 311   } else if (code == lir_instanceof) {
 312     assert(info_for_exception == NULL, "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, NULL)
 322   , _object(object)
 323   , _array(array)
 324   , _klass(NULL)
 325   , _tmp1(tmp1)
 326   , _tmp2(tmp2)
 327   , _tmp3(tmp3)
 328   , _fast_check(false)
 329   , _info_for_patch(NULL)
 330   , _info_for_exception(info_for_exception)
 331   , _stub(NULL)
 332   , _profiled_method(NULL)
 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 != NULL, "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, NULL)
 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() != NULL, "must be");
 413       assert(op->_info == NULL, "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() != NULL, "must be");
 424       if (op->_info != NULL)           do_info(op->_info);
 425       if (op->_result->is_valid())     do_output(op->_result);
 426       break;
 427     }
 428 
 429 

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

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













































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

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











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

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




























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

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


















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



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




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

1387                     tmp));
1388 }
1389 
1390 
1391 void LIR_List::unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1392  append(new LIR_Op2(
1393                     lir_ushr,
1394                     value,
1395                     count,
1396                     dst,
1397                     tmp));
1398 }
1399 
1400 void LIR_List::fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less) {
1401   append(new LIR_Op2(is_unordered_less ? lir_ucmp_fd2i : lir_cmp_fd2i,
1402                      left,
1403                      right,
1404                      dst));
1405 }
1406 
1407 void LIR_List::lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info) {
1408   append(new LIR_OpLock(
1409                     lir_lock,
1410                     hdr,
1411                     obj,
1412                     lock,
1413                     scratch,
1414                     stub,
1415                     info));

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



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

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

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





















1485 void LIR_List::cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1486                         LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1487   append(new LIR_OpCompareAndSwap(lir_cas_long, addr, cmp_value, new_value, t1, t2, result));
1488 }
1489 
1490 void LIR_List::cas_obj(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_obj, addr, cmp_value, new_value, t1, t2, result));
1493 }
1494 
1495 void LIR_List::cas_int(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_int, addr, cmp_value, new_value, t1, t2, result));
1498 }
1499 
1500 
1501 #ifdef PRODUCT
1502 
1503 void print_LIR(BlockList* blocks) {
1504 }

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

1701      // LIR_Op1
1702      case lir_fxch:                  s = "fxch";          break;
1703      case lir_fld:                   s = "fld";           break;
1704      case lir_push:                  s = "push";          break;
1705      case lir_pop:                   s = "pop";           break;
1706      case lir_null_check:            s = "null_check";    break;
1707      case lir_return:                s = "return";        break;
1708      case lir_safepoint:             s = "safepoint";     break;
1709      case lir_leal:                  s = "leal";          break;
1710      case lir_branch:                s = "branch";        break;
1711      case lir_cond_float_branch:     s = "flt_cond_br";   break;
1712      case lir_move:                  s = "move";          break;
1713      case lir_roundfp:               s = "roundfp";       break;
1714      case lir_rtcall:                s = "rtcall";        break;
1715      case lir_throw:                 s = "throw";         break;
1716      case lir_unwind:                s = "unwind";        break;
1717      case lir_convert:               s = "convert";       break;
1718      case lir_alloc_object:          s = "alloc_obj";     break;
1719      case lir_monaddr:               s = "mon_addr";      break;
1720      // LIR_Op2

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






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


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

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






































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

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








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

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

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

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

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

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

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

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

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

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

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

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