< prev index next >

src/hotspot/share/c1/c1_LIR.hpp

Print this page

 300   friend BasicType as_BasicType(OprType t);
 301 
 302   OprType type_field_valid() const               { assert(is_register() || is_stack(), "should not be called otherwise"); return (OprType)(value() & type_mask); }
 303   OprType type_field() const                     { return is_illegal() ? unknown_type : (OprType)(value() & type_mask); }
 304 
 305   static OprSize size_for(BasicType t) {
 306     switch (t) {
 307       case T_LONG:
 308       case T_DOUBLE:
 309         return double_size;
 310         break;
 311 
 312       case T_FLOAT:
 313       case T_BOOLEAN:
 314       case T_CHAR:
 315       case T_BYTE:
 316       case T_SHORT:
 317       case T_INT:
 318       case T_ADDRESS:
 319       case T_OBJECT:

 320       case T_ARRAY:
 321       case T_METADATA:
 322         return single_size;
 323         break;
 324 
 325       default:
 326         ShouldNotReachHere();
 327         return single_size;
 328       }
 329   }
 330 
 331 
 332   void validate_type() const PRODUCT_RETURN;
 333 
 334   BasicType type() const {
 335     if (is_pointer()) {
 336       return pointer()->type();
 337     }
 338     return as_BasicType(type_field());
 339   }

 450 #endif
 451 
 452   jint      as_jint()    const { return as_constant_ptr()->as_jint(); }
 453   jlong     as_jlong()   const { return as_constant_ptr()->as_jlong(); }
 454   jfloat    as_jfloat()  const { return as_constant_ptr()->as_jfloat(); }
 455   jdouble   as_jdouble() const { return as_constant_ptr()->as_jdouble(); }
 456   jobject   as_jobject() const { return as_constant_ptr()->as_jobject(); }
 457 
 458   void print() const PRODUCT_RETURN;
 459   void print(outputStream* out) const PRODUCT_RETURN;
 460 };
 461 
 462 
 463 inline LIR_OprDesc::OprType as_OprType(BasicType type) {
 464   switch (type) {
 465   case T_INT:      return LIR_OprDesc::int_type;
 466   case T_LONG:     return LIR_OprDesc::long_type;
 467   case T_FLOAT:    return LIR_OprDesc::float_type;
 468   case T_DOUBLE:   return LIR_OprDesc::double_type;
 469   case T_OBJECT:

 470   case T_ARRAY:    return LIR_OprDesc::object_type;
 471   case T_ADDRESS:  return LIR_OprDesc::address_type;
 472   case T_METADATA: return LIR_OprDesc::metadata_type;
 473   case T_ILLEGAL:  // fall through
 474   default: ShouldNotReachHere(); return LIR_OprDesc::unknown_type;
 475   }
 476 }
 477 
 478 inline BasicType as_BasicType(LIR_OprDesc::OprType t) {
 479   switch (t) {
 480   case LIR_OprDesc::int_type:     return T_INT;
 481   case LIR_OprDesc::long_type:    return T_LONG;
 482   case LIR_OprDesc::float_type:   return T_FLOAT;
 483   case LIR_OprDesc::double_type:  return T_DOUBLE;
 484   case LIR_OprDesc::object_type:  return T_OBJECT;
 485   case LIR_OprDesc::address_type: return T_ADDRESS;
 486   case LIR_OprDesc::metadata_type:return T_METADATA;
 487   case LIR_OprDesc::unknown_type: // fall through
 488   default: ShouldNotReachHere();  return T_ILLEGAL;
 489   }

 640   }
 641   static LIR_Opr double_xmm(int reg) {
 642     return (LIR_Opr)(intptr_t)((reg << LIR_OprDesc::reg1_shift) |
 643                                (reg << LIR_OprDesc::reg2_shift) |
 644                                LIR_OprDesc::double_type         |
 645                                LIR_OprDesc::fpu_register        |
 646                                LIR_OprDesc::double_size         |
 647                                LIR_OprDesc::is_xmm_mask);
 648   }
 649 #endif // X86
 650 
 651   static LIR_Opr virtual_register(int index, BasicType type) {
 652     if (index > LIR_OprDesc::vreg_max) {
 653       // Running out of virtual registers. Caller should bailout.
 654       return illegalOpr;
 655     }
 656 
 657     LIR_Opr res;
 658     switch (type) {
 659       case T_OBJECT: // fall through

 660       case T_ARRAY:
 661         res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift)  |
 662                                             LIR_OprDesc::object_type  |
 663                                             LIR_OprDesc::cpu_register |
 664                                             LIR_OprDesc::single_size  |
 665                                             LIR_OprDesc::virtual_mask);
 666         break;
 667 
 668       case T_METADATA:
 669         res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift)  |
 670                                             LIR_OprDesc::metadata_type|
 671                                             LIR_OprDesc::cpu_register |
 672                                             LIR_OprDesc::single_size  |
 673                                             LIR_OprDesc::virtual_mask);
 674         break;
 675 
 676       case T_INT:
 677         res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |
 678                                   LIR_OprDesc::int_type              |
 679                                   LIR_OprDesc::cpu_register          |

 745                                t |
 746                                LIR_OprDesc::cpu_register |
 747                                LIR_OprDesc::size_for(type) | LIR_OprDesc::virtual_mask);
 748 #else // __SOFTFP__
 749     LIR_Opr old_res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) | t |
 750                                           ((type == T_FLOAT || type == T_DOUBLE) ?  LIR_OprDesc::fpu_register : LIR_OprDesc::cpu_register) |
 751                                LIR_OprDesc::size_for(type) | LIR_OprDesc::virtual_mask);
 752     assert(res == old_res, "old and new method not equal");
 753 #endif // __SOFTFP__
 754 #endif // ASSERT
 755 
 756     return res;
 757   }
 758 
 759   // 'index' is computed by FrameMap::local_stack_pos(index); do not use other parameters as
 760   // the index is platform independent; a double stack useing indeces 2 and 3 has always
 761   // index 2.
 762   static LIR_Opr stack(int index, BasicType type) {
 763     LIR_Opr res;
 764     switch (type) {

 765       case T_OBJECT: // fall through
 766       case T_ARRAY:
 767         res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |
 768                                   LIR_OprDesc::object_type           |
 769                                   LIR_OprDesc::stack_value           |
 770                                   LIR_OprDesc::single_size);
 771         break;
 772 
 773       case T_METADATA:
 774         res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |
 775                                   LIR_OprDesc::metadata_type         |
 776                                   LIR_OprDesc::stack_value           |
 777                                   LIR_OprDesc::single_size);
 778         break;
 779       case T_INT:
 780         res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |
 781                                   LIR_OprDesc::int_type              |
 782                                   LIR_OprDesc::stack_value           |
 783                                   LIR_OprDesc::single_size);
 784         break;

 858 class  LIR_Op;
 859 class    LIR_Op0;
 860 class      LIR_OpLabel;
 861 class    LIR_Op1;
 862 class      LIR_OpBranch;
 863 class      LIR_OpConvert;
 864 class      LIR_OpAllocObj;
 865 class      LIR_OpReturn;
 866 class      LIR_OpRoundFP;
 867 class    LIR_Op2;
 868 class    LIR_OpDelay;
 869 class    LIR_Op3;
 870 class      LIR_OpAllocArray;
 871 class    LIR_OpCall;
 872 class      LIR_OpJavaCall;
 873 class      LIR_OpRTCall;
 874 class    LIR_OpArrayCopy;
 875 class    LIR_OpUpdateCRC32;
 876 class    LIR_OpLock;
 877 class    LIR_OpTypeCheck;



 878 class    LIR_OpCompareAndSwap;
 879 class    LIR_OpProfileCall;
 880 class    LIR_OpProfileType;

 881 #ifdef ASSERT
 882 class    LIR_OpAssert;
 883 #endif
 884 
 885 // LIR operation codes
 886 enum LIR_Code {
 887     lir_none
 888   , begin_op0
 889       , lir_label
 890       , lir_nop
 891       , lir_std_entry
 892       , lir_osr_entry
 893       , lir_fpop_raw
 894       , lir_breakpoint
 895       , lir_rtcall
 896       , lir_membar
 897       , lir_membar_acquire
 898       , lir_membar_release
 899       , lir_membar_loadload
 900       , lir_membar_storestore
 901       , lir_membar_loadstore
 902       , lir_membar_storeload
 903       , lir_get_thread
 904       , lir_on_spin_wait

 905   , end_op0
 906   , begin_op1
 907       , lir_fxch
 908       , lir_fld
 909       , lir_push
 910       , lir_pop
 911       , lir_null_check
 912       , lir_return
 913       , lir_leal
 914       , lir_branch
 915       , lir_cond_float_branch
 916       , lir_move
 917       , lir_convert
 918       , lir_alloc_object
 919       , lir_monaddr
 920       , lir_roundfp
 921       , lir_safepoint
 922       , lir_unwind
 923   , end_op1
 924   , begin_op2

 961       , lir_dynamic_call
 962   , end_opJavaCall
 963   , begin_opArrayCopy
 964       , lir_arraycopy
 965   , end_opArrayCopy
 966   , begin_opUpdateCRC32
 967       , lir_updatecrc32
 968   , end_opUpdateCRC32
 969   , begin_opLock
 970     , lir_lock
 971     , lir_unlock
 972   , end_opLock
 973   , begin_delay_slot
 974     , lir_delay_slot
 975   , end_delay_slot
 976   , begin_opTypeCheck
 977     , lir_instanceof
 978     , lir_checkcast
 979     , lir_store_check
 980   , end_opTypeCheck









 981   , begin_opCompareAndSwap
 982     , lir_cas_long
 983     , lir_cas_obj
 984     , lir_cas_int
 985   , end_opCompareAndSwap
 986   , begin_opMDOProfile
 987     , lir_profile_call
 988     , lir_profile_type

 989   , end_opMDOProfile
 990   , begin_opAssert
 991     , lir_assert
 992   , end_opAssert
 993 };
 994 
 995 
 996 enum LIR_Condition {
 997     lir_cond_equal
 998   , lir_cond_notEqual
 999   , lir_cond_less
1000   , lir_cond_lessEqual
1001   , lir_cond_greaterEqual
1002   , lir_cond_greater
1003   , lir_cond_belowEqual
1004   , lir_cond_aboveEqual
1005   , lir_cond_always
1006   , lir_cond_unknown = -1
1007 };
1008 

