< 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 {

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

 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 {
 340   if (code == lir_store_check) {
 341     _stub = new ArrayStoreExceptionStub(object, info_for_exception);
 342     assert(info_for_exception != NULL, "store_check throws exceptions");
 343   } else {
 344     ShouldNotReachHere();
 345   }
 346 }
 347 































 348 
 349 LIR_OpArrayCopy::LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length,
 350                                  LIR_Opr tmp, ciArrayKlass* expected_type, int flags, CodeEmitInfo* info)
 351   : LIR_Op(lir_arraycopy, LIR_OprFact::illegalOpr, info)
 352   , _src(src)
 353   , _src_pos(src_pos)
 354   , _dst(dst)
 355   , _dst_pos(dst_pos)
 356   , _length(length)
 357   , _tmp(tmp)
 358   , _expected_type(expected_type)
 359   , _flags(flags) {
 360   _stub = new ArrayCopyStub(this);
 361 }
 362 
 363 LIR_OpUpdateCRC32::LIR_OpUpdateCRC32(LIR_Opr crc, LIR_Opr val, LIR_Opr res)
 364   : LIR_Op(lir_updatecrc32, res, NULL)
 365   , _crc(crc)
 366   , _val(val) {
 367 }

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

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

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

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













































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

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











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

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




























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

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


















1044 void LIR_OpCompareAndSwap::emit_code(LIR_Assembler* masm) {
1045   masm->emit_compare_and_swap(this);
1046 }
1047 
1048 void LIR_Op3::emit_code(LIR_Assembler* masm) {
1049   masm->emit_op3(this);
1050 }
1051 
1052 void LIR_OpLock::emit_code(LIR_Assembler* masm) {
1053   masm->emit_lock(this);
1054   if (stub()) {
1055     masm->append_code_stub(stub());
1056   }



1057 }
1058 
1059 void LIR_OpLoadKlass::emit_code(LIR_Assembler* masm) {
1060   masm->emit_load_klass(this);
1061 }
1062 
1063 #ifdef ASSERT
1064 void LIR_OpAssert::emit_code(LIR_Assembler* masm) {
1065   masm->emit_assert(this);
1066 }
1067 #endif
1068 
1069 void LIR_OpDelay::emit_code(LIR_Assembler* masm) {
1070   masm->emit_delay(this);
1071 }
1072 
1073 void LIR_OpProfileCall::emit_code(LIR_Assembler* masm) {
1074   masm->emit_profile_call(this);
1075 }
1076 
1077 void LIR_OpProfileType::emit_code(LIR_Assembler* masm) {
1078   masm->emit_profile_type(this);
1079 }
1080 




