< prev index next >

src/hotspot/share/c1/c1_LIR.hpp

Print this page

 321   friend BasicType as_BasicType(OprType t);
 322 
 323   OprType type_field_valid() const               { assert(is_register() || is_stack(), "should not be called otherwise"); return (OprType)(value() & type_mask); }
 324   OprType type_field() const                     { return is_illegal() ? unknown_type : (OprType)(value() & type_mask); }
 325 
 326   static OprSize size_for(BasicType t) {
 327     switch (t) {
 328       case T_LONG:
 329       case T_DOUBLE:
 330         return double_size;
 331         break;
 332 
 333       case T_FLOAT:
 334       case T_BOOLEAN:
 335       case T_CHAR:
 336       case T_BYTE:
 337       case T_SHORT:
 338       case T_INT:
 339       case T_ADDRESS:
 340       case T_OBJECT:

 341       case T_ARRAY:
 342       case T_METADATA:
 343         return single_size;
 344         break;
 345 
 346       default:
 347         ShouldNotReachHere();
 348         return single_size;
 349       }
 350   }
 351 
 352 
 353   void validate_type() const PRODUCT_RETURN;
 354 
 355   BasicType type() const {
 356     if (is_pointer()) {
 357       return pointer()->type();
 358     }
 359     return as_BasicType(type_field());
 360   }

 470   int fpu() const { return lo_reg_half(); }
 471 #endif
 472 
 473   jint      as_jint()    const { return as_constant_ptr()->as_jint(); }
 474   jlong     as_jlong()   const { return as_constant_ptr()->as_jlong(); }
 475   jfloat    as_jfloat()  const { return as_constant_ptr()->as_jfloat(); }
 476   jdouble   as_jdouble() const { return as_constant_ptr()->as_jdouble(); }
 477   jobject   as_jobject() const { return as_constant_ptr()->as_jobject(); }
 478 
 479   void print() const PRODUCT_RETURN;
 480   void print(outputStream* out) const PRODUCT_RETURN;
 481 };
 482 
 483 inline LIR_Opr::OprType as_OprType(BasicType type) {
 484   switch (type) {
 485   case T_INT:      return LIR_Opr::int_type;
 486   case T_LONG:     return LIR_Opr::long_type;
 487   case T_FLOAT:    return LIR_Opr::float_type;
 488   case T_DOUBLE:   return LIR_Opr::double_type;
 489   case T_OBJECT:

 490   case T_ARRAY:    return LIR_Opr::object_type;
 491   case T_ADDRESS:  return LIR_Opr::address_type;
 492   case T_METADATA: return LIR_Opr::metadata_type;
 493   case T_ILLEGAL:  // fall through
 494   default: ShouldNotReachHere(); return LIR_Opr::unknown_type;
 495   }
 496 }
 497 
 498 inline BasicType as_BasicType(LIR_Opr::OprType t) {
 499   switch (t) {
 500   case LIR_Opr::int_type:     return T_INT;
 501   case LIR_Opr::long_type:    return T_LONG;
 502   case LIR_Opr::float_type:   return T_FLOAT;
 503   case LIR_Opr::double_type:  return T_DOUBLE;
 504   case LIR_Opr::object_type:  return T_OBJECT;
 505   case LIR_Opr::address_type: return T_ADDRESS;
 506   case LIR_Opr::metadata_type:return T_METADATA;
 507   case LIR_Opr::unknown_type: // fall through
 508   default: ShouldNotReachHere();  return T_ILLEGAL;
 509   }

 661   }
 662   static LIR_Opr double_xmm(int reg) {
 663     return (LIR_Opr)(intptr_t)((reg << LIR_Opr::reg1_shift) |
 664                                (reg << LIR_Opr::reg2_shift) |
 665                                LIR_Opr::double_type         |
 666                                LIR_Opr::fpu_register        |
 667                                LIR_Opr::double_size         |
 668                                LIR_Opr::is_xmm_mask);
 669   }
 670 #endif // X86
 671 
 672   static LIR_Opr virtual_register(int index, BasicType type) {
 673     if (index > LIR_Opr::vreg_max) {
 674       // Running out of virtual registers. Caller should bailout.
 675       return illegalOpr;
 676     }
 677 
 678     LIR_Opr res;
 679     switch (type) {
 680       case T_OBJECT: // fall through

 681       case T_ARRAY:
 682         res = (LIR_Opr)(intptr_t)((index << LIR_Opr::data_shift)  |
 683                                             LIR_Opr::object_type  |
 684                                             LIR_Opr::cpu_register |
 685                                             LIR_Opr::single_size  |
 686                                             LIR_Opr::virtual_mask);
 687         break;
 688 
 689       case T_METADATA:
 690         res = (LIR_Opr)(intptr_t)((index << LIR_Opr::data_shift)  |
 691                                             LIR_Opr::metadata_type|
 692                                             LIR_Opr::cpu_register |
 693                                             LIR_Opr::single_size  |
 694                                             LIR_Opr::virtual_mask);
 695         break;
 696 
 697       case T_INT:
 698         res = (LIR_Opr)(intptr_t)((index << LIR_Opr::data_shift) |
 699                                   LIR_Opr::int_type              |
 700                                   LIR_Opr::cpu_register          |

 765                                t |
 766                                LIR_Opr::cpu_register |
 767                                LIR_Opr::size_for(type) | LIR_Opr::virtual_mask);
 768 #else // __SOFTFP__
 769     LIR_Opr old_res = (LIR_Opr)(intptr_t)((index << LIR_Opr::data_shift) | t |
 770                                           ((type == T_FLOAT || type == T_DOUBLE) ?  LIR_Opr::fpu_register : LIR_Opr::cpu_register) |
 771                                LIR_Opr::size_for(type) | LIR_Opr::virtual_mask);
 772     assert(res == old_res, "old and new method not equal");
 773 #endif // __SOFTFP__
 774 #endif // ASSERT
 775 
 776     return res;
 777   }
 778 
 779   // 'index' is computed by FrameMap::local_stack_pos(index); do not use other parameters as
 780   // the index is platform independent; a double stack using indices 2 and 3 has always
 781   // index 2.
 782   static LIR_Opr stack(int index, BasicType type) {
 783     LIR_Opr res;
 784     switch (type) {

 785       case T_OBJECT: // fall through
 786       case T_ARRAY:
 787         res = (LIR_Opr)(intptr_t)((index << LIR_Opr::data_shift) |
 788                                   LIR_Opr::object_type           |
 789                                   LIR_Opr::stack_value           |
 790                                   LIR_Opr::single_size);
 791         break;
 792 
 793       case T_METADATA:
 794         res = (LIR_Opr)(intptr_t)((index << LIR_Opr::data_shift) |
 795                                   LIR_Opr::metadata_type         |
 796                                   LIR_Opr::stack_value           |
 797                                   LIR_Opr::single_size);
 798         break;
 799       case T_INT:
 800         res = (LIR_Opr)(intptr_t)((index << LIR_Opr::data_shift) |
 801                                   LIR_Opr::int_type              |
 802                                   LIR_Opr::stack_value           |
 803                                   LIR_Opr::single_size);
 804         break;

 879 class    LIR_Op0;
 880 class      LIR_OpLabel;
 881 class    LIR_Op1;
 882 class      LIR_OpBranch;
 883 class      LIR_OpConvert;
 884 class      LIR_OpAllocObj;
 885 class      LIR_OpReturn;
 886 class      LIR_OpRoundFP;
 887 class    LIR_Op2;
 888 class    LIR_OpDelay;
 889 class    LIR_Op3;
 890 class      LIR_OpAllocArray;
 891 class    LIR_Op4;
 892 class    LIR_OpCall;
 893 class      LIR_OpJavaCall;
 894 class      LIR_OpRTCall;
 895 class    LIR_OpArrayCopy;
 896 class    LIR_OpUpdateCRC32;
 897 class    LIR_OpLock;
 898 class    LIR_OpTypeCheck;



 899 class    LIR_OpCompareAndSwap;
 900 class    LIR_OpLoadKlass;
 901 class    LIR_OpProfileCall;
 902 class    LIR_OpProfileType;

 903 #ifdef ASSERT
 904 class    LIR_OpAssert;
 905 #endif
 906 
 907 // LIR operation codes
 908 enum LIR_Code {
 909     lir_none
 910   , begin_op0
 911       , lir_label
 912       , lir_nop
 913       , lir_std_entry
 914       , lir_osr_entry
 915       , lir_fpop_raw
 916       , lir_breakpoint
 917       , lir_rtcall
 918       , lir_membar
 919       , lir_membar_acquire
 920       , lir_membar_release
 921       , lir_membar_loadload
 922       , lir_membar_storestore
 923       , lir_membar_loadstore
 924       , lir_membar_storeload
 925       , lir_get_thread
 926       , lir_on_spin_wait

 927   , end_op0
 928   , begin_op1
 929       , lir_fxch
 930       , lir_fld
 931       , lir_push
 932       , lir_pop
 933       , lir_null_check
 934       , lir_return
 935       , lir_leal
 936       , lir_move
 937       , lir_convert
 938       , lir_alloc_object
 939       , lir_monaddr
 940       , lir_roundfp
 941       , lir_safepoint
 942       , lir_unwind
 943       , lir_load_klass
 944   , end_op1
 945   , begin_op2
 946       , lir_branch

 986       , lir_dynamic_call
 987   , end_opJavaCall
 988   , begin_opArrayCopy
 989       , lir_arraycopy
 990   , end_opArrayCopy
 991   , begin_opUpdateCRC32
 992       , lir_updatecrc32
 993   , end_opUpdateCRC32
 994   , begin_opLock
 995     , lir_lock
 996     , lir_unlock
 997   , end_opLock
 998   , begin_delay_slot
 999     , lir_delay_slot
1000   , end_delay_slot
1001   , begin_opTypeCheck
1002     , lir_instanceof
1003     , lir_checkcast
1004     , lir_store_check
1005   , end_opTypeCheck









1006   , begin_opCompareAndSwap
1007     , lir_cas_long
1008     , lir_cas_obj
1009     , lir_cas_int
1010   , end_opCompareAndSwap
1011   , begin_opMDOProfile
1012     , lir_profile_call
1013     , lir_profile_type

1014   , end_opMDOProfile
1015   , begin_opAssert
1016     , lir_assert
1017   , end_opAssert
1018 #ifdef INCLUDE_ZGC
1019   , begin_opZLoadBarrierTest
1020     , lir_zloadbarrier_test
1021   , end_opZLoadBarrierTest
1022 #endif
1023 };
1024 
1025 
1026 enum LIR_Condition {
1027     lir_cond_equal
1028   , lir_cond_notEqual
1029   , lir_cond_less
1030   , lir_cond_lessEqual
1031   , lir_cond_greaterEqual
1032   , lir_cond_greater
1033   , lir_cond_belowEqual

1142   virtual LIR_OpCall* as_OpCall() { return NULL; }
1143   virtual LIR_OpJavaCall* as_OpJavaCall() { return NULL; }
1144   virtual LIR_OpLabel* as_OpLabel() { return NULL; }
1145   virtual LIR_OpDelay* as_OpDelay() { return NULL; }
1146   virtual LIR_OpLock* as_OpLock() { return NULL; }
1147   virtual LIR_OpAllocArray* as_OpAllocArray() { return NULL; }
1148   virtual LIR_OpAllocObj* as_OpAllocObj() { return NULL; }
1149   virtual LIR_OpRoundFP* as_OpRoundFP() { return NULL; }
1150   virtual LIR_OpBranch* as_OpBranch() { return NULL; }
1151   virtual LIR_OpReturn* as_OpReturn() { return NULL; }
1152   virtual LIR_OpRTCall* as_OpRTCall() { return NULL; }
1153   virtual LIR_OpConvert* as_OpConvert() { return NULL; }
1154   virtual LIR_Op0* as_Op0() { return NULL; }
1155   virtual LIR_Op1* as_Op1() { return NULL; }
1156   virtual LIR_Op2* as_Op2() { return NULL; }
1157   virtual LIR_Op3* as_Op3() { return NULL; }
1158   virtual LIR_Op4* as_Op4() { return NULL; }
1159   virtual LIR_OpArrayCopy* as_OpArrayCopy() { return NULL; }
1160   virtual LIR_OpUpdateCRC32* as_OpUpdateCRC32() { return NULL; }
1161   virtual LIR_OpTypeCheck* as_OpTypeCheck() { return NULL; }



1162   virtual LIR_OpCompareAndSwap* as_OpCompareAndSwap() { return NULL; }
1163   virtual LIR_OpLoadKlass* as_OpLoadKlass() { return NULL; }
1164   virtual LIR_OpProfileCall* as_OpProfileCall() { return NULL; }
1165   virtual LIR_OpProfileType* as_OpProfileType() { return NULL; }

1166 #ifdef ASSERT
1167   virtual LIR_OpAssert* as_OpAssert() { return NULL; }
1168 #endif
1169 
1170   virtual void verify() const {}
1171 };
1172 
1173 // for calls
1174 class LIR_OpCall: public LIR_Op {
1175  friend class LIR_OpVisitState;
1176 
1177  protected:
1178   address      _addr;
1179   LIR_OprList* _arguments;
1180  protected:
1181   LIR_OpCall(LIR_Code code, address addr, LIR_Opr result,
1182              LIR_OprList* arguments, CodeEmitInfo* info = NULL)
1183     : LIR_Op(code, result, info)
1184     , _addr(addr)
1185     , _arguments(arguments) {}

1218                  LIR_OprList* arguments, CodeEmitInfo* info)
1219   : LIR_OpCall(code, (address)vtable_offset, result, arguments, info)
1220   , _method(method)
1221   , _receiver(receiver)
1222   , _method_handle_invoke_SP_save_opr(LIR_OprFact::illegalOpr)
1223   { assert(is_in_range(code, begin_opJavaCall, end_opJavaCall), "code check"); }
1224 
1225   LIR_Opr receiver() const                       { return _receiver; }
1226   ciMethod* method() const                       { return _method;   }
1227 
1228   // JSR 292 support.
1229   bool is_invokedynamic() const                  { return code() == lir_dynamic_call; }
1230   bool is_method_handle_invoke() const {
1231     return method()->is_compiled_lambda_form() ||   // Java-generated lambda form
1232            method()->is_method_handle_intrinsic();  // JVM-generated MH intrinsic
1233   }
1234 
1235   virtual void emit_code(LIR_Assembler* masm);
1236   virtual LIR_OpJavaCall* as_OpJavaCall() { return this; }
1237   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;


1238 };
1239 
1240 // --------------------------------------------------
1241 // LIR_OpLabel
1242 // --------------------------------------------------
1243 // Location where a branch can continue
1244 class LIR_OpLabel: public LIR_Op {
1245  friend class LIR_OpVisitState;
1246 
1247  private:
1248   Label* _label;
1249  public:
1250   LIR_OpLabel(Label* lbl)
1251    : LIR_Op(lir_label, LIR_OprFact::illegalOpr, NULL)
1252    , _label(lbl)                                 {}
1253   Label* label() const                           { return _label; }
1254 
1255   virtual void emit_code(LIR_Assembler* masm);
1256   virtual LIR_OpLabel* as_OpLabel() { return this; }
1257   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;

1269   LIR_Opr   _dst_pos;
1270   LIR_Opr   _length;
1271   LIR_Opr   _tmp;
1272   ciArrayKlass* _expected_type;
1273   int       _flags;
1274 
1275 public:
1276   enum Flags {
1277     src_null_check         = 1 << 0,
1278     dst_null_check         = 1 << 1,
1279     src_pos_positive_check = 1 << 2,
1280     dst_pos_positive_check = 1 << 3,
1281     length_positive_check  = 1 << 4,
1282     src_range_check        = 1 << 5,
1283     dst_range_check        = 1 << 6,
1284     type_check             = 1 << 7,
1285     overlapping            = 1 << 8,
1286     unaligned              = 1 << 9,
1287     src_objarray           = 1 << 10,
1288     dst_objarray           = 1 << 11,
1289     all_flags              = (1 << 12) - 1



1290   };
1291 
1292   LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length, LIR_Opr tmp,
1293                   ciArrayKlass* expected_type, int flags, CodeEmitInfo* info);
1294 
1295   LIR_Opr src() const                            { return _src; }
1296   LIR_Opr src_pos() const                        { return _src_pos; }
1297   LIR_Opr dst() const                            { return _dst; }
1298   LIR_Opr dst_pos() const                        { return _dst_pos; }
1299   LIR_Opr length() const                         { return _length; }
1300   LIR_Opr tmp() const                            { return _tmp; }
1301   int flags() const                              { return _flags; }
1302   ciArrayKlass* expected_type() const            { return _expected_type; }
1303   ArrayCopyStub* stub() const                    { return _stub; }
1304 
1305   virtual void emit_code(LIR_Assembler* masm);
1306   virtual LIR_OpArrayCopy* as_OpArrayCopy() { return this; }
1307   void print_instr(outputStream* out) const PRODUCT_RETURN;
1308 };
1309 

1532 };
1533 
1534 // LIR_OpTypeCheck
1535 class LIR_OpTypeCheck: public LIR_Op {
1536  friend class LIR_OpVisitState;
1537 
1538  private:
1539   LIR_Opr       _object;
1540   LIR_Opr       _array;
1541   ciKlass*      _klass;
1542   LIR_Opr       _tmp1;
1543   LIR_Opr       _tmp2;
1544   LIR_Opr       _tmp3;
1545   bool          _fast_check;
1546   CodeEmitInfo* _info_for_patch;
1547   CodeEmitInfo* _info_for_exception;
1548   CodeStub*     _stub;
1549   ciMethod*     _profiled_method;
1550   int           _profiled_bci;
1551   bool          _should_profile;

1552 
1553 public:
1554   LIR_OpTypeCheck(LIR_Code code, LIR_Opr result, LIR_Opr object, ciKlass* klass,
1555                   LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
1556                   CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub);
1557   LIR_OpTypeCheck(LIR_Code code, LIR_Opr object, LIR_Opr array,
1558                   LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, CodeEmitInfo* info_for_exception);
1559 
1560   LIR_Opr object() const                         { return _object;         }
1561   LIR_Opr array() const                          { assert(code() == lir_store_check, "not valid"); return _array;         }
1562   LIR_Opr tmp1() const                           { return _tmp1;           }
1563   LIR_Opr tmp2() const                           { return _tmp2;           }
1564   LIR_Opr tmp3() const                           { return _tmp3;           }
1565   ciKlass* klass() const                         { assert(code() == lir_instanceof || code() == lir_checkcast, "not valid"); return _klass;          }
1566   bool fast_check() const                        { assert(code() == lir_instanceof || code() == lir_checkcast, "not valid"); return _fast_check;     }
1567   CodeEmitInfo* info_for_patch() const           { return _info_for_patch;  }
1568   CodeEmitInfo* info_for_exception() const       { return _info_for_exception; }
1569   CodeStub* stub() const                         { return _stub;           }
1570 
1571   // MethodData* profiling
1572   void set_profiled_method(ciMethod *method)     { _profiled_method = method; }
1573   void set_profiled_bci(int bci)                 { _profiled_bci = bci;       }
1574   void set_should_profile(bool b)                { _should_profile = b;       }
1575   ciMethod* profiled_method() const              { return _profiled_method;   }
1576   int       profiled_bci() const                 { return _profiled_bci;      }
1577   bool      should_profile() const               { return _should_profile;    }
1578 
1579   virtual bool is_patching() { return _info_for_patch != NULL; }
1580   virtual void emit_code(LIR_Assembler* masm);
1581   virtual LIR_OpTypeCheck* as_OpTypeCheck() { return this; }
1582   void print_instr(outputStream* out) const PRODUCT_RETURN;
1583 };
1584 












































































