< prev index next >

src/hotspot/share/c1/c1_LIR.hpp

Print this page

 872 //
 873 class  LIR_Op;
 874 class    LIR_Op0;
 875 class      LIR_OpLabel;
 876 class    LIR_Op1;
 877 class      LIR_OpBranch;
 878 class      LIR_OpConvert;
 879 class      LIR_OpAllocObj;
 880 class      LIR_OpReturn;
 881 class    LIR_Op2;
 882 class    LIR_Op3;
 883 class      LIR_OpAllocArray;
 884 class    LIR_Op4;
 885 class    LIR_OpCall;
 886 class      LIR_OpJavaCall;
 887 class      LIR_OpRTCall;
 888 class    LIR_OpArrayCopy;
 889 class    LIR_OpUpdateCRC32;
 890 class    LIR_OpLock;
 891 class    LIR_OpTypeCheck;



 892 class    LIR_OpCompareAndSwap;
 893 class    LIR_OpLoadKlass;
 894 class    LIR_OpProfileCall;
 895 class    LIR_OpProfileType;

 896 #ifdef ASSERT
 897 class    LIR_OpAssert;
 898 #endif
 899 
 900 // LIR operation codes
 901 enum LIR_Code {
 902     lir_none
 903   , begin_op0
 904       , lir_label
 905       , lir_nop
 906       , lir_std_entry
 907       , lir_osr_entry
 908       , lir_breakpoint
 909       , lir_rtcall
 910       , lir_membar
 911       , lir_membar_acquire
 912       , lir_membar_release
 913       , lir_membar_loadload
 914       , lir_membar_storestore
 915       , lir_membar_loadstore
 916       , lir_membar_storeload
 917       , lir_get_thread
 918       , lir_on_spin_wait

 919   , end_op0
 920   , begin_op1
 921       , lir_push
 922       , lir_pop
 923       , lir_null_check
 924       , lir_return
 925       , lir_leal
 926       , lir_move
 927       , lir_convert
 928       , lir_alloc_object
 929       , lir_monaddr
 930       , lir_sqrt
 931       , lir_abs
 932       , lir_neg
 933       , lir_f2hf
 934       , lir_hf2f
 935       , lir_safepoint
 936       , lir_unwind
 937       , lir_load_klass
 938   , end_op1

 972       , lir_static_call
 973       , lir_optvirtual_call
 974       , lir_icvirtual_call
 975       , lir_dynamic_call
 976   , end_opJavaCall
 977   , begin_opArrayCopy
 978       , lir_arraycopy
 979   , end_opArrayCopy
 980   , begin_opUpdateCRC32
 981       , lir_updatecrc32
 982   , end_opUpdateCRC32
 983   , begin_opLock
 984     , lir_lock
 985     , lir_unlock
 986   , end_opLock
 987   , begin_opTypeCheck
 988     , lir_instanceof
 989     , lir_checkcast
 990     , lir_store_check
 991   , end_opTypeCheck









 992   , begin_opCompareAndSwap
 993     , lir_cas_long
 994     , lir_cas_obj
 995     , lir_cas_int
 996   , end_opCompareAndSwap
 997   , begin_opMDOProfile
 998     , lir_profile_call
 999     , lir_profile_type

1000   , end_opMDOProfile
1001   , begin_opAssert
1002     , lir_assert
1003   , end_opAssert
1004 #if INCLUDE_ZGC
1005   , begin_opXLoadBarrierTest
1006     , lir_xloadbarrier_test
1007   , end_opXLoadBarrierTest
1008 #endif
1009 };
1010 
1011 
1012 enum LIR_Condition {
1013     lir_cond_equal
1014   , lir_cond_notEqual
1015   , lir_cond_less
1016   , lir_cond_lessEqual
1017   , lir_cond_greaterEqual
1018   , lir_cond_greater
1019   , lir_cond_belowEqual

1118 
1119   virtual bool is_patching() { return false; }
1120   virtual LIR_OpCall* as_OpCall() { return nullptr; }
1121   virtual LIR_OpJavaCall* as_OpJavaCall() { return nullptr; }
1122   virtual LIR_OpLabel* as_OpLabel() { return nullptr; }
1123   virtual LIR_OpLock* as_OpLock() { return nullptr; }
1124   virtual LIR_OpAllocArray* as_OpAllocArray() { return nullptr; }
1125   virtual LIR_OpAllocObj* as_OpAllocObj() { return nullptr; }
1126   virtual LIR_OpBranch* as_OpBranch() { return nullptr; }
1127   virtual LIR_OpReturn* as_OpReturn() { return nullptr; }
1128   virtual LIR_OpRTCall* as_OpRTCall() { return nullptr; }
1129   virtual LIR_OpConvert* as_OpConvert() { return nullptr; }
1130   virtual LIR_Op0* as_Op0() { return nullptr; }
1131   virtual LIR_Op1* as_Op1() { return nullptr; }
1132   virtual LIR_Op2* as_Op2() { return nullptr; }
1133   virtual LIR_Op3* as_Op3() { return nullptr; }
1134   virtual LIR_Op4* as_Op4() { return nullptr; }
1135   virtual LIR_OpArrayCopy* as_OpArrayCopy() { return nullptr; }
1136   virtual LIR_OpUpdateCRC32* as_OpUpdateCRC32() { return nullptr; }
1137   virtual LIR_OpTypeCheck* as_OpTypeCheck() { return nullptr; }



1138   virtual LIR_OpCompareAndSwap* as_OpCompareAndSwap() { return nullptr; }
1139   virtual LIR_OpLoadKlass* as_OpLoadKlass() { return nullptr; }
1140   virtual LIR_OpProfileCall* as_OpProfileCall() { return nullptr; }
1141   virtual LIR_OpProfileType* as_OpProfileType() { return nullptr; }

1142 #ifdef ASSERT
1143   virtual LIR_OpAssert* as_OpAssert() { return nullptr; }
1144 #endif
1145 
1146   virtual void verify() const {}
1147 };
1148 
1149 // for calls
1150 class LIR_OpCall: public LIR_Op {
1151  friend class LIR_OpVisitState;
1152 
1153  protected:
1154   address      _addr;
1155   LIR_OprList* _arguments;
1156  protected:
1157   LIR_OpCall(LIR_Code code, address addr, LIR_Opr result,
1158              LIR_OprList* arguments, CodeEmitInfo* info = nullptr)
1159     : LIR_Op(code, result, info)
1160     , _addr(addr)
1161     , _arguments(arguments) {}

1191                  LIR_Opr receiver, LIR_Opr result, intptr_t vtable_offset,
1192                  LIR_OprList* arguments, CodeEmitInfo* info)
1193   : LIR_OpCall(code, (address)vtable_offset, result, arguments, info)
1194   , _method(method)
1195   , _receiver(receiver)
1196   { assert(is_in_range(code, begin_opJavaCall, end_opJavaCall), "code check"); }
1197 
1198   LIR_Opr receiver() const                       { return _receiver; }
1199   ciMethod* method() const                       { return _method;   }
1200 
1201   // JSR 292 support.
1202   bool is_invokedynamic() const                  { return code() == lir_dynamic_call; }
1203   bool is_method_handle_invoke() const {
1204     return method()->is_compiled_lambda_form() ||   // Java-generated lambda form
1205            method()->is_method_handle_intrinsic();  // JVM-generated MH intrinsic
1206   }
1207 
1208   virtual void emit_code(LIR_Assembler* masm);
1209   virtual LIR_OpJavaCall* as_OpJavaCall() { return this; }
1210   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;