1081 // LIR_List
1082 LIR_List::LIR_List(Compilation* compilation, BlockBegin* block)
1083   : _operations(8)
1084   , _compilation(compilation)
1085 #ifndef PRODUCT
1086   , _block(block)
1087 #endif
1088 #ifdef ASSERT
1089   , _file(NULL)
1090   , _line(0)
1091 #endif
1092 { }
1093 
1094 
1095 #ifdef ASSERT
1096 void LIR_List::set_file_and_line(const char * file, int line) {
1097   const char * f = strrchr(file, '/');
1098   if (f == NULL) f = strrchr(file, '\\');
1099   if (f == NULL) {
1100     f = file;

1342                     tmp));
1343 }
1344 
1345 
1346 void LIR_List::unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1347  append(new LIR_Op2(
1348                     lir_ushr,
1349                     value,
1350                     count,
1351                     dst,
1352                     tmp));
1353 }
1354 
1355 void LIR_List::fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less) {
1356   append(new LIR_Op2(is_unordered_less ? lir_ucmp_fd2i : lir_cmp_fd2i,
1357                      left,
1358                      right,
1359                      dst));
1360 }
1361 
1362 void LIR_List::lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info) {
1363   append(new LIR_OpLock(
1364                     lir_lock,
1365                     hdr,
1366                     obj,
1367                     lock,
1368                     scratch,
1369                     stub,
1370                     info));

1371 }
1372 
1373 void LIR_List::unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub) {
1374   append(new LIR_OpLock(
1375                     lir_unlock,
1376                     hdr,
1377                     obj,
1378                     lock,
1379                     scratch,
1380                     stub,
1381                     NULL));
1382 }
1383 
1384 
1385 void check_LIR() {
1386   // cannot do the proper checking as PRODUCT and other modes return different results
1387   // guarantee(sizeof(LIR_Opr) == wordSize, "may not have a v-table");
1388 }
1389 
1390 
1391 
1392 void LIR_List::checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
1393                           LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
1394                           CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
1395                           ciMethod* profiled_method, int profiled_bci) {



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

1398   if (profiled_method != NULL) {
1399     c->set_profiled_method(profiled_method);
1400     c->set_profiled_bci(profiled_bci);
1401     c->set_should_profile(true);
1402   }
1403   append(c);
1404 }
1405 
1406 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) {
1407   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_instanceof, result, object, klass, tmp1, tmp2, tmp3, fast_check, NULL, info_for_patch, NULL);
1408   if (profiled_method != NULL) {
1409     c->set_profiled_method(profiled_method);
1410     c->set_profiled_bci(profiled_bci);
1411     c->set_should_profile(true);
1412   }
1413   append(c);
1414 }
1415 
1416 
1417 void LIR_List::store_check(LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3,
1418                            CodeEmitInfo* info_for_exception, ciMethod* profiled_method, int profiled_bci) {

1419   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_store_check, object, array, tmp1, tmp2, tmp3, info_for_exception);
1420   if (profiled_method != NULL) {
1421     c->set_profiled_method(profiled_method);
1422     c->set_profiled_bci(profiled_bci);
1423     c->set_should_profile(true);
1424   }
1425   append(c);
1426 }
1427 
1428 void LIR_List::null_check(LIR_Opr opr, CodeEmitInfo* info, bool deoptimize_on_null) {
1429   if (deoptimize_on_null) {
1430     // Emit an explicit null check and deoptimize if opr is null
1431     CodeStub* deopt = new DeoptimizeStub(info, Deoptimization::Reason_null_check, Deoptimization::Action_none);
1432     cmp(lir_cond_equal, opr, LIR_OprFact::oopConst(NULL));
1433     branch(lir_cond_equal, deopt);
1434   } else {
1435     // Emit an implicit null check
1436     append(new LIR_Op1(lir_null_check, opr, info));
1437   }
1438 }
1439 





















1440 void LIR_List::cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1441                         LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1442   append(new LIR_OpCompareAndSwap(lir_cas_long, addr, cmp_value, new_value, t1, t2, result));
1443 }
1444 
1445 void LIR_List::cas_obj(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1446                        LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1447   append(new LIR_OpCompareAndSwap(lir_cas_obj, addr, cmp_value, new_value, t1, t2, result));
1448 }
1449 
1450 void LIR_List::cas_int(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1451                        LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1452   append(new LIR_OpCompareAndSwap(lir_cas_int, addr, cmp_value, new_value, t1, t2, result));
1453 }
1454 
1455 
1456 #ifdef PRODUCT
1457 
1458 void print_LIR(BlockList* blocks) {
1459 }

