< 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_OprDesc::as_register() const {
  37   return FrameMap::cpu_rnr2reg(cpu_regnr());
  38 }
  39 
  40 Register LIR_OprDesc::as_register_lo() const {
  41   return FrameMap::cpu_rnr2reg(cpu_regnrLo());
  42 }
  43 
  44 Register LIR_OprDesc::as_register_hi() const {
  45   return FrameMap::cpu_rnr2reg(cpu_regnrHi());
  46 }
  47 
  48 LIR_Opr LIR_OprFact::illegalOpr = LIR_OprFact::illegal();
  49 
  50 LIR_Opr LIR_OprFact::value_type(ValueType* type) {

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

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

 136              ARM_ONLY(|| kindfield == cpu_register)
 137              PPC32_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 and PPC32 (softfp ABI)
 142       assert((kindfield == fpu_register || kindfield == stack_value
 143              ARM_ONLY(|| kindfield == cpu_register)
 144              PPC32_ONLY(|| kindfield == cpu_register) ) &&
 145              size_field() == double_size, "must match");
 146       break;
 147     case T_BOOLEAN:
 148     case T_CHAR:
 149     case T_BYTE:
 150     case T_SHORT:
 151     case T_INT:
 152     case T_ADDRESS:
 153     case T_OBJECT:
 154     case T_METADATA:
 155     case T_ARRAY:

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

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

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

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

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

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

 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);

 883     case lir_profile_call: {
 884       assert(op->as_OpProfileCall() != NULL, "must be");
 885       LIR_OpProfileCall* opProfileCall = (LIR_OpProfileCall*)op;
 886 
 887       if (opProfileCall->_recv->is_valid())              do_temp(opProfileCall->_recv);
 888       assert(opProfileCall->_mdo->is_valid(), "used");   do_temp(opProfileCall->_mdo);
 889       assert(opProfileCall->_tmp1->is_valid(), "used");  do_temp(opProfileCall->_tmp1);
 890       break;
 891     }
 892 
 893 // LIR_OpProfileType:
 894     case lir_profile_type: {
 895       assert(op->as_OpProfileType() != NULL, "must be");
 896       LIR_OpProfileType* opProfileType = (LIR_OpProfileType*)op;
 897 
 898       do_input(opProfileType->_mdp); do_temp(opProfileType->_mdp);
 899       do_input(opProfileType->_obj);
 900       do_temp(opProfileType->_tmp);
 901       break;
 902     }
 903   default:











 904     op->visit(this);
 905   }
 906 }
 907 
 908 void LIR_Op::visit(LIR_OpVisitState* state) {
 909   ShouldNotReachHere();
 910 }
 911 
 912 void LIR_OpVisitState::do_stub(CodeStub* stub) {
 913   if (stub != NULL) {
 914     stub->visit(this);
 915   }
 916 }
 917 
 918 XHandlers* LIR_OpVisitState::all_xhandler() {
 919   XHandlers* result = NULL;
 920 
 921   int i;
 922   for (i = 0; i < info_count(); i++) {
 923     if (info_at(i)->exception_handlers() != NULL) {

 956          !has_slow_case();
 957 }
 958 #endif
 959 
 960 // LIR_OpReturn
 961 LIR_OpReturn::LIR_OpReturn(LIR_Opr opr) :
 962     LIR_Op1(lir_return, opr, (CodeEmitInfo*)NULL /* info */),
 963     _stub(NULL) {
 964   if (VM_Version::supports_stack_watermark_barrier()) {
 965     _stub = new C1SafepointPollStub();
 966   }
 967 }
 968 
 969 //---------------------------------------------------
 970 
 971 
 972 void LIR_OpJavaCall::emit_code(LIR_Assembler* masm) {
 973   masm->emit_call(this);
 974 }
 975 




























 976 void LIR_OpRTCall::emit_code(LIR_Assembler* masm) {
 977   masm->emit_rtcall(this);
 978 }
 979 
 980 void LIR_OpLabel::emit_code(LIR_Assembler* masm) {
 981   masm->emit_opLabel(this);
 982 }
 983 
 984 void LIR_OpArrayCopy::emit_code(LIR_Assembler* masm) {
 985   masm->emit_arraycopy(this);
 986   masm->append_code_stub(stub());
 987 }
 988 
 989 void LIR_OpUpdateCRC32::emit_code(LIR_Assembler* masm) {
 990   masm->emit_updatecrc32(this);
 991 }
 992 
 993 void LIR_Op0::emit_code(LIR_Assembler* masm) {
 994   masm->emit_op0(this);
 995 }

1016     masm->append_code_stub(stub());
1017   }
1018 }
1019 
1020 void LIR_Op2::emit_code(LIR_Assembler* masm) {
1021   masm->emit_op2(this);
1022 }
1023 
1024 void LIR_OpAllocArray::emit_code(LIR_Assembler* masm) {
1025   masm->emit_alloc_array(this);
1026   masm->append_code_stub(stub());
1027 }
1028 
1029 void LIR_OpTypeCheck::emit_code(LIR_Assembler* masm) {
1030   masm->emit_opTypeCheck(this);
1031   if (stub()) {
1032     masm->append_code_stub(stub());
1033   }
1034 }
1035 


