1585 // LIR_Op2
1586 class LIR_Op2: public LIR_Op {
1587  friend class LIR_OpVisitState;
1588 
1589   int  _fpu_stack_size; // for sin/cos implementation on Intel
1590 
1591  protected:
1592   LIR_Opr   _opr1;
1593   LIR_Opr   _opr2;
1594   BasicType _type;
1595   LIR_Opr   _tmp1;
1596   LIR_Opr   _tmp2;
1597   LIR_Opr   _tmp3;
1598   LIR_Opr   _tmp4;
1599   LIR_Opr   _tmp5;
1600   LIR_Condition _condition;
1601 
1602   void verify() const;
1603 
1604  public:

1859 
1860 //--------------------------------
1861 class LabelObj: public CompilationResourceObj {
1862  private:
1863   Label _label;
1864  public:
1865   LabelObj()                                     {}
1866   Label* label()                                 { return &_label; }
1867 };
1868 
1869 
1870 class LIR_OpLock: public LIR_Op {
1871  friend class LIR_OpVisitState;
1872 
1873  private:
1874   LIR_Opr _hdr;
1875   LIR_Opr _obj;
1876   LIR_Opr _lock;
1877   LIR_Opr _scratch;
1878   CodeStub* _stub;

1879  public:
1880   LIR_OpLock(LIR_Code code, LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info)
1881     : LIR_Op(code, LIR_OprFact::illegalOpr, info)
1882     , _hdr(hdr)
1883     , _obj(obj)
1884     , _lock(lock)
1885     , _scratch(scratch)
1886     , _stub(stub)                      {}

1887 
1888   LIR_Opr hdr_opr() const                        { return _hdr; }
1889   LIR_Opr obj_opr() const                        { return _obj; }
1890   LIR_Opr lock_opr() const                       { return _lock; }
1891   LIR_Opr scratch_opr() const                    { return _scratch; }
1892   CodeStub* stub() const                         { return _stub; }

1893 
1894   virtual void emit_code(LIR_Assembler* masm);
1895   virtual LIR_OpLock* as_OpLock() { return this; }
1896   void print_instr(outputStream* out) const PRODUCT_RETURN;
1897 };
1898 
1899 class LIR_OpLoadKlass: public LIR_Op {
1900   friend class LIR_OpVisitState;
1901 
1902  private:
1903   LIR_Opr _obj;
1904  public:
1905   LIR_OpLoadKlass(LIR_Opr obj, LIR_Opr result, CodeEmitInfo* info)
1906     : LIR_Op(lir_load_klass, result, info)
1907     , _obj(obj)
1908     {}
1909 
1910   LIR_Opr obj()        const { return _obj;  }
1911 
1912   virtual LIR_OpLoadKlass* as_OpLoadKlass() { return this; }

2056     , _obj(obj)
2057     , _tmp(tmp)
2058     , _exact_klass(exact_klass)
2059     , _current_klass(current_klass)
2060     , _not_null(not_null)
2061     , _no_conflict(no_conflict) { }
2062 
2063   LIR_Opr      mdp()              const             { return _mdp;              }
2064   LIR_Opr      obj()              const             { return _obj;              }
2065   LIR_Opr      tmp()              const             { return _tmp;              }
2066   ciKlass*     exact_klass()      const             { return _exact_klass;      }
2067   intptr_t     current_klass()    const             { return _current_klass;    }
2068   bool         not_null()         const             { return _not_null;         }
2069   bool         no_conflict()      const             { return _no_conflict;      }
2070 
2071   virtual void emit_code(LIR_Assembler* masm);
2072   virtual LIR_OpProfileType* as_OpProfileType() { return this; }
2073   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
2074 };
2075 
































2076 class LIR_InsertionBuffer;
2077 
2078 //--------------------------------LIR_List---------------------------------------------------
2079 // Maintains a list of LIR instructions (one instance of LIR_List per basic block)
2080 // The LIR instructions are appended by the LIR_List class itself;
2081 //
2082 // Notes:
2083 // - all offsets are(should be) in bytes
2084 // - local positions are specified with an offset, with offset 0 being local 0
2085 
2086 class LIR_List: public CompilationResourceObj {
2087  private:
2088   LIR_OpList  _operations;
2089 
2090   Compilation*  _compilation;
2091 #ifndef PRODUCT
2092   BlockBegin*   _block;
2093 #endif
2094 #ifdef ASSERT
2095   const char *  _file;

2328   void unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp);
2329 
2330   void shift_left(LIR_Opr value, int count, LIR_Opr dst)       { shift_left(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2331   void shift_right(LIR_Opr value, int count, LIR_Opr dst)      { shift_right(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2332   void unsigned_shift_right(LIR_Opr value, int count, LIR_Opr dst) { unsigned_shift_right(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2333 
2334   void lcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst)        { append(new LIR_Op2(lir_cmp_l2i,  left, right, dst)); }
2335   void fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less);
2336 
2337   void call_runtime_leaf(address routine, LIR_Opr tmp, LIR_Opr result, LIR_OprList* arguments) {
2338     append(new LIR_OpRTCall(routine, tmp, result, arguments));
2339   }
2340 
2341   void call_runtime(address routine, LIR_Opr tmp, LIR_Opr result,
2342                     LIR_OprList* arguments, CodeEmitInfo* info) {
2343     append(new LIR_OpRTCall(routine, tmp, result, arguments, info));
2344   }
2345 
2346   void load_stack_address_monitor(int monitor_ix, LIR_Opr dst)  { append(new LIR_Op1(lir_monaddr, LIR_OprFact::intConst(monitor_ix), dst)); }
2347   void unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub);
2348   void lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info);
2349 
2350   void breakpoint()                                                  { append(new LIR_Op0(lir_breakpoint)); }
2351 
2352   void arraycopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length, LIR_Opr tmp, ciArrayKlass* expected_type, int flags, CodeEmitInfo* info) { append(new LIR_OpArrayCopy(src, src_pos, dst, dst_pos, length, tmp, expected_type, flags, info)); }
2353 
2354   void update_crc32(LIR_Opr crc, LIR_Opr val, LIR_Opr res)  { append(new LIR_OpUpdateCRC32(crc, val, res)); }
2355 
2356   void 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);
2357   void store_check(LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, CodeEmitInfo* info_for_exception, ciMethod* profiled_method, int profiled_bci);






2358 
2359   void checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
2360                   LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
2361                   CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
2362                   ciMethod* profiled_method, int profiled_bci);
2363   // MethodData* profiling
2364   void profile_call(ciMethod* method, int bci, ciMethod* callee, LIR_Opr mdo, LIR_Opr recv, LIR_Opr t1, ciKlass* cha_klass) {
2365     append(new LIR_OpProfileCall(method, bci, callee, mdo, recv, t1, cha_klass));
2366   }
2367   void profile_type(LIR_Address* mdp, LIR_Opr obj, ciKlass* exact_klass, intptr_t current_klass, LIR_Opr tmp, bool not_null, bool no_conflict) {
2368     append(new LIR_OpProfileType(LIR_OprFact::address(mdp), obj, exact_klass, current_klass, tmp, not_null, no_conflict));
2369   }