1636 
1637 const char * LIR_Op::name() const {
1638   const char* s = NULL;
1639   switch(code()) {
1640      // LIR_Op0
1641      case lir_membar:                s = "membar";        break;
1642      case lir_membar_acquire:        s = "membar_acquire"; break;
1643      case lir_membar_release:        s = "membar_release"; break;
1644      case lir_membar_loadload:       s = "membar_loadload";   break;
1645      case lir_membar_storestore:     s = "membar_storestore"; break;
1646      case lir_membar_loadstore:      s = "membar_loadstore";  break;
1647      case lir_membar_storeload:      s = "membar_storeload";  break;
1648      case lir_label:                 s = "label";         break;
1649      case lir_nop:                   s = "nop";           break;
1650      case lir_on_spin_wait:          s = "on_spin_wait";  break;
1651      case lir_std_entry:             s = "std_entry";     break;
1652      case lir_osr_entry:             s = "osr_entry";     break;
1653      case lir_fpop_raw:              s = "fpop_raw";      break;
1654      case lir_breakpoint:            s = "breakpoint";    break;
1655      case lir_get_thread:            s = "get_thread";    break;

1656      // LIR_Op1
1657      case lir_fxch:                  s = "fxch";          break;
1658      case lir_fld:                   s = "fld";           break;
1659      case lir_push:                  s = "push";          break;
1660      case lir_pop:                   s = "pop";           break;
1661      case lir_null_check:            s = "null_check";    break;
1662      case lir_return:                s = "return";        break;
1663      case lir_safepoint:             s = "safepoint";     break;
1664      case lir_leal:                  s = "leal";          break;
1665      case lir_branch:                s = "branch";        break;
1666      case lir_cond_float_branch:     s = "flt_cond_br";   break;
1667      case lir_move:                  s = "move";          break;
1668      case lir_roundfp:               s = "roundfp";       break;
1669      case lir_rtcall:                s = "rtcall";        break;
1670      case lir_throw:                 s = "throw";         break;
1671      case lir_unwind:                s = "unwind";        break;
1672      case lir_convert:               s = "convert";       break;
1673      case lir_alloc_object:          s = "alloc_obj";     break;
1674      case lir_monaddr:               s = "mon_addr";      break;
1675      // LIR_Op2

1701      case lir_fmad:                  s = "fmad";          break;
1702      case lir_fmaf:                  s = "fmaf";          break;
1703      // LIR_OpJavaCall
1704      case lir_static_call:           s = "static";        break;
1705      case lir_optvirtual_call:       s = "optvirtual";    break;
1706      case lir_icvirtual_call:        s = "icvirtual";     break;
1707      case lir_dynamic_call:          s = "dynamic";       break;
1708      // LIR_OpArrayCopy
1709      case lir_arraycopy:             s = "arraycopy";     break;
1710      // LIR_OpUpdateCRC32
1711      case lir_updatecrc32:           s = "updatecrc32";   break;
1712      // LIR_OpLock
1713      case lir_lock:                  s = "lock";          break;
1714      case lir_unlock:                s = "unlock";        break;
1715      // LIR_OpDelay
1716      case lir_delay_slot:            s = "delay";         break;
1717      // LIR_OpTypeCheck
1718      case lir_instanceof:            s = "instanceof";    break;
1719      case lir_checkcast:             s = "checkcast";     break;
1720      case lir_store_check:           s = "store_check";   break;






1721      // LIR_OpCompareAndSwap
1722      case lir_cas_long:              s = "cas_long";      break;
1723      case lir_cas_obj:               s = "cas_obj";      break;
1724      case lir_cas_int:               s = "cas_int";      break;
1725      // LIR_OpProfileCall
1726      case lir_profile_call:          s = "profile_call";  break;
1727      // LIR_OpProfileType
1728      case lir_profile_type:          s = "profile_type";  break;


1729      // LIR_OpAssert
1730 #ifdef ASSERT
1731      case lir_assert:                s = "assert";        break;
1732 #endif
1733      case lir_none:                  ShouldNotReachHere();break;
1734     default:                         s = "illegal_op";    break;
1735   }
1736   return s;
1737 }
1738 
1739 // LIR_OpJavaCall
1740 void LIR_OpJavaCall::print_instr(outputStream* out) const {
1741   out->print("call: ");
1742   out->print("[addr: " INTPTR_FORMAT "]", p2i(address()));
1743   if (receiver()->is_valid()) {
1744     out->print(" [recv: ");   receiver()->print(out);   out->print("]");
1745   }
1746   if (result_opr()->is_valid()) {
1747     out->print(" [result: "); result_opr()->print(out); out->print("]");
1748   }

1938   out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
1939 }
1940 
1941 
1942 void LIR_OpTypeCheck::print_instr(outputStream* out) const {
1943   object()->print(out);                  out->print(" ");
1944   if (code() == lir_store_check) {
1945     array()->print(out);                 out->print(" ");
1946   }
1947   if (code() != lir_store_check) {
1948     klass()->print_name_on(out);         out->print(" ");
1949     if (fast_check())                 out->print("fast_check ");
1950   }
1951   tmp1()->print(out);                    out->print(" ");
1952   tmp2()->print(out);                    out->print(" ");
1953   tmp3()->print(out);                    out->print(" ");
1954   result_opr()->print(out);              out->print(" ");
1955   if (info_for_exception() != NULL) out->print(" [bci:%d]", info_for_exception()->stack()->bci());
1956 }
1957 






