1211 };
1212 
1213 // --------------------------------------------------
1214 // LIR_OpLabel
1215 // --------------------------------------------------
1216 // Location where a branch can continue
1217 class LIR_OpLabel: public LIR_Op {
1218  friend class LIR_OpVisitState;
1219 
1220  private:
1221   Label* _label;
1222  public:
1223   LIR_OpLabel(Label* lbl)
1224    : LIR_Op(lir_label, LIR_OprFact::illegalOpr, nullptr)
1225    , _label(lbl)                                 {}
1226   Label* label() const                           { return _label; }
1227 
1228   virtual void emit_code(LIR_Assembler* masm);
1229   virtual LIR_OpLabel* as_OpLabel() { return this; }
1230   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;

1242   LIR_Opr   _dst_pos;
1243   LIR_Opr   _length;
1244   LIR_Opr   _tmp;
1245   ciArrayKlass* _expected_type;
1246   int       _flags;
1247 
1248 public:
1249   enum Flags {
1250     src_null_check         = 1 << 0,
1251     dst_null_check         = 1 << 1,
1252     src_pos_positive_check = 1 << 2,
1253     dst_pos_positive_check = 1 << 3,
1254     length_positive_check  = 1 << 4,
1255     src_range_check        = 1 << 5,
1256     dst_range_check        = 1 << 6,
1257     type_check             = 1 << 7,
1258     overlapping            = 1 << 8,
1259     unaligned              = 1 << 9,
1260     src_objarray           = 1 << 10,
1261     dst_objarray           = 1 << 11,
1262     all_flags              = (1 << 12) - 1



1263   };
1264 
1265   LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length, LIR_Opr tmp,
1266                   ciArrayKlass* expected_type, int flags, CodeEmitInfo* info);
1267 
1268   LIR_Opr src() const                            { return _src; }
1269   LIR_Opr src_pos() const                        { return _src_pos; }
1270   LIR_Opr dst() const                            { return _dst; }
1271   LIR_Opr dst_pos() const                        { return _dst_pos; }
1272   LIR_Opr length() const                         { return _length; }
1273   LIR_Opr tmp() const                            { return _tmp; }
1274   int flags() const                              { return _flags; }
1275   ciArrayKlass* expected_type() const            { return _expected_type; }
1276   ArrayCopyStub* stub() const                    { return _stub; }
1277   static int get_initial_copy_flags()            { return LIR_OpArrayCopy::unaligned |
1278                                                           LIR_OpArrayCopy::overlapping; }
1279 
1280   virtual void emit_code(LIR_Assembler* masm);
1281   virtual LIR_OpArrayCopy* as_OpArrayCopy() { return this; }
1282   void print_instr(outputStream* out) const PRODUCT_RETURN;

1497 
1498 
1499 // LIR_OpTypeCheck
1500 class LIR_OpTypeCheck: public LIR_Op {
1501  friend class LIR_OpVisitState;
1502 
1503  private:
1504   LIR_Opr       _object;
1505   LIR_Opr       _array;
1506   ciKlass*      _klass;
1507   LIR_Opr       _tmp1;
1508   LIR_Opr       _tmp2;
1509   LIR_Opr       _tmp3;
1510   CodeEmitInfo* _info_for_patch;
1511   CodeEmitInfo* _info_for_exception;
1512   CodeStub*     _stub;
1513   ciMethod*     _profiled_method;
1514   int           _profiled_bci;
1515   bool          _should_profile;
1516   bool          _fast_check;

1517 
1518 public:
1519   LIR_OpTypeCheck(LIR_Code code, LIR_Opr result, LIR_Opr object, ciKlass* klass,
1520                   LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
1521                   CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub);
1522   LIR_OpTypeCheck(LIR_Code code, LIR_Opr object, LIR_Opr array,
1523                   LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, CodeEmitInfo* info_for_exception);
1524 
1525   LIR_Opr object() const                         { return _object;         }
1526   LIR_Opr array() const                          { assert(code() == lir_store_check, "not valid"); return _array;         }
1527   LIR_Opr tmp1() const                           { return _tmp1;           }
1528   LIR_Opr tmp2() const                           { return _tmp2;           }
1529   LIR_Opr tmp3() const                           { return _tmp3;           }
1530   ciKlass* klass() const                         { assert(code() == lir_instanceof || code() == lir_checkcast, "not valid"); return _klass;          }
1531   bool fast_check() const                        { assert(code() == lir_instanceof || code() == lir_checkcast, "not valid"); return _fast_check;     }
1532   CodeEmitInfo* info_for_patch() const           { return _info_for_patch;  }
1533   CodeEmitInfo* info_for_exception() const       { return _info_for_exception; }
1534   CodeStub* stub() const                         { return _stub;           }
1535 
1536   // MethodData* profiling
1537   void set_profiled_method(ciMethod *method)     { _profiled_method = method; }
1538   void set_profiled_bci(int bci)                 { _profiled_bci = bci;       }
1539   void set_should_profile(bool b)                { _should_profile = b;       }
1540   ciMethod* profiled_method() const              { return _profiled_method;   }
1541   int       profiled_bci() const                 { return _profiled_bci;      }
1542   bool      should_profile() const               { return _should_profile;    }
1543 
1544   virtual bool is_patching() { return _info_for_patch != nullptr; }
1545   virtual void emit_code(LIR_Assembler* masm);
1546   virtual LIR_OpTypeCheck* as_OpTypeCheck() { return this; }
1547   void print_instr(outputStream* out) const PRODUCT_RETURN;
1548 };
1549 












































































1550 // LIR_Op2
1551 class LIR_Op2: public LIR_Op {
1552  friend class LIR_OpVisitState;
1553 
1554  protected:
1555   LIR_Opr   _opr1;
1556   LIR_Opr   _opr2;
1557   LIR_Opr   _tmp1;
1558   LIR_Opr   _tmp2;
1559   LIR_Opr   _tmp3;
1560   LIR_Opr   _tmp4;
1561   LIR_Opr   _tmp5;
1562   LIR_Condition _condition;
1563   BasicType _type;
1564 
1565   void verify() const;
1566 
1567  public:
1568   LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, CodeEmitInfo* info = nullptr, BasicType type = T_ILLEGAL)
1569     : LIR_Op(code, LIR_OprFact::illegalOpr, info)

1688   void          negate_cond();
1689 
1690   virtual void emit_code(LIR_Assembler* masm);
1691   virtual LIR_OpBranch* as_OpBranch() { return this; }
1692   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1693 };
1694 
1695 class LIR_OpAllocArray : public LIR_Op {
1696  friend class LIR_OpVisitState;
1697 
1698  private:
1699   LIR_Opr   _klass;
1700   LIR_Opr   _len;
1701   LIR_Opr   _tmp1;
1702   LIR_Opr   _tmp2;
1703   LIR_Opr   _tmp3;
1704   LIR_Opr   _tmp4;
1705   CodeStub* _stub;
1706   BasicType _type;
1707   bool      _zero_array;

1708 
1709  public:
1710   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 zero_array)
1711     : LIR_Op(lir_alloc_array, result, nullptr)
1712     , _klass(klass)
1713     , _len(len)
1714     , _tmp1(t1)
1715     , _tmp2(t2)
1716     , _tmp3(t3)
1717     , _tmp4(t4)
1718     , _stub(stub)
1719     , _type(type)
1720     , _zero_array(zero_array) {}

