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_OpUpdateCRC32;
881 class LIR_OpLock;
882 class LIR_OpTypeCheck;
883 class LIR_OpCompareAndSwap;
884 class LIR_OpProfileCall;
885 #ifdef ASSERT
886 class LIR_OpAssert;
887 #endif
888
889 // LIR operation codes
890 enum LIR_Code {
891 lir_none
892 , begin_op0
893 , lir_word_align
894 , lir_label
895 , lir_nop
896 , lir_backwardbranch_target
897 , lir_std_entry
898 , lir_osr_entry
899 , lir_build_frame
900 , lir_fpop_raw
901 , lir_24bit_FPU
902 , lir_reset_FPU
903 , lir_breakpoint
904 , lir_rtcall
988 , end_opUpdateCRC32
989 , begin_opLock
990 , lir_lock
991 , lir_unlock
992 , end_opLock
993 , begin_delay_slot
994 , lir_delay_slot
995 , end_delay_slot
996 , begin_opTypeCheck
997 , lir_instanceof
998 , lir_checkcast
999 , lir_store_check
1000 , end_opTypeCheck
1001 , begin_opCompareAndSwap
1002 , lir_cas_long
1003 , lir_cas_obj
1004 , lir_cas_int
1005 , end_opCompareAndSwap
1006 , begin_opMDOProfile
1007 , lir_profile_call
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
1128 virtual LIR_OpCall* as_OpCall() { return NULL; }
1129 virtual LIR_OpJavaCall* as_OpJavaCall() { return NULL; }
1130 virtual LIR_OpLabel* as_OpLabel() { return NULL; }
1131 virtual LIR_OpDelay* as_OpDelay() { return NULL; }
1132 virtual LIR_OpLock* as_OpLock() { return NULL; }
1133 virtual LIR_OpAllocArray* as_OpAllocArray() { return NULL; }
1134 virtual LIR_OpAllocObj* as_OpAllocObj() { return NULL; }
1135 virtual LIR_OpRoundFP* as_OpRoundFP() { return NULL; }
1136 virtual LIR_OpBranch* as_OpBranch() { return NULL; }
1137 virtual LIR_OpRTCall* as_OpRTCall() { return NULL; }
1138 virtual LIR_OpConvert* as_OpConvert() { return NULL; }
1139 virtual LIR_Op0* as_Op0() { return NULL; }
1140 virtual LIR_Op1* as_Op1() { return NULL; }
1141 virtual LIR_Op2* as_Op2() { return NULL; }
1142 virtual LIR_Op3* as_Op3() { return NULL; }
1143 virtual LIR_OpArrayCopy* as_OpArrayCopy() { return NULL; }
1144 virtual LIR_OpUpdateCRC32* as_OpUpdateCRC32() { return NULL; }
1145 virtual LIR_OpTypeCheck* as_OpTypeCheck() { return NULL; }
1146 virtual LIR_OpCompareAndSwap* as_OpCompareAndSwap() { return NULL; }
1147 virtual LIR_OpProfileCall* as_OpProfileCall() { return NULL; }
1148 #ifdef ASSERT
1149 virtual LIR_OpAssert* as_OpAssert() { return NULL; }
1150 #endif
1151
1152 virtual void verify() const {}
1153 };
1154
1155 // for calls
1156 class LIR_OpCall: public LIR_Op {
1157 friend class LIR_OpVisitState;
1158
1159 protected:
1160 address _addr;
1161 LIR_OprList* _arguments;
1162 protected:
1163 LIR_OpCall(LIR_Code code, address addr, LIR_Opr result,
1164 LIR_OprList* arguments, CodeEmitInfo* info = NULL)
1165 : LIR_Op(code, result, info)
1166 , _arguments(arguments)
1167 , _addr(addr) {}
1908 virtual void emit_code(LIR_Assembler* masm);
1909 virtual LIR_OpCompareAndSwap * as_OpCompareAndSwap () { return this; }
1910 virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1911 };
1912
1913 // LIR_OpProfileCall
1914 class LIR_OpProfileCall : public LIR_Op {
1915 friend class LIR_OpVisitState;
1916
1917 private:
1918 ciMethod* _profiled_method;
1919 int _profiled_bci;
1920 ciMethod* _profiled_callee;
1921 LIR_Opr _mdo;
1922 LIR_Opr _recv;
1923 LIR_Opr _tmp1;
1924 ciKlass* _known_holder;
1925
1926 public:
1927 // Destroys recv
1928 LIR_OpProfileCall(LIR_Code code, ciMethod* profiled_method, int profiled_bci, ciMethod* profiled_callee, LIR_Opr mdo, LIR_Opr recv, LIR_Opr t1, ciKlass* known_holder)
1929 : LIR_Op(code, LIR_OprFact::illegalOpr, NULL) // no result, no info
1930 , _profiled_method(profiled_method)
1931 , _profiled_bci(profiled_bci)
1932 , _profiled_callee(profiled_callee)
1933 , _mdo(mdo)
1934 , _recv(recv)
1935 , _tmp1(t1)
1936 , _known_holder(known_holder) { }
1937
1938 ciMethod* profiled_method() const { return _profiled_method; }
1939 int profiled_bci() const { return _profiled_bci; }
1940 ciMethod* profiled_callee() const { return _profiled_callee; }
1941 LIR_Opr mdo() const { return _mdo; }
1942 LIR_Opr recv() const { return _recv; }
1943 LIR_Opr tmp1() const { return _tmp1; }
1944 ciKlass* known_holder() const { return _known_holder; }
1945
1946 virtual void emit_code(LIR_Assembler* masm);
1947 virtual LIR_OpProfileCall* as_OpProfileCall() { return this; }
1948 virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1949 };
1950
1951 class LIR_InsertionBuffer;
1952
1953 //--------------------------------LIR_List---------------------------------------------------
1954 // Maintains a list of LIR instructions (one instance of LIR_List per basic block)
1955 // The LIR instructions are appended by the LIR_List class itself;
1956 //
1957 // Notes:
1958 // - all offsets are(should be) in bytes
1959 // - local positions are specified with an offset, with offset 0 being local 0
1960
1961 class LIR_List: public CompilationResourceObj {
1962 private:
1963 LIR_OpList _operations;
1964
1965 Compilation* _compilation;
1966 #ifndef PRODUCT
1967 BlockBegin* _block;
1968 #endif
1969 #ifdef ASSERT
1970 const char * _file;
2230
2231 void set_24bit_fpu() { append(new LIR_Op0(lir_24bit_FPU )); }
2232 void restore_fpu() { append(new LIR_Op0(lir_reset_FPU )); }
2233 void breakpoint() { append(new LIR_Op0(lir_breakpoint)); }
2234
2235 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)); }
2236
2237 void update_crc32(LIR_Opr crc, LIR_Opr val, LIR_Opr res) { append(new LIR_OpUpdateCRC32(crc, val, res)); }
2238
2239 void fpop_raw() { append(new LIR_Op0(lir_fpop_raw)); }
2240
2241 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);
2242 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);
2243
2244 void checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
2245 LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
2246 CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
2247 ciMethod* profiled_method, int profiled_bci);
2248 // MethodData* profiling
2249 void profile_call(ciMethod* method, int bci, ciMethod* callee, LIR_Opr mdo, LIR_Opr recv, LIR_Opr t1, ciKlass* cha_klass) {
2250 append(new LIR_OpProfileCall(lir_profile_call, method, bci, callee, mdo, recv, t1, cha_klass));
2251 }
2252
2253 void xadd(LIR_Opr src, LIR_Opr add, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xadd, src, add, res, tmp)); }
2254 void xchg(LIR_Opr src, LIR_Opr set, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xchg, src, set, res, tmp)); }
2255 #ifdef ASSERT
2256 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)); }
2257 #endif
2258 };
2259
2260 void print_LIR(BlockList* blocks);
2261
2262 class LIR_InsertionBuffer : public CompilationResourceObj {
2263 private:
2264 LIR_List* _lir; // the lir list where ops of this buffer should be inserted later (NULL when uninitialized)
2265
2266 // list of insertion points. index and count are stored alternately:
2267 // _index_and_count[i * 2]: the index into lir list where "count" ops should be inserted
2268 // _index_and_count[i * 2 + 1]: the number of ops to be inserted at index
2269 intStack _index_and_count;
2270
|
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_OpUpdateCRC32;
881 class LIR_OpLock;
882 class LIR_OpTypeCheck;
883 class LIR_OpCompareAndSwap;
884 class LIR_OpProfileCall;
885 class LIR_OpProfileType;
886 #ifdef ASSERT
887 class LIR_OpAssert;
888 #endif
889
890 // LIR operation codes
891 enum LIR_Code {
892 lir_none
893 , begin_op0
894 , lir_word_align
895 , lir_label
896 , lir_nop
897 , lir_backwardbranch_target
898 , lir_std_entry
899 , lir_osr_entry
900 , lir_build_frame
901 , lir_fpop_raw
902 , lir_24bit_FPU
903 , lir_reset_FPU
904 , lir_breakpoint
905 , lir_rtcall
989 , end_opUpdateCRC32
990 , begin_opLock
991 , lir_lock
992 , lir_unlock
993 , end_opLock
994 , begin_delay_slot
995 , lir_delay_slot
996 , end_delay_slot
997 , begin_opTypeCheck
998 , lir_instanceof
999 , lir_checkcast
1000 , lir_store_check
1001 , end_opTypeCheck
1002 , begin_opCompareAndSwap
1003 , lir_cas_long
1004 , lir_cas_obj
1005 , lir_cas_int
1006 , end_opCompareAndSwap
1007 , begin_opMDOProfile
1008 , lir_profile_call
1009 , lir_profile_type
1010 , end_opMDOProfile
1011 , begin_opAssert
1012 , lir_assert
1013 , end_opAssert
1014 };
1015
1016
1017 enum LIR_Condition {
1018 lir_cond_equal
1019 , lir_cond_notEqual
1020 , lir_cond_less
1021 , lir_cond_lessEqual
1022 , lir_cond_greaterEqual
1023 , lir_cond_greater
1024 , lir_cond_belowEqual
1025 , lir_cond_aboveEqual
1026 , lir_cond_always
1027 , lir_cond_unknown = -1
1028 };
1029
1130 virtual LIR_OpCall* as_OpCall() { return NULL; }
1131 virtual LIR_OpJavaCall* as_OpJavaCall() { return NULL; }
1132 virtual LIR_OpLabel* as_OpLabel() { return NULL; }
1133 virtual LIR_OpDelay* as_OpDelay() { return NULL; }
1134 virtual LIR_OpLock* as_OpLock() { return NULL; }
1135 virtual LIR_OpAllocArray* as_OpAllocArray() { return NULL; }
1136 virtual LIR_OpAllocObj* as_OpAllocObj() { return NULL; }
1137 virtual LIR_OpRoundFP* as_OpRoundFP() { return NULL; }
1138 virtual LIR_OpBranch* as_OpBranch() { return NULL; }
1139 virtual LIR_OpRTCall* as_OpRTCall() { return NULL; }
1140 virtual LIR_OpConvert* as_OpConvert() { return NULL; }
1141 virtual LIR_Op0* as_Op0() { return NULL; }
1142 virtual LIR_Op1* as_Op1() { return NULL; }
1143 virtual LIR_Op2* as_Op2() { return NULL; }
1144 virtual LIR_Op3* as_Op3() { return NULL; }
1145 virtual LIR_OpArrayCopy* as_OpArrayCopy() { return NULL; }
1146 virtual LIR_OpUpdateCRC32* as_OpUpdateCRC32() { return NULL; }
1147 virtual LIR_OpTypeCheck* as_OpTypeCheck() { return NULL; }
1148 virtual LIR_OpCompareAndSwap* as_OpCompareAndSwap() { return NULL; }
1149 virtual LIR_OpProfileCall* as_OpProfileCall() { return NULL; }
1150 virtual LIR_OpProfileType* as_OpProfileType() { return NULL; }
1151 #ifdef ASSERT
1152 virtual LIR_OpAssert* as_OpAssert() { return NULL; }
1153 #endif
1154
1155 virtual void verify() const {}
1156 };
1157
1158 // for calls
1159 class LIR_OpCall: public LIR_Op {
1160 friend class LIR_OpVisitState;
1161
1162 protected:
1163 address _addr;
1164 LIR_OprList* _arguments;
1165 protected:
1166 LIR_OpCall(LIR_Code code, address addr, LIR_Opr result,
1167 LIR_OprList* arguments, CodeEmitInfo* info = NULL)
1168 : LIR_Op(code, result, info)
1169 , _arguments(arguments)
1170 , _addr(addr) {}
1911 virtual void emit_code(LIR_Assembler* masm);
1912 virtual LIR_OpCompareAndSwap * as_OpCompareAndSwap () { return this; }
1913 virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1914 };
1915
1916 // LIR_OpProfileCall
1917 class LIR_OpProfileCall : public LIR_Op {
1918 friend class LIR_OpVisitState;
1919
1920 private:
1921 ciMethod* _profiled_method;
1922 int _profiled_bci;
1923 ciMethod* _profiled_callee;
1924 LIR_Opr _mdo;
1925 LIR_Opr _recv;
1926 LIR_Opr _tmp1;
1927 ciKlass* _known_holder;
1928
1929 public:
1930 // Destroys recv
1931 LIR_OpProfileCall(ciMethod* profiled_method, int profiled_bci, ciMethod* profiled_callee, LIR_Opr mdo, LIR_Opr recv, LIR_Opr t1, ciKlass* known_holder)
1932 : LIR_Op(lir_profile_call, LIR_OprFact::illegalOpr, NULL) // no result, no info
1933 , _profiled_method(profiled_method)
1934 , _profiled_bci(profiled_bci)
1935 , _profiled_callee(profiled_callee)
1936 , _mdo(mdo)
1937 , _recv(recv)
1938 , _tmp1(t1)
1939 , _known_holder(known_holder) { }
1940
1941 ciMethod* profiled_method() const { return _profiled_method; }
1942 int profiled_bci() const { return _profiled_bci; }
1943 ciMethod* profiled_callee() const { return _profiled_callee; }
1944 LIR_Opr mdo() const { return _mdo; }
1945 LIR_Opr recv() const { return _recv; }
1946 LIR_Opr tmp1() const { return _tmp1; }
1947 ciKlass* known_holder() const { return _known_holder; }
1948
1949 virtual void emit_code(LIR_Assembler* masm);
1950 virtual LIR_OpProfileCall* as_OpProfileCall() { return this; }
1951 virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1952 };
1953
1954 // LIR_OpProfileType
1955 class LIR_OpProfileType : public LIR_Op {
1956 friend class LIR_OpVisitState;
1957
1958 private:
1959 LIR_Opr _mdp;
1960 LIR_Opr _obj;
1961 LIR_Opr _tmp;
1962 ciKlass* _exact_klass; // non NULL if we know the klass statically (no need to load it from _obj)
1963 intptr_t _current_klass; // what the profiling currently reports
1964 bool _not_null; // true if we know statically that _obj cannot be null
1965 bool _no_conflict; // true if we're profling parameters, _exact_klass is not NULL and we know
1966 // _exact_klass it the only possible type for this parameter in any context.
1967
1968 public:
1969 // Destroys recv
1970 LIR_OpProfileType(LIR_Opr mdp, LIR_Opr obj, ciKlass* exact_klass, intptr_t current_klass, LIR_Opr tmp, bool not_null, bool no_conflict)
1971 : LIR_Op(lir_profile_type, LIR_OprFact::illegalOpr, NULL) // no result, no info
1972 , _mdp(mdp)
1973 , _obj(obj)
1974 , _exact_klass(exact_klass)
1975 , _current_klass(current_klass)
1976 , _tmp(tmp)
1977 , _not_null(not_null)
1978 , _no_conflict(no_conflict) { }
1979
1980 LIR_Opr mdp() const { return _mdp; }
1981 LIR_Opr obj() const { return _obj; }
1982 LIR_Opr tmp() const { return _tmp; }
1983 ciKlass* exact_klass() const { return _exact_klass; }
1984 intptr_t current_klass() const { return _current_klass; }
1985 bool not_null() const { return _not_null; }
1986 bool no_conflict() const { return _no_conflict; }
1987
1988 virtual void emit_code(LIR_Assembler* masm);
1989 virtual LIR_OpProfileType* as_OpProfileType() { return this; }
1990 virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1991 };
1992
1993 class LIR_InsertionBuffer;
1994
1995 //--------------------------------LIR_List---------------------------------------------------
1996 // Maintains a list of LIR instructions (one instance of LIR_List per basic block)
1997 // The LIR instructions are appended by the LIR_List class itself;
1998 //
1999 // Notes:
2000 // - all offsets are(should be) in bytes
2001 // - local positions are specified with an offset, with offset 0 being local 0
2002
2003 class LIR_List: public CompilationResourceObj {
2004 private:
2005 LIR_OpList _operations;
2006
2007 Compilation* _compilation;
2008 #ifndef PRODUCT
2009 BlockBegin* _block;
2010 #endif
2011 #ifdef ASSERT
2012 const char * _file;
2272
2273 void set_24bit_fpu() { append(new LIR_Op0(lir_24bit_FPU )); }
2274 void restore_fpu() { append(new LIR_Op0(lir_reset_FPU )); }
2275 void breakpoint() { append(new LIR_Op0(lir_breakpoint)); }
2276
2277 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)); }
2278
2279 void update_crc32(LIR_Opr crc, LIR_Opr val, LIR_Opr res) { append(new LIR_OpUpdateCRC32(crc, val, res)); }
2280
2281 void fpop_raw() { append(new LIR_Op0(lir_fpop_raw)); }
2282
2283 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);
2284 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);
2285
2286 void checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
2287 LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
2288 CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
2289 ciMethod* profiled_method, int profiled_bci);
2290 // MethodData* profiling
2291 void profile_call(ciMethod* method, int bci, ciMethod* callee, LIR_Opr mdo, LIR_Opr recv, LIR_Opr t1, ciKlass* cha_klass) {
2292 append(new LIR_OpProfileCall(method, bci, callee, mdo, recv, t1, cha_klass));
2293 }
2294 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) {
2295 append(new LIR_OpProfileType(LIR_OprFact::address(mdp), obj, exact_klass, current_klass, tmp, not_null, no_conflict));
2296 }
2297
2298 void xadd(LIR_Opr src, LIR_Opr add, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xadd, src, add, res, tmp)); }
2299 void xchg(LIR_Opr src, LIR_Opr set, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xchg, src, set, res, tmp)); }
2300 #ifdef ASSERT
2301 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)); }
2302 #endif
2303 };
2304
2305 void print_LIR(BlockList* blocks);
2306
2307 class LIR_InsertionBuffer : public CompilationResourceObj {
2308 private:
2309 LIR_List* _lir; // the lir list where ops of this buffer should be inserted later (NULL when uninitialized)
2310
2311 // list of insertion points. index and count are stored alternately:
2312 // _index_and_count[i * 2]: the index into lir list where "count" ops should be inserted
2313 // _index_and_count[i * 2 + 1]: the number of ops to be inserted at index
2314 intStack _index_and_count;
2315
|