1111   virtual bool is_patching() { return false; }
1112   virtual LIR_OpCall* as_OpCall() { return NULL; }
1113   virtual LIR_OpJavaCall* as_OpJavaCall() { return NULL; }
1114   virtual LIR_OpLabel* as_OpLabel() { return NULL; }
1115   virtual LIR_OpDelay* as_OpDelay() { return NULL; }
1116   virtual LIR_OpLock* as_OpLock() { return NULL; }
1117   virtual LIR_OpAllocArray* as_OpAllocArray() { return NULL; }
1118   virtual LIR_OpAllocObj* as_OpAllocObj() { return NULL; }
1119   virtual LIR_OpRoundFP* as_OpRoundFP() { return NULL; }
1120   virtual LIR_OpBranch* as_OpBranch() { return NULL; }
1121   virtual LIR_OpReturn* as_OpReturn() { return NULL; }
1122   virtual LIR_OpRTCall* as_OpRTCall() { return NULL; }
1123   virtual LIR_OpConvert* as_OpConvert() { return NULL; }
1124   virtual LIR_Op0* as_Op0() { return NULL; }
1125   virtual LIR_Op1* as_Op1() { return NULL; }
1126   virtual LIR_Op2* as_Op2() { return NULL; }
1127   virtual LIR_Op3* as_Op3() { return NULL; }
1128   virtual LIR_OpArrayCopy* as_OpArrayCopy() { return NULL; }
1129   virtual LIR_OpUpdateCRC32* as_OpUpdateCRC32() { return NULL; }
1130   virtual LIR_OpTypeCheck* as_OpTypeCheck() { return NULL; }