1721 
1722   LIR_Opr   klass()   const                      { return _klass;       }
1723   LIR_Opr   len()     const                      { return _len;         }
1724   LIR_Opr   obj()     const                      { return result_opr(); }
1725   LIR_Opr   tmp1()    const                      { return _tmp1;        }
1726   LIR_Opr   tmp2()    const                      { return _tmp2;        }
1727   LIR_Opr   tmp3()    const                      { return _tmp3;        }
1728   LIR_Opr   tmp4()    const                      { return _tmp4;        }
1729   BasicType type()    const                      { return _type;        }
1730   CodeStub* stub()    const                      { return _stub;        }
1731   bool zero_array()   const                      { return _zero_array;  }

1732 
1733   virtual void emit_code(LIR_Assembler* masm);
1734   virtual LIR_OpAllocArray * as_OpAllocArray () { return this; }
1735   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1736 };
1737 
1738 
1739 class LIR_Op3: public LIR_Op {
1740  friend class LIR_OpVisitState;
1741 
1742  private:
1743   LIR_Opr _opr1;
1744   LIR_Opr _opr2;
1745   LIR_Opr _opr3;
1746  public:
1747   LIR_Op3(LIR_Code code, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr opr3, LIR_Opr result, CodeEmitInfo* info = nullptr)
1748     : LIR_Op(code, result, info)
1749     , _opr1(opr1)
1750     , _opr2(opr2)
1751     , _opr3(opr3)                                { assert(is_in_range(code, begin_op3, end_op3), "code check"); }

1818 
1819 //--------------------------------
1820 class LabelObj: public CompilationResourceObj {
1821  private:
1822   Label _label;
1823  public:
1824   LabelObj()                                     {}
1825   Label* label()                                 { return &_label; }
1826 };
1827 
1828 
1829 class LIR_OpLock: public LIR_Op {
1830  friend class LIR_OpVisitState;
1831 
1832  private:
1833   LIR_Opr _hdr;
1834   LIR_Opr _obj;
1835   LIR_Opr _lock;
1836   LIR_Opr _scratch;
1837   CodeStub* _stub;

1838  public:
1839   LIR_OpLock(LIR_Code code, LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info)
1840     : LIR_Op(code, LIR_OprFact::illegalOpr, info)
1841     , _hdr(hdr)
1842     , _obj(obj)
1843     , _lock(lock)
1844     , _scratch(scratch)
1845     , _stub(stub)                      {}

1846 
1847   LIR_Opr hdr_opr() const                        { return _hdr; }
1848   LIR_Opr obj_opr() const                        { return _obj; }
1849   LIR_Opr lock_opr() const                       { return _lock; }
1850   LIR_Opr scratch_opr() const                    { return _scratch; }
1851   CodeStub* stub() const                         { return _stub; }

1852 
1853   virtual void emit_code(LIR_Assembler* masm);
1854   virtual LIR_OpLock* as_OpLock() { return this; }
1855   void print_instr(outputStream* out) const PRODUCT_RETURN;
1856 };
1857 
1858 class LIR_OpLoadKlass: public LIR_Op {
1859   friend class LIR_OpVisitState;
1860 
1861  private:
1862   LIR_Opr _obj;
1863  public:
1864   LIR_OpLoadKlass(LIR_Opr obj, LIR_Opr result, CodeEmitInfo* info)
1865     : LIR_Op(lir_load_klass, result, info)
1866     , _obj(obj)
1867     {}
1868 
1869   LIR_Opr obj()        const { return _obj;  }
1870 
1871   virtual LIR_OpLoadKlass* as_OpLoadKlass() { return this; }

1997     , _obj(obj)
1998     , _tmp(tmp)
1999     , _exact_klass(exact_klass)
2000     , _current_klass(current_klass)
2001     , _not_null(not_null)
2002     , _no_conflict(no_conflict) { }
2003 
2004   LIR_Opr      mdp()              const             { return _mdp;              }
2005   LIR_Opr      obj()              const             { return _obj;              }
2006   LIR_Opr      tmp()              const             { return _tmp;              }
2007   ciKlass*     exact_klass()      const             { return _exact_klass;      }
2008   intptr_t     current_klass()    const             { return _current_klass;    }
2009   bool         not_null()         const             { return _not_null;         }
2010   bool         no_conflict()      const             { return _no_conflict;      }
2011 
2012   virtual void emit_code(LIR_Assembler* masm);
2013   virtual LIR_OpProfileType* as_OpProfileType() { return this; }
2014   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
2015 };
2016 
































2017 class LIR_InsertionBuffer;
2018 
2019 //--------------------------------LIR_List---------------------------------------------------
2020 // Maintains a list of LIR instructions (one instance of LIR_List per basic block)
2021 // The LIR instructions are appended by the LIR_List class itself;
2022 //
2023 // Notes:
2024 // - all offsets are(should be) in bytes
2025 // - local positions are specified with an offset, with offset 0 being local 0
2026 
2027 class LIR_List: public CompilationResourceObj {
2028  private:
2029   LIR_OpList  _operations;
2030 
2031   Compilation*  _compilation;
2032 #ifndef PRODUCT
2033   BlockBegin*   _block;
2034 #endif
2035 #ifdef ASSERT
2036   const char *  _file;

2221   void div (LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_div, left, right, res, tmp)); }
2222   void rem (LIR_Opr left, LIR_Opr right, LIR_Opr res, CodeEmitInfo* info = nullptr)      { append(new LIR_Op2(lir_rem, left, right, res, info)); }
2223 
2224   void volatile_load_mem_reg(LIR_Address* address, LIR_Opr dst, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);
2225   void volatile_load_unsafe_reg(LIR_Opr base, LIR_Opr offset, LIR_Opr dst, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code);
2226 
2227   void load(LIR_Address* addr, LIR_Opr src, CodeEmitInfo* info = nullptr, LIR_PatchCode patch_code = lir_patch_none);
2228 
2229   void store_mem_int(jint v,    LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);
2230   void store_mem_oop(jobject o, LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);
2231   void store(LIR_Opr src, LIR_Address* addr, CodeEmitInfo* info = nullptr, LIR_PatchCode patch_code = lir_patch_none);
2232   void volatile_store_mem_reg(LIR_Opr src, LIR_Address* address, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);
2233   void volatile_store_unsafe_reg(LIR_Opr src, LIR_Opr base, LIR_Opr offset, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code);
2234 
2235   void idiv(LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);
2236   void idiv(LIR_Opr left, int   right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);
2237   void irem(LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);
2238   void irem(LIR_Opr left, int   right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);
2239 
2240   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);
2241   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 zero_array = true);
2242 
2243   // jump is an unconditional branch
2244   void jump(BlockBegin* block) {
2245     append(new LIR_OpBranch(lir_cond_always, block));
2246   }
2247   void jump(CodeStub* stub) {
2248     append(new LIR_OpBranch(lir_cond_always, stub));
2249   }
2250   void branch(LIR_Condition cond, Label* lbl) {
2251     append(new LIR_OpBranch(cond, lbl));
2252   }
2253   // Should not be used for fp comparisons
2254   void branch(LIR_Condition cond, BlockBegin* block) {
2255     append(new LIR_OpBranch(cond, block));
2256   }
2257   // Should not be used for fp comparisons
2258   void branch(LIR_Condition cond, CodeStub* stub) {
2259     append(new LIR_OpBranch(cond, stub));
2260   }
2261   // Should only be used for fp comparisons

