< prev index next >

src/hotspot/share/c1/c1_LIR.hpp

Print this page

 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

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









1008   , begin_opCompareAndSwap
1009     , lir_cas_long
1010     , lir_cas_obj
1011     , lir_cas_int
1012   , end_opCompareAndSwap
1013   , begin_opMDOProfile
1014     , lir_profile_call
1015     , lir_profile_type

1016   , end_opMDOProfile
1017   , begin_opAssert
1018     , lir_assert
1019   , end_opAssert
1020 #ifdef INCLUDE_ZGC
1021   , begin_opXLoadBarrierTest
1022     , lir_xloadbarrier_test
1023   , end_opXLoadBarrierTest
1024 #endif
1025 };
1026 
1027 
1028 enum LIR_Condition {
1029     lir_cond_equal
1030   , lir_cond_notEqual
1031   , lir_cond_less
1032   , lir_cond_lessEqual
1033   , lir_cond_greaterEqual
1034   , lir_cond_greater
1035   , lir_cond_belowEqual

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



1164   virtual LIR_OpCompareAndSwap* as_OpCompareAndSwap() { return nullptr; }
1165   virtual LIR_OpLoadKlass* as_OpLoadKlass() { return nullptr; }
1166   virtual LIR_OpProfileCall* as_OpProfileCall() { return nullptr; }
1167   virtual LIR_OpProfileType* as_OpProfileType() { return nullptr; }

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

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


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

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



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

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

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












































































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

1733   void          change_ublock(BlockBegin* b);
1734   void          negate_cond();
1735 
1736   virtual void emit_code(LIR_Assembler* masm);
1737   virtual LIR_OpBranch* as_OpBranch() { return this; }
1738   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1739 };
1740 
1741 class LIR_OpAllocArray : public LIR_Op {
1742  friend class LIR_OpVisitState;
1743 
1744  private:
1745   LIR_Opr   _klass;
1746   LIR_Opr   _len;
1747   LIR_Opr   _tmp1;
1748   LIR_Opr   _tmp2;
1749   LIR_Opr   _tmp3;
1750   LIR_Opr   _tmp4;
1751   BasicType _type;
1752   CodeStub* _stub;

1753 
1754  public:
1755   LIR_OpAllocArray(LIR_Opr klass, LIR_Opr len, LIR_Opr result, LIR_Opr t1, LIR_Opr t2, LIR_Opr t3, LIR_Opr t4, BasicType type, CodeStub* stub)
1756     : LIR_Op(lir_alloc_array, result, nullptr)
1757     , _klass(klass)
1758     , _len(len)
1759     , _tmp1(t1)
1760     , _tmp2(t2)
1761     , _tmp3(t3)
1762     , _tmp4(t4)
1763     , _type(type)
1764     , _stub(stub) {}

1765 
1766   LIR_Opr   klass()   const                      { return _klass;       }
1767   LIR_Opr   len()     const                      { return _len;         }
1768   LIR_Opr   obj()     const                      { return result_opr(); }
1769   LIR_Opr   tmp1()    const                      { return _tmp1;        }
1770   LIR_Opr   tmp2()    const                      { return _tmp2;        }
1771   LIR_Opr   tmp3()    const                      { return _tmp3;        }
1772   LIR_Opr   tmp4()    const                      { return _tmp4;        }
1773   BasicType type()    const                      { return _type;        }
1774   CodeStub* stub()    const                      { return _stub;        }

1775 
1776   virtual void emit_code(LIR_Assembler* masm);
1777   virtual LIR_OpAllocArray * as_OpAllocArray () { return this; }
1778   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1779 };
1780 
1781 
1782 class LIR_Op3: public LIR_Op {
1783  friend class LIR_OpVisitState;
1784 
1785  private:
1786   LIR_Opr _opr1;
1787   LIR_Opr _opr2;
1788   LIR_Opr _opr3;
1789  public:
1790   LIR_Op3(LIR_Code code, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr opr3, LIR_Opr result, CodeEmitInfo* info = nullptr)
1791     : LIR_Op(code, result, info)
1792     , _opr1(opr1)
1793     , _opr2(opr2)
1794     , _opr3(opr3)                                { assert(is_in_range(code, begin_op3, end_op3), "code check"); }

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

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

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

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

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
































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

2285   void div (LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_div, left, right, res, tmp)); }
2286   void rem (LIR_Opr left, LIR_Opr right, LIR_Opr res, CodeEmitInfo* info = nullptr)      { append(new LIR_Op2(lir_rem, left, right, res, info)); }
2287 
2288   void volatile_load_mem_reg(LIR_Address* address, LIR_Opr dst, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);
2289   void volatile_load_unsafe_reg(LIR_Opr base, LIR_Opr offset, LIR_Opr dst, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code);
2290 
2291   void load(LIR_Address* addr, LIR_Opr src, CodeEmitInfo* info = nullptr, LIR_PatchCode patch_code = lir_patch_none);
2292 
2293   void store_mem_int(jint v,    LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);
2294   void store_mem_oop(jobject o, LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);
2295   void store(LIR_Opr src, LIR_Address* addr, CodeEmitInfo* info = nullptr, LIR_PatchCode patch_code = lir_patch_none);
2296   void volatile_store_mem_reg(LIR_Opr src, LIR_Address* address, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);
2297   void volatile_store_unsafe_reg(LIR_Opr src, LIR_Opr base, LIR_Opr offset, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code);
2298 
2299   void idiv(LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);
2300   void idiv(LIR_Opr left, int   right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);
2301   void irem(LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);
2302   void irem(LIR_Opr left, int   right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);
2303 
2304   void allocate_object(LIR_Opr dst, LIR_Opr t1, LIR_Opr t2, LIR_Opr t3, LIR_Opr t4, int header_size, int object_size, LIR_Opr klass, bool init_check, CodeStub* stub);
2305   void allocate_array(LIR_Opr dst, LIR_Opr len, LIR_Opr t1,LIR_Opr t2, LIR_Opr t3,LIR_Opr t4, BasicType type, LIR_Opr klass, CodeStub* stub);
2306 
2307   // jump is an unconditional branch
2308   void jump(BlockBegin* block) {
2309     append(new LIR_OpBranch(lir_cond_always, block));
2310   }
2311   void jump(CodeStub* stub) {
2312     append(new LIR_OpBranch(lir_cond_always, stub));
2313   }
2314   void branch(LIR_Condition cond, Label* lbl) {
2315     append(new LIR_OpBranch(cond, lbl));
2316   }
2317   // Should not be used for fp comparisons
2318   void branch(LIR_Condition cond, BlockBegin* block) {
2319     append(new LIR_OpBranch(cond, block));
2320   }
2321   // Should not be used for fp comparisons
2322   void branch(LIR_Condition cond, CodeStub* stub) {
2323     append(new LIR_OpBranch(cond, stub));
2324   }
2325   // Should only be used for fp comparisons