2370 
2371   void xadd(LIR_Opr src, LIR_Opr add, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xadd, src, add, res, tmp)); }
2372   void xchg(LIR_Opr src, LIR_Opr set, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xchg, src, set, res, tmp)); }
2373 
2374   void load_klass(LIR_Opr obj, LIR_Opr result, CodeEmitInfo* info) { append(new LIR_OpLoadKlass(obj, result, info)); }
2375 
2376 #ifdef ASSERT
2377   void lir_assert(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, const char* msg, bool halt) { append(new LIR_OpAssert(condition, opr1, opr2, msg, halt)); }
2378 #endif
2379 };
2380 
2381 void print_LIR(BlockList* blocks);
2382 
2383 class LIR_InsertionBuffer : public CompilationResourceObj {
2384  private:
2385   LIR_List*   _lir;   // the lir list where ops of this buffer should be inserted later (NULL when uninitialized)
2386 
2387   // list of insertion points. index and count are stored alternately:
2388   // _index_and_count[i * 2]:     the index into lir list where "count" ops should be inserted
2389   // _index_and_count[i * 2 + 1]: the number of ops to be inserted at index

 321   friend BasicType as_BasicType(OprType t);
 322 
 323   OprType type_field_valid() const               { assert(is_register() || is_stack(), "should not be called otherwise"); return (OprType)(value() & type_mask); }
 324   OprType type_field() const                     { return is_illegal() ? unknown_type : (OprType)(value() & type_mask); }
 325 
 326   static OprSize size_for(BasicType t) {
 327     switch (t) {
 328       case T_LONG:
 329       case T_DOUBLE:
 330         return double_size;
 331         break;
 332 
 333       case T_FLOAT:
 334       case T_BOOLEAN:
 335       case T_CHAR:
 336       case T_BYTE:
 337       case T_SHORT:
 338       case T_INT:
 339       case T_ADDRESS:
 340       case T_OBJECT:
 341       case T_PRIMITIVE_OBJECT:
 342       case T_ARRAY:
 343       case T_METADATA:
 344         return single_size;
 345         break;
 346 
 347       default:
 348         ShouldNotReachHere();
 349         return single_size;
 350       }
 351   }
 352 
 353 
 354   void validate_type() const PRODUCT_RETURN;
 355 
 356   BasicType type() const {
 357     if (is_pointer()) {
 358       return pointer()->type();
 359     }
 360     return as_BasicType(type_field());
 361   }

 471   int fpu() const { return lo_reg_half(); }
 472 #endif
 473 
 474   jint      as_jint()    const { return as_constant_ptr()->as_jint(); }
 475   jlong     as_jlong()   const { return as_constant_ptr()->as_jlong(); }
 476   jfloat    as_jfloat()  const { return as_constant_ptr()->as_jfloat(); }
 477   jdouble   as_jdouble() const { return as_constant_ptr()->as_jdouble(); }
 478   jobject   as_jobject() const { return as_constant_ptr()->as_jobject(); }
 479 
 480   void print() const PRODUCT_RETURN;
 481   void print(outputStream* out) const PRODUCT_RETURN;
 482 };
 483 
 484 inline LIR_Opr::OprType as_OprType(BasicType type) {
 485   switch (type) {
 486   case T_INT:      return LIR_Opr::int_type;
 487   case T_LONG:     return LIR_Opr::long_type;
 488   case T_FLOAT:    return LIR_Opr::float_type;
 489   case T_DOUBLE:   return LIR_Opr::double_type;
 490   case T_OBJECT:
 491   case T_PRIMITIVE_OBJECT:
 492   case T_ARRAY:    return LIR_Opr::object_type;
 493   case T_ADDRESS:  return LIR_Opr::address_type;
 494   case T_METADATA: return LIR_Opr::metadata_type;
 495   case T_ILLEGAL:  // fall through
 496   default: ShouldNotReachHere(); return LIR_Opr::unknown_type;
 497   }
 498 }
 499 
 500 inline BasicType as_BasicType(LIR_Opr::OprType t) {
 501   switch (t) {
 502   case LIR_Opr::int_type:     return T_INT;
 503   case LIR_Opr::long_type:    return T_LONG;
 504   case LIR_Opr::float_type:   return T_FLOAT;
 505   case LIR_Opr::double_type:  return T_DOUBLE;
 506   case LIR_Opr::object_type:  return T_OBJECT;
 507   case LIR_Opr::address_type: return T_ADDRESS;
 508   case LIR_Opr::metadata_type:return T_METADATA;
 509   case LIR_Opr::unknown_type: // fall through
 510   default: ShouldNotReachHere();  return T_ILLEGAL;
 511   }

 663   }
 664   static LIR_Opr double_xmm(int reg) {
 665     return (LIR_Opr)(intptr_t)((reg << LIR_Opr::reg1_shift) |
 666                                (reg << LIR_Opr::reg2_shift) |
 667                                LIR_Opr::double_type         |
 668                                LIR_Opr::fpu_register        |
 669                                LIR_Opr::double_size         |
 670                                LIR_Opr::is_xmm_mask);
 671   }
 672 #endif // X86
 673 
 674   static LIR_Opr virtual_register(int index, BasicType type) {
 675     if (index > LIR_Opr::vreg_max) {
 676       // Running out of virtual registers. Caller should bailout.
 677       return illegalOpr;
 678     }
 679 
 680     LIR_Opr res;
 681     switch (type) {
 682       case T_OBJECT: // fall through
 683       case T_PRIMITIVE_OBJECT: // fall through
 684       case T_ARRAY:
 685         res = (LIR_Opr)(intptr_t)((index << LIR_Opr::data_shift)  |
 686                                             LIR_Opr::object_type  |
 687                                             LIR_Opr::cpu_register |
 688                                             LIR_Opr::single_size  |
 689                                             LIR_Opr::virtual_mask);
 690         break;
 691 
 692       case T_METADATA:
 693         res = (LIR_Opr)(intptr_t)((index << LIR_Opr::data_shift)  |
 694                                             LIR_Opr::metadata_type|
 695                                             LIR_Opr::cpu_register |
 696                                             LIR_Opr::single_size  |
 697                                             LIR_Opr::virtual_mask);
 698         break;
 699 
 700       case T_INT:
 701         res = (LIR_Opr)(intptr_t)((index << LIR_Opr::data_shift) |
 702                                   LIR_Opr::int_type              |
 703                                   LIR_Opr::cpu_register          |

 768                                t |
 769                                LIR_Opr::cpu_register |
 770                                LIR_Opr::size_for(type) | LIR_Opr::virtual_mask);
 771 #else // __SOFTFP__
 772     LIR_Opr old_res = (LIR_Opr)(intptr_t)((index << LIR_Opr::data_shift) | t |
 773                                           ((type == T_FLOAT || type == T_DOUBLE) ?  LIR_Opr::fpu_register : LIR_Opr::cpu_register) |
 774                                LIR_Opr::size_for(type) | LIR_Opr::virtual_mask);
 775     assert(res == old_res, "old and new method not equal");
 776 #endif // __SOFTFP__
 777 #endif // ASSERT
 778 
 779     return res;
 780   }
 781 
 782   // 'index' is computed by FrameMap::local_stack_pos(index); do not use other parameters as
 783   // the index is platform independent; a double stack using indices 2 and 3 has always
 784   // index 2.
 785   static LIR_Opr stack(int index, BasicType type) {
 786     LIR_Opr res;
 787     switch (type) {
 788       case T_PRIMITIVE_OBJECT: // fall through
 789       case T_OBJECT: // fall through
 790       case T_ARRAY:
 791         res = (LIR_Opr)(intptr_t)((index << LIR_Opr::data_shift) |
 792                                   LIR_Opr::object_type           |
 793                                   LIR_Opr::stack_value           |
 794                                   LIR_Opr::single_size);
 795         break;
 796 
 797       case T_METADATA:
 798         res = (LIR_Opr)(intptr_t)((index << LIR_Opr::data_shift) |
 799                                   LIR_Opr::metadata_type         |
 800                                   LIR_Opr::stack_value           |
 801                                   LIR_Opr::single_size);
 802         break;
 803       case T_INT:
 804         res = (LIR_Opr)(intptr_t)((index << LIR_Opr::data_shift) |
 805                                   LIR_Opr::int_type              |
 806                                   LIR_Opr::stack_value           |
 807                                   LIR_Opr::single_size);
 808         break;

 883 class    LIR_Op0;
 884 class      LIR_OpLabel;
 885 class    LIR_Op1;
 886 class      LIR_OpBranch;
 887 class      LIR_OpConvert;
 888 class      LIR_OpAllocObj;
 889 class      LIR_OpReturn;
 890 class      LIR_OpRoundFP;
 891 class    LIR_Op2;
 892 class    LIR_OpDelay;
 893 class    LIR_Op3;
 894 class      LIR_OpAllocArray;
 895 class    LIR_Op4;
 896 class    LIR_OpCall;
 897 class      LIR_OpJavaCall;
 898 class      LIR_OpRTCall;
 899 class    LIR_OpArrayCopy;
 900 class    LIR_OpUpdateCRC32;
 901 class    LIR_OpLock;
 902 class    LIR_OpTypeCheck;
 903 class    LIR_OpFlattenedArrayCheck;
 904 class    LIR_OpNullFreeArrayCheck;
 905 class    LIR_OpSubstitutabilityCheck;
 906 class    LIR_OpCompareAndSwap;
 907 class    LIR_OpLoadKlass;
 908 class    LIR_OpProfileCall;
 909 class    LIR_OpProfileType;
 910 class    LIR_OpProfileInlineType;
 911 #ifdef ASSERT
 912 class    LIR_OpAssert;
 913 #endif
 914 
 915 // LIR operation codes
 916 enum LIR_Code {
 917     lir_none
 918   , begin_op0
 919       , lir_label
 920       , lir_nop
 921       , lir_std_entry
 922       , lir_osr_entry
 923       , lir_fpop_raw
 924       , lir_breakpoint
 925       , lir_rtcall
 926       , lir_membar
 927       , lir_membar_acquire
 928       , lir_membar_release
 929       , lir_membar_loadload
 930       , lir_membar_storestore
 931       , lir_membar_loadstore
 932       , lir_membar_storeload
 933       , lir_get_thread
 934       , lir_on_spin_wait
 935       , lir_check_orig_pc
 936   , end_op0
 937   , begin_op1
 938       , lir_fxch
 939       , lir_fld
 940       , lir_push
 941       , lir_pop
 942       , lir_null_check
 943       , lir_return
 944       , lir_leal
 945       , lir_move
 946       , lir_convert
 947       , lir_alloc_object
 948       , lir_monaddr
 949       , lir_roundfp
 950       , lir_safepoint
 951       , lir_unwind
 952       , lir_load_klass
 953   , end_op1
 954   , begin_op2
 955       , lir_branch

 995       , lir_dynamic_call
 996   , end_opJavaCall
 997   , begin_opArrayCopy
 998       , lir_arraycopy
 999   , end_opArrayCopy
1000   , begin_opUpdateCRC32
1001       , lir_updatecrc32
1002   , end_opUpdateCRC32
1003   , begin_opLock
1004     , lir_lock
1005     , lir_unlock
1006   , end_opLock
1007   , begin_delay_slot
1008     , lir_delay_slot
1009   , end_delay_slot
1010   , begin_opTypeCheck
1011     , lir_instanceof
1012     , lir_checkcast
1013     , lir_store_check
1014   , end_opTypeCheck
1015   , begin_opFlattenedArrayCheck
1016     , lir_flattened_array_check
1017   , end_opFlattenedArrayCheck
1018   , begin_opNullFreeArrayCheck
1019     , lir_null_free_array_check
1020   , end_opNullFreeArrayCheck
1021   , begin_opSubstitutabilityCheck
1022     , lir_substitutability_check
1023   , end_opSubstitutabilityCheck
1024   , begin_opCompareAndSwap
1025     , lir_cas_long
1026     , lir_cas_obj
1027     , lir_cas_int
1028   , end_opCompareAndSwap
1029   , begin_opMDOProfile
1030     , lir_profile_call
1031     , lir_profile_type
1032     , lir_profile_inline_type
1033   , end_opMDOProfile
1034   , begin_opAssert
1035     , lir_assert
1036   , end_opAssert
1037 #ifdef INCLUDE_ZGC
1038   , begin_opZLoadBarrierTest
1039     , lir_zloadbarrier_test
1040   , end_opZLoadBarrierTest
1041 #endif
1042 };
1043 
1044 
1045 enum LIR_Condition {
1046     lir_cond_equal
1047   , lir_cond_notEqual
1048   , lir_cond_less
1049   , lir_cond_lessEqual
1050   , lir_cond_greaterEqual
1051   , lir_cond_greater
1052   , lir_cond_belowEqual

1161   virtual LIR_OpCall* as_OpCall() { return NULL; }
1162   virtual LIR_OpJavaCall* as_OpJavaCall() { return NULL; }
1163   virtual LIR_OpLabel* as_OpLabel() { return NULL; }
1164   virtual LIR_OpDelay* as_OpDelay() { return NULL; }
1165   virtual LIR_OpLock* as_OpLock() { return NULL; }
1166   virtual LIR_OpAllocArray* as_OpAllocArray() { return NULL; }
1167   virtual LIR_OpAllocObj* as_OpAllocObj() { return NULL; }
1168   virtual LIR_OpRoundFP* as_OpRoundFP() { return NULL; }
1169   virtual LIR_OpBranch* as_OpBranch() { return NULL; }
1170   virtual LIR_OpReturn* as_OpReturn() { return NULL; }
1171   virtual LIR_OpRTCall* as_OpRTCall() { return NULL; }
1172   virtual LIR_OpConvert* as_OpConvert() { return NULL; }
1173   virtual LIR_Op0* as_Op0() { return NULL; }
1174   virtual LIR_Op1* as_Op1() { return NULL; }
1175   virtual LIR_Op2* as_Op2() { return NULL; }
1176   virtual LIR_Op3* as_Op3() { return NULL; }
1177   virtual LIR_Op4* as_Op4() { return NULL; }
1178   virtual LIR_OpArrayCopy* as_OpArrayCopy() { return NULL; }
1179   virtual LIR_OpUpdateCRC32* as_OpUpdateCRC32() { return NULL; }
1180   virtual LIR_OpTypeCheck* as_OpTypeCheck() { return NULL; }
1181   virtual LIR_OpFlattenedArrayCheck* as_OpFlattenedArrayCheck() { return NULL; }
1182   virtual LIR_OpNullFreeArrayCheck* as_OpNullFreeArrayCheck() { return NULL; }
1183   virtual LIR_OpSubstitutabilityCheck* as_OpSubstitutabilityCheck() { return NULL; }
1184   virtual LIR_OpCompareAndSwap* as_OpCompareAndSwap() { return NULL; }
1185   virtual LIR_OpLoadKlass* as_OpLoadKlass() { return NULL; }
1186   virtual LIR_OpProfileCall* as_OpProfileCall() { return NULL; }
1187   virtual LIR_OpProfileType* as_OpProfileType() { return NULL; }
1188   virtual LIR_OpProfileInlineType* as_OpProfileInlineType() { return NULL; }
1189 #ifdef ASSERT
1190   virtual LIR_OpAssert* as_OpAssert() { return NULL; }
1191 #endif
1192 
1193   virtual void verify() const {}
1194 };
1195 
1196 // for calls
1197 class LIR_OpCall: public LIR_Op {
1198  friend class LIR_OpVisitState;
1199 
1200  protected:
1201   address      _addr;
1202   LIR_OprList* _arguments;
1203  protected:
1204   LIR_OpCall(LIR_Code code, address addr, LIR_Opr result,
1205              LIR_OprList* arguments, CodeEmitInfo* info = NULL)
1206     : LIR_Op(code, result, info)
1207     , _addr(addr)
1208     , _arguments(arguments) {}

1241                  LIR_OprList* arguments, CodeEmitInfo* info)
1242   : LIR_OpCall(code, (address)vtable_offset, result, arguments, info)
1243   , _method(method)
1244   , _receiver(receiver)
1245   , _method_handle_invoke_SP_save_opr(LIR_OprFact::illegalOpr)
1246   { assert(is_in_range(code, begin_opJavaCall, end_opJavaCall), "code check"); }
1247 
1248   LIR_Opr receiver() const                       { return _receiver; }
1249   ciMethod* method() const                       { return _method;   }
1250 
1251   // JSR 292 support.
1252   bool is_invokedynamic() const                  { return code() == lir_dynamic_call; }
1253   bool is_method_handle_invoke() const {
1254     return method()->is_compiled_lambda_form() ||   // Java-generated lambda form
1255            method()->is_method_handle_intrinsic();  // JVM-generated MH intrinsic
1256   }
1257 
1258   virtual void emit_code(LIR_Assembler* masm);
1259   virtual LIR_OpJavaCall* as_OpJavaCall() { return this; }
1260   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1261 
1262   bool maybe_return_as_fields(ciInlineKlass** vk = NULL) const;
1263 };
1264 
1265 // --------------------------------------------------
1266 // LIR_OpLabel
1267 // --------------------------------------------------
1268 // Location where a branch can continue
1269 class LIR_OpLabel: public LIR_Op {
1270  friend class LIR_OpVisitState;
1271 
1272  private:
1273   Label* _label;
1274  public:
1275   LIR_OpLabel(Label* lbl)
1276    : LIR_Op(lir_label, LIR_OprFact::illegalOpr, NULL)
1277    , _label(lbl)                                 {}
1278   Label* label() const                           { return _label; }
1279 
1280   virtual void emit_code(LIR_Assembler* masm);
1281   virtual LIR_OpLabel* as_OpLabel() { return this; }
1282   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;

1294   LIR_Opr   _dst_pos;
1295   LIR_Opr   _length;
1296   LIR_Opr   _tmp;
1297   ciArrayKlass* _expected_type;
1298   int       _flags;
1299 
1300 public:
1301   enum Flags {
1302     src_null_check         = 1 << 0,
1303     dst_null_check         = 1 << 1,
1304     src_pos_positive_check = 1 << 2,
1305     dst_pos_positive_check = 1 << 3,
1306     length_positive_check  = 1 << 4,
1307     src_range_check        = 1 << 5,
1308     dst_range_check        = 1 << 6,
1309     type_check             = 1 << 7,
1310     overlapping            = 1 << 8,
1311     unaligned              = 1 << 9,
1312     src_objarray           = 1 << 10,
1313     dst_objarray           = 1 << 11,
1314     always_slow_path       = 1 << 12,
1315     src_inlinetype_check   = 1 << 13,
1316     dst_inlinetype_check   = 1 << 14,
1317     all_flags              = (1 << 15) - 1
1318   };
1319 
1320   LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length, LIR_Opr tmp,
1321                   ciArrayKlass* expected_type, int flags, CodeEmitInfo* info);
1322 
1323   LIR_Opr src() const                            { return _src; }
1324   LIR_Opr src_pos() const                        { return _src_pos; }
1325   LIR_Opr dst() const                            { return _dst; }
1326   LIR_Opr dst_pos() const                        { return _dst_pos; }
1327   LIR_Opr length() const                         { return _length; }
1328   LIR_Opr tmp() const                            { return _tmp; }
1329   int flags() const                              { return _flags; }
1330   ciArrayKlass* expected_type() const            { return _expected_type; }
1331   ArrayCopyStub* stub() const                    { return _stub; }
1332 
1333   virtual void emit_code(LIR_Assembler* masm);
1334   virtual LIR_OpArrayCopy* as_OpArrayCopy() { return this; }
1335   void print_instr(outputStream* out) const PRODUCT_RETURN;
1336 };
1337 

1560 };
1561 
1562 // LIR_OpTypeCheck
1563 class LIR_OpTypeCheck: public LIR_Op {
1564  friend class LIR_OpVisitState;
1565 
1566  private:
1567   LIR_Opr       _object;
1568   LIR_Opr       _array;
1569   ciKlass*      _klass;
1570   LIR_Opr       _tmp1;
1571   LIR_Opr       _tmp2;
1572   LIR_Opr       _tmp3;
1573   bool          _fast_check;
1574   CodeEmitInfo* _info_for_patch;
1575   CodeEmitInfo* _info_for_exception;
1576   CodeStub*     _stub;
1577   ciMethod*     _profiled_method;
1578   int           _profiled_bci;
1579   bool          _should_profile;
1580   bool          _need_null_check;
1581 
1582 public:
1583   LIR_OpTypeCheck(LIR_Code code, LIR_Opr result, LIR_Opr object, ciKlass* klass,
1584                   LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
1585                   CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub, bool need_null_check = true);
1586   LIR_OpTypeCheck(LIR_Code code, LIR_Opr object, LIR_Opr array,
1587                   LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, CodeEmitInfo* info_for_exception);
1588 
1589   LIR_Opr object() const                         { return _object;         }
1590   LIR_Opr array() const                          { assert(code() == lir_store_check, "not valid"); return _array;         }
1591   LIR_Opr tmp1() const                           { return _tmp1;           }
1592   LIR_Opr tmp2() const                           { return _tmp2;           }
1593   LIR_Opr tmp3() const                           { return _tmp3;           }
1594   ciKlass* klass() const                         { assert(code() == lir_instanceof || code() == lir_checkcast, "not valid"); return _klass;          }
1595   bool fast_check() const                        { assert(code() == lir_instanceof || code() == lir_checkcast, "not valid"); return _fast_check;     }
1596   CodeEmitInfo* info_for_patch() const           { return _info_for_patch;  }
1597   CodeEmitInfo* info_for_exception() const       { return _info_for_exception; }
1598   CodeStub* stub() const                         { return _stub;           }
1599 
1600   // MethodData* profiling
1601   void set_profiled_method(ciMethod *method)     { _profiled_method = method; }
1602   void set_profiled_bci(int bci)                 { _profiled_bci = bci;       }
1603   void set_should_profile(bool b)                { _should_profile = b;       }
1604   ciMethod* profiled_method() const              { return _profiled_method;   }
1605   int       profiled_bci() const                 { return _profiled_bci;      }
1606   bool      should_profile() const               { return _should_profile;    }
1607   bool      need_null_check() const              { return _need_null_check;   }
1608   virtual bool is_patching() { return _info_for_patch != NULL; }
1609   virtual void emit_code(LIR_Assembler* masm);
1610   virtual LIR_OpTypeCheck* as_OpTypeCheck() { return this; }
1611   void print_instr(outputStream* out) const PRODUCT_RETURN;
1612 };
1613 
1614 // LIR_OpFlattenedArrayCheck
1615 class LIR_OpFlattenedArrayCheck: public LIR_Op {
1616  friend class LIR_OpVisitState;
1617 
1618  private:
1619   LIR_Opr       _array;
1620   LIR_Opr       _value;
1621   LIR_Opr       _tmp;
1622   CodeStub*     _stub;
1623 public:
1624   LIR_OpFlattenedArrayCheck(LIR_Opr array, LIR_Opr value, LIR_Opr tmp, CodeStub* stub);
1625   LIR_Opr array() const                          { return _array;         }
1626   LIR_Opr value() const                          { return _value;         }
1627   LIR_Opr tmp() const                            { return _tmp;           }
1628   CodeStub* stub() const                         { return _stub;          }
1629 
1630   virtual void emit_code(LIR_Assembler* masm);
1631   virtual LIR_OpFlattenedArrayCheck* as_OpFlattenedArrayCheck() { return this; }
1632   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1633 };
1634 
1635 // LIR_OpNullFreeArrayCheck
1636 class LIR_OpNullFreeArrayCheck: public LIR_Op {
1637  friend class LIR_OpVisitState;
1638 
1639  private:
1640   LIR_Opr       _array;
1641   LIR_Opr       _tmp;
1642 public:
1643   LIR_OpNullFreeArrayCheck(LIR_Opr array, LIR_Opr tmp);
1644   LIR_Opr array() const                          { return _array;         }
1645   LIR_Opr tmp() const                            { return _tmp;           }
1646 
1647   virtual void emit_code(LIR_Assembler* masm);
1648   virtual LIR_OpNullFreeArrayCheck* as_OpNullFreeArrayCheck() { return this; }
1649   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1650 };
1651 
1652 class LIR_OpSubstitutabilityCheck: public LIR_Op {
1653  friend class LIR_OpVisitState;
1654 
1655  private:
1656   LIR_Opr       _left;
1657   LIR_Opr       _right;
1658   LIR_Opr       _equal_result;
1659   LIR_Opr       _not_equal_result;
1660   LIR_Opr       _tmp1;
1661   LIR_Opr       _tmp2;
1662   ciKlass*      _left_klass;
1663   ciKlass*      _right_klass;
1664   LIR_Opr       _left_klass_op;
1665   LIR_Opr       _right_klass_op;
1666   CodeStub*     _stub;
1667 public:
1668   LIR_OpSubstitutabilityCheck(LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr equal_result, LIR_Opr not_equal_result,
1669                               LIR_Opr tmp1, LIR_Opr tmp2,
1670                               ciKlass* left_klass, ciKlass* right_klass, LIR_Opr left_klass_op, LIR_Opr right_klass_op,
1671                               CodeEmitInfo* info, CodeStub* stub);
1672 
1673   LIR_Opr left() const             { return _left; }
1674   LIR_Opr right() const            { return _right; }
1675   LIR_Opr equal_result() const     { return _equal_result; }
1676   LIR_Opr not_equal_result() const { return _not_equal_result; }
1677   LIR_Opr tmp1() const             { return _tmp1; }
1678   LIR_Opr tmp2() const             { return _tmp2; }
1679   ciKlass* left_klass() const      { return _left_klass; }
1680   ciKlass* right_klass() const     { return _right_klass; }
1681   LIR_Opr left_klass_op() const    { return _left_klass_op; }
1682   LIR_Opr right_klass_op() const   { return _right_klass_op; }
1683   CodeStub* stub() const           { return _stub; }
1684 
1685   virtual void emit_code(LIR_Assembler* masm);
1686   virtual LIR_OpSubstitutabilityCheck* as_OpSubstitutabilityCheck() { return this; }
1687   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1688 };
1689 
1690 // LIR_Op2
1691 class LIR_Op2: public LIR_Op {
1692  friend class LIR_OpVisitState;
1693 
1694   int  _fpu_stack_size; // for sin/cos implementation on Intel
1695 
1696  protected:
1697   LIR_Opr   _opr1;
1698   LIR_Opr   _opr2;
1699   BasicType _type;
1700   LIR_Opr   _tmp1;
1701   LIR_Opr   _tmp2;
1702   LIR_Opr   _tmp3;
1703   LIR_Opr   _tmp4;
1704   LIR_Opr   _tmp5;
1705   LIR_Condition _condition;
1706 
1707   void verify() const;
1708 
1709  public:

1964 
1965 //--------------------------------
1966 class LabelObj: public CompilationResourceObj {
1967  private:
1968   Label _label;
1969  public:
1970   LabelObj()                                     {}
1971   Label* label()                                 { return &_label; }
1972 };
1973 
1974 
1975 class LIR_OpLock: public LIR_Op {
1976  friend class LIR_OpVisitState;
1977 
1978  private:
1979   LIR_Opr _hdr;
1980   LIR_Opr _obj;
1981   LIR_Opr _lock;
1982   LIR_Opr _scratch;
1983   CodeStub* _stub;
1984   CodeStub* _throw_imse_stub;
1985  public:
1986   LIR_OpLock(LIR_Code code, LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info, CodeStub* throw_imse_stub=NULL)
1987     : LIR_Op(code, LIR_OprFact::illegalOpr, info)
1988     , _hdr(hdr)
1989     , _obj(obj)
1990     , _lock(lock)
1991     , _scratch(scratch)
1992     , _stub(stub)
1993     , _throw_imse_stub(throw_imse_stub)                    {}
1994 
1995   LIR_Opr hdr_opr() const                        { return _hdr; }
1996   LIR_Opr obj_opr() const                        { return _obj; }
1997   LIR_Opr lock_opr() const                       { return _lock; }
1998   LIR_Opr scratch_opr() const                    { return _scratch; }
1999   CodeStub* stub() const                         { return _stub; }
2000   CodeStub* throw_imse_stub() const              { return _throw_imse_stub; }
2001 
2002   virtual void emit_code(LIR_Assembler* masm);
2003   virtual LIR_OpLock* as_OpLock() { return this; }
2004   void print_instr(outputStream* out) const PRODUCT_RETURN;
2005 };
2006 
2007 class LIR_OpLoadKlass: public LIR_Op {
2008   friend class LIR_OpVisitState;
2009 
2010  private:
2011   LIR_Opr _obj;
2012  public:
2013   LIR_OpLoadKlass(LIR_Opr obj, LIR_Opr result, CodeEmitInfo* info)
2014     : LIR_Op(lir_load_klass, result, info)
2015     , _obj(obj)
2016     {}
2017 
2018   LIR_Opr obj()        const { return _obj;  }
2019 
2020   virtual LIR_OpLoadKlass* as_OpLoadKlass() { return this; }

2164     , _obj(obj)
2165     , _tmp(tmp)
2166     , _exact_klass(exact_klass)
2167     , _current_klass(current_klass)
2168     , _not_null(not_null)
2169     , _no_conflict(no_conflict) { }
2170 
2171   LIR_Opr      mdp()              const             { return _mdp;              }
2172   LIR_Opr      obj()              const             { return _obj;              }
2173   LIR_Opr      tmp()              const             { return _tmp;              }
2174   ciKlass*     exact_klass()      const             { return _exact_klass;      }
2175   intptr_t     current_klass()    const             { return _current_klass;    }
2176   bool         not_null()         const             { return _not_null;         }
2177   bool         no_conflict()      const             { return _no_conflict;      }
2178 
2179   virtual void emit_code(LIR_Assembler* masm);
2180   virtual LIR_OpProfileType* as_OpProfileType() { return this; }
2181   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
2182 };
2183 
2184 // LIR_OpProfileInlineType
2185 class LIR_OpProfileInlineType : public LIR_Op {
2186  friend class LIR_OpVisitState;
2187 
2188  private:
2189   LIR_Opr      _mdp;
2190   LIR_Opr      _obj;
2191   int          _flag;
2192   LIR_Opr      _tmp;
2193   bool         _not_null;      // true if we know statically that _obj cannot be null
2194 
2195  public:
2196   // Destroys recv
2197   LIR_OpProfileInlineType(LIR_Opr mdp, LIR_Opr obj, int flag, LIR_Opr tmp, bool not_null)
2198     : LIR_Op(lir_profile_inline_type, LIR_OprFact::illegalOpr, NULL)  // no result, no info
2199     , _mdp(mdp)
2200     , _obj(obj)
2201     , _flag(flag)
2202     , _tmp(tmp)
2203     , _not_null(not_null) { }
2204 
2205   LIR_Opr      mdp()              const             { return _mdp;              }
2206   LIR_Opr      obj()              const             { return _obj;              }
2207   int          flag()             const             { return _flag;             }
2208   LIR_Opr      tmp()              const             { return _tmp;              }
2209   bool         not_null()         const             { return _not_null;         }
2210 
2211   virtual void emit_code(LIR_Assembler* masm);
2212   virtual LIR_OpProfileInlineType* as_OpProfileInlineType() { return this; }
2213   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
2214 };
2215 
2216 class LIR_InsertionBuffer;
2217 
2218 //--------------------------------LIR_List---------------------------------------------------
2219 // Maintains a list of LIR instructions (one instance of LIR_List per basic block)
2220 // The LIR instructions are appended by the LIR_List class itself;
2221 //
2222 // Notes:
2223 // - all offsets are(should be) in bytes
2224 // - local positions are specified with an offset, with offset 0 being local 0
2225 
2226 class LIR_List: public CompilationResourceObj {
2227  private:
2228   LIR_OpList  _operations;
2229 
2230   Compilation*  _compilation;
2231 #ifndef PRODUCT
2232   BlockBegin*   _block;
2233 #endif
2234 #ifdef ASSERT
2235   const char *  _file;

2468   void unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp);
2469 
2470   void shift_left(LIR_Opr value, int count, LIR_Opr dst)       { shift_left(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2471   void shift_right(LIR_Opr value, int count, LIR_Opr dst)      { shift_right(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2472   void unsigned_shift_right(LIR_Opr value, int count, LIR_Opr dst) { unsigned_shift_right(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2473 
2474   void lcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst)        { append(new LIR_Op2(lir_cmp_l2i,  left, right, dst)); }
2475   void fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less);
2476 
2477   void call_runtime_leaf(address routine, LIR_Opr tmp, LIR_Opr result, LIR_OprList* arguments) {
2478     append(new LIR_OpRTCall(routine, tmp, result, arguments));
2479   }
2480 
2481   void call_runtime(address routine, LIR_Opr tmp, LIR_Opr result,
2482                     LIR_OprList* arguments, CodeEmitInfo* info) {
2483     append(new LIR_OpRTCall(routine, tmp, result, arguments, info));
2484   }
2485 
2486   void load_stack_address_monitor(int monitor_ix, LIR_Opr dst)  { append(new LIR_Op1(lir_monaddr, LIR_OprFact::intConst(monitor_ix), dst)); }
2487   void unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub);
2488   void lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info, CodeStub* throw_imse_stub=NULL);
2489 
2490   void breakpoint()                                                  { append(new LIR_Op0(lir_breakpoint)); }
2491 
2492   void arraycopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length, LIR_Opr tmp, ciArrayKlass* expected_type, int flags, CodeEmitInfo* info) { append(new LIR_OpArrayCopy(src, src_pos, dst, dst_pos, length, tmp, expected_type, flags, info)); }
2493 
2494   void update_crc32(LIR_Opr crc, LIR_Opr val, LIR_Opr res)  { append(new LIR_OpUpdateCRC32(crc, val, res)); }
2495 
2496   void 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);
2497   void store_check(LIR_Opr object, LIR_Opr array, LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, CodeEmitInfo* info_for_exception, ciMethod* profiled_method, int profiled_bci);
2498   void check_flattened_array(LIR_Opr array, LIR_Opr value, LIR_Opr tmp, CodeStub* stub);
2499   void check_null_free_array(LIR_Opr array, LIR_Opr tmp);
2500   void substitutability_check(LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr equal_result, LIR_Opr not_equal_result,
2501                               LIR_Opr tmp1, LIR_Opr tmp2,
2502                               ciKlass* left_klass, ciKlass* right_klass, LIR_Opr left_klass_op, LIR_Opr right_klass_op,
2503                               CodeEmitInfo* info, CodeStub* stub);
2504 
2505   void checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
2506                   LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
2507                   CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
2508                   ciMethod* profiled_method, int profiled_bci, bool is_null_free);
2509   // MethodData* profiling
2510   void profile_call(ciMethod* method, int bci, ciMethod* callee, LIR_Opr mdo, LIR_Opr recv, LIR_Opr t1, ciKlass* cha_klass) {
2511     append(new LIR_OpProfileCall(method, bci, callee, mdo, recv, t1, cha_klass));
2512   }
2513   void profile_type(LIR_Address* mdp, LIR_Opr obj, ciKlass* exact_klass, intptr_t current_klass, LIR_Opr tmp, bool not_null, bool no_conflict) {
2514     append(new LIR_OpProfileType(LIR_OprFact::address(mdp), obj, exact_klass, current_klass, tmp, not_null, no_conflict));
2515   }
2516   void profile_inline_type(LIR_Address* mdp, LIR_Opr obj, int flag, LIR_Opr tmp, bool not_null) {
2517     append(new LIR_OpProfileInlineType(LIR_OprFact::address(mdp), obj, flag, tmp, not_null));
2518   }
2519 
2520   void xadd(LIR_Opr src, LIR_Opr add, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xadd, src, add, res, tmp)); }
2521   void xchg(LIR_Opr src, LIR_Opr set, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xchg, src, set, res, tmp)); }
2522 
2523   void load_klass(LIR_Opr obj, LIR_Opr result, CodeEmitInfo* info) { append(new LIR_OpLoadKlass(obj, result, info)); }
2524 
2525 #ifdef ASSERT
2526   void lir_assert(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, const char* msg, bool halt) { append(new LIR_OpAssert(condition, opr1, opr2, msg, halt)); }
2527 #endif
2528 };
2529 
2530 void print_LIR(BlockList* blocks);
2531 
2532 class LIR_InsertionBuffer : public CompilationResourceObj {
2533  private:
2534   LIR_List*   _lir;   // the lir list where ops of this buffer should be inserted later (NULL when uninitialized)
2535 
2536   // list of insertion points. index and count are stored alternately:
2537   // _index_and_count[i * 2]:     the index into lir list where "count" ops should be inserted
2538   // _index_and_count[i * 2 + 1]: the number of ops to be inserted at index
< prev index next >