2268   void unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp);
2269 
2270   void shift_left(LIR_Opr value, int count, LIR_Opr dst)       { shift_left(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2271   void shift_right(LIR_Opr value, int count, LIR_Opr dst)      { shift_right(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2272   void unsigned_shift_right(LIR_Opr value, int count, LIR_Opr dst) { unsigned_shift_right(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2273 
2274   void lcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst)        { append(new LIR_Op2(lir_cmp_l2i,  left, right, dst)); }
2275   void fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less);
2276 
2277   void call_runtime_leaf(address routine, LIR_Opr tmp, LIR_Opr result, LIR_OprList* arguments) {
2278     append(new LIR_OpRTCall(routine, tmp, result, arguments));
2279   }
2280 
2281   void call_runtime(address routine, LIR_Opr tmp, LIR_Opr result,
2282                     LIR_OprList* arguments, CodeEmitInfo* info) {
2283     append(new LIR_OpRTCall(routine, tmp, result, arguments, info));
2284   }
2285 
2286   void load_stack_address_monitor(int monitor_ix, LIR_Opr dst)  { append(new LIR_Op1(lir_monaddr, LIR_OprFact::intConst(monitor_ix), dst)); }
2287   void unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub);
2288   void lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info);
2289 
2290   void breakpoint()                                                  { append(new LIR_Op0(lir_breakpoint)); }
2291 
2292   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)); }
2293 
2294   void update_crc32(LIR_Opr crc, LIR_Opr val, LIR_Opr res)  { append(new LIR_OpUpdateCRC32(crc, val, res)); }
2295 
2296   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);
2297   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);






2298 
2299   void checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
2300                   LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
2301                   CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
2302                   ciMethod* profiled_method, int profiled_bci);
2303   // MethodData* profiling
2304   void profile_call(ciMethod* method, int bci, ciMethod* callee, LIR_Opr mdo, LIR_Opr recv, LIR_Opr t1, ciKlass* cha_klass) {
2305     append(new LIR_OpProfileCall(method, bci, callee, mdo, recv, t1, cha_klass));
2306   }
2307   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) {
2308     append(new LIR_OpProfileType(LIR_OprFact::address(mdp), obj, exact_klass, current_klass, tmp, not_null, no_conflict));
2309   }