1131   virtual LIR_OpCompareAndSwap* as_OpCompareAndSwap() { return NULL; }
1132   virtual LIR_OpProfileCall* as_OpProfileCall() { return NULL; }
1133   virtual LIR_OpProfileType* as_OpProfileType() { return NULL; }

1134 #ifdef ASSERT
1135   virtual LIR_OpAssert* as_OpAssert() { return NULL; }
1136 #endif
1137 
1138   virtual void verify() const {}
1139 };
1140 
1141 // for calls
1142 class LIR_OpCall: public LIR_Op {
1143  friend class LIR_OpVisitState;
1144 
1145  protected:
1146   address      _addr;
1147   LIR_OprList* _arguments;
1148  protected:
1149   LIR_OpCall(LIR_Code code, address addr, LIR_Opr result,
1150              LIR_OprList* arguments, CodeEmitInfo* info = NULL)
1151     : LIR_Op(code, result, info)
1152     , _addr(addr)
1153     , _arguments(arguments) {}

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


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

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



1258   };
1259 
1260   LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length, LIR_Opr tmp,
1261                   ciArrayKlass* expected_type, int flags, CodeEmitInfo* info);
1262 
1263   LIR_Opr src() const                            { return _src; }
1264   LIR_Opr src_pos() const                        { return _src_pos; }
1265   LIR_Opr dst() const                            { return _dst; }
1266   LIR_Opr dst_pos() const                        { return _dst_pos; }
1267   LIR_Opr length() const                         { return _length; }
1268   LIR_Opr tmp() const                            { return _tmp; }
1269   int flags() const                              { return _flags; }
1270   ciArrayKlass* expected_type() const            { return _expected_type; }
1271   ArrayCopyStub* stub() const                    { return _stub; }
1272 
1273   virtual void emit_code(LIR_Assembler* masm);
1274   virtual LIR_OpArrayCopy* as_OpArrayCopy() { return this; }
1275   void print_instr(outputStream* out) const PRODUCT_RETURN;
1276 };
1277 

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

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












































































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

1764 
1765 //--------------------------------
1766 class LabelObj: public CompilationResourceObj {
1767  private:
1768   Label _label;
1769  public:
1770   LabelObj()                                     {}
1771   Label* label()                                 { return &_label; }
1772 };
1773 
1774 
1775 class LIR_OpLock: public LIR_Op {
1776  friend class LIR_OpVisitState;
1777 
1778  private:
1779   LIR_Opr _hdr;
1780   LIR_Opr _obj;
1781   LIR_Opr _lock;
1782   LIR_Opr _scratch;
1783   CodeStub* _stub;

1784  public:
1785   LIR_OpLock(LIR_Code code, LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info)
1786     : LIR_Op(code, LIR_OprFact::illegalOpr, info)
1787     , _hdr(hdr)
1788     , _obj(obj)
1789     , _lock(lock)
1790     , _scratch(scratch)
1791     , _stub(stub)                      {}

1792 
1793   LIR_Opr hdr_opr() const                        { return _hdr; }
1794   LIR_Opr obj_opr() const                        { return _obj; }
1795   LIR_Opr lock_opr() const                       { return _lock; }
1796   LIR_Opr scratch_opr() const                    { return _scratch; }
1797   CodeStub* stub() const                         { return _stub; }

1798 
1799   virtual void emit_code(LIR_Assembler* masm);
1800   virtual LIR_OpLock* as_OpLock() { return this; }
1801   void print_instr(outputStream* out) const PRODUCT_RETURN;
1802 };
1803 
1804 
1805 class LIR_OpDelay: public LIR_Op {
1806  friend class LIR_OpVisitState;
1807 
1808  private:
1809   LIR_Op* _op;
1810 
1811  public:
1812   LIR_OpDelay(LIR_Op* op, CodeEmitInfo* info):
1813     LIR_Op(lir_delay_slot, LIR_OprFact::illegalOpr, info),
1814     _op(op) {
1815     assert(op->code() == lir_nop, "should be filling with nops");
1816   }
1817   virtual void emit_code(LIR_Assembler* masm);

1944     , _obj(obj)
1945     , _tmp(tmp)
1946     , _exact_klass(exact_klass)
1947     , _current_klass(current_klass)
1948     , _not_null(not_null)
1949     , _no_conflict(no_conflict) { }
1950 
1951   LIR_Opr      mdp()              const             { return _mdp;              }
1952   LIR_Opr      obj()              const             { return _obj;              }
1953   LIR_Opr      tmp()              const             { return _tmp;              }
1954   ciKlass*     exact_klass()      const             { return _exact_klass;      }
1955   intptr_t     current_klass()    const             { return _current_klass;    }
1956   bool         not_null()         const             { return _not_null;         }
1957   bool         no_conflict()      const             { return _no_conflict;      }
1958 
1959   virtual void emit_code(LIR_Assembler* masm);
1960   virtual LIR_OpProfileType* as_OpProfileType() { return this; }
1961   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1962 };
1963 
