1036 void LIR_OpCompareAndSwap::emit_code(LIR_Assembler* masm) {
1037   masm->emit_compare_and_swap(this);
1038 }
1039 
1040 void LIR_Op3::emit_code(LIR_Assembler* masm) {
1041   masm->emit_op3(this);
1042 }
1043 
1044 void LIR_OpLock::emit_code(LIR_Assembler* masm) {
1045   masm->emit_lock(this);
1046   if (stub()) {
1047     masm->append_code_stub(stub());
1048   }



1049 }
1050 
1051 #ifdef ASSERT
1052 void LIR_OpAssert::emit_code(LIR_Assembler* masm) {
1053   masm->emit_assert(this);
1054 }
1055 #endif
1056 
1057 void LIR_OpDelay::emit_code(LIR_Assembler* masm) {
1058   masm->emit_delay(this);
1059 }
1060 
1061 void LIR_OpProfileCall::emit_code(LIR_Assembler* masm) {
1062   masm->emit_profile_call(this);
1063 }
1064 
1065 void LIR_OpProfileType::emit_code(LIR_Assembler* masm) {
1066   masm->emit_profile_type(this);
1067 }
1068 




1069 // LIR_List
1070 LIR_List::LIR_List(Compilation* compilation, BlockBegin* block)
1071   : _operations(8)
1072   , _compilation(compilation)
1073 #ifndef PRODUCT
1074   , _block(block)
1075 #endif
1076 #ifdef ASSERT
1077   , _file(NULL)
1078   , _line(0)
1079 #endif
1080 { }
1081 
1082 
1083 #ifdef ASSERT
1084 void LIR_List::set_file_and_line(const char * file, int line) {
1085   const char * f = strrchr(file, '/');
1086   if (f == NULL) f = strrchr(file, '\\');
1087   if (f == NULL) {
1088     f = file;

1330                     tmp));
1331 }
1332 
1333 
1334 void LIR_List::unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp) {
1335  append(new LIR_Op2(
1336                     lir_ushr,
1337                     value,
1338                     count,
1339                     dst,
1340                     tmp));
1341 }
1342 
1343 void LIR_List::fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less) {
1344   append(new LIR_Op2(is_unordered_less ? lir_ucmp_fd2i : lir_cmp_fd2i,
1345                      left,
1346                      right,
1347                      dst));
1348 }
1349 
1350 void LIR_List::lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info) {
1351   append(new LIR_OpLock(
1352                     lir_lock,
1353                     hdr,
1354                     obj,
1355                     lock,
1356                     scratch,
1357                     stub,
1358                     info));

1359 }
1360 
1361 void LIR_List::unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub) {
1362   append(new LIR_OpLock(
1363                     lir_unlock,
1364                     hdr,
1365                     obj,
1366                     lock,
1367                     scratch,
1368                     stub,
1369                     NULL));
1370 }
1371 
1372 
1373 void check_LIR() {
1374   // cannot do the proper checking as PRODUCT and other modes return different results
1375   // guarantee(sizeof(LIR_OprDesc) == wordSize, "may not have a v-table");
1376 }
1377 
1378 
1379 
1380 void LIR_List::checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
1381                           LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
1382                           CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
1383                           ciMethod* profiled_method, int profiled_bci) {



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

1386   if (profiled_method != NULL) {
1387     c->set_profiled_method(profiled_method);
1388     c->set_profiled_bci(profiled_bci);
1389     c->set_should_profile(true);
1390   }
1391   append(c);
1392 }
1393 
1394 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) {
1395   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_instanceof, result, object, klass, tmp1, tmp2, tmp3, fast_check, NULL, info_for_patch, NULL);
1396   if (profiled_method != NULL) {
1397     c->set_profiled_method(profiled_method);
1398     c->set_profiled_bci(profiled_bci);
1399     c->set_should_profile(true);
1400   }
1401   append(c);
1402 }
1403 
1404 
1405 void LIR_List::store_check(LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3,
1406                            CodeEmitInfo* info_for_exception, ciMethod* profiled_method, int profiled_bci) {

1407   LIR_OpTypeCheck* c = new LIR_OpTypeCheck(lir_store_check, object, array, tmp1, tmp2, tmp3, info_for_exception);
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 void LIR_List::null_check(LIR_Opr opr, CodeEmitInfo* info, bool deoptimize_on_null) {
1417   if (deoptimize_on_null) {
1418     // Emit an explicit null check and deoptimize if opr is null
1419     CodeStub* deopt = new DeoptimizeStub(info, Deoptimization::Reason_null_check, Deoptimization::Action_none);
1420     cmp(lir_cond_equal, opr, LIR_OprFact::oopConst(NULL));
1421     branch(lir_cond_equal, deopt);
1422   } else {
1423     // Emit an implicit null check
1424     append(new LIR_Op1(lir_null_check, opr, info));
1425   }
1426 }
1427 





















1428 void LIR_List::cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1429                         LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1430   append(new LIR_OpCompareAndSwap(lir_cas_long, addr, cmp_value, new_value, t1, t2, result));
1431 }
1432 
1433 void LIR_List::cas_obj(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1434                        LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1435   append(new LIR_OpCompareAndSwap(lir_cas_obj, addr, cmp_value, new_value, t1, t2, result));
1436 }
1437 
1438 void LIR_List::cas_int(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1439                        LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1440   append(new LIR_OpCompareAndSwap(lir_cas_int, addr, cmp_value, new_value, t1, t2, result));
1441 }
1442 
1443 
1444 #ifdef PRODUCT
1445 
1446 void print_LIR(BlockList* blocks) {
1447 }