2310 
2311   void xadd(LIR_Opr src, LIR_Opr add, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xadd, src, add, res, tmp)); }
2312   void xchg(LIR_Opr src, LIR_Opr set, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xchg, src, set, res, tmp)); }
2313 
2314   void load_klass(LIR_Opr obj, LIR_Opr result, CodeEmitInfo* info) { append(new LIR_OpLoadKlass(obj, result, info)); }
2315 
2316 #ifdef ASSERT
2317   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)); }
2318 #endif
2319 };
2320 
2321 void print_LIR(BlockList* blocks);
2322 
2323 class LIR_InsertionBuffer : public CompilationResourceObj {
2324  private:
2325   LIR_List*   _lir;   // the lir list where ops of this buffer should be inserted later (null when uninitialized)
2326 
2327   // list of insertion points. index and count are stored alternately:
2328   // _index_and_count[i * 2]:     the index into lir list where "count" ops should be inserted
2329   // _index_and_count[i * 2 + 1]: the number of ops to be inserted at index

 872 //
 873 class  LIR_Op;
 874 class    LIR_Op0;
 875 class      LIR_OpLabel;
 876 class    LIR_Op1;
 877 class      LIR_OpBranch;
 878 class      LIR_OpConvert;
 879 class      LIR_OpAllocObj;
 880 class      LIR_OpReturn;
 881 class    LIR_Op2;
 882 class    LIR_Op3;
 883 class      LIR_OpAllocArray;
 884 class    LIR_Op4;
 885 class    LIR_OpCall;
 886 class      LIR_OpJavaCall;
 887 class      LIR_OpRTCall;
 888 class    LIR_OpArrayCopy;
 889 class    LIR_OpUpdateCRC32;
 890 class    LIR_OpLock;
 891 class    LIR_OpTypeCheck;
 892 class    LIR_OpFlattenedArrayCheck;
 893 class    LIR_OpNullFreeArrayCheck;
 894 class    LIR_OpSubstitutabilityCheck;
 895 class    LIR_OpCompareAndSwap;
 896 class    LIR_OpLoadKlass;
 897 class    LIR_OpProfileCall;
 898 class    LIR_OpProfileType;
 899 class    LIR_OpProfileInlineType;
 900 #ifdef ASSERT
 901 class    LIR_OpAssert;
 902 #endif
 903 
 904 // LIR operation codes
 905 enum LIR_Code {
 906     lir_none
 907   , begin_op0
 908       , lir_label
 909       , lir_nop
 910       , lir_std_entry
 911       , lir_osr_entry
 912       , lir_breakpoint
 913       , lir_rtcall
 914       , lir_membar
 915       , lir_membar_acquire
 916       , lir_membar_release
 917       , lir_membar_loadload
 918       , lir_membar_storestore
 919       , lir_membar_loadstore
 920       , lir_membar_storeload
 921       , lir_get_thread
 922       , lir_on_spin_wait
 923       , lir_check_orig_pc
 924   , end_op0
 925   , begin_op1
 926       , lir_push
 927       , lir_pop
 928       , lir_null_check
 929       , lir_return
 930       , lir_leal
 931       , lir_move
 932       , lir_convert
 933       , lir_alloc_object
 934       , lir_monaddr
 935       , lir_sqrt
 936       , lir_abs
 937       , lir_neg
 938       , lir_f2hf
 939       , lir_hf2f
 940       , lir_safepoint
 941       , lir_unwind
 942       , lir_load_klass
 943   , end_op1

 977       , lir_static_call
 978       , lir_optvirtual_call
 979       , lir_icvirtual_call
 980       , lir_dynamic_call
 981   , end_opJavaCall
 982   , begin_opArrayCopy
 983       , lir_arraycopy
 984   , end_opArrayCopy
 985   , begin_opUpdateCRC32
 986       , lir_updatecrc32
 987   , end_opUpdateCRC32
 988   , begin_opLock
 989     , lir_lock
 990     , lir_unlock
 991   , end_opLock
 992   , begin_opTypeCheck
 993     , lir_instanceof
 994     , lir_checkcast
 995     , lir_store_check
 996   , end_opTypeCheck
 997   , begin_opFlattenedArrayCheck
 998     , lir_flat_array_check
 999   , end_opFlattenedArrayCheck
1000   , begin_opNullFreeArrayCheck
1001     , lir_null_free_array_check
1002   , end_opNullFreeArrayCheck
1003   , begin_opSubstitutabilityCheck
1004     , lir_substitutability_check
1005   , end_opSubstitutabilityCheck
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     , lir_profile_inline_type
1015   , end_opMDOProfile
1016   , begin_opAssert
1017     , lir_assert
1018   , end_opAssert
1019 #if INCLUDE_ZGC
1020   , begin_opXLoadBarrierTest
1021     , lir_xloadbarrier_test
1022   , end_opXLoadBarrierTest
1023 #endif
1024 };
1025 
1026 
1027 enum LIR_Condition {
1028     lir_cond_equal
1029   , lir_cond_notEqual
1030   , lir_cond_less
1031   , lir_cond_lessEqual
1032   , lir_cond_greaterEqual
1033   , lir_cond_greater
1034   , lir_cond_belowEqual

1133 
1134   virtual bool is_patching() { return false; }
1135   virtual LIR_OpCall* as_OpCall() { return nullptr; }
1136   virtual LIR_OpJavaCall* as_OpJavaCall() { return nullptr; }
1137   virtual LIR_OpLabel* as_OpLabel() { return nullptr; }
1138   virtual LIR_OpLock* as_OpLock() { return nullptr; }
1139   virtual LIR_OpAllocArray* as_OpAllocArray() { return nullptr; }
1140   virtual LIR_OpAllocObj* as_OpAllocObj() { return nullptr; }
1141   virtual LIR_OpBranch* as_OpBranch() { return nullptr; }
1142   virtual LIR_OpReturn* as_OpReturn() { return nullptr; }
1143   virtual LIR_OpRTCall* as_OpRTCall() { return nullptr; }
1144   virtual LIR_OpConvert* as_OpConvert() { return nullptr; }
1145   virtual LIR_Op0* as_Op0() { return nullptr; }
1146   virtual LIR_Op1* as_Op1() { return nullptr; }
1147   virtual LIR_Op2* as_Op2() { return nullptr; }
1148   virtual LIR_Op3* as_Op3() { return nullptr; }
1149   virtual LIR_Op4* as_Op4() { return nullptr; }
1150   virtual LIR_OpArrayCopy* as_OpArrayCopy() { return nullptr; }
1151   virtual LIR_OpUpdateCRC32* as_OpUpdateCRC32() { return nullptr; }
1152   virtual LIR_OpTypeCheck* as_OpTypeCheck() { return nullptr; }
1153   virtual LIR_OpFlattenedArrayCheck* as_OpFlattenedArrayCheck() { return nullptr; }
1154   virtual LIR_OpNullFreeArrayCheck* as_OpNullFreeArrayCheck() { return nullptr; }
1155   virtual LIR_OpSubstitutabilityCheck* as_OpSubstitutabilityCheck() { return nullptr; }
1156   virtual LIR_OpCompareAndSwap* as_OpCompareAndSwap() { return nullptr; }
1157   virtual LIR_OpLoadKlass* as_OpLoadKlass() { return nullptr; }
1158   virtual LIR_OpProfileCall* as_OpProfileCall() { return nullptr; }
1159   virtual LIR_OpProfileType* as_OpProfileType() { return nullptr; }
1160   virtual LIR_OpProfileInlineType* as_OpProfileInlineType() { return nullptr; }
1161 #ifdef ASSERT
1162   virtual LIR_OpAssert* as_OpAssert() { return nullptr; }
1163 #endif
1164 
1165   virtual void verify() const {}
1166 };
1167 
1168 // for calls
1169 class LIR_OpCall: public LIR_Op {
1170  friend class LIR_OpVisitState;
1171 
1172  protected:
1173   address      _addr;
1174   LIR_OprList* _arguments;
1175  protected:
1176   LIR_OpCall(LIR_Code code, address addr, LIR_Opr result,
1177              LIR_OprList* arguments, CodeEmitInfo* info = nullptr)
1178     : LIR_Op(code, result, info)
1179     , _addr(addr)
1180     , _arguments(arguments) {}

1210                  LIR_Opr receiver, LIR_Opr result, intptr_t vtable_offset,
1211                  LIR_OprList* arguments, CodeEmitInfo* info)
1212   : LIR_OpCall(code, (address)vtable_offset, result, arguments, info)
1213   , _method(method)
1214   , _receiver(receiver)
1215   { assert(is_in_range(code, begin_opJavaCall, end_opJavaCall), "code check"); }
1216 
1217   LIR_Opr receiver() const                       { return _receiver; }
1218   ciMethod* method() const                       { return _method;   }
1219 
1220   // JSR 292 support.
1221   bool is_invokedynamic() const                  { return code() == lir_dynamic_call; }
1222   bool is_method_handle_invoke() const {
1223     return method()->is_compiled_lambda_form() ||   // Java-generated lambda form
1224            method()->is_method_handle_intrinsic();  // JVM-generated MH intrinsic
1225   }
1226 
1227   virtual void emit_code(LIR_Assembler* masm);
1228   virtual LIR_OpJavaCall* as_OpJavaCall() { return this; }
1229   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1230 
1231   bool maybe_return_as_fields(ciInlineKlass** vk = nullptr) const;
1232 };
1233 
1234 // --------------------------------------------------
1235 // LIR_OpLabel
1236 // --------------------------------------------------
1237 // Location where a branch can continue
1238 class LIR_OpLabel: public LIR_Op {
1239  friend class LIR_OpVisitState;
1240 
1241  private:
1242   Label* _label;
1243  public:
1244   LIR_OpLabel(Label* lbl)
1245    : LIR_Op(lir_label, LIR_OprFact::illegalOpr, nullptr)
1246    , _label(lbl)                                 {}
1247   Label* label() const                           { return _label; }
1248 
1249   virtual void emit_code(LIR_Assembler* masm);
1250   virtual LIR_OpLabel* as_OpLabel() { return this; }
1251   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;

1263   LIR_Opr   _dst_pos;
1264   LIR_Opr   _length;
1265   LIR_Opr   _tmp;
1266   ciArrayKlass* _expected_type;
1267   int       _flags;
1268 
1269 public:
1270   enum Flags {
1271     src_null_check         = 1 << 0,
1272     dst_null_check         = 1 << 1,
1273     src_pos_positive_check = 1 << 2,
1274     dst_pos_positive_check = 1 << 3,
1275     length_positive_check  = 1 << 4,
1276     src_range_check        = 1 << 5,
1277     dst_range_check        = 1 << 6,
1278     type_check             = 1 << 7,
1279     overlapping            = 1 << 8,
1280     unaligned              = 1 << 9,
1281     src_objarray           = 1 << 10,
1282     dst_objarray           = 1 << 11,
1283     always_slow_path       = 1 << 12,
1284     src_inlinetype_check   = 1 << 13,
1285     dst_inlinetype_check   = 1 << 14,
1286     all_flags              = (1 << 15) - 1
1287   };
1288 
1289   LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length, LIR_Opr tmp,
1290                   ciArrayKlass* expected_type, int flags, CodeEmitInfo* info);
1291 
1292   LIR_Opr src() const                            { return _src; }
1293   LIR_Opr src_pos() const                        { return _src_pos; }
1294   LIR_Opr dst() const                            { return _dst; }
1295   LIR_Opr dst_pos() const                        { return _dst_pos; }
1296   LIR_Opr length() const                         { return _length; }
1297   LIR_Opr tmp() const                            { return _tmp; }
1298   int flags() const                              { return _flags; }
1299   ciArrayKlass* expected_type() const            { return _expected_type; }
1300   ArrayCopyStub* stub() const                    { return _stub; }
1301   static int get_initial_copy_flags()            { return LIR_OpArrayCopy::unaligned |
1302                                                           LIR_OpArrayCopy::overlapping; }
1303 
1304   virtual void emit_code(LIR_Assembler* masm);
1305   virtual LIR_OpArrayCopy* as_OpArrayCopy() { return this; }
1306   void print_instr(outputStream* out) const PRODUCT_RETURN;

