src/share/vm/c1/c1_LIR.hpp

Print this page
rev 4136 : 7153771: array bound check elimination for c1
Summary: when possible optimize out array bound checks, inserting predicates when needed.
Reviewed-by:


 864 class  LIR_Op;
 865 class    LIR_Op0;
 866 class      LIR_OpLabel;
 867 class    LIR_Op1;
 868 class      LIR_OpBranch;
 869 class      LIR_OpConvert;
 870 class      LIR_OpAllocObj;
 871 class      LIR_OpRoundFP;
 872 class    LIR_Op2;
 873 class    LIR_OpDelay;
 874 class    LIR_Op3;
 875 class      LIR_OpAllocArray;
 876 class    LIR_OpCall;
 877 class      LIR_OpJavaCall;
 878 class      LIR_OpRTCall;
 879 class    LIR_OpArrayCopy;
 880 class    LIR_OpLock;
 881 class    LIR_OpTypeCheck;
 882 class    LIR_OpCompareAndSwap;
 883 class    LIR_OpProfileCall;

 884 
 885 
 886 // LIR operation codes
 887 enum LIR_Code {
 888     lir_none
 889   , begin_op0
 890       , lir_word_align
 891       , lir_label
 892       , lir_nop
 893       , lir_backwardbranch_target
 894       , lir_std_entry
 895       , lir_osr_entry
 896       , lir_build_frame
 897       , lir_fpop_raw
 898       , lir_24bit_FPU
 899       , lir_reset_FPU
 900       , lir_breakpoint
 901       , lir_rtcall
 902       , lir_membar
 903       , lir_membar_acquire


 983   , begin_opLock
 984     , lir_lock
 985     , lir_unlock
 986   , end_opLock
 987   , begin_delay_slot
 988     , lir_delay_slot
 989   , end_delay_slot
 990   , begin_opTypeCheck
 991     , lir_instanceof
 992     , lir_checkcast
 993     , lir_store_check
 994   , end_opTypeCheck
 995   , begin_opCompareAndSwap
 996     , lir_cas_long
 997     , lir_cas_obj
 998     , lir_cas_int
 999   , end_opCompareAndSwap
1000   , begin_opMDOProfile
1001     , lir_profile_call
1002   , end_opMDOProfile



1003 };
1004 
1005 
1006 enum LIR_Condition {
1007     lir_cond_equal
1008   , lir_cond_notEqual
1009   , lir_cond_less
1010   , lir_cond_lessEqual
1011   , lir_cond_greaterEqual
1012   , lir_cond_greater
1013   , lir_cond_belowEqual
1014   , lir_cond_aboveEqual
1015   , lir_cond_always
1016   , lir_cond_unknown = -1
1017 };
1018 
1019 
1020 enum LIR_PatchCode {
1021   lir_patch_none,
1022   lir_patch_low,


1118 
1119   virtual LIR_OpCall* as_OpCall() { return NULL; }
1120   virtual LIR_OpJavaCall* as_OpJavaCall() { return NULL; }
1121   virtual LIR_OpLabel* as_OpLabel() { return NULL; }
1122   virtual LIR_OpDelay* as_OpDelay() { return NULL; }
1123   virtual LIR_OpLock* as_OpLock() { return NULL; }
1124   virtual LIR_OpAllocArray* as_OpAllocArray() { return NULL; }
1125   virtual LIR_OpAllocObj* as_OpAllocObj() { return NULL; }
1126   virtual LIR_OpRoundFP* as_OpRoundFP() { return NULL; }
1127   virtual LIR_OpBranch* as_OpBranch() { return NULL; }
1128   virtual LIR_OpRTCall* as_OpRTCall() { return NULL; }
1129   virtual LIR_OpConvert* as_OpConvert() { return NULL; }
1130   virtual LIR_Op0* as_Op0() { return NULL; }
1131   virtual LIR_Op1* as_Op1() { return NULL; }
1132   virtual LIR_Op2* as_Op2() { return NULL; }
1133   virtual LIR_Op3* as_Op3() { return NULL; }
1134   virtual LIR_OpArrayCopy* as_OpArrayCopy() { return NULL; }
1135   virtual LIR_OpTypeCheck* as_OpTypeCheck() { return NULL; }
1136   virtual LIR_OpCompareAndSwap* as_OpCompareAndSwap() { return NULL; }
1137   virtual LIR_OpProfileCall* as_OpProfileCall() { return NULL; }

1138 
1139   virtual void verify() const {}
1140 };
1141 
1142 // for calls
1143 class LIR_OpCall: public LIR_Op {
1144  friend class LIR_OpVisitState;
1145 
1146  protected:
1147   address      _addr;
1148   LIR_OprList* _arguments;
1149  protected:
1150   LIR_OpCall(LIR_Code code, address addr, LIR_Opr result,
1151              LIR_OprList* arguments, CodeEmitInfo* info = NULL)
1152     : LIR_Op(code, result, info)
1153     , _arguments(arguments)
1154     , _addr(addr) {}
1155 
1156  public:
1157   address addr() const                           { return _addr; }


1606   LIR_Opr   _tmp3;
1607   LIR_Opr   _tmp4;
1608   LIR_Opr   _tmp5;
1609   LIR_Condition _condition;
1610 
1611   void verify() const;
1612 
1613  public:
1614   LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, CodeEmitInfo* info = NULL)
1615     : LIR_Op(code, LIR_OprFact::illegalOpr, info)
1616     , _opr1(opr1)
1617     , _opr2(opr2)
1618     , _type(T_ILLEGAL)
1619     , _condition(condition)
1620     , _fpu_stack_size(0)
1621     , _tmp1(LIR_OprFact::illegalOpr)
1622     , _tmp2(LIR_OprFact::illegalOpr)
1623     , _tmp3(LIR_OprFact::illegalOpr)
1624     , _tmp4(LIR_OprFact::illegalOpr)
1625     , _tmp5(LIR_OprFact::illegalOpr) {
1626     assert(code == lir_cmp, "code check");
1627   }
1628 
1629   LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type)
1630     : LIR_Op(code, result, NULL)
1631     , _opr1(opr1)
1632     , _opr2(opr2)
1633     , _type(type)
1634     , _condition(condition)
1635     , _fpu_stack_size(0)
1636     , _tmp1(LIR_OprFact::illegalOpr)
1637     , _tmp2(LIR_OprFact::illegalOpr)
1638     , _tmp3(LIR_OprFact::illegalOpr)
1639     , _tmp4(LIR_OprFact::illegalOpr)
1640     , _tmp5(LIR_OprFact::illegalOpr) {
1641     assert(code == lir_cmove, "code check");
1642     assert(type != T_ILLEGAL, "cmove should have type");
1643   }
1644 
1645   LIR_Op2(LIR_Code code, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result = LIR_OprFact::illegalOpr,
1646           CodeEmitInfo* info = NULL, BasicType type = T_ILLEGAL)