1624 
1625 const char * LIR_Op::name() const {
1626   const char* s = NULL;
1627   switch(code()) {
1628      // LIR_Op0
1629      case lir_membar:                s = "membar";        break;
1630      case lir_membar_acquire:        s = "membar_acquire"; break;
1631      case lir_membar_release:        s = "membar_release"; break;
1632      case lir_membar_loadload:       s = "membar_loadload";   break;
1633      case lir_membar_storestore:     s = "membar_storestore"; break;
1634      case lir_membar_loadstore:      s = "membar_loadstore";  break;
1635      case lir_membar_storeload:      s = "membar_storeload";  break;
1636      case lir_label:                 s = "label";         break;
1637      case lir_nop:                   s = "nop";           break;
1638      case lir_on_spin_wait:          s = "on_spin_wait";  break;
1639      case lir_std_entry:             s = "std_entry";     break;
1640      case lir_osr_entry:             s = "osr_entry";     break;
1641      case lir_fpop_raw:              s = "fpop_raw";      break;
1642      case lir_breakpoint:            s = "breakpoint";    break;
1643      case lir_get_thread:            s = "get_thread";    break;

1644      // LIR_Op1
1645      case lir_fxch:                  s = "fxch";          break;
1646      case lir_fld:                   s = "fld";           break;
1647      case lir_push:                  s = "push";          break;
1648      case lir_pop:                   s = "pop";           break;
1649      case lir_null_check:            s = "null_check";    break;
1650      case lir_return:                s = "return";        break;
1651      case lir_safepoint:             s = "safepoint";     break;
1652      case lir_leal:                  s = "leal";          break;
1653      case lir_branch:                s = "branch";        break;
1654      case lir_cond_float_branch:     s = "flt_cond_br";   break;
1655      case lir_move:                  s = "move";          break;
1656      case lir_roundfp:               s = "roundfp";       break;
1657      case lir_rtcall:                s = "rtcall";        break;
1658      case lir_throw:                 s = "throw";         break;
1659      case lir_unwind:                s = "unwind";        break;
1660      case lir_convert:               s = "convert";       break;
1661      case lir_alloc_object:          s = "alloc_obj";     break;
1662      case lir_monaddr:               s = "mon_addr";      break;
1663      // LIR_Op2

1689      case lir_fmad:                  s = "fmad";          break;
1690      case lir_fmaf:                  s = "fmaf";          break;
1691      // LIR_OpJavaCall
1692      case lir_static_call:           s = "static";        break;
1693      case lir_optvirtual_call:       s = "optvirtual";    break;
1694      case lir_icvirtual_call:        s = "icvirtual";     break;
1695      case lir_dynamic_call:          s = "dynamic";       break;
1696      // LIR_OpArrayCopy
1697      case lir_arraycopy:             s = "arraycopy";     break;
1698      // LIR_OpUpdateCRC32
1699      case lir_updatecrc32:           s = "updatecrc32";   break;
1700      // LIR_OpLock
1701      case lir_lock:                  s = "lock";          break;
1702      case lir_unlock:                s = "unlock";        break;
1703      // LIR_OpDelay
1704      case lir_delay_slot:            s = "delay";         break;
1705      // LIR_OpTypeCheck
1706      case lir_instanceof:            s = "instanceof";    break;
1707      case lir_checkcast:             s = "checkcast";     break;
1708      case lir_store_check:           s = "store_check";   break;






1709      // LIR_OpCompareAndSwap
1710      case lir_cas_long:              s = "cas_long";      break;
1711      case lir_cas_obj:               s = "cas_obj";      break;
1712      case lir_cas_int:               s = "cas_int";      break;
1713      // LIR_OpProfileCall
1714      case lir_profile_call:          s = "profile_call";  break;
1715      // LIR_OpProfileType
1716      case lir_profile_type:          s = "profile_type";  break;


1717      // LIR_OpAssert
1718 #ifdef ASSERT
1719      case lir_assert:                s = "assert";        break;
1720 #endif
1721      case lir_none:                  ShouldNotReachHere();break;
1722     default:                         s = "illegal_op";    break;
1723   }
1724   return s;
1725 }
1726 
1727 // LIR_OpJavaCall
1728 void LIR_OpJavaCall::print_instr(outputStream* out) const {
1729   out->print("call: ");
1730   out->print("[addr: " INTPTR_FORMAT "]", p2i(address()));
1731   if (receiver()->is_valid()) {
1732     out->print(" [recv: ");   receiver()->print(out);   out->print("]");
1733   }
1734   if (result_opr()->is_valid()) {
1735     out->print(" [result: "); result_opr()->print(out); out->print("]");
1736   }

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






































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

1993   mdo()->print(out);           out->print(" ");
1994   recv()->print(out);          out->print(" ");
1995   tmp1()->print(out);          out->print(" ");
1996 }
1997 
1998 // LIR_OpProfileType
1999 void LIR_OpProfileType::print_instr(outputStream* out) const {
2000   out->print("exact = ");
2001   if  (exact_klass() == NULL) {
2002     out->print("unknown");
2003   } else {
2004     exact_klass()->print_name_on(out);
2005   }
2006   out->print(" current = "); ciTypeEntries::print_ciklass(out, current_klass());
2007   out->print(" ");
2008   mdp()->print(out);          out->print(" ");
2009   obj()->print(out);          out->print(" ");
2010   tmp()->print(out);          out->print(" ");
2011 }
2012 