1521 
1522 
1523 // LIR_OpTypeCheck
1524 class LIR_OpTypeCheck: public LIR_Op {
1525  friend class LIR_OpVisitState;
1526 
1527  private:
1528   LIR_Opr       _object;
1529   LIR_Opr       _array;
1530   ciKlass*      _klass;
1531   LIR_Opr       _tmp1;
1532   LIR_Opr       _tmp2;
1533   LIR_Opr       _tmp3;
1534   CodeEmitInfo* _info_for_patch;
1535   CodeEmitInfo* _info_for_exception;
1536   CodeStub*     _stub;
1537   ciMethod*     _profiled_method;
1538   int           _profiled_bci;
1539   bool          _should_profile;
1540   bool          _fast_check;
1541   bool          _need_null_check;
1542 
1543 public:
1544   LIR_OpTypeCheck(LIR_Code code, LIR_Opr result, LIR_Opr object, ciKlass* klass,
1545                   LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
1546                   CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub, bool need_null_check = true);
1547   LIR_OpTypeCheck(LIR_Code code, LIR_Opr object, LIR_Opr array,
1548                   LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, CodeEmitInfo* info_for_exception);
1549 
1550   LIR_Opr object() const                         { return _object;         }
1551   LIR_Opr array() const                          { assert(code() == lir_store_check, "not valid"); return _array;         }
1552   LIR_Opr tmp1() const                           { return _tmp1;           }
1553   LIR_Opr tmp2() const                           { return _tmp2;           }
1554   LIR_Opr tmp3() const                           { return _tmp3;           }
1555   ciKlass* klass() const                         { assert(code() == lir_instanceof || code() == lir_checkcast, "not valid"); return _klass;          }
1556   bool fast_check() const                        { assert(code() == lir_instanceof || code() == lir_checkcast, "not valid"); return _fast_check;     }
1557   CodeEmitInfo* info_for_patch() const           { return _info_for_patch;  }
1558   CodeEmitInfo* info_for_exception() const       { return _info_for_exception; }
1559   CodeStub* stub() const                         { return _stub;           }
1560 
1561   // MethodData* profiling
1562   void set_profiled_method(ciMethod *method)     { _profiled_method = method; }
1563   void set_profiled_bci(int bci)                 { _profiled_bci = bci;       }
1564   void set_should_profile(bool b)                { _should_profile = b;       }
1565   ciMethod* profiled_method() const              { return _profiled_method;   }
1566   int       profiled_bci() const                 { return _profiled_bci;      }
1567   bool      should_profile() const               { return _should_profile;    }
1568   bool      need_null_check() const              { return _need_null_check;   }
1569   virtual bool is_patching() { return _info_for_patch != nullptr; }
1570   virtual void emit_code(LIR_Assembler* masm);
1571   virtual LIR_OpTypeCheck* as_OpTypeCheck() { return this; }
1572   void print_instr(outputStream* out) const PRODUCT_RETURN;
1573 };
1574 
1575 // LIR_OpFlattenedArrayCheck
1576 class LIR_OpFlattenedArrayCheck: public LIR_Op {
1577  friend class LIR_OpVisitState;
1578 
1579  private:
1580   LIR_Opr       _array;
1581   LIR_Opr       _value;
1582   LIR_Opr       _tmp;
1583   CodeStub*     _stub;
1584 public:
1585   LIR_OpFlattenedArrayCheck(LIR_Opr array, LIR_Opr value, LIR_Opr tmp, CodeStub* stub);
1586   LIR_Opr array() const                          { return _array;         }
1587   LIR_Opr value() const                          { return _value;         }
1588   LIR_Opr tmp() const                            { return _tmp;           }
1589   CodeStub* stub() const                         { return _stub;          }
1590 
1591   virtual void emit_code(LIR_Assembler* masm);
1592   virtual LIR_OpFlattenedArrayCheck* as_OpFlattenedArrayCheck() { return this; }
1593   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1594 };
1595 
1596 // LIR_OpNullFreeArrayCheck
1597 class LIR_OpNullFreeArrayCheck: public LIR_Op {
1598  friend class LIR_OpVisitState;
1599 
1600  private:
1601   LIR_Opr       _array;
1602   LIR_Opr       _tmp;
1603 public:
1604   LIR_OpNullFreeArrayCheck(LIR_Opr array, LIR_Opr tmp);
1605   LIR_Opr array() const                          { return _array;         }
1606   LIR_Opr tmp() const                            { return _tmp;           }
1607 
1608   virtual void emit_code(LIR_Assembler* masm);
1609   virtual LIR_OpNullFreeArrayCheck* as_OpNullFreeArrayCheck() { return this; }
1610   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1611 };
1612 
1613 class LIR_OpSubstitutabilityCheck: public LIR_Op {
1614  friend class LIR_OpVisitState;
1615 
1616  private:
1617   LIR_Opr       _left;
1618   LIR_Opr       _right;
1619   LIR_Opr       _equal_result;
1620   LIR_Opr       _not_equal_result;
1621   LIR_Opr       _tmp1;
1622   LIR_Opr       _tmp2;
1623   ciKlass*      _left_klass;
1624   ciKlass*      _right_klass;
1625   LIR_Opr       _left_klass_op;
1626   LIR_Opr       _right_klass_op;
1627   CodeStub*     _stub;
1628 public:
1629   LIR_OpSubstitutabilityCheck(LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr equal_result, LIR_Opr not_equal_result,
1630                               LIR_Opr tmp1, LIR_Opr tmp2,
1631                               ciKlass* left_klass, ciKlass* right_klass, LIR_Opr left_klass_op, LIR_Opr right_klass_op,
1632                               CodeEmitInfo* info, CodeStub* stub);
1633 
1634   LIR_Opr left() const             { return _left; }
1635   LIR_Opr right() const            { return _right; }
1636   LIR_Opr equal_result() const     { return _equal_result; }
1637   LIR_Opr not_equal_result() const { return _not_equal_result; }
1638   LIR_Opr tmp1() const             { return _tmp1; }
1639   LIR_Opr tmp2() const             { return _tmp2; }
1640   ciKlass* left_klass() const      { return _left_klass; }
1641   ciKlass* right_klass() const     { return _right_klass; }
1642   LIR_Opr left_klass_op() const    { return _left_klass_op; }
1643   LIR_Opr right_klass_op() const   { return _right_klass_op; }
1644   CodeStub* stub() const           { return _stub; }
1645 
1646   virtual void emit_code(LIR_Assembler* masm);
1647   virtual LIR_OpSubstitutabilityCheck* as_OpSubstitutabilityCheck() { return this; }
1648   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1649 };
1650 
1651 // LIR_Op2
1652 class LIR_Op2: public LIR_Op {
1653  friend class LIR_OpVisitState;
1654 
1655  protected:
1656   LIR_Opr   _opr1;
1657   LIR_Opr   _opr2;
1658   LIR_Opr   _tmp1;
1659   LIR_Opr   _tmp2;
1660   LIR_Opr   _tmp3;
1661   LIR_Opr   _tmp4;
1662   LIR_Opr   _tmp5;
1663   LIR_Condition _condition;
1664   BasicType _type;
1665 
1666   void verify() const;
1667 
1668  public:
1669   LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, CodeEmitInfo* info = nullptr, BasicType type = T_ILLEGAL)
1670     : LIR_Op(code, LIR_OprFact::illegalOpr, info)