1964 class LIR_InsertionBuffer;
1965 
1966 //--------------------------------LIR_List---------------------------------------------------
1967 // Maintains a list of LIR instructions (one instance of LIR_List per basic block)
1968 // The LIR instructions are appended by the LIR_List class itself;
1969 //
1970 // Notes:
1971 // - all offsets are(should be) in bytes
1972 // - local positions are specified with an offset, with offset 0 being local 0
1973 
1974 class LIR_List: public CompilationResourceObj {
1975  private:
1976   LIR_OpList  _operations;
1977 
1978   Compilation*  _compilation;
1979 #ifndef PRODUCT
1980   BlockBegin*   _block;
1981 #endif
1982 #ifdef ASSERT
1983   const char *  _file;

2201   void unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp);
2202 
2203   void shift_left(LIR_Opr value, int count, LIR_Opr dst)       { shift_left(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2204   void shift_right(LIR_Opr value, int count, LIR_Opr dst)      { shift_right(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2205   void unsigned_shift_right(LIR_Opr value, int count, LIR_Opr dst) { unsigned_shift_right(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2206 
2207   void lcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst)        { append(new LIR_Op2(lir_cmp_l2i,  left, right, dst)); }
2208   void fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less);
2209 
2210   void call_runtime_leaf(address routine, LIR_Opr tmp, LIR_Opr result, LIR_OprList* arguments) {
2211     append(new LIR_OpRTCall(routine, tmp, result, arguments));
2212   }
2213 
2214   void call_runtime(address routine, LIR_Opr tmp, LIR_Opr result,
2215                     LIR_OprList* arguments, CodeEmitInfo* info) {
2216     append(new LIR_OpRTCall(routine, tmp, result, arguments, info));
2217   }
2218 
2219   void load_stack_address_monitor(int monitor_ix, LIR_Opr dst)  { append(new LIR_Op1(lir_monaddr, LIR_OprFact::intConst(monitor_ix), dst)); }
2220   void unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub);
2221   void lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info);
2222 
2223   void breakpoint()                                                  { append(new LIR_Op0(lir_breakpoint)); }
2224 
2225   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)); }
2226 
2227   void update_crc32(LIR_Opr crc, LIR_Opr val, LIR_Opr res)  { append(new LIR_OpUpdateCRC32(crc, val, res)); }
2228 
2229   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);
2230   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);






2231 
2232   void checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
2233                   LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
2234                   CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
2235                   ciMethod* profiled_method, int profiled_bci);
2236   // MethodData* profiling
2237   void profile_call(ciMethod* method, int bci, ciMethod* callee, LIR_Opr mdo, LIR_Opr recv, LIR_Opr t1, ciKlass* cha_klass) {
2238     append(new LIR_OpProfileCall(method, bci, callee, mdo, recv, t1, cha_klass));
2239   }
2240   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) {
2241     append(new LIR_OpProfileType(LIR_OprFact::address(mdp), obj, exact_klass, current_klass, tmp, not_null, no_conflict));
2242   }