2332   void unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp);
2333 
2334   void shift_left(LIR_Opr value, int count, LIR_Opr dst)       { shift_left(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2335   void shift_right(LIR_Opr value, int count, LIR_Opr dst)      { shift_right(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2336   void unsigned_shift_right(LIR_Opr value, int count, LIR_Opr dst) { unsigned_shift_right(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2337 
2338   void lcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst)        { append(new LIR_Op2(lir_cmp_l2i,  left, right, dst)); }
2339   void fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less);
2340 
2341   void call_runtime_leaf(address routine, LIR_Opr tmp, LIR_Opr result, LIR_OprList* arguments) {
2342     append(new LIR_OpRTCall(routine, tmp, result, arguments));
2343   }
2344 
2345   void call_runtime(address routine, LIR_Opr tmp, LIR_Opr result,
2346                     LIR_OprList* arguments, CodeEmitInfo* info) {
2347     append(new LIR_OpRTCall(routine, tmp, result, arguments, info));
2348   }
2349 
2350   void load_stack_address_monitor(int monitor_ix, LIR_Opr dst)  { append(new LIR_Op1(lir_monaddr, LIR_OprFact::intConst(monitor_ix), dst)); }
2351   void unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub);
2352   void lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info);
2353 
2354   void breakpoint()                                                  { append(new LIR_Op0(lir_breakpoint)); }
2355 
2356   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)); }
2357 
2358   void update_crc32(LIR_Opr crc, LIR_Opr val, LIR_Opr res)  { append(new LIR_OpUpdateCRC32(crc, val, res)); }
2359 
2360   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);
2361   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);