1958 
1959 // LIR_Op3
1960 void LIR_Op3::print_instr(outputStream* out) const {
1961   in_opr1()->print(out);    out->print(" ");
1962   in_opr2()->print(out);    out->print(" ");
1963   in_opr3()->print(out);    out->print(" ");
1964   result_opr()->print(out);
1965 }
1966 
1967 
1968 void LIR_OpLock::print_instr(outputStream* out) const {
1969   hdr_opr()->print(out);   out->print(" ");
1970   obj_opr()->print(out);   out->print(" ");
1971   lock_opr()->print(out);  out->print(" ");
1972   if (_scratch->is_valid()) {
1973     _scratch->print(out);  out->print(" ");
1974   }
1975   out->print("[lbl:" INTPTR_FORMAT "]", p2i(stub()->entry()));
1976 }
1977 

2004   mdo()->print(out);           out->print(" ");
2005   recv()->print(out);          out->print(" ");
2006   tmp1()->print(out);          out->print(" ");
2007 }
2008 
2009 // LIR_OpProfileType
2010 void LIR_OpProfileType::print_instr(outputStream* out) const {
2011   out->print("exact = ");
2012   if  (exact_klass() == NULL) {
2013     out->print("unknown");
2014   } else {
2015     exact_klass()->print_name_on(out);
2016   }
2017   out->print(" current = "); ciTypeEntries::print_ciklass(out, current_klass());
2018   out->print(" ");
2019   mdp()->print(out);          out->print(" ");
2020   obj()->print(out);          out->print(" ");
2021   tmp()->print(out);          out->print(" ");
2022 }
2023 