2243 
2244   void xadd(LIR_Opr src, LIR_Opr add, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xadd, src, add, res, tmp)); }
2245   void xchg(LIR_Opr src, LIR_Opr set, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xchg, src, set, res, tmp)); }
2246 #ifdef ASSERT
2247   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)); }
2248 #endif
2249 };
2250 
2251 void print_LIR(BlockList* blocks);
2252 
2253 class LIR_InsertionBuffer : public CompilationResourceObj {
2254  private:
2255   LIR_List*   _lir;   // the lir list where ops of this buffer should be inserted later (NULL when uninitialized)
2256 
2257   // list of insertion points. index and count are stored alternately:
2258   // _index_and_count[i * 2]:     the index into lir list where "count" ops should be inserted
2259   // _index_and_count[i * 2 + 1]: the number of ops to be inserted at index
2260   intStack    _index_and_count;
2261 
2262   // the LIR_Ops to be inserted

 300   friend BasicType as_BasicType(OprType t);
 301 
 302   OprType type_field_valid() const               { assert(is_register() || is_stack(), "should not be called otherwise"); return (OprType)(value() & type_mask); }
 303   OprType type_field() const                     { return is_illegal() ? unknown_type : (OprType)(value() & type_mask); }
 304 
 305   static OprSize size_for(BasicType t) {
 306     switch (t) {
 307       case T_LONG:
 308       case T_DOUBLE:
 309         return double_size;
 310         break;
 311 
 312       case T_FLOAT:
 313       case T_BOOLEAN:
 314       case T_CHAR:
 315       case T_BYTE:
 316       case T_SHORT:
 317       case T_INT:
 318       case T_ADDRESS:
 319       case T_OBJECT:
 320       case T_INLINE_TYPE:
 321       case T_ARRAY:
 322       case T_METADATA:
 323         return single_size;
 324         break;
 325 
 326       default:
 327         ShouldNotReachHere();
 328         return single_size;
 329       }
 330   }
 331 
 332 
 333   void validate_type() const PRODUCT_RETURN;
 334 
 335   BasicType type() const {
 336     if (is_pointer()) {
 337       return pointer()->type();
 338     }
 339     return as_BasicType(type_field());
 340   }

 451 #endif
 452 
 453   jint      as_jint()    const { return as_constant_ptr()->as_jint(); }
 454   jlong     as_jlong()   const { return as_constant_ptr()->as_jlong(); }
 455   jfloat    as_jfloat()  const { return as_constant_ptr()->as_jfloat(); }
 456   jdouble   as_jdouble() const { return as_constant_ptr()->as_jdouble(); }
 457   jobject   as_jobject() const { return as_constant_ptr()->as_jobject(); }
 458 
 459   void print() const PRODUCT_RETURN;
 460   void print(outputStream* out) const PRODUCT_RETURN;
 461 };
 462 
 463 
 464 inline LIR_OprDesc::OprType as_OprType(BasicType type) {
 465   switch (type) {
 466   case T_INT:      return LIR_OprDesc::int_type;
 467   case T_LONG:     return LIR_OprDesc::long_type;
 468   case T_FLOAT:    return LIR_OprDesc::float_type;
 469   case T_DOUBLE:   return LIR_OprDesc::double_type;
 470   case T_OBJECT:
 471   case T_INLINE_TYPE:
 472   case T_ARRAY:    return LIR_OprDesc::object_type;
 473   case T_ADDRESS:  return LIR_OprDesc::address_type;
 474   case T_METADATA: return LIR_OprDesc::metadata_type;
 475   case T_ILLEGAL:  // fall through
 476   default: ShouldNotReachHere(); return LIR_OprDesc::unknown_type;
 477   }
 478 }
 479 
 480 inline BasicType as_BasicType(LIR_OprDesc::OprType t) {
 481   switch (t) {
 482   case LIR_OprDesc::int_type:     return T_INT;
 483   case LIR_OprDesc::long_type:    return T_LONG;
 484   case LIR_OprDesc::float_type:   return T_FLOAT;
 485   case LIR_OprDesc::double_type:  return T_DOUBLE;
 486   case LIR_OprDesc::object_type:  return T_OBJECT;
 487   case LIR_OprDesc::address_type: return T_ADDRESS;
 488   case LIR_OprDesc::metadata_type:return T_METADATA;
 489   case LIR_OprDesc::unknown_type: // fall through
 490   default: ShouldNotReachHere();  return T_ILLEGAL;
 491   }

 642   }
 643   static LIR_Opr double_xmm(int reg) {
 644     return (LIR_Opr)(intptr_t)((reg << LIR_OprDesc::reg1_shift) |
 645                                (reg << LIR_OprDesc::reg2_shift) |
 646                                LIR_OprDesc::double_type         |
 647                                LIR_OprDesc::fpu_register        |
 648                                LIR_OprDesc::double_size         |
 649                                LIR_OprDesc::is_xmm_mask);
 650   }
 651 #endif // X86
 652 
 653   static LIR_Opr virtual_register(int index, BasicType type) {
 654     if (index > LIR_OprDesc::vreg_max) {
 655       // Running out of virtual registers. Caller should bailout.
 656       return illegalOpr;
 657     }
 658 
 659     LIR_Opr res;
 660     switch (type) {
 661       case T_OBJECT: // fall through
 662       case T_INLINE_TYPE: // fall through
 663       case T_ARRAY:
 664         res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift)  |
 665                                             LIR_OprDesc::object_type  |
 666                                             LIR_OprDesc::cpu_register |
 667                                             LIR_OprDesc::single_size  |
 668                                             LIR_OprDesc::virtual_mask);
 669         break;
 670 
 671       case T_METADATA:
 672         res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift)  |
 673                                             LIR_OprDesc::metadata_type|
 674                                             LIR_OprDesc::cpu_register |
 675                                             LIR_OprDesc::single_size  |
 676                                             LIR_OprDesc::virtual_mask);
 677         break;
 678 
 679       case T_INT:
 680         res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |
 681                                   LIR_OprDesc::int_type              |
 682                                   LIR_OprDesc::cpu_register          |

 748                                t |
 749                                LIR_OprDesc::cpu_register |
 750                                LIR_OprDesc::size_for(type) | LIR_OprDesc::virtual_mask);
 751 #else // __SOFTFP__
 752     LIR_Opr old_res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) | t |
 753                                           ((type == T_FLOAT || type == T_DOUBLE) ?  LIR_OprDesc::fpu_register : LIR_OprDesc::cpu_register) |
 754                                LIR_OprDesc::size_for(type) | LIR_OprDesc::virtual_mask);
 755     assert(res == old_res, "old and new method not equal");
 756 #endif // __SOFTFP__
 757 #endif // ASSERT
 758 
 759     return res;
 760   }
 761 
 762   // 'index' is computed by FrameMap::local_stack_pos(index); do not use other parameters as
 763   // the index is platform independent; a double stack useing indeces 2 and 3 has always
 764   // index 2.
 765   static LIR_Opr stack(int index, BasicType type) {
 766     LIR_Opr res;
 767     switch (type) {
 768       case T_INLINE_TYPE: // fall through
 769       case T_OBJECT: // fall through
 770       case T_ARRAY:
 771         res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |
 772                                   LIR_OprDesc::object_type           |
 773                                   LIR_OprDesc::stack_value           |
 774                                   LIR_OprDesc::single_size);
 775         break;
 776 
 777       case T_METADATA:
 778         res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |
 779                                   LIR_OprDesc::metadata_type         |
 780                                   LIR_OprDesc::stack_value           |
 781                                   LIR_OprDesc::single_size);
 782         break;
 783       case T_INT:
 784         res = (LIR_Opr)(intptr_t)((index << LIR_OprDesc::data_shift) |
 785                                   LIR_OprDesc::int_type              |
 786                                   LIR_OprDesc::stack_value           |
 787                                   LIR_OprDesc::single_size);
 788         break;

 862 class  LIR_Op;
 863 class    LIR_Op0;
 864 class      LIR_OpLabel;
 865 class    LIR_Op1;
 866 class      LIR_OpBranch;
 867 class      LIR_OpConvert;
 868 class      LIR_OpAllocObj;
 869 class      LIR_OpReturn;
 870 class      LIR_OpRoundFP;
 871 class    LIR_Op2;
 872 class    LIR_OpDelay;
 873 class    LIR_Op3;
 874 class      LIR_OpAllocArray;
 875 class    LIR_OpCall;
 876 class      LIR_OpJavaCall;
 877 class      LIR_OpRTCall;
 878 class    LIR_OpArrayCopy;
 879 class    LIR_OpUpdateCRC32;
 880 class    LIR_OpLock;
 881 class    LIR_OpTypeCheck;
 882 class    LIR_OpFlattenedArrayCheck;
 883 class    LIR_OpNullFreeArrayCheck;
 884 class    LIR_OpSubstitutabilityCheck;
 885 class    LIR_OpCompareAndSwap;
 886 class    LIR_OpProfileCall;
 887 class    LIR_OpProfileType;
 888 class    LIR_OpProfileInlineType;
 889 #ifdef ASSERT
 890 class    LIR_OpAssert;
 891 #endif
 892 
 893 // LIR operation codes
 894 enum LIR_Code {
 895     lir_none
 896   , begin_op0
 897       , lir_label
 898       , lir_nop
 899       , lir_std_entry
 900       , lir_osr_entry
 901       , lir_fpop_raw
 902       , lir_breakpoint
 903       , lir_rtcall
 904       , lir_membar
 905       , lir_membar_acquire
 906       , lir_membar_release
 907       , lir_membar_loadload
 908       , lir_membar_storestore
 909       , lir_membar_loadstore
 910       , lir_membar_storeload
 911       , lir_get_thread
 912       , lir_on_spin_wait
 913       , lir_check_orig_pc
 914   , end_op0
 915   , begin_op1
 916       , lir_fxch
 917       , lir_fld
 918       , lir_push
 919       , lir_pop
 920       , lir_null_check
 921       , lir_return
 922       , lir_leal
 923       , lir_branch
 924       , lir_cond_float_branch
 925       , lir_move
 926       , lir_convert
 927       , lir_alloc_object
 928       , lir_monaddr
 929       , lir_roundfp
 930       , lir_safepoint
 931       , lir_unwind
 932   , end_op1
 933   , begin_op2

 970       , lir_dynamic_call
 971   , end_opJavaCall
 972   , begin_opArrayCopy
 973       , lir_arraycopy
 974   , end_opArrayCopy
 975   , begin_opUpdateCRC32
 976       , lir_updatecrc32
 977   , end_opUpdateCRC32
 978   , begin_opLock
 979     , lir_lock
 980     , lir_unlock
 981   , end_opLock
 982   , begin_delay_slot
 983     , lir_delay_slot
 984   , end_delay_slot
 985   , begin_opTypeCheck
 986     , lir_instanceof
 987     , lir_checkcast
 988     , lir_store_check
 989   , end_opTypeCheck
 990   , begin_opFlattenedArrayCheck
 991     , lir_flattened_array_check
 992   , end_opFlattenedArrayCheck
 993   , begin_opNullFreeArrayCheck
 994     , lir_null_free_array_check
 995   , end_opNullFreeArrayCheck
 996   , begin_opSubstitutabilityCheck
 997     , lir_substitutability_check
 998   , end_opSubstitutabilityCheck
 999   , begin_opCompareAndSwap
1000     , lir_cas_long
1001     , lir_cas_obj
1002     , lir_cas_int
1003   , end_opCompareAndSwap
1004   , begin_opMDOProfile
1005     , lir_profile_call
1006     , lir_profile_type
1007     , lir_profile_inline_type
1008   , end_opMDOProfile
1009   , begin_opAssert
1010     , lir_assert
1011   , end_opAssert
1012 };
1013 
1014 
1015 enum LIR_Condition {
1016     lir_cond_equal
1017   , lir_cond_notEqual
1018   , lir_cond_less
1019   , lir_cond_lessEqual
1020   , lir_cond_greaterEqual
1021   , lir_cond_greater
1022   , lir_cond_belowEqual
1023   , lir_cond_aboveEqual
1024   , lir_cond_always
1025   , lir_cond_unknown = -1
1026 };
1027 

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

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

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

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

