1 /*
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
860 // - LIR_OpN, means an instruction that has N input operands
861 //
862 // class hierarchy:
863 //
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 #ifdef ASSERT
885 class LIR_OpAssert;
886 #endif
887
888 // LIR operation codes
889 enum LIR_Code {
890 lir_none
891 , begin_op0
892 , lir_word_align
893 , lir_label
894 , lir_nop
895 , lir_backwardbranch_target
896 , lir_std_entry
897 , lir_osr_entry
898 , lir_build_frame
899 , lir_fpop_raw
965 , lir_alloc_array
966 , lir_throw
967 , lir_compare_to
968 , lir_xadd
969 , lir_xchg
970 , end_op2
971 , begin_op3
972 , lir_idiv
973 , lir_irem
974 , end_op3
975 , begin_opJavaCall
976 , lir_static_call
977 , lir_optvirtual_call
978 , lir_icvirtual_call
979 , lir_virtual_call
980 , lir_dynamic_call
981 , end_opJavaCall
982 , begin_opArrayCopy
983 , lir_arraycopy
984 , end_opArrayCopy
985 , begin_opLock
986 , lir_lock
987 , lir_unlock
988 , end_opLock
989 , begin_delay_slot
990 , lir_delay_slot
991 , end_delay_slot
992 , begin_opTypeCheck
993 , lir_instanceof
994 , lir_checkcast
995 , lir_store_check
996 , end_opTypeCheck
997 , begin_opCompareAndSwap
998 , lir_cas_long
999 , lir_cas_obj
1000 , lir_cas_int
1001 , end_opCompareAndSwap
1002 , begin_opMDOProfile
1003 , lir_profile_call
1004 , end_opMDOProfile
1120 virtual void emit_code(LIR_Assembler* masm) = 0;
1121 virtual void print_instr(outputStream* out) const = 0;
1122 virtual void print_on(outputStream* st) const PRODUCT_RETURN;
1123
1124 virtual LIR_OpCall* as_OpCall() { return NULL; }
1125 virtual LIR_OpJavaCall* as_OpJavaCall() { return NULL; }
1126 virtual LIR_OpLabel* as_OpLabel() { return NULL; }
1127 virtual LIR_OpDelay* as_OpDelay() { return NULL; }
1128 virtual LIR_OpLock* as_OpLock() { return NULL; }
1129 virtual LIR_OpAllocArray* as_OpAllocArray() { return NULL; }
1130 virtual LIR_OpAllocObj* as_OpAllocObj() { return NULL; }
1131 virtual LIR_OpRoundFP* as_OpRoundFP() { return NULL; }
1132 virtual LIR_OpBranch* as_OpBranch() { return NULL; }
1133 virtual LIR_OpRTCall* as_OpRTCall() { return NULL; }
1134 virtual LIR_OpConvert* as_OpConvert() { return NULL; }
1135 virtual LIR_Op0* as_Op0() { return NULL; }
1136 virtual LIR_Op1* as_Op1() { return NULL; }
1137 virtual LIR_Op2* as_Op2() { return NULL; }
1138 virtual LIR_Op3* as_Op3() { return NULL; }
1139 virtual LIR_OpArrayCopy* as_OpArrayCopy() { return NULL; }
1140 virtual LIR_OpTypeCheck* as_OpTypeCheck() { return NULL; }
1141 virtual LIR_OpCompareAndSwap* as_OpCompareAndSwap() { return NULL; }
1142 virtual LIR_OpProfileCall* as_OpProfileCall() { return NULL; }
1143 #ifdef ASSERT
1144 virtual LIR_OpAssert* as_OpAssert() { return NULL; }
1145 #endif
1146
1147 virtual void verify() const {}
1148 };
1149
1150 // for calls
1151 class LIR_OpCall: public LIR_Op {
1152 friend class LIR_OpVisitState;
1153
1154 protected:
1155 address _addr;
1156 LIR_OprList* _arguments;
1157 protected:
1158 LIR_OpCall(LIR_Code code, address addr, LIR_Opr result,
1159 LIR_OprList* arguments, CodeEmitInfo* info = NULL)
1276 };
1277
1278 LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length, LIR_Opr tmp,
1279 ciArrayKlass* expected_type, int flags, CodeEmitInfo* info);
1280
1281 LIR_Opr src() const { return _src; }
1282 LIR_Opr src_pos() const { return _src_pos; }
1283 LIR_Opr dst() const { return _dst; }
1284 LIR_Opr dst_pos() const { return _dst_pos; }
1285 LIR_Opr length() const { return _length; }
1286 LIR_Opr tmp() const { return _tmp; }
1287 int flags() const { return _flags; }
1288 ciArrayKlass* expected_type() const { return _expected_type; }
1289 ArrayCopyStub* stub() const { return _stub; }
1290
1291 virtual void emit_code(LIR_Assembler* masm);
1292 virtual LIR_OpArrayCopy* as_OpArrayCopy() { return this; }
1293 void print_instr(outputStream* out) const PRODUCT_RETURN;
1294 };
1295
1296
1297 // --------------------------------------------------
1298 // LIR_Op0
1299 // --------------------------------------------------
1300 class LIR_Op0: public LIR_Op {
1301 friend class LIR_OpVisitState;
1302
1303 public:
1304 LIR_Op0(LIR_Code code)
1305 : LIR_Op(code, LIR_OprFact::illegalOpr, NULL) { assert(is_in_range(code, begin_op0, end_op0), "code check"); }
1306 LIR_Op0(LIR_Code code, LIR_Opr result, CodeEmitInfo* info = NULL)
1307 : LIR_Op(code, result, info) { assert(is_in_range(code, begin_op0, end_op0), "code check"); }
1308
1309 virtual void emit_code(LIR_Assembler* masm);
1310 virtual LIR_Op0* as_Op0() { return this; }
1311 virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1312 };
1313
1314
1315 // --------------------------------------------------
2195
2196 void call_runtime_leaf(address routine, LIR_Opr tmp, LIR_Opr result, LIR_OprList* arguments) {
2197 append(new LIR_OpRTCall(routine, tmp, result, arguments));
2198 }
2199
2200 void call_runtime(address routine, LIR_Opr tmp, LIR_Opr result,
2201 LIR_OprList* arguments, CodeEmitInfo* info) {
2202 append(new LIR_OpRTCall(routine, tmp, result, arguments, info));
2203 }
2204
2205 void load_stack_address_monitor(int monitor_ix, LIR_Opr dst) { append(new LIR_Op1(lir_monaddr, LIR_OprFact::intConst(monitor_ix), dst)); }
2206 void unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub);
2207 void lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info);
2208
2209 void set_24bit_fpu() { append(new LIR_Op0(lir_24bit_FPU )); }
2210 void restore_fpu() { append(new LIR_Op0(lir_reset_FPU )); }
2211 void breakpoint() { append(new LIR_Op0(lir_breakpoint)); }
2212
2213 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)); }
2214
2215 void fpop_raw() { append(new LIR_Op0(lir_fpop_raw)); }
2216
2217 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);
2218 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);
2219
2220 void checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
2221 LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
2222 CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
2223 ciMethod* profiled_method, int profiled_bci);
2224 // MethodData* profiling
2225 void profile_call(ciMethod* method, int bci, ciMethod* callee, LIR_Opr mdo, LIR_Opr recv, LIR_Opr t1, ciKlass* cha_klass) {
2226 append(new LIR_OpProfileCall(lir_profile_call, method, bci, callee, mdo, recv, t1, cha_klass));
2227 }
2228
2229 void xadd(LIR_Opr src, LIR_Opr add, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xadd, src, add, res, tmp)); }
2230 void xchg(LIR_Opr src, LIR_Opr set, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xchg, src, set, res, tmp)); }
2231 #ifdef ASSERT
2232 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)); }
2233 #endif
2234 };
|
1 /*
2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
860 // - LIR_OpN, means an instruction that has N input operands
861 //
862 // class hierarchy:
863 //
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_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
966 , lir_alloc_array
967 , lir_throw
968 , lir_compare_to
969 , lir_xadd
970 , lir_xchg
971 , end_op2
972 , begin_op3
973 , lir_idiv
974 , lir_irem
975 , end_op3
976 , begin_opJavaCall
977 , lir_static_call
978 , lir_optvirtual_call
979 , lir_icvirtual_call
980 , lir_virtual_call
981 , lir_dynamic_call
982 , end_opJavaCall
983 , begin_opArrayCopy
984 , lir_arraycopy
985 , end_opArrayCopy
986 , begin_opUpdateCRC32
987 , lir_updatecrc32
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
1124 virtual void emit_code(LIR_Assembler* masm) = 0;
1125 virtual void print_instr(outputStream* out) const = 0;
1126 virtual void print_on(outputStream* st) const PRODUCT_RETURN;
1127
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)
1281 };
1282
1283 LIR_OpArrayCopy(LIR_Opr src, LIR_Opr src_pos, LIR_Opr dst, LIR_Opr dst_pos, LIR_Opr length, LIR_Opr tmp,
1284 ciArrayKlass* expected_type, int flags, CodeEmitInfo* info);
1285
1286 LIR_Opr src() const { return _src; }
1287 LIR_Opr src_pos() const { return _src_pos; }
1288 LIR_Opr dst() const { return _dst; }
1289 LIR_Opr dst_pos() const { return _dst_pos; }
1290 LIR_Opr length() const { return _length; }
1291 LIR_Opr tmp() const { return _tmp; }
1292 int flags() const { return _flags; }
1293 ciArrayKlass* expected_type() const { return _expected_type; }
1294 ArrayCopyStub* stub() const { return _stub; }
1295
1296 virtual void emit_code(LIR_Assembler* masm);
1297 virtual LIR_OpArrayCopy* as_OpArrayCopy() { return this; }
1298 void print_instr(outputStream* out) const PRODUCT_RETURN;
1299 };
1300
1301 // LIR_OpUpdateCRC32
1302 class LIR_OpUpdateCRC32: public LIR_Op {
1303 friend class LIR_OpVisitState;
1304
1305 private:
1306 LIR_Opr _crc;
1307 LIR_Opr _val;
1308
1309 public:
1310
1311 LIR_OpUpdateCRC32(LIR_Opr crc, LIR_Opr val, LIR_Opr res);
1312
1313 LIR_Opr crc() const { return _crc; }
1314 LIR_Opr val() const { return _val; }
1315
1316 virtual void emit_code(LIR_Assembler* masm);
1317 virtual LIR_OpUpdateCRC32* as_OpUpdateCRC32() { return this; }
1318 void print_instr(outputStream* out) const PRODUCT_RETURN;
1319 };
1320
1321 // --------------------------------------------------
1322 // LIR_Op0
1323 // --------------------------------------------------
1324 class LIR_Op0: public LIR_Op {
1325 friend class LIR_OpVisitState;
1326
1327 public:
1328 LIR_Op0(LIR_Code code)
1329 : LIR_Op(code, LIR_OprFact::illegalOpr, NULL) { assert(is_in_range(code, begin_op0, end_op0), "code check"); }
1330 LIR_Op0(LIR_Code code, LIR_Opr result, CodeEmitInfo* info = NULL)
1331 : LIR_Op(code, result, info) { assert(is_in_range(code, begin_op0, end_op0), "code check"); }
1332
1333 virtual void emit_code(LIR_Assembler* masm);
1334 virtual LIR_Op0* as_Op0() { return this; }
1335 virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
1336 };
1337
1338
1339 // --------------------------------------------------
2219
2220 void call_runtime_leaf(address routine, LIR_Opr tmp, LIR_Opr result, LIR_OprList* arguments) {
2221 append(new LIR_OpRTCall(routine, tmp, result, arguments));
2222 }
2223
2224 void call_runtime(address routine, LIR_Opr tmp, LIR_Opr result,
2225 LIR_OprList* arguments, CodeEmitInfo* info) {
2226 append(new LIR_OpRTCall(routine, tmp, result, arguments, info));
2227 }
2228
2229 void load_stack_address_monitor(int monitor_ix, LIR_Opr dst) { append(new LIR_Op1(lir_monaddr, LIR_OprFact::intConst(monitor_ix), dst)); }
2230 void unlock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub);
2231 void lock_object(LIR_Opr hdr, LIR_Opr obj, LIR_Opr lock, LIR_Opr scratch, CodeStub* stub, CodeEmitInfo* info);
2232
2233 void set_24bit_fpu() { append(new LIR_Op0(lir_24bit_FPU )); }
2234 void restore_fpu() { append(new LIR_Op0(lir_reset_FPU )); }
2235 void breakpoint() { append(new LIR_Op0(lir_breakpoint)); }
2236
2237 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)); }
2238
2239 void update_crc32(LIR_Opr crc, LIR_Opr val, LIR_Opr res) { append(new LIR_OpUpdateCRC32(crc, val, res)); }
2240
2241 void fpop_raw() { append(new LIR_Op0(lir_fpop_raw)); }
2242
2243 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);
2244 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);
2245
2246 void checkcast (LIR_Opr result, LIR_Opr object, ciKlass* klass,
2247 LIR_Opr tmp1, LIR_Opr tmp2, LIR_Opr tmp3, bool fast_check,
2248 CodeEmitInfo* info_for_exception, CodeEmitInfo* info_for_patch, CodeStub* stub,
2249 ciMethod* profiled_method, int profiled_bci);
2250 // MethodData* profiling
2251 void profile_call(ciMethod* method, int bci, ciMethod* callee, LIR_Opr mdo, LIR_Opr recv, LIR_Opr t1, ciKlass* cha_klass) {
2252 append(new LIR_OpProfileCall(lir_profile_call, method, bci, callee, mdo, recv, t1, cha_klass));
2253 }
2254
2255 void xadd(LIR_Opr src, LIR_Opr add, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xadd, src, add, res, tmp)); }
2256 void xchg(LIR_Opr src, LIR_Opr set, LIR_Opr res, LIR_Opr tmp) { append(new LIR_Op2(lir_xchg, src, set, res, tmp)); }
2257 #ifdef ASSERT
2258 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)); }
2259 #endif
2260 };
|