1789   void          negate_cond();
1790 
1791   virtual void emit_code(LIR_Assembler* masm);
1792   virtual LIR_OpBranch* as_OpBranch() { return this; }
1793   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1794 };
1795 
1796 class LIR_OpAllocArray : public LIR_Op {
1797  friend class LIR_OpVisitState;
1798 
1799  private:
1800   LIR_Opr   _klass;
1801   LIR_Opr   _len;
1802   LIR_Opr   _tmp1;
1803   LIR_Opr   _tmp2;
1804   LIR_Opr   _tmp3;
1805   LIR_Opr   _tmp4;
1806   CodeStub* _stub;
1807   BasicType _type;
1808   bool      _zero_array;
1809   bool      _always_slow_path;
1810 
1811  public:
1812   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 zero_array, bool always_slow_path)
1813     : LIR_Op(lir_alloc_array, result, nullptr)
1814     , _klass(klass)
1815     , _len(len)
1816     , _tmp1(t1)
1817     , _tmp2(t2)
1818     , _tmp3(t3)
1819     , _tmp4(t4)
1820     , _stub(stub)
1821     , _type(type)
1822     , _zero_array(zero_array)
1823     , _always_slow_path(always_slow_path) {}
1824 
1825   LIR_Opr   klass()   const                      { return _klass;       }
1826   LIR_Opr   len()     const                      { return _len;         }
1827   LIR_Opr   obj()     const                      { return result_opr(); }
1828   LIR_Opr   tmp1()    const                      { return _tmp1;        }
1829   LIR_Opr   tmp2()    const                      { return _tmp2;        }
1830   LIR_Opr   tmp3()    const                      { return _tmp3;        }
1831   LIR_Opr   tmp4()    const                      { return _tmp4;        }
1832   BasicType type()    const                      { return _type;        }
1833   CodeStub* stub()    const                      { return _stub;        }
1834   bool      zero_array() const                   { return _zero_array;  }
1835   bool      always_slow_path() const             { return _always_slow_path; }
1836 
1837   virtual void emit_code(LIR_Assembler* masm);
1838   virtual LIR_OpAllocArray * as_OpAllocArray () { return this; }
1839   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1840 };
1841 
1842 
1843 class LIR_Op3: public LIR_Op {
1844  friend class LIR_OpVisitState;
1845 
1846  private:
1847   LIR_Opr _opr1;
1848   LIR_Opr _opr2;
1849   LIR_Opr _opr3;
1850  public:
1851   LIR_Op3(LIR_Code code, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr opr3, LIR_Opr result, CodeEmitInfo* info = nullptr)
1852     : LIR_Op(code, result, info)
1853     , _opr1(opr1)
1854     , _opr2(opr2)
1855     , _opr3(opr3)                                { assert(is_in_range(code, begin_op3, end_op3), "code check"); }

1922 
1923 //--------------------------------
1924 class LabelObj: public CompilationResourceObj {
1925  private:
1926   Label _label;
1927  public:
1928   LabelObj()                                     {}
1929   Label* label()                                 { return &_label; }
1930 };
1931 
1932 
1933 class LIR_OpLock: public LIR_Op {
1934  friend class LIR_OpVisitState;
1935 
1936  private:
1937   LIR_Opr _hdr;
1938   LIR_Opr _obj;
1939   LIR_Opr _lock;
1940   LIR_Opr _scratch;
1941   CodeStub* _stub;
1942   CodeStub* _throw_ie_stub;
1943  public:
1944   LIR_OpLock(LIR_Code code, LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info, CodeStub* throw_ie_stub=nullptr)
1945     : LIR_Op(code, LIR_OprFact::illegalOpr, info)
1946     , _hdr(hdr)
1947     , _obj(obj)
1948     , _lock(lock)
1949     , _scratch(scratch)
1950     , _stub(stub)
1951     , _throw_ie_stub(throw_ie_stub)                    {}
1952 
1953   LIR_Opr hdr_opr() const                        { return _hdr; }
1954   LIR_Opr obj_opr() const                        { return _obj; }
1955   LIR_Opr lock_opr() const                       { return _lock; }
1956   LIR_Opr scratch_opr() const                    { return _scratch; }
1957   CodeStub* stub() const                         { return _stub; }
1958   CodeStub* throw_ie_stub() const                { return _throw_ie_stub; }
1959 
1960   virtual void emit_code(LIR_Assembler* masm);
1961   virtual LIR_OpLock* as_OpLock() { return this; }
1962   void print_instr(outputStream* out) const PRODUCT_RETURN;
1963 };
1964 
1965 class LIR_OpLoadKlass: public LIR_Op {
1966   friend class LIR_OpVisitState;
1967 
1968  private:
1969   LIR_Opr _obj;
1970  public:
1971   LIR_OpLoadKlass(LIR_Opr obj, LIR_Opr result, CodeEmitInfo* info)
1972     : LIR_Op(lir_load_klass, result, info)
1973     , _obj(obj)
1974     {}
1975 
1976   LIR_Opr obj()        const { return _obj;  }
1977 
1978   virtual LIR_OpLoadKlass* as_OpLoadKlass() { return this; }

2104     , _obj(obj)
2105     , _tmp(tmp)
2106     , _exact_klass(exact_klass)
2107     , _current_klass(current_klass)
2108     , _not_null(not_null)
2109     , _no_conflict(no_conflict) { }
2110 
2111   LIR_Opr      mdp()              const             { return _mdp;              }
2112   LIR_Opr      obj()              const             { return _obj;              }
2113   LIR_Opr      tmp()              const             { return _tmp;              }
2114   ciKlass*     exact_klass()      const             { return _exact_klass;      }
2115   intptr_t     current_klass()    const             { return _current_klass;    }
2116   bool         not_null()         const             { return _not_null;         }
2117   bool         no_conflict()      const             { return _no_conflict;      }
2118 
2119   virtual void emit_code(LIR_Assembler* masm);
2120   virtual LIR_OpProfileType* as_OpProfileType() { return this; }
2121   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
2122 };
2123 
2124 // LIR_OpProfileInlineType
2125 class LIR_OpProfileInlineType : public LIR_Op {
2126  friend class LIR_OpVisitState;
2127 
2128  private:
2129   LIR_Opr      _mdp;
2130   LIR_Opr      _obj;
2131   int          _flag;
2132   LIR_Opr      _tmp;
2133   bool         _not_null;      // true if we know statically that _obj cannot be null
2134 
2135  public:
2136   // Destroys recv
2137   LIR_OpProfileInlineType(LIR_Opr mdp, LIR_Opr obj, int flag, LIR_Opr tmp, bool not_null)
2138     : LIR_Op(lir_profile_inline_type, LIR_OprFact::illegalOpr, nullptr)  // no result, no info
2139     , _mdp(mdp)
2140     , _obj(obj)
2141     , _flag(flag)
2142     , _tmp(tmp)
2143     , _not_null(not_null) { }
2144 
2145   LIR_Opr      mdp()              const             { return _mdp;              }
2146   LIR_Opr      obj()              const             { return _obj;              }
2147   int          flag()             const             { return _flag;             }
2148   LIR_Opr      tmp()              const             { return _tmp;              }
2149   bool         not_null()         const             { return _not_null;         }
2150 
2151   virtual void emit_code(LIR_Assembler* masm);
2152   virtual LIR_OpProfileInlineType* as_OpProfileInlineType() { return this; }
2153   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
2154 };
2155 
2156 class LIR_InsertionBuffer;
2157 
2158 //--------------------------------LIR_List---------------------------------------------------
2159 // Maintains a list of LIR instructions (one instance of LIR_List per basic block)
2160 // The LIR instructions are appended by the LIR_List class itself;
2161 //
2162 // Notes:
2163 // - all offsets are(should be) in bytes
2164 // - local positions are specified with an offset, with offset 0 being local 0
2165 
2166 class LIR_List: public CompilationResourceObj {
2167  private:
2168   LIR_OpList  _operations;
2169 
2170   Compilation*  _compilation;
2171 #ifndef PRODUCT
2172   BlockBegin*   _block;
2173 #endif
2174 #ifdef ASSERT
2175   const char *  _file;

2360   void div (LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_div, left, right, res, tmp)); }
2361   void rem (LIR_Opr left, LIR_Opr right, LIR_Opr res, CodeEmitInfo* info = nullptr)      { append(new LIR_Op2(lir_rem, left, right, res, info)); }
2362 
2363   void volatile_load_mem_reg(LIR_Address* address, LIR_Opr dst, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);
2364   void volatile_load_unsafe_reg(LIR_Opr base, LIR_Opr offset, LIR_Opr dst, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code);
2365 
2366   void load(LIR_Address* addr, LIR_Opr src, CodeEmitInfo* info = nullptr, LIR_PatchCode patch_code = lir_patch_none);
2367 
2368   void store_mem_int(jint v,    LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);
2369   void store_mem_oop(jobject o, LIR_Opr base, int offset_in_bytes, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);
2370   void store(LIR_Opr src, LIR_Address* addr, CodeEmitInfo* info = nullptr, LIR_PatchCode patch_code = lir_patch_none);
2371   void volatile_store_mem_reg(LIR_Opr src, LIR_Address* address, CodeEmitInfo* info, LIR_PatchCode patch_code = lir_patch_none);
2372   void volatile_store_unsafe_reg(LIR_Opr src, LIR_Opr base, LIR_Opr offset, BasicType type, CodeEmitInfo* info, LIR_PatchCode patch_code);
2373 
2374   void idiv(LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);
2375   void idiv(LIR_Opr left, int   right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);
2376   void irem(LIR_Opr left, LIR_Opr right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);
2377   void irem(LIR_Opr left, int   right, LIR_Opr res, LIR_Opr tmp, CodeEmitInfo* info);
2378 
2379   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);
2380   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 zero_array = true, bool always_slow_path = false);
2381 
2382   // jump is an unconditional branch
2383   void jump(BlockBegin* block) {
2384     append(new LIR_OpBranch(lir_cond_always, block));
2385   }
2386   void jump(CodeStub* stub) {
2387     append(new LIR_OpBranch(lir_cond_always, stub));
2388   }
2389   void branch(LIR_Condition cond, Label* lbl) {
2390     append(new LIR_OpBranch(cond, lbl));
2391   }
2392   // Should not be used for fp comparisons
2393   void branch(LIR_Condition cond, BlockBegin* block) {
2394     append(new LIR_OpBranch(cond, block));
2395   }
2396   // Should not be used for fp comparisons
2397   void branch(LIR_Condition cond, CodeStub* stub) {
2398     append(new LIR_OpBranch(cond, stub));
2399   }
2400   // Should only be used for fp comparisons