1869 
1870 //--------------------------------
1871 class LabelObj: public CompilationResourceObj {
1872  private:
1873   Label _label;
1874  public:
1875   LabelObj()                                     {}
1876   Label* label()                                 { return &_label; }
1877 };
1878 
1879 
1880 class LIR_OpLock: public LIR_Op {
1881  friend class LIR_OpVisitState;
1882 
1883  private:
1884   LIR_Opr _hdr;
1885   LIR_Opr _obj;
1886   LIR_Opr _lock;
1887   LIR_Opr _scratch;
1888   CodeStub* _stub;
1889   CodeStub* _throw_imse_stub;
1890  public:
1891   LIR_OpLock(LIR_Code code, LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info, CodeStub* throw_imse_stub=NULL)
1892     : LIR_Op(code, LIR_OprFact::illegalOpr, info)
1893     , _hdr(hdr)
1894     , _obj(obj)
1895     , _lock(lock)
1896     , _scratch(scratch)
1897     , _stub(stub)
1898     , _throw_imse_stub(throw_imse_stub)                    {}
1899 
1900   LIR_Opr hdr_opr() const                        { return _hdr; }
1901   LIR_Opr obj_opr() const                        { return _obj; }
1902   LIR_Opr lock_opr() const                       { return _lock; }
1903   LIR_Opr scratch_opr() const                    { return _scratch; }
1904   CodeStub* stub() const                         { return _stub; }
1905   CodeStub* throw_imse_stub() const              { return _throw_imse_stub; }
1906 
1907   virtual void emit_code(LIR_Assembler* masm);
1908   virtual LIR_OpLock* as_OpLock() { return this; }
1909   void print_instr(outputStream* out) const PRODUCT_RETURN;
1910 };
1911 
1912 
1913 class LIR_OpDelay: public LIR_Op {
1914  friend class LIR_OpVisitState;
1915 
1916  private:
1917   LIR_Op* _op;
1918 
1919  public:
1920   LIR_OpDelay(LIR_Op* op, CodeEmitInfo* info):
1921     LIR_Op(lir_delay_slot, LIR_OprFact::illegalOpr, info),
1922     _op(op) {
1923     assert(op->code() == lir_nop, "should be filling with nops");
1924   }
1925   virtual void emit_code(LIR_Assembler* masm);

2052     , _obj(obj)
2053     , _tmp(tmp)
2054     , _exact_klass(exact_klass)
2055     , _current_klass(current_klass)
2056     , _not_null(not_null)
2057     , _no_conflict(no_conflict) { }
2058 
2059   LIR_Opr      mdp()              const             { return _mdp;              }
2060   LIR_Opr      obj()              const             { return _obj;              }
2061   LIR_Opr      tmp()              const             { return _tmp;              }
2062   ciKlass*     exact_klass()      const             { return _exact_klass;      }
2063   intptr_t     current_klass()    const             { return _current_klass;    }
2064   bool         not_null()         const             { return _not_null;         }
2065   bool         no_conflict()      const             { return _no_conflict;      }
2066 
2067   virtual void emit_code(LIR_Assembler* masm);
2068   virtual LIR_OpProfileType* as_OpProfileType() { return this; }
2069   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
2070 };
2071 
2072 // LIR_OpProfileInlineType
2073 class LIR_OpProfileInlineType : public LIR_Op {
2074  friend class LIR_OpVisitState;
2075 
2076  private:
2077   LIR_Opr      _mdp;
2078   LIR_Opr      _obj;
2079   int          _flag;
2080   LIR_Opr      _tmp;
2081   bool         _not_null;      // true if we know statically that _obj cannot be null
2082 
2083  public:
2084   // Destroys recv
2085   LIR_OpProfileInlineType(LIR_Opr mdp, LIR_Opr obj, int flag, LIR_Opr tmp, bool not_null)
2086     : LIR_Op(lir_profile_inline_type, LIR_OprFact::illegalOpr, NULL)  // no result, no info
2087     , _mdp(mdp)
2088     , _obj(obj)
2089     , _flag(flag)
2090     , _tmp(tmp)
2091     , _not_null(not_null) { }
2092 
2093   LIR_Opr      mdp()              const             { return _mdp;              }
2094   LIR_Opr      obj()              const             { return _obj;              }
2095   int          flag()             const             { return _flag;             }
2096   LIR_Opr      tmp()              const             { return _tmp;              }
2097   bool         not_null()         const             { return _not_null;         }
2098 
2099   virtual void emit_code(LIR_Assembler* masm);
2100   virtual LIR_OpProfileInlineType* as_OpProfileInlineType() { return this; }
2101   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
2102 };
2103 
2104 class LIR_InsertionBuffer;
2105 
2106 //--------------------------------LIR_List---------------------------------------------------
2107 // Maintains a list of LIR instructions (one instance of LIR_List per basic block)
2108 // The LIR instructions are appended by the LIR_List class itself;
2109 //
2110 // Notes:
2111 // - all offsets are(should be) in bytes
2112 // - local positions are specified with an offset, with offset 0 being local 0
2113 
2114 class LIR_List: public CompilationResourceObj {
2115  private:
2116   LIR_OpList  _operations;
2117 
2118   Compilation*  _compilation;
2119 #ifndef PRODUCT
2120   BlockBegin*   _block;
2121 #endif
2122 #ifdef ASSERT
2123   const char *  _file;

2341   void unsigned_shift_right(LIR_Opr value, LIR_Opr count, LIR_Opr dst, LIR_Opr tmp);
2342 
2343   void shift_left(LIR_Opr value, int count, LIR_Opr dst)       { shift_left(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2344   void shift_right(LIR_Opr value, int count, LIR_Opr dst)      { shift_right(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2345   void unsigned_shift_right(LIR_Opr value, int count, LIR_Opr dst) { unsigned_shift_right(value, LIR_OprFact::intConst(count), dst, LIR_OprFact::illegalOpr); }
2346 
2347   void lcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst)        { append(new LIR_Op2(lir_cmp_l2i,  left, right, dst)); }
2348   void fcmp2int(LIR_Opr left, LIR_Opr right, LIR_Opr dst, bool is_unordered_less);
2349 
2350   void call_runtime_leaf(address routine, LIR_Opr tmp, LIR_Opr result, LIR_OprList* arguments) {
2351     append(new LIR_OpRTCall(routine, tmp, result, arguments));
2352   }
2353 
2354   void call_runtime(address routine, LIR_Opr tmp, LIR_Opr result,
2355                     LIR_OprList* arguments, CodeEmitInfo* info) {
2356     append(new LIR_OpRTCall(routine, tmp, result, arguments, info));
2357   }
2358 
2359   void load_stack_address_monitor(int monitor_ix, LIR_Opr dst)  { append(new LIR_Op1(lir_monaddr, LIR_OprFact::intConst(monitor_ix), dst)); }
2360   void unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub);
2361   void lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info, CodeStub* throw_imse_stub=NULL);
2362 
2363   void breakpoint()                                                  { append(new LIR_Op0(lir_breakpoint)); }
2364 
2365   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)); }
2366 
2367   void update_crc32(LIR_Opr crc, LIR_Opr val, LIR_Opr res)  { append(new LIR_OpUpdateCRC32(crc, val, res)); }
2368 
2369   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);
2370   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);
2371   void check_flattened_array(LIR_Opr array, LIR_Opr value, LIR_Opr tmp, CodeStub* stub);
2372   void check_null_free_array(LIR_Opr array, LIR_Opr tmp);
2373   void substitutability_check(LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr equal_result, LIR_Opr not_equal_result,
2374                               LIR_Opr tmp1, LIR_Opr tmp2,
2375                               ciKlass* left_klass, ciKlass* right_klass, LIR_Opr left_klass_op, LIR_Opr right_klass_op,
2376                               CodeEmitInfo* info, CodeStub* stub);
2377 
2378   void checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
2379                   LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
2380                   CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
2381                   ciMethod* profiled_method, int profiled_bci, bool is_null_free);
2382   // MethodData* profiling
2383   void profile_call(ciMethod* method, int bci, ciMethod* callee, LIR_Opr mdo, LIR_Opr recv, LIR_Opr t1, ciKlass* cha_klass) {
2384     append(new LIR_OpProfileCall(method, bci, callee, mdo, recv, t1, cha_klass));
2385   }
2386   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) {
2387     append(new LIR_OpProfileType(LIR_OprFact::address(mdp), obj, exact_klass, current_klass, tmp, not_null, no_conflict));
2388   }
2389   void profile_inline_type(LIR_Address* mdp, LIR_Opr obj, int flag, LIR_Opr tmp, bool not_null) {
2390     append(new LIR_OpProfileInlineType(LIR_OprFact::address(mdp), obj, flag, tmp, not_null));
2391   }
2392 
2393   void xadd(LIR_Opr src, LIR_Opr add, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xadd, src, add, res, tmp)); }
2394   void xchg(LIR_Opr src, LIR_Opr set, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xchg, src, set, res, tmp)); }
2395 #ifdef ASSERT
2396   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)); }
2397 #endif
2398 };
2399 
2400 void print_LIR(BlockList* blocks);
2401 
2402 class LIR_InsertionBuffer : public CompilationResourceObj {
2403  private:
2404   LIR_List*   _lir;   // the lir list where ops of this buffer should be inserted later (NULL when uninitialized)
2405 
2406   // list of insertion points. index and count are stored alternately:
2407   // _index_and_count[i * 2]:     the index into lir list where "count" ops should be inserted
2408   // _index_and_count[i * 2 + 1]: the number of ops to be inserted at index
2409   intStack    _index_and_count;
2410 
2411   // the LIR_Ops to be inserted
< prev index next >