2013 #endif // PRODUCT
2014 
2015 // Implementation of LIR_InsertionBuffer
2016 
2017 void LIR_InsertionBuffer::append(int index, LIR_Op* op) {
2018   assert(_index_and_count.length() % 2 == 0, "must have a count for each index");
2019 
2020   int i = number_of_insertion_points() - 1;
2021   if (i < 0 || index_at(i) < index) {
2022     append_new(index, 1);
2023   } else {
2024     assert(index_at(i) == index, "can append LIR_Ops in ascending order only");
2025     assert(count_at(i) > 0, "check");
2026     set_count_at(i, count_at(i) + 1);
2027   }
2028   _ops.push(op);
2029 
2030   DEBUG_ONLY(verify());
2031 }
2032 

  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_OprDesc::as_register() const {
  38   return FrameMap::cpu_rnr2reg(cpu_regnr());
  39 }
  40 
  41 Register LIR_OprDesc::as_register_lo() const {
  42   return FrameMap::cpu_rnr2reg(cpu_regnrLo());
  43 }
  44 
  45 Register LIR_OprDesc::as_register_hi() const {
  46   return FrameMap::cpu_rnr2reg(cpu_regnrHi());
  47 }
  48 
  49 LIR_Opr LIR_OprFact::illegalOpr = LIR_OprFact::illegal();
  50 
  51 LIR_Opr LIR_OprFact::value_type(ValueType* type) {

  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_OprDesc::type_char(BasicType t) {
  97   switch (t) {
  98     case T_ARRAY:
  99     case T_INLINE_TYPE:
 100       t = T_OBJECT;
 101     case T_BOOLEAN:
 102     case T_CHAR:
 103     case T_FLOAT:
 104     case T_DOUBLE:
 105     case T_BYTE:
 106     case T_SHORT:
 107     case T_INT:
 108     case T_LONG:
 109     case T_OBJECT:
 110     case T_ADDRESS:
 111     case T_VOID:
 112       return ::type2char(t);
 113     case T_METADATA:
 114       return 'M';
 115     case T_ILLEGAL:
 116       return '?';
 117 
 118     default:
 119       ShouldNotReachHere();

 138              ARM_ONLY(|| kindfield == cpu_register)
 139              PPC32_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 and PPC32 (softfp ABI)
 144       assert((kindfield == fpu_register || kindfield == stack_value
 145              ARM_ONLY(|| kindfield == cpu_register)
 146              PPC32_ONLY(|| kindfield == cpu_register) ) &&
 147              size_field() == double_size, "must match");
 148       break;
 149     case T_BOOLEAN:
 150     case T_CHAR:
 151     case T_BYTE:
 152     case T_SHORT:
 153     case T_INT:
 154     case T_ADDRESS:
 155     case T_OBJECT:
 156     case T_METADATA:
 157     case T_ARRAY:
 158     case T_INLINE_TYPE:
 159       assert((kindfield == cpu_register || kindfield == stack_value) &&
 160              size_field() == single_size, "must match");
 161       break;
 162 
 163     case T_ILLEGAL:
 164       // XXX TKR also means unknown right now
 165       // assert(is_illegal(), "must match");
 166       break;
 167 
 168     default:
 169       ShouldNotReachHere();
 170     }
 171   }
 172 #endif
 173 
 174 }
 175 #endif // PRODUCT
 176 
 177 
 178 bool LIR_OprDesc::is_oop() const {

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

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

 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);

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