1666     , _type(T_ILLEGAL)
1667     , _condition(lir_cond_unknown)
1668     , _fpu_stack_size(0)
1669     , _tmp1(tmp1)
1670     , _tmp2(tmp2)
1671     , _tmp3(tmp3)
1672     , _tmp4(tmp4)
1673     , _tmp5(tmp5) {
1674     assert(code != lir_cmp && is_in_range(code, begin_op2, end_op2), "code check");
1675   }
1676 
1677   LIR_Opr in_opr1() const                        { return _opr1; }
1678   LIR_Opr in_opr2() const                        { return _opr2; }
1679   BasicType type()  const                        { return _type; }
1680   LIR_Opr tmp1_opr() const                       { return _tmp1; }
1681   LIR_Opr tmp2_opr() const                       { return _tmp2; }
1682   LIR_Opr tmp3_opr() const                       { return _tmp3; }
1683   LIR_Opr tmp4_opr() const                       { return _tmp4; }
1684   LIR_Opr tmp5_opr() const                       { return _tmp5; }
1685   LIR_Condition condition() const  {
1686     assert(code() == lir_cmp || code() == lir_cmove, "only valid for cmp and cmove"); return _condition;
1687   }
1688   void set_condition(LIR_Condition condition) {
1689     assert(code() == lir_cmp || code() == lir_cmove, "only valid for cmp and cmove");  _condition = condition;
1690   }
1691 
1692   void set_fpu_stack_size(int size)              { _fpu_stack_size = size; }
1693   int  fpu_stack_size() const                    { return _fpu_stack_size; }
1694 
1695   void set_in_opr1(LIR_Opr opr)                  { _opr1 = opr; }
1696   void set_in_opr2(LIR_Opr opr)                  { _opr2 = opr; }
1697 
1698   virtual void emit_code(LIR_Assembler* masm);
1699   virtual LIR_Op2* as_Op2() { return this; }
1700   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1701 };
1702 
1703 class LIR_OpAllocArray : public LIR_Op {
1704  friend class LIR_OpVisitState;
1705 
1706  private:


1806 
1807 class LIR_OpDelay: public LIR_Op {
1808  friend class LIR_OpVisitState;
1809 
1810  private:
1811   LIR_Op* _op;
1812 
1813  public:
1814   LIR_OpDelay(LIR_Op* op, CodeEmitInfo* info):
1815     LIR_Op(lir_delay_slot, LIR_OprFact::illegalOpr, info),
1816     _op(op) {
1817     assert(op->code() == lir_nop || LIRFillDelaySlots, "should be filling with nops");
1818   }
1819   virtual void emit_code(LIR_Assembler* masm);
1820   virtual LIR_OpDelay* as_OpDelay() { return this; }
1821   void print_instr(outputStream* out) const PRODUCT_RETURN;
1822   LIR_Op* delay_op() const { return _op; }
1823   CodeEmitInfo* call_info() const { return info(); }
1824 };
1825 
























1826 
1827 // LIR_OpCompareAndSwap
1828 class LIR_OpCompareAndSwap : public LIR_Op {
1829  friend class LIR_OpVisitState;
1830 
1831  private:
1832   LIR_Opr _addr;
1833   LIR_Opr _cmp_value;
1834   LIR_Opr _new_value;
1835   LIR_Opr _tmp1;
1836   LIR_Opr _tmp2;
1837 
1838  public:
1839   LIR_OpCompareAndSwap(LIR_Code code, LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1840                        LIR_Opr t1, LIR_Opr t2, LIR_Opr result)
1841     : LIR_Op(code, result, NULL)  // no result, no info
1842     , _addr(addr)
1843     , _cmp_value(cmp_value)
1844     , _new_value(new_value)
1845     , _tmp1(t1)


2179   void breakpoint()                                                  { append(new LIR_Op0(lir_breakpoint)); }
2180 
2181   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)); }
2182 
2183   void fpop_raw()                                { append(new LIR_Op0(lir_fpop_raw)); }
2184 
2185   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);
2186   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);
2187 
2188   void checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
2189                   LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
2190                   CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
2191                   ciMethod* profiled_method, int profiled_bci);
2192   // MethodData* profiling
2193   void profile_call(ciMethod* method, int bci, ciMethod* callee, LIR_Opr mdo, LIR_Opr recv, LIR_Opr t1, ciKlass* cha_klass) {
2194     append(new LIR_OpProfileCall(lir_profile_call, method, bci, callee, mdo, recv, t1, cha_klass));
2195   }
2196 
2197   void xadd(LIR_Opr src, LIR_Opr add, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xadd, src, add, res, tmp)); }
2198   void xchg(LIR_Opr src, LIR_Opr set, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xchg, src, set, res, tmp)); }