2362 
2363   void checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
2364                   LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
2365                   CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
2366                   ciMethod* profiled_method, int profiled_bci);
2367   // MethodData* profiling
2368   void profile_call(ciMethod* method, int bci, ciMethod* callee, LIR_Opr mdo, LIR_Opr recv, LIR_Opr t1, ciKlass* cha_klass) {
2369     append(new LIR_OpProfileCall(method, bci, callee, mdo, recv, t1, cha_klass));
2370   }
2371   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) {
2372     append(new LIR_OpProfileType(LIR_OprFact::address(mdp), obj, exact_klass, current_klass, tmp, not_null, no_conflict));
2373   }



2374 
2375   void xadd(LIR_Opr src, LIR_Opr add, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xadd, src, add, res, tmp)); }
2376   void xchg(LIR_Opr src, LIR_Opr set, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xchg, src, set, res, tmp)); }
2377 
2378   void load_klass(LIR_Opr obj, LIR_Opr result, CodeEmitInfo* info) { append(new LIR_OpLoadKlass(obj, result, info)); }
2379 
2380 #ifdef ASSERT
2381   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)); }
2382 #endif
2383 };
2384 
2385 void print_LIR(BlockList* blocks);
2386 
2387 class LIR_InsertionBuffer : public CompilationResourceObj {
2388  private:
2389   LIR_List*   _lir;   // the lir list where ops of this buffer should be inserted later (null when uninitialized)
2390 
2391   // list of insertion points. index and count are stored alternately:
2392   // _index_and_count[i * 2]:     the index into lir list where "count" ops should be inserted
2393   // _index_and_count[i * 2 + 1]: the number of ops to be inserted at index

 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_OpFlattenedArrayCheck;
 900 class    LIR_OpNullFreeArrayCheck;
 901 class    LIR_OpSubstitutabilityCheck;
 902 class    LIR_OpCompareAndSwap;
 903 class    LIR_OpLoadKlass;
 904 class    LIR_OpProfileCall;
 905 class    LIR_OpProfileType;
 906 class    LIR_OpProfileInlineType;
 907 #ifdef ASSERT
 908 class    LIR_OpAssert;
 909 #endif
 910 
 911 // LIR operation codes
 912 enum LIR_Code {
 913     lir_none
 914   , begin_op0
 915       , lir_label
 916       , lir_nop
 917       , lir_std_entry
 918       , lir_osr_entry
 919       , lir_fpop_raw
 920       , lir_breakpoint
 921       , lir_rtcall
 922       , lir_membar
 923       , lir_membar_acquire
 924       , lir_membar_release
 925       , lir_membar_loadload
 926       , lir_membar_storestore
 927       , lir_membar_loadstore
 928       , lir_membar_storeload
 929       , lir_get_thread
 930       , lir_on_spin_wait
 931       , lir_check_orig_pc
 932   , end_op0
 933   , begin_op1
 934       , lir_fxch
 935       , lir_fld
 936       , lir_push
 937       , lir_pop
 938       , lir_null_check
 939       , lir_return
 940       , lir_leal
 941       , lir_move
 942       , lir_convert
 943       , lir_alloc_object
 944       , lir_monaddr
 945       , lir_roundfp
 946       , lir_safepoint
 947       , lir_unwind
 948       , lir_load_klass
 949   , end_op1
 950   , begin_op2
 951       , lir_branch

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

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

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

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

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

1834   void          change_ublock(BlockBegin* b);
1835   void          negate_cond();
1836 
1837   virtual void emit_code(LIR_Assembler* masm);
1838   virtual LIR_OpBranch* as_OpBranch() { return this; }
1839   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1840 };
1841 
1842 class LIR_OpAllocArray : public LIR_Op {
1843  friend class LIR_OpVisitState;
1844 
1845  private:
1846   LIR_Opr   _klass;
1847   LIR_Opr   _len;
1848   LIR_Opr   _tmp1;
1849   LIR_Opr   _tmp2;
1850   LIR_Opr   _tmp3;
1851   LIR_Opr   _tmp4;
1852   BasicType _type;
1853   CodeStub* _stub;
1854   bool      _is_null_free;
1855 
1856  public:
1857   LIR_OpAllocArray(LIR_Opr klass, LIR_Opr len, LIR_Opr result, LIR_Opr t1, LIR_Opr t2, LIR_Opr t3, LIR_Opr t4, BasicType type, CodeStub* stub, bool is_null_free)
1858     : LIR_Op(lir_alloc_array, result, nullptr)
1859     , _klass(klass)
1860     , _len(len)
1861     , _tmp1(t1)
1862     , _tmp2(t2)
1863     , _tmp3(t3)
1864     , _tmp4(t4)
1865     , _type(type)
1866     , _stub(stub)
1867     , _is_null_free(is_null_free) {}
1868 
1869   LIR_Opr   klass()   const                      { return _klass;       }
1870   LIR_Opr   len()     const                      { return _len;         }
1871   LIR_Opr   obj()     const                      { return result_opr(); }
1872   LIR_Opr   tmp1()    const                      { return _tmp1;        }
1873   LIR_Opr   tmp2()    const                      { return _tmp2;        }
1874   LIR_Opr   tmp3()    const                      { return _tmp3;        }
1875   LIR_Opr   tmp4()    const                      { return _tmp4;        }
1876   BasicType type()    const                      { return _type;        }
1877   CodeStub* stub()    const                      { return _stub;        }
1878   bool      is_null_free() const                 { return _is_null_free;}
1879 
1880   virtual void emit_code(LIR_Assembler* masm);
1881   virtual LIR_OpAllocArray * as_OpAllocArray () { return this; }
1882   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1883 };
1884 
1885 
1886 class LIR_Op3: public LIR_Op {
1887  friend class LIR_OpVisitState;
1888 
1889  private:
1890   LIR_Opr _opr1;
1891   LIR_Opr _opr2;
1892   LIR_Opr _opr3;
1893  public:
1894   LIR_Op3(LIR_Code code, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr opr3, LIR_Opr result, CodeEmitInfo* info = nullptr)
1895     : LIR_Op(code, result, info)
1896     , _opr1(opr1)
1897     , _opr2(opr2)
1898     , _opr3(opr3)                                { assert(is_in_range(code, begin_op3, end_op3), "code check"); }

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

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

2424   void div (LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_div, left, right, res, tmp)); }
2425   void rem (LIR_Opr left, LIR_Opr right, LIR_Opr res, CodeEmitInfo* info = nullptr)      { append(new LIR_Op2(lir_rem, left, right, res, info)); }
2426 
2427   void volatile_load_mem_reg(LIR_Address* address, LIR_Opr dst, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);
2428   void volatile_load_unsafe_reg(LIR_Opr base, LIR_Opr offset, LIR_Opr dst, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code);
2429 
2430   void load(LIR_Address* addr, LIR_Opr src, CodeEmitInfo* info = nullptr, LIR_PatchCode patch_code = lir_patch_none);
2431 
2432   void store_mem_int(jint v,    LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);
2433   void store_mem_oop(jobject o, LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);
2434   void store(LIR_Opr src, LIR_Address* addr, CodeEmitInfo* info = nullptr, LIR_PatchCode patch_code = lir_patch_none);
2435   void volatile_store_mem_reg(LIR_Opr src, LIR_Address* address, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);
2436   void volatile_store_unsafe_reg(LIR_Opr src, LIR_Opr base, LIR_Opr offset, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code);
2437 
2438   void idiv(LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);
2439   void idiv(LIR_Opr left, int   right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);
2440   void irem(LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);
2441   void irem(LIR_Opr left, int   right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);
2442 
2443   void allocate_object(LIR_Opr dst, LIR_Opr t1, LIR_Opr t2, LIR_Opr t3, LIR_Opr t4, int header_size, int object_size, LIR_Opr klass, bool init_check, CodeStub* stub);
2444   void allocate_array(LIR_Opr dst, LIR_Opr len, LIR_Opr t1,LIR_Opr t2, LIR_Opr t3,LIR_Opr t4, BasicType type, LIR_Opr klass, CodeStub* stub, bool is_null_free);
2445 
2446   // jump is an unconditional branch
2447   void jump(BlockBegin* block) {
2448     append(new LIR_OpBranch(lir_cond_always, block));
2449   }
2450   void jump(CodeStub* stub) {
2451     append(new LIR_OpBranch(lir_cond_always, stub));
2452   }
2453   void branch(LIR_Condition cond, Label* lbl) {
2454     append(new LIR_OpBranch(cond, lbl));
2455   }
2456   // Should not be used for fp comparisons
2457   void branch(LIR_Condition cond, BlockBegin* block) {
2458     append(new LIR_OpBranch(cond, block));
2459   }
2460   // Should not be used for fp comparisons
2461   void branch(LIR_Condition cond, CodeStub* stub) {
2462     append(new LIR_OpBranch(cond, stub));
2463   }
2464   // Should only be used for fp comparisons

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