1050          !has_slow_case();
1051 }
1052 #endif
1053 
1054 // LIR_OpReturn
1055 LIR_OpReturn::LIR_OpReturn(LIR_Opr opr) :
1056     LIR_Op1(lir_return, opr, (CodeEmitInfo*)NULL /* info */),
1057     _stub(NULL) {
1058   if (VM_Version::supports_stack_watermark_barrier()) {
1059     _stub = new C1SafepointPollStub();
1060   }
1061 }
1062 
1063 //---------------------------------------------------
1064 
1065 
1066 void LIR_OpJavaCall::emit_code(LIR_Assembler* masm) {
1067   masm->emit_call(this);
1068 }
1069 
1070 bool LIR_OpJavaCall::maybe_return_as_fields(ciInlineKlass** vk_ret) const {
1071   if (InlineTypeReturnedAsFields &&
1072       (method()->signature()->returns_null_free_inline_type() ||
1073        method()->is_method_handle_intrinsic())) {
1074     ciType* return_type = method()->return_type();
1075     if (return_type->is_inlinetype()) {
1076       ciInlineKlass* vk = return_type->as_inline_klass();
1077       if (vk->can_be_returned_as_fields()) {
1078         if (vk_ret != NULL) {
1079           *vk_ret = vk;
1080         }
1081         return true;
1082       }
1083     } else if (return_type->is_instance_klass()) {
1084       // An inline type might be returned from the call but we don't know its
1085       // type. Either we get a buffered inline type (and nothing needs to be done)
1086       // or one of the inlines being returned is the klass of the inline type
1087       // (RAX on x64, with LSB set to 1) and we need to allocate an inline
1088       // type instance of that type and initialize it with other values being
1089       // returned (in other registers).
1090       assert(!return_type->as_instance_klass()->is_loaded() ||
1091              method()->is_method_handle_intrinsic(), "unexpected return type");
1092       return true;
1093     }
1094   }
1095   return false;
1096 }
1097 
1098 void LIR_OpRTCall::emit_code(LIR_Assembler* masm) {
1099   masm->emit_rtcall(this);
1100 }
1101 
1102 void LIR_OpLabel::emit_code(LIR_Assembler* masm) {
1103   masm->emit_opLabel(this);
1104 }
1105 
1106 void LIR_OpArrayCopy::emit_code(LIR_Assembler* masm) {
1107   masm->emit_arraycopy(this);
1108   masm->append_code_stub(stub());
1109 }
1110 
1111 void LIR_OpUpdateCRC32::emit_code(LIR_Assembler* masm) {
1112   masm->emit_updatecrc32(this);
1113 }
1114 
1115 void LIR_Op0::emit_code(LIR_Assembler* masm) {
1116   masm->emit_op0(this);
1117 }

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

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

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

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

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

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