2407   void unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp);
2408 
2409   void shift_left(LIR_Opr value, int count, LIR_Opr dst)       { shift_left(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2410   void shift_right(LIR_Opr value, int count, LIR_Opr dst)      { shift_right(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2411   void unsigned_shift_right(LIR_Opr value, int count, LIR_Opr dst) { unsigned_shift_right(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2412 
2413   void lcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst)        { append(new LIR_Op2(lir_cmp_l2i,  left, right, dst)); }
2414   void fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less);
2415 
2416   void call_runtime_leaf(address routine, LIR_Opr tmp, LIR_Opr result, LIR_OprList* arguments) {
2417     append(new LIR_OpRTCall(routine, tmp, result, arguments));
2418   }
2419 
2420   void call_runtime(address routine, LIR_Opr tmp, LIR_Opr result,
2421                     LIR_OprList* arguments, CodeEmitInfo* info) {
2422     append(new LIR_OpRTCall(routine, tmp, result, arguments, info));
2423   }
2424 
2425   void load_stack_address_monitor(int monitor_ix, LIR_Opr dst)  { append(new LIR_Op1(lir_monaddr, LIR_OprFact::intConst(monitor_ix), dst)); }
2426   void unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub);
2427   void lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info, CodeStub* throw_ie_stub=nullptr);
2428 
2429   void breakpoint()                                                  { append(new LIR_Op0(lir_breakpoint)); }
2430 
2431   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)); }
2432 
2433   void update_crc32(LIR_Opr crc, LIR_Opr val, LIR_Opr res)  { append(new LIR_OpUpdateCRC32(crc, val, res)); }
2434 
2435   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);
2436   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);
2437   void check_flat_array(LIR_Opr array, LIR_Opr value, LIR_Opr tmp, CodeStub* stub);
2438   void check_null_free_array(LIR_Opr array, LIR_Opr tmp);
2439   void substitutability_check(LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr equal_result, LIR_Opr not_equal_result,
2440                               LIR_Opr tmp1, LIR_Opr tmp2,
2441                               ciKlass* left_klass, ciKlass* right_klass, LIR_Opr left_klass_op, LIR_Opr right_klass_op,
2442                               CodeEmitInfo* info, CodeStub* stub);
2443 
2444   void checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
2445                   LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
2446                   CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
2447                   ciMethod* profiled_method, int profiled_bci, bool is_null_free);
2448   // MethodData* profiling
2449   void profile_call(ciMethod* method, int bci, ciMethod* callee, LIR_Opr mdo, LIR_Opr recv, LIR_Opr t1, ciKlass* cha_klass) {
2450     append(new LIR_OpProfileCall(method, bci, callee, mdo, recv, t1, cha_klass));
2451   }
2452   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) {
2453     append(new LIR_OpProfileType(LIR_OprFact::address(mdp), obj, exact_klass, current_klass, tmp, not_null, no_conflict));
2454   }
2455   void profile_inline_type(LIR_Address* mdp, LIR_Opr obj, int flag, LIR_Opr tmp, bool not_null) {
2456     append(new LIR_OpProfileInlineType(LIR_OprFact::address(mdp), obj, flag, tmp, not_null));
2457   }
2458 
2459   void xadd(LIR_Opr src, LIR_Opr add, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xadd, src, add, res, tmp)); }
2460   void xchg(LIR_Opr src, LIR_Opr set, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xchg, src, set, res, tmp)); }
2461 
2462   void load_klass(LIR_Opr obj, LIR_Opr result, CodeEmitInfo* info) { append(new LIR_OpLoadKlass(obj, result, info)); }
2463 
2464 #ifdef ASSERT
2465   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)); }
2466 #endif
2467 };
2468 
2469 void print_LIR(BlockList* blocks);
2470 
2471 class LIR_InsertionBuffer : public CompilationResourceObj {
2472  private:
2473   LIR_List*   _lir;   // the lir list where ops of this buffer should be inserted later (null when uninitialized)
2474 
2475   // list of insertion points. index and count are stored alternately:
2476   // _index_and_count[i * 2]:     the index into lir list where "count" ops should be inserted
2477   // _index_and_count[i * 2 + 1]: the number of ops to be inserted at index
< prev index next >