2024 #endif // PRODUCT
2025 
2026 // Implementation of LIR_InsertionBuffer
2027 
2028 void LIR_InsertionBuffer::append(int index, LIR_Op* op) {
2029   assert(_index_and_count.length() % 2 == 0, "must have a count for each index");
2030 
2031   int i = number_of_insertion_points() - 1;
2032   if (i < 0 || index_at(i) < index) {
2033     append_new(index, 1);
2034   } else {
2035     assert(index_at(i) == index, "can append LIR_Ops in ascending order only");
2036     assert(count_at(i) > 0, "check");
2037     set_count_at(i, count_at(i) + 1);
2038   }
2039   _ops.push(op);
2040 
2041   DEBUG_ONLY(verify());
2042 }
2043 

  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 {

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

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

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

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

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

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

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

1810 
1811 const char * LIR_Op::name() const {
1812   const char* s = NULL;
1813   switch(code()) {
1814      // LIR_Op0
1815      case lir_membar:                s = "membar";        break;
1816      case lir_membar_acquire:        s = "membar_acquire"; break;
1817      case lir_membar_release:        s = "membar_release"; break;
1818      case lir_membar_loadload:       s = "membar_loadload";   break;
1819      case lir_membar_storestore:     s = "membar_storestore"; break;
1820      case lir_membar_loadstore:      s = "membar_loadstore";  break;
1821      case lir_membar_storeload:      s = "membar_storeload";  break;
1822      case lir_label:                 s = "label";         break;
1823      case lir_nop:                   s = "nop";           break;
1824      case lir_on_spin_wait:          s = "on_spin_wait";  break;
1825      case lir_std_entry:             s = "std_entry";     break;
1826      case lir_osr_entry:             s = "osr_entry";     break;
1827      case lir_fpop_raw:              s = "fpop_raw";      break;
1828      case lir_breakpoint:            s = "breakpoint";    break;
1829      case lir_get_thread:            s = "get_thread";    break;
1830      case lir_check_orig_pc:         s = "check_orig_pc"; break;
1831      // LIR_Op1
1832      case lir_fxch:                  s = "fxch";          break;
1833      case lir_fld:                   s = "fld";           break;
1834      case lir_push:                  s = "push";          break;
1835      case lir_pop:                   s = "pop";           break;
1836      case lir_null_check:            s = "null_check";    break;
1837      case lir_return:                s = "return";        break;
1838      case lir_safepoint:             s = "safepoint";     break;
1839      case lir_leal:                  s = "leal";          break;
1840      case lir_branch:                s = "branch";        break;
1841      case lir_cond_float_branch:     s = "flt_cond_br";   break;
1842      case lir_move:                  s = "move";          break;
1843      case lir_roundfp:               s = "roundfp";       break;
1844      case lir_rtcall:                s = "rtcall";        break;
1845      case lir_throw:                 s = "throw";         break;
1846      case lir_unwind:                s = "unwind";        break;
1847      case lir_convert:               s = "convert";       break;
1848      case lir_alloc_object:          s = "alloc_obj";     break;
1849      case lir_monaddr:               s = "mon_addr";      break;
1850      // LIR_Op2

1876      case lir_fmad:                  s = "fmad";          break;
1877      case lir_fmaf:                  s = "fmaf";          break;
1878      // LIR_OpJavaCall
1879      case lir_static_call:           s = "static";        break;
1880      case lir_optvirtual_call:       s = "optvirtual";    break;
1881      case lir_icvirtual_call:        s = "icvirtual";     break;
1882      case lir_dynamic_call:          s = "dynamic";       break;
1883      // LIR_OpArrayCopy
1884      case lir_arraycopy:             s = "arraycopy";     break;
1885      // LIR_OpUpdateCRC32
1886      case lir_updatecrc32:           s = "updatecrc32";   break;
1887      // LIR_OpLock
1888      case lir_lock:                  s = "lock";          break;
1889      case lir_unlock:                s = "unlock";        break;
1890      // LIR_OpDelay
1891      case lir_delay_slot:            s = "delay";         break;
1892      // LIR_OpTypeCheck
1893      case lir_instanceof:            s = "instanceof";    break;
1894      case lir_checkcast:             s = "checkcast";     break;
1895      case lir_store_check:           s = "store_check";   break;
1896      // LIR_OpFlattenedArrayCheck
1897      case lir_flattened_array_check: s = "flattened_array_check"; break;
1898      // LIR_OpNullFreeArrayCheck
1899      case lir_null_free_array_check: s = "null_free_array_check"; break;
1900      // LIR_OpSubstitutabilityCheck
1901      case lir_substitutability_check: s = "substitutability_check"; break;
1902      // LIR_OpCompareAndSwap
1903      case lir_cas_long:              s = "cas_long";      break;
1904      case lir_cas_obj:               s = "cas_obj";      break;
1905      case lir_cas_int:               s = "cas_int";      break;
1906      // LIR_OpProfileCall
1907      case lir_profile_call:          s = "profile_call";  break;
1908      // LIR_OpProfileType
1909      case lir_profile_type:          s = "profile_type";  break;
1910      // LIR_OpProfileInlineType
1911      case lir_profile_inline_type:   s = "profile_inline_type"; break;
1912      // LIR_OpAssert
1913 #ifdef ASSERT
1914      case lir_assert:                s = "assert";        break;
1915 #endif
1916      case lir_none:                  ShouldNotReachHere();break;
1917     default:                         s = "illegal_op";    break;
1918   }
1919   return s;
1920 }
1921 
1922 // LIR_OpJavaCall
1923 void LIR_OpJavaCall::print_instr(outputStream* out) const {
1924   out->print("call: ");
1925   out->print("[addr: " INTPTR_FORMAT "]", p2i(address()));
1926   if (receiver()->is_valid()) {
1927     out->print(" [recv: ");   receiver()->print(out);   out->print("]");
1928   }
1929   if (result_opr()->is_valid()) {
1930     out->print(" [result: "); result_opr()->print(out); out->print("]");
1931   }

2121   out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2122 }
2123 
2124 
2125 void LIR_OpTypeCheck::print_instr(outputStream* out) const {
2126   object()->print(out);                  out->print(" ");
2127   if (code() == lir_store_check) {
2128     array()->print(out);                 out->print(" ");
2129   }
2130   if (code() != lir_store_check) {
2131     klass()->print_name_on(out);         out->print(" ");
2132     if (fast_check())                 out->print("fast_check ");
2133   }
2134   tmp1()->print(out);                    out->print(" ");
2135   tmp2()->print(out);                    out->print(" ");
2136   tmp3()->print(out);                    out->print(" ");
2137   result_opr()->print(out);              out->print(" ");
2138   if (info_for_exception() != NULL) out->print(" [bci:%d]", info_for_exception()->stack()->bci());
2139 }
2140 
2141 void LIR_OpFlattenedArrayCheck::print_instr(outputStream* out) const {
2142   array()->print(out);                   out->print(" ");
2143   value()->print(out);                   out->print(" ");
2144   tmp()->print(out);                     out->print(" ");
2145   if (stub() != NULL) {
2146     out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2147   }
2148 }
2149 
2150 void LIR_OpNullFreeArrayCheck::print_instr(outputStream* out) const {
2151   array()->print(out);                   out->print(" ");
2152   tmp()->print(out);                     out->print(" ");
2153 }
2154 
2155 void LIR_OpSubstitutabilityCheck::print_instr(outputStream* out) const {
2156   result_opr()->print(out);              out->print(" ");
2157   left()->print(out);                    out->print(" ");
2158   right()->print(out);                   out->print(" ");
2159   equal_result()->print(out);            out->print(" ");
2160   not_equal_result()->print(out);        out->print(" ");
2161   tmp1()->print(out);                    out->print(" ");
2162   tmp2()->print(out);                    out->print(" ");
2163   if (left_klass() == NULL) {
2164     out->print("unknown ");
2165   } else {
2166     left_klass()->print(out);            out->print(" ");
2167   }
2168   if (right_klass() == NULL) {
2169     out->print("unknown ");
2170   } else {
2171     right_klass()->print(out);           out->print(" ");
2172   }
2173   left_klass_op()->print(out);           out->print(" ");
2174   right_klass_op()->print(out);          out->print(" ");
2175   if (stub() != NULL) {
2176     out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2177   }
2178 }
2179 
2180 // LIR_Op3
2181 void LIR_Op3::print_instr(outputStream* out) const {
2182   in_opr1()->print(out);    out->print(" ");
2183   in_opr2()->print(out);    out->print(" ");
2184   in_opr3()->print(out);    out->print(" ");
2185   result_opr()->print(out);
2186 }
2187 
2188 
2189 void LIR_OpLock::print_instr(outputStream* out) const {
2190   hdr_opr()->print(out);   out->print(" ");
2191   obj_opr()->print(out);   out->print(" ");
2192   lock_opr()->print(out);  out->print(" ");
2193   if (_scratch->is_valid()) {
2194     _scratch->print(out);  out->print(" ");
2195   }
2196   out->print("[lbl:" INTPTR_FORMAT "]", p2i(stub()->entry()));
2197 }
2198 

2225   mdo()->print(out);           out->print(" ");
2226   recv()->print(out);          out->print(" ");
2227   tmp1()->print(out);          out->print(" ");
2228 }
2229 
2230 // LIR_OpProfileType
2231 void LIR_OpProfileType::print_instr(outputStream* out) const {
2232   out->print("exact = ");
2233   if  (exact_klass() == NULL) {
2234     out->print("unknown");
2235   } else {
2236     exact_klass()->print_name_on(out);
2237   }
2238   out->print(" current = "); ciTypeEntries::print_ciklass(out, current_klass());
2239   out->print(" ");
2240   mdp()->print(out);          out->print(" ");
2241   obj()->print(out);          out->print(" ");
2242   tmp()->print(out);          out->print(" ");
2243 }
2244 
2245 // LIR_OpProfileInlineType
2246 void LIR_OpProfileInlineType::print_instr(outputStream* out) const {
2247   out->print(" flag = %x ", flag());
2248   mdp()->print(out);          out->print(" ");
2249   obj()->print(out);          out->print(" ");
2250   tmp()->print(out);          out->print(" ");
2251 }
2252 
2253 #endif // PRODUCT
2254 
2255 // Implementation of LIR_InsertionBuffer
2256 
2257 void LIR_InsertionBuffer::append(int index, LIR_Op* op) {
2258   assert(_index_and_count.length() % 2 == 0, "must have a count for each index");
2259 
2260   int i = number_of_insertion_points() - 1;
2261   if (i < 0 || index_at(i) < index) {
2262     append_new(index, 1);
2263   } else {
2264     assert(index_at(i) == index, "can append LIR_Ops in ascending order only");
2265     assert(count_at(i) > 0, "check");
2266     set_count_at(i, count_at(i) + 1);
2267   }
2268   _ops.push(op);
2269 
2270   DEBUG_ONLY(verify());
2271 }
2272 
< prev index next >