< prev index next >

src/hotspot/share/c1/c1_LIR.cpp

Print this page


   1 /*
   2  * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "c1/c1_InstructionPrinter.hpp"
  27 #include "c1/c1_LIR.hpp"
  28 #include "c1/c1_LIRAssembler.hpp"
  29 #include "c1/c1_ValueStack.hpp"
  30 #include "ci/ciInstance.hpp"

  31 #include "runtime/sharedRuntime.hpp"
  32 
  33 Register LIR_OprDesc::as_register() const {
  34   return FrameMap::cpu_rnr2reg(cpu_regnr());
  35 }
  36 
  37 Register LIR_OprDesc::as_register_lo() const {
  38   return FrameMap::cpu_rnr2reg(cpu_regnrLo());
  39 }
  40 
  41 Register LIR_OprDesc::as_register_hi() const {
  42   return FrameMap::cpu_rnr2reg(cpu_regnrHi());
  43 }
  44 
  45 LIR_Opr LIR_OprFact::illegalOpr = LIR_OprFact::illegal();
  46 
  47 LIR_Opr LIR_OprFact::value_type(ValueType* type) {
  48   ValueTag tag = type->tag();
  49   switch (tag) {
  50   case metaDataTag : {


  90 //---------------------------------------------------
  91 
  92 
  93 LIR_Address::Scale LIR_Address::scale(BasicType type) {
  94   int elem_size = type2aelembytes(type);
  95   switch (elem_size) {
  96   case 1: return LIR_Address::times_1;
  97   case 2: return LIR_Address::times_2;
  98   case 4: return LIR_Address::times_4;
  99   case 8: return LIR_Address::times_8;
 100   }
 101   ShouldNotReachHere();
 102   return LIR_Address::times_1;
 103 }
 104 
 105 //---------------------------------------------------
 106 
 107 char LIR_OprDesc::type_char(BasicType t) {
 108   switch (t) {
 109     case T_ARRAY:

 110       t = T_OBJECT;
 111     case T_BOOLEAN:
 112     case T_CHAR:
 113     case T_FLOAT:
 114     case T_DOUBLE:
 115     case T_BYTE:
 116     case T_SHORT:
 117     case T_INT:
 118     case T_LONG:
 119     case T_OBJECT:
 120     case T_ADDRESS:
 121     case T_VOID:
 122       return ::type2char(t);
 123     case T_METADATA:
 124       return 'M';
 125     case T_ILLEGAL:
 126       return '?';
 127 
 128     default:
 129       ShouldNotReachHere();


 148              ARM_ONLY(|| kindfield == cpu_register)
 149              PPC32_ONLY(|| kindfield == cpu_register) ) &&
 150              size_field() == single_size, "must match");
 151       break;
 152     case T_DOUBLE:
 153       // FP return values can be also in CPU registers on ARM and PPC32 (softfp ABI)
 154       assert((kindfield == fpu_register || kindfield == stack_value
 155              ARM_ONLY(|| kindfield == cpu_register)
 156              PPC32_ONLY(|| kindfield == cpu_register) ) &&
 157              size_field() == double_size, "must match");
 158       break;
 159     case T_BOOLEAN:
 160     case T_CHAR:
 161     case T_BYTE:
 162     case T_SHORT:
 163     case T_INT:
 164     case T_ADDRESS:
 165     case T_OBJECT:
 166     case T_METADATA:
 167     case T_ARRAY:

 168       assert((kindfield == cpu_register || kindfield == stack_value) &&
 169              size_field() == single_size, "must match");
 170       break;
 171 
 172     case T_ILLEGAL:
 173       // XXX TKR also means unknown right now
 174       // assert(is_illegal(), "must match");
 175       break;
 176 
 177     default:
 178       ShouldNotReachHere();
 179     }
 180   }
 181 #endif
 182 
 183 }
 184 #endif // PRODUCT
 185 
 186 
 187 bool LIR_OprDesc::is_oop() const {


 294   assert(_ublock != NULL, "must have old block");
 295   _ublock = b;
 296 }
 297 
 298 void LIR_OpBranch::negate_cond() {
 299   switch (_cond) {
 300     case lir_cond_equal:        _cond = lir_cond_notEqual;     break;
 301     case lir_cond_notEqual:     _cond = lir_cond_equal;        break;
 302     case lir_cond_less:         _cond = lir_cond_greaterEqual; break;
 303     case lir_cond_lessEqual:    _cond = lir_cond_greater;      break;
 304     case lir_cond_greaterEqual: _cond = lir_cond_less;         break;
 305     case lir_cond_greater:      _cond = lir_cond_lessEqual;    break;
 306     default: ShouldNotReachHere();
 307   }
 308 }
 309 
 310 
 311 LIR_OpTypeCheck::LIR_OpTypeCheck(LIR_Code code, LIR_Opr result, LIR_Opr object, ciKlass* klass,
 312                                  LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3,
 313                                  bool fast_check, CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch,
 314                                  CodeStub* stub)
 315 
 316   : LIR_Op(code, result, NULL)
 317   , _object(object)
 318   , _array(LIR_OprFact::illegalOpr)
 319   , _klass(klass)
 320   , _tmp1(tmp1)
 321   , _tmp2(tmp2)
 322   , _tmp3(tmp3)
 323   , _fast_check(fast_check)
 324   , _info_for_patch(info_for_patch)
 325   , _info_for_exception(info_for_exception)
 326   , _stub(stub)
 327   , _profiled_method(NULL)
 328   , _profiled_bci(-1)
 329   , _should_profile(false)

 330 {
 331   if (code == lir_checkcast) {
 332     assert(info_for_exception != NULL, "checkcast throws exceptions");
 333   } else if (code == lir_instanceof) {
 334     assert(info_for_exception == NULL, "instanceof throws no exceptions");
 335   } else {
 336     ShouldNotReachHere();
 337   }
 338 }
 339 
 340 
 341 
 342 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)
 343   : LIR_Op(code, LIR_OprFact::illegalOpr, NULL)
 344   , _object(object)
 345   , _array(array)
 346   , _klass(NULL)
 347   , _tmp1(tmp1)
 348   , _tmp2(tmp2)
 349   , _tmp3(tmp3)
 350   , _fast_check(false)
 351   , _info_for_patch(NULL)
 352   , _info_for_exception(info_for_exception)
 353   , _stub(NULL)
 354   , _profiled_method(NULL)
 355   , _profiled_bci(-1)
 356   , _should_profile(false)

 357 {
 358   if (code == lir_store_check) {
 359     _stub = new ArrayStoreExceptionStub(object, info_for_exception);
 360     assert(info_for_exception != NULL, "store_check throws exceptions");
 361   } else {
 362     ShouldNotReachHere();
 363   }
 364 }
 365 































 366 
 367 LIR_OpArrayCopy::LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length,
 368                                  LIR_Opr tmp, ciArrayKlass* expected_type, int flags, CodeEmitInfo* info)
 369   : LIR_Op(lir_arraycopy, LIR_OprFact::illegalOpr, info)
 370   , _src(src)
 371   , _src_pos(src_pos)
 372   , _dst(dst)
 373   , _dst_pos(dst_pos)
 374   , _length(length)
 375   , _tmp(tmp)
 376   , _expected_type(expected_type)
 377   , _flags(flags) {
 378   _stub = new ArrayCopyStub(this);
 379 }
 380 
 381 LIR_OpUpdateCRC32::LIR_OpUpdateCRC32(LIR_Opr crc, LIR_Opr val, LIR_Opr res)
 382   : LIR_Op(lir_updatecrc32, res, NULL)
 383   , _crc(crc)
 384   , _val(val) {
 385 }


 800 
 801 
 802 // LIR_OpLock
 803     case lir_lock:
 804     case lir_unlock: {
 805       assert(op->as_OpLock() != NULL, "must be");
 806       LIR_OpLock* opLock = (LIR_OpLock*)op;
 807 
 808       if (opLock->_info)                          do_info(opLock->_info);
 809 
 810       // TODO: check if these operands really have to be temp
 811       // (or if input is sufficient). This may have influence on the oop map!
 812       assert(opLock->_lock->is_valid(), "used");  do_temp(opLock->_lock);
 813       assert(opLock->_hdr->is_valid(),  "used");  do_temp(opLock->_hdr);
 814       assert(opLock->_obj->is_valid(),  "used");  do_temp(opLock->_obj);
 815 
 816       if (opLock->_scratch->is_valid())           do_temp(opLock->_scratch);
 817       assert(opLock->_result->is_illegal(), "unused");
 818 
 819       do_stub(opLock->_stub);

 820 
 821       break;
 822     }
 823 
 824 
 825 // LIR_OpDelay
 826     case lir_delay_slot: {
 827       assert(op->as_OpDelay() != NULL, "must be");
 828       LIR_OpDelay* opDelay = (LIR_OpDelay*)op;
 829 
 830       visit(opDelay->delay_op());
 831       break;
 832     }
 833 
 834 // LIR_OpTypeCheck
 835     case lir_instanceof:
 836     case lir_checkcast:
 837     case lir_store_check: {
 838       assert(op->as_OpTypeCheck() != NULL, "must be");
 839       LIR_OpTypeCheck* opTypeCheck = (LIR_OpTypeCheck*)op;
 840 
 841       if (opTypeCheck->_info_for_exception)       do_info(opTypeCheck->_info_for_exception);
 842       if (opTypeCheck->_info_for_patch)           do_info(opTypeCheck->_info_for_patch);
 843       if (opTypeCheck->_object->is_valid())       do_input(opTypeCheck->_object);
 844       if (op->code() == lir_store_check && opTypeCheck->_object->is_valid()) {
 845         do_temp(opTypeCheck->_object);
 846       }
 847       if (opTypeCheck->_array->is_valid())        do_input(opTypeCheck->_array);
 848       if (opTypeCheck->_tmp1->is_valid())         do_temp(opTypeCheck->_tmp1);
 849       if (opTypeCheck->_tmp2->is_valid())         do_temp(opTypeCheck->_tmp2);
 850       if (opTypeCheck->_tmp3->is_valid())         do_temp(opTypeCheck->_tmp3);
 851       if (opTypeCheck->_result->is_valid())       do_output(opTypeCheck->_result);
 852                                                   do_stub(opTypeCheck->_stub);
 853       break;
 854     }
 855 













































 856 // LIR_OpCompareAndSwap
 857     case lir_cas_long:
 858     case lir_cas_obj:
 859     case lir_cas_int: {
 860       assert(op->as_OpCompareAndSwap() != NULL, "must be");
 861       LIR_OpCompareAndSwap* opCompareAndSwap = (LIR_OpCompareAndSwap*)op;
 862 
 863       assert(opCompareAndSwap->_addr->is_valid(),      "used");
 864       assert(opCompareAndSwap->_cmp_value->is_valid(), "used");
 865       assert(opCompareAndSwap->_new_value->is_valid(), "used");
 866       if (opCompareAndSwap->_info)                    do_info(opCompareAndSwap->_info);
 867                                                       do_input(opCompareAndSwap->_addr);
 868                                                       do_temp(opCompareAndSwap->_addr);
 869                                                       do_input(opCompareAndSwap->_cmp_value);
 870                                                       do_temp(opCompareAndSwap->_cmp_value);
 871                                                       do_input(opCompareAndSwap->_new_value);
 872                                                       do_temp(opCompareAndSwap->_new_value);
 873       if (opCompareAndSwap->_tmp1->is_valid())        do_temp(opCompareAndSwap->_tmp1);
 874       if (opCompareAndSwap->_tmp2->is_valid())        do_temp(opCompareAndSwap->_tmp2);
 875       if (opCompareAndSwap->_result->is_valid())      do_output(opCompareAndSwap->_result);


 963 #ifdef ASSERT
 964 bool LIR_OpVisitState::no_operands(LIR_Op* op) {
 965   visit(op);
 966 
 967   return opr_count(inputMode) == 0 &&
 968          opr_count(outputMode) == 0 &&
 969          opr_count(tempMode) == 0 &&
 970          info_count() == 0 &&
 971          !has_call() &&
 972          !has_slow_case();
 973 }
 974 #endif
 975 
 976 //---------------------------------------------------
 977 
 978 
 979 void LIR_OpJavaCall::emit_code(LIR_Assembler* masm) {
 980   masm->emit_call(this);
 981 }
 982 







































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


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


















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



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


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

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



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

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

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





















1435 void LIR_List::cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1436                         LIR_Opr t1, LIR_Opr t2, LIR_Opr result) {
1437   append(new LIR_OpCompareAndSwap(lir_cas_long, addr, cmp_value, new_value, t1, t2, result));
1438 }
1439 
1440 void LIR_List::cas_obj(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_obj, addr, cmp_value, new_value, t1, t2, result));
1443 }
1444 
1445 void LIR_List::cas_int(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_int, addr, cmp_value, new_value, t1, t2, result));
1448 }
1449 
1450 
1451 #ifdef PRODUCT
1452 
1453 void print_LIR(BlockList* blocks) {
1454 }


1707      case lir_fmaf:                  s = "fmaf";          break;
1708      // LIR_OpJavaCall
1709      case lir_static_call:           s = "static";        break;
1710      case lir_optvirtual_call:       s = "optvirtual";    break;
1711      case lir_icvirtual_call:        s = "icvirtual";     break;
1712      case lir_virtual_call:          s = "virtual";       break;
1713      case lir_dynamic_call:          s = "dynamic";       break;
1714      // LIR_OpArrayCopy
1715      case lir_arraycopy:             s = "arraycopy";     break;
1716      // LIR_OpUpdateCRC32
1717      case lir_updatecrc32:           s = "updatecrc32";   break;
1718      // LIR_OpLock
1719      case lir_lock:                  s = "lock";          break;
1720      case lir_unlock:                s = "unlock";        break;
1721      // LIR_OpDelay
1722      case lir_delay_slot:            s = "delay";         break;
1723      // LIR_OpTypeCheck
1724      case lir_instanceof:            s = "instanceof";    break;
1725      case lir_checkcast:             s = "checkcast";     break;
1726      case lir_store_check:           s = "store_check";   break;






1727      // LIR_OpCompareAndSwap
1728      case lir_cas_long:              s = "cas_long";      break;
1729      case lir_cas_obj:               s = "cas_obj";      break;
1730      case lir_cas_int:               s = "cas_int";      break;
1731      // LIR_OpProfileCall
1732      case lir_profile_call:          s = "profile_call";  break;
1733      // LIR_OpProfileType
1734      case lir_profile_type:          s = "profile_type";  break;
1735      // LIR_OpAssert
1736 #ifdef ASSERT
1737      case lir_assert:                s = "assert";        break;
1738 #endif
1739      case lir_none:                  ShouldNotReachHere();break;
1740     default:                         s = "illegal_op";    break;
1741   }
1742   return s;
1743 }
1744 
1745 // LIR_OpJavaCall
1746 void LIR_OpJavaCall::print_instr(outputStream* out) const {


1952   out->print("[label:" INTPTR_FORMAT "]", p2i(stub()->entry()));
1953 }
1954 
1955 
1956 void LIR_OpTypeCheck::print_instr(outputStream* out) const {
1957   object()->print(out);                  out->print(" ");
1958   if (code() == lir_store_check) {
1959     array()->print(out);                 out->print(" ");
1960   }
1961   if (code() != lir_store_check) {
1962     klass()->print_name_on(out);         out->print(" ");
1963     if (fast_check())                 out->print("fast_check ");
1964   }
1965   tmp1()->print(out);                    out->print(" ");
1966   tmp2()->print(out);                    out->print(" ");
1967   tmp3()->print(out);                    out->print(" ");
1968   result_opr()->print(out);              out->print(" ");
1969   if (info_for_exception() != NULL) out->print(" [bci:%d]", info_for_exception()->stack()->bci());
1970 }
1971 






























1972 
1973 // LIR_Op3
1974 void LIR_Op3::print_instr(outputStream* out) const {
1975   in_opr1()->print(out);    out->print(" ");
1976   in_opr2()->print(out);    out->print(" ");
1977   in_opr3()->print(out);    out->print(" ");
1978   result_opr()->print(out);
1979 }
1980 
1981 
1982 void LIR_OpLock::print_instr(outputStream* out) const {
1983   hdr_opr()->print(out);   out->print(" ");
1984   obj_opr()->print(out);   out->print(" ");
1985   lock_opr()->print(out);  out->print(" ");
1986   if (_scratch->is_valid()) {
1987     _scratch->print(out);  out->print(" ");
1988   }
1989   out->print("[lbl:" INTPTR_FORMAT "]", p2i(stub()->entry()));
1990 }
1991 


   1 /*
   2  * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "c1/c1_InstructionPrinter.hpp"
  27 #include "c1/c1_LIR.hpp"
  28 #include "c1/c1_LIRAssembler.hpp"
  29 #include "c1/c1_ValueStack.hpp"
  30 #include "ci/ciInstance.hpp"
  31 #include "ci/ciValueKlass.hpp"
  32 #include "runtime/sharedRuntime.hpp"
  33 
  34 Register LIR_OprDesc::as_register() const {
  35   return FrameMap::cpu_rnr2reg(cpu_regnr());
  36 }
  37 
  38 Register LIR_OprDesc::as_register_lo() const {
  39   return FrameMap::cpu_rnr2reg(cpu_regnrLo());
  40 }
  41 
  42 Register LIR_OprDesc::as_register_hi() const {
  43   return FrameMap::cpu_rnr2reg(cpu_regnrHi());
  44 }
  45 
  46 LIR_Opr LIR_OprFact::illegalOpr = LIR_OprFact::illegal();
  47 
  48 LIR_Opr LIR_OprFact::value_type(ValueType* type) {
  49   ValueTag tag = type->tag();
  50   switch (tag) {
  51   case metaDataTag : {


  91 //---------------------------------------------------
  92 
  93 
  94 LIR_Address::Scale LIR_Address::scale(BasicType type) {
  95   int elem_size = type2aelembytes(type);
  96   switch (elem_size) {
  97   case 1: return LIR_Address::times_1;
  98   case 2: return LIR_Address::times_2;
  99   case 4: return LIR_Address::times_4;
 100   case 8: return LIR_Address::times_8;
 101   }
 102   ShouldNotReachHere();
 103   return LIR_Address::times_1;
 104 }
 105 
 106 //---------------------------------------------------
 107 
 108 char LIR_OprDesc::type_char(BasicType t) {
 109   switch (t) {
 110     case T_ARRAY:
 111     case T_VALUETYPE:
 112       t = T_OBJECT;
 113     case T_BOOLEAN:
 114     case T_CHAR:
 115     case T_FLOAT:
 116     case T_DOUBLE:
 117     case T_BYTE:
 118     case T_SHORT:
 119     case T_INT:
 120     case T_LONG:
 121     case T_OBJECT:
 122     case T_ADDRESS:
 123     case T_VOID:
 124       return ::type2char(t);
 125     case T_METADATA:
 126       return 'M';
 127     case T_ILLEGAL:
 128       return '?';
 129 
 130     default:
 131       ShouldNotReachHere();


 150              ARM_ONLY(|| kindfield == cpu_register)
 151              PPC32_ONLY(|| kindfield == cpu_register) ) &&
 152              size_field() == single_size, "must match");
 153       break;
 154     case T_DOUBLE:
 155       // FP return values can be also in CPU registers on ARM and PPC32 (softfp ABI)
 156       assert((kindfield == fpu_register || kindfield == stack_value
 157              ARM_ONLY(|| kindfield == cpu_register)
 158              PPC32_ONLY(|| kindfield == cpu_register) ) &&
 159              size_field() == double_size, "must match");
 160       break;
 161     case T_BOOLEAN:
 162     case T_CHAR:
 163     case T_BYTE:
 164     case T_SHORT:
 165     case T_INT:
 166     case T_ADDRESS:
 167     case T_OBJECT:
 168     case T_METADATA:
 169     case T_ARRAY:
 170     case T_VALUETYPE:
 171       assert((kindfield == cpu_register || kindfield == stack_value) &&
 172              size_field() == single_size, "must match");
 173       break;
 174 
 175     case T_ILLEGAL:
 176       // XXX TKR also means unknown right now
 177       // assert(is_illegal(), "must match");
 178       break;
 179 
 180     default:
 181       ShouldNotReachHere();
 182     }
 183   }
 184 #endif
 185 
 186 }
 187 #endif // PRODUCT
 188 
 189 
 190 bool LIR_OprDesc::is_oop() const {


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


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


1045 #ifdef ASSERT
1046 bool LIR_OpVisitState::no_operands(LIR_Op* op) {
1047   visit(op);
1048 
1049   return opr_count(inputMode) == 0 &&
1050          opr_count(outputMode) == 0 &&
1051          opr_count(tempMode) == 0 &&
1052          info_count() == 0 &&
1053          !has_call() &&
1054          !has_slow_case();
1055 }
1056 #endif
1057 
1058 //---------------------------------------------------
1059 
1060 
1061 void LIR_OpJavaCall::emit_code(LIR_Assembler* masm) {
1062   masm->emit_call(this);
1063 }
1064 
1065 bool LIR_OpJavaCall::maybe_return_as_fields(ciValueKlass** vk_ret) const {
1066   if (ValueTypeReturnedAsFields) {
1067     if (method()->signature()->maybe_returns_never_null()) {
1068       ciType* return_type = method()->return_type();
1069       if (return_type->is_valuetype()) {
1070         ciValueKlass* vk = return_type->as_value_klass();
1071         if (vk->can_be_returned_as_fields()) {
1072           if (vk_ret != NULL) {
1073             *vk_ret = vk;
1074           }
1075           return true;
1076         }
1077       } else {
1078         assert(return_type->is_instance_klass() && !return_type->as_instance_klass()->is_loaded(), "must be");
1079         if (vk_ret != NULL) {
1080           *vk_ret = NULL;
1081         }
1082         return true;
1083       }
1084     } else if (is_method_handle_invoke()) {
1085       BasicType bt = method()->return_type()->basic_type();
1086       if (bt == T_OBJECT || bt == T_VALUETYPE) {
1087         // A value type might be returned from the call but we don't know its
1088         // type. Either we get a buffered value (and nothing needs to be done)
1089         // or one of the values being returned is the klass of the value type
1090         // (RAX on x64, with LSB set to 1) and we need to allocate a value
1091         // type instance of that type and initialize it with other values being
1092         // returned (in other registers).
1093         // type.
1094         if (vk_ret != NULL) {
1095           *vk_ret = NULL;
1096         }
1097         return true;
1098       }
1099     }
1100   }
1101   return false;
1102 }
1103 
1104 void LIR_OpRTCall::emit_code(LIR_Assembler* masm) {
1105   masm->emit_rtcall(this);
1106 }
1107 
1108 void LIR_OpLabel::emit_code(LIR_Assembler* masm) {
1109   masm->emit_opLabel(this);
1110 }
1111 
1112 void LIR_OpArrayCopy::emit_code(LIR_Assembler* masm) {
1113   masm->emit_arraycopy(this);
1114   masm->append_code_stub(stub());
1115 }
1116 
1117 void LIR_OpUpdateCRC32::emit_code(LIR_Assembler* masm) {
1118   masm->emit_updatecrc32(this);
1119 }
1120 
1121 void LIR_Op0::emit_code(LIR_Assembler* masm) {
1122   masm->emit_op0(this);
1123 }


1144     masm->append_code_stub(stub());
1145   }
1146 }
1147 
1148 void LIR_Op2::emit_code(LIR_Assembler* masm) {
1149   masm->emit_op2(this);
1150 }
1151 
1152 void LIR_OpAllocArray::emit_code(LIR_Assembler* masm) {
1153   masm->emit_alloc_array(this);
1154   masm->append_code_stub(stub());
1155 }
1156 
1157 void LIR_OpTypeCheck::emit_code(LIR_Assembler* masm) {
1158   masm->emit_opTypeCheck(this);
1159   if (stub()) {
1160     masm->append_code_stub(stub());
1161   }
1162 }
1163 
1164 void LIR_OpFlattenedArrayCheck::emit_code(LIR_Assembler* masm) {
1165   masm->emit_opFlattenedArrayCheck(this);
1166   if (stub() != NULL) {
1167     masm->append_code_stub(stub());
1168   }
1169 }
1170 
1171 void LIR_OpNullFreeArrayCheck::emit_code(LIR_Assembler* masm) {
1172   masm->emit_opNullFreeArrayCheck(this);
1173 }
1174 
1175 void LIR_OpSubstitutabilityCheck::emit_code(LIR_Assembler* masm) {
1176   masm->emit_opSubstitutabilityCheck(this);
1177   if (stub() != NULL) {
1178     masm->append_code_stub(stub());
1179   }
1180 }
1181 
1182 void LIR_OpCompareAndSwap::emit_code(LIR_Assembler* masm) {
1183   masm->emit_compare_and_swap(this);
1184 }
1185 
1186 void LIR_Op3::emit_code(LIR_Assembler* masm) {
1187   masm->emit_op3(this);
1188 }
1189 
1190 void LIR_OpLock::emit_code(LIR_Assembler* masm) {
1191   masm->emit_lock(this);
1192   if (stub()) {
1193     masm->append_code_stub(stub());
1194   }
1195   if (throw_imse_stub()) {
1196     masm->append_code_stub(throw_imse_stub());
1197   }
1198 }
1199 
1200 #ifdef ASSERT
1201 void LIR_OpAssert::emit_code(LIR_Assembler* masm) {
1202   masm->emit_assert(this);
1203 }
1204 #endif
1205 
1206 void LIR_OpDelay::emit_code(LIR_Assembler* masm) {
1207   masm->emit_delay(this);
1208 }
1209 
1210 void LIR_OpProfileCall::emit_code(LIR_Assembler* masm) {
1211   masm->emit_profile_call(this);
1212 }
1213 
1214 void LIR_OpProfileType::emit_code(LIR_Assembler* masm) {
1215   masm->emit_profile_type(this);
1216 }
1217 


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


1876      case lir_fmaf:                  s = "fmaf";          break;
1877      // LIR_OpJavaCall
1878      case lir_static_call:           s = "static";        break;
1879      case lir_optvirtual_call:       s = "optvirtual";    break;
1880      case lir_icvirtual_call:        s = "icvirtual";     break;
1881      case lir_virtual_call:          s = "virtual";       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_OpAssert
1911 #ifdef ASSERT
1912      case lir_assert:                s = "assert";        break;
1913 #endif
1914      case lir_none:                  ShouldNotReachHere();break;
1915     default:                         s = "illegal_op";    break;
1916   }
1917   return s;
1918 }
1919 
1920 // LIR_OpJavaCall
1921 void LIR_OpJavaCall::print_instr(outputStream* out) const {


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


< prev index next >