2199 };
2200 
2201 void print_LIR(BlockList* blocks);
2202 
2203 class LIR_InsertionBuffer : public CompilationResourceObj {
2204  private:
2205   LIR_List*   _lir;   // the lir list where ops of this buffer should be inserted later (NULL when uninitialized)
2206 
2207   // list of insertion points. index and count are stored alternately:
2208   // _index_and_count[i * 2]:     the index into lir list where "count" ops should be inserted
2209   // _index_and_count[i * 2 + 1]: the number of ops to be inserted at index
2210   intStack    _index_and_count;
2211 
2212   // the LIR_Ops to be inserted
2213   LIR_OpList  _ops;
2214 
2215   void append_new(int index, int count)  { _index_and_count.append(index); _index_and_count.append(count); }
2216   void set_index_at(int i, int value)    { _index_and_count.at_put((i << 1),     value); }
2217   void set_count_at(int i, int value)    { _index_and_count.at_put((i << 1) + 1, value); }
2218 




 864 class  LIR_Op;
 865 class    LIR_Op0;
 866 class      LIR_OpLabel;
 867 class    LIR_Op1;
 868 class      LIR_OpBranch;
 869 class      LIR_OpConvert;
 870 class      LIR_OpAllocObj;
 871 class      LIR_OpRoundFP;
 872 class    LIR_Op2;
 873 class    LIR_OpDelay;
 874 class    LIR_Op3;
 875 class      LIR_OpAllocArray;
 876 class    LIR_OpCall;
 877 class      LIR_OpJavaCall;
 878 class      LIR_OpRTCall;
 879 class    LIR_OpArrayCopy;
 880 class    LIR_OpLock;
 881 class    LIR_OpTypeCheck;
 882 class    LIR_OpCompareAndSwap;
 883 class    LIR_OpProfileCall;
 884 class    LIR_OpAssert;
 885 
 886 
 887 // LIR operation codes
 888 enum LIR_Code {
 889     lir_none
 890   , begin_op0
 891       , lir_word_align
 892       , lir_label
 893       , lir_nop
 894       , lir_backwardbranch_target
 895       , lir_std_entry
 896       , lir_osr_entry
 897       , lir_build_frame
 898       , lir_fpop_raw
 899       , lir_24bit_FPU
 900       , lir_reset_FPU
 901       , lir_breakpoint
 902       , lir_rtcall
 903       , lir_membar
 904       , lir_membar_acquire


 984   , begin_opLock
 985     , lir_lock
 986     , lir_unlock
 987   , end_opLock
 988   , begin_delay_slot
 989     , lir_delay_slot
 990   , end_delay_slot
 991   , begin_opTypeCheck
 992     , lir_instanceof
 993     , lir_checkcast
 994     , lir_store_check
 995   , end_opTypeCheck
 996   , begin_opCompareAndSwap
 997     , lir_cas_long
 998     , lir_cas_obj
 999     , lir_cas_int
1000   , end_opCompareAndSwap
1001   , begin_opMDOProfile
1002     , lir_profile_call
1003   , end_opMDOProfile
1004   , begin_opAssert
1005     , lir_assert
1006   , end_opAssert
1007 };
1008 
1009 
1010 enum LIR_Condition {
1011     lir_cond_equal
1012   , lir_cond_notEqual
1013   , lir_cond_less
1014   , lir_cond_lessEqual
1015   , lir_cond_greaterEqual
1016   , lir_cond_greater
1017   , lir_cond_belowEqual
1018   , lir_cond_aboveEqual
1019   , lir_cond_always
1020   , lir_cond_unknown = -1
1021 };
1022 
1023 
1024 enum LIR_PatchCode {
1025   lir_patch_none,
1026   lir_patch_low,


1122 
1123   virtual LIR_OpCall* as_OpCall() { return NULL; }
1124   virtual LIR_OpJavaCall* as_OpJavaCall() { return NULL; }
1125   virtual LIR_OpLabel* as_OpLabel() { return NULL; }
1126   virtual LIR_OpDelay* as_OpDelay() { return NULL; }
1127   virtual LIR_OpLock* as_OpLock() { return NULL; }
1128   virtual LIR_OpAllocArray* as_OpAllocArray() { return NULL; }
1129   virtual LIR_OpAllocObj* as_OpAllocObj() { return NULL; }
1130   virtual LIR_OpRoundFP* as_OpRoundFP() { return NULL; }
1131   virtual LIR_OpBranch* as_OpBranch() { return NULL; }
1132   virtual LIR_OpRTCall* as_OpRTCall() { return NULL; }
1133   virtual LIR_OpConvert* as_OpConvert() { return NULL; }
1134   virtual LIR_Op0* as_Op0() { return NULL; }
1135   virtual LIR_Op1* as_Op1() { return NULL; }
1136   virtual LIR_Op2* as_Op2() { return NULL; }
1137   virtual LIR_Op3* as_Op3() { return NULL; }
1138   virtual LIR_OpArrayCopy* as_OpArrayCopy() { return NULL; }
1139   virtual LIR_OpTypeCheck* as_OpTypeCheck() { return NULL; }
1140   virtual LIR_OpCompareAndSwap* as_OpCompareAndSwap() { return NULL; }
1141   virtual LIR_OpProfileCall* as_OpProfileCall() { return NULL; }
1142   virtual LIR_OpAssert* as_OpAssert() { return NULL; }
1143 
1144   virtual void verify() const {}
1145 };
1146 
1147 // for calls
1148 class LIR_OpCall: public LIR_Op {
1149  friend class LIR_OpVisitState;
1150 
1151  protected:
1152   address      _addr;
1153   LIR_OprList* _arguments;
1154  protected:
1155   LIR_OpCall(LIR_Code code, address addr, LIR_Opr result,
1156              LIR_OprList* arguments, CodeEmitInfo* info = NULL)
1157     : LIR_Op(code, result, info)
1158     , _arguments(arguments)
1159     , _addr(addr) {}
1160 
1161  public:
1162   address addr() const                           { return _addr; }


1611   LIR_Opr   _tmp3;
1612   LIR_Opr   _tmp4;
1613   LIR_Opr   _tmp5;
1614   LIR_Condition _condition;
1615 
1616   void verify() const;
1617 
1618  public:
1619   LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, CodeEmitInfo* info = NULL)
1620     : LIR_Op(code, LIR_OprFact::illegalOpr, info)
1621     , _opr1(opr1)
1622     , _opr2(opr2)
1623     , _type(T_ILLEGAL)
1624     , _condition(condition)
1625     , _fpu_stack_size(0)
1626     , _tmp1(LIR_OprFact::illegalOpr)
1627     , _tmp2(LIR_OprFact::illegalOpr)
1628     , _tmp3(LIR_OprFact::illegalOpr)
1629     , _tmp4(LIR_OprFact::illegalOpr)
1630     , _tmp5(LIR_OprFact::illegalOpr) {
1631     assert(code == lir_cmp || code == lir_assert, "code check");
1632   }
1633 
1634   LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type)
1635     : LIR_Op(code, result, NULL)
1636     , _opr1(opr1)
1637     , _opr2(opr2)
1638     , _type(type)
1639     , _condition(condition)
1640     , _fpu_stack_size(0)
1641     , _tmp1(LIR_OprFact::illegalOpr)
1642     , _tmp2(LIR_OprFact::illegalOpr)
1643     , _tmp3(LIR_OprFact::illegalOpr)
1644     , _tmp4(LIR_OprFact::illegalOpr)
1645     , _tmp5(LIR_OprFact::illegalOpr) {
1646     assert(code == lir_cmove, "code check");
1647     assert(type != T_ILLEGAL, "cmove should have type");
1648   }
1649 
1650   LIR_Op2(LIR_Code code, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result = LIR_OprFact::illegalOpr,
1651           CodeEmitInfo* info = NULL, BasicType type = T_ILLEGAL)


1671     , _type(T_ILLEGAL)
1672     , _condition(lir_cond_unknown)
1673     , _fpu_stack_size(0)
1674     , _tmp1(tmp1)
1675     , _tmp2(tmp2)
1676     , _tmp3(tmp3)
1677     , _tmp4(tmp4)
1678     , _tmp5(tmp5) {
1679     assert(code != lir_cmp && is_in_range(code, begin_op2, end_op2), "code check");
1680   }
1681 
1682   LIR_Opr in_opr1() const                        { return _opr1; }
1683   LIR_Opr in_opr2() const                        { return _opr2; }
1684   BasicType type()  const                        { return _type; }
1685   LIR_Opr tmp1_opr() const                       { return _tmp1; }
1686   LIR_Opr tmp2_opr() const                       { return _tmp2; }
1687   LIR_Opr tmp3_opr() const                       { return _tmp3; }
1688   LIR_Opr tmp4_opr() const                       { return _tmp4; }
1689   LIR_Opr tmp5_opr() const                       { return _tmp5; }
1690   LIR_Condition condition() const  {
1691     assert(code() == lir_cmp || code() == lir_cmove || code() == lir_assert, "only valid for cmp and cmove and assert"); return _condition;
1692   }
1693   void set_condition(LIR_Condition condition) {
1694     assert(code() == lir_cmp || code() == lir_cmove, "only valid for cmp and cmove");  _condition = condition;
1695   }
1696 
1697   void set_fpu_stack_size(int size)              { _fpu_stack_size = size; }
1698   int  fpu_stack_size() const                    { return _fpu_stack_size; }
1699 
1700   void set_in_opr1(LIR_Opr opr)                  { _opr1 = opr; }
1701   void set_in_opr2(LIR_Opr opr)                  { _opr2 = opr; }
1702 
1703   virtual void emit_code(LIR_Assembler* masm);
1704   virtual LIR_Op2* as_Op2() { return this; }
1705   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1706 };
1707 
1708 class LIR_OpAllocArray : public LIR_Op {
1709  friend class LIR_OpVisitState;
1710 
1711  private:


1811 
1812 class LIR_OpDelay: public LIR_Op {
1813  friend class LIR_OpVisitState;
1814 
1815  private:
1816   LIR_Op* _op;
1817 
1818  public:
1819   LIR_OpDelay(LIR_Op* op, CodeEmitInfo* info):
1820     LIR_Op(lir_delay_slot, LIR_OprFact::illegalOpr, info),
1821     _op(op) {
1822     assert(op->code() == lir_nop || LIRFillDelaySlots, "should be filling with nops");
1823   }
1824   virtual void emit_code(LIR_Assembler* masm);
1825   virtual LIR_OpDelay* as_OpDelay() { return this; }
1826   void print_instr(outputStream* out) const PRODUCT_RETURN;
1827   LIR_Op* delay_op() const { return _op; }
1828   CodeEmitInfo* call_info() const { return info(); }
1829 };
1830 
1831 #ifndef PRODUCT
1832 // LIR_OpAssert
1833 class LIR_OpAssert : public LIR_Op2 {
1834  friend class LIR_OpVisitState;
1835 
1836  private:
1837   const char* _msg;
1838   bool        _halt;
1839 
1840  public:
1841   LIR_OpAssert(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, const char* msg, bool halt)
1842     : LIR_Op2(lir_assert, condition, opr1, opr2)
1843     , _halt(halt)
1844     , _msg(msg) {
1845   }
1846 
1847   const char* msg() const                        { return _msg; }
1848   bool        halt() const                       { return _halt; }
1849 
1850   virtual void emit_code(LIR_Assembler* masm);
1851   virtual LIR_OpAssert* as_OpAssert()            { return this; }
1852   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1853 };
1854 #endif
1855 
1856 // LIR_OpCompareAndSwap
1857 class LIR_OpCompareAndSwap : public LIR_Op {
1858  friend class LIR_OpVisitState;
1859 
1860  private:
1861   LIR_Opr _addr;
1862   LIR_Opr _cmp_value;
1863   LIR_Opr _new_value;
1864   LIR_Opr _tmp1;
1865   LIR_Opr _tmp2;
1866 
1867  public:
1868   LIR_OpCompareAndSwap(LIR_Code code, LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
1869                        LIR_Opr t1, LIR_Opr t2, LIR_Opr result)
1870     : LIR_Op(code, result, NULL)  // no result, no info
1871     , _addr(addr)
1872     , _cmp_value(cmp_value)
1873     , _new_value(new_value)
1874     , _tmp1(t1)


2208   void breakpoint()                                                  { append(new LIR_Op0(lir_breakpoint)); }
2209 
2210   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)); }
2211 
2212   void fpop_raw()                                { append(new LIR_Op0(lir_fpop_raw)); }
2213 
2214   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);
2215   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);
2216 
2217   void checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
2218                   LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
2219                   CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
2220                   ciMethod* profiled_method, int profiled_bci);
2221   // MethodData* profiling
2222   void profile_call(ciMethod* method, int bci, ciMethod* callee, LIR_Opr mdo, LIR_Opr recv, LIR_Opr t1, ciKlass* cha_klass) {
2223     append(new LIR_OpProfileCall(lir_profile_call, method, bci, callee, mdo, recv, t1, cha_klass));
2224   }
2225 
2226   void xadd(LIR_Opr src, LIR_Opr add, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xadd, src, add, res, tmp)); }
2227   void xchg(LIR_Opr src, LIR_Opr set, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xchg, src, set, res, tmp)); }
2228 #ifndef PRODUCT
2229   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)); }
2230 #endif
2231 };
2232 
2233 void print_LIR(BlockList* blocks);
2234 
2235 class LIR_InsertionBuffer : public CompilationResourceObj {
2236  private:
2237   LIR_List*   _lir;   // the lir list where ops of this buffer should be inserted later (NULL when uninitialized)
2238 
2239   // list of insertion points. index and count are stored alternately:
2240   // _index_and_count[i * 2]:     the index into lir list where "count" ops should be inserted
2241   // _index_and_count[i * 2 + 1]: the number of ops to be inserted at index
2242   intStack    _index_and_count;
2243 
2244   // the LIR_Ops to be inserted
2245   LIR_OpList  _ops;
2246 
2247   void append_new(int index, int count)  { _index_and_count.append(index); _index_and_count.append(count); }
2248   void set_index_at(int i, int value)    { _index_and_count.at_put((i << 1),     value); }
2249   void set_count_at(int i, int value)    { _index_and_count.at_put((i << 1) + 1, value); }
2250