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 *
23 */
24
25 #include "c1/c1_Compilation.hpp"
26 #include "c1/c1_FrameMap.hpp"
27 #include "c1/c1_Instruction.hpp"
28 #include "c1/c1_LIRAssembler.hpp"
29 #include "c1/c1_LIRGenerator.hpp"
30 #include "c1/c1_Runtime1.hpp"
31 #include "c1/c1_ValueStack.hpp"
32 #include "ci/ciArray.hpp"
33 #include "ci/ciObjArrayKlass.hpp"
34 #include "ci/ciTypeArrayKlass.hpp"
35 #include "gc/shared/c1/barrierSetC1.hpp"
36 #include "runtime/sharedRuntime.hpp"
37 #include "runtime/stubRoutines.hpp"
38 #include "utilities/powerOfTwo.hpp"
39 #include "vmreg_x86.inline.hpp"
40
41 #ifdef ASSERT
42 #define __ gen()->lir(__FILE__, __LINE__)->
43 #else
44 #define __ gen()->lir()->
45 #endif
46
47 // Item will be loaded into a byte register; Intel only
48 void LIRItem::load_byte_item() {
49 load_item();
50 LIR_Opr res = result();
51
52 if (!res->is_virtual() || !_gen->is_vreg_flag_set(res, LIRGenerator::byte_reg)) {
264 void LIRGenerator::array_store_check(LIR_Opr value, LIR_Opr array, CodeEmitInfo* store_check_info, ciMethod* profiled_method, int profiled_bci) {
265 LIR_Opr tmp1 = new_register(objectType);
266 LIR_Opr tmp2 = new_register(objectType);
267 LIR_Opr tmp3 = new_register(objectType);
268 __ store_check(value, array, tmp1, tmp2, tmp3, store_check_info, profiled_method, profiled_bci);
269 }
270
271 //----------------------------------------------------------------------
272 // visitor functions
273 //----------------------------------------------------------------------
274
275 void LIRGenerator::do_MonitorEnter(MonitorEnter* x) {
276 assert(x->is_pinned(),"");
277 LIRItem obj(x->obj(), this);
278 obj.load_item();
279
280 set_no_result(x);
281
282 // "lock" stores the address of the monitor stack slot, so this is not an oop
283 LIR_Opr lock = new_register(T_INT);
284
285 CodeEmitInfo* info_for_exception = nullptr;
286 if (x->needs_null_check()) {
287 info_for_exception = state_for(x);
288 }
289 // this CodeEmitInfo must not have the xhandlers because here the
290 // object is already locked (xhandlers expect object to be unlocked)
291 CodeEmitInfo* info = state_for(x, x->state(), true);
292 LIR_Opr tmp = new_register(T_ADDRESS);
293 monitor_enter(obj.result(), lock, syncTempOpr(), tmp,
294 x->monitor_no(), info_for_exception, info);
295 }
296
297
298 void LIRGenerator::do_MonitorExit(MonitorExit* x) {
299 assert(x->is_pinned(),"");
300
301 LIRItem obj(x->obj(), this);
302 obj.dont_load_item();
303
304 LIR_Opr lock = new_register(T_INT);
305 LIR_Opr obj_temp = new_register(T_INT);
306 set_no_result(x);
307 monitor_exit(obj_temp, lock, syncTempOpr(), LIR_OprFact::illegalOpr, x->monitor_no());
308 }
309
310 // _ineg, _lneg, _fneg, _dneg
311 void LIRGenerator::do_NegateOp(NegateOp* x) {
312 LIRItem value(x->x(), this);
313 value.set_destroys_register();
314 value.load_item();
1112 log2ArrayIndexScale.load_item_force(cc->at(3));
1113
1114 __ call_runtime_leaf(StubRoutines::vectorizedMismatch(), getThreadTemp(), result_reg, cc->args());
1115 __ move(result_reg, result);
1116 }
1117
1118 void LIRGenerator::do_Convert(Convert* x) {
1119 LIRItem value(x->value(), this);
1120 value.load_item();
1121 LIR_Opr input = value.result();
1122 LIR_Opr result = rlock(x);
1123 __ convert(x->op(), input, result);
1124 assert(result->is_virtual(), "result must be virtual register");
1125 set_result(x, result);
1126 }
1127
1128
1129 void LIRGenerator::do_NewInstance(NewInstance* x) {
1130 print_if_not_loaded(x);
1131
1132 CodeEmitInfo* info = state_for(x, x->state());
1133 LIR_Opr reg = result_register_for(x->type());
1134 new_instance(reg, x->klass(), x->is_unresolved(),
1135 FrameMap::rcx_oop_opr,
1136 FrameMap::rdi_oop_opr,
1137 FrameMap::rsi_oop_opr,
1138 LIR_OprFact::illegalOpr,
1139 FrameMap::rdx_metadata_opr, info);
1140 LIR_Opr result = rlock_result(x);
1141 __ move(reg, result);
1142 }
1143
1144
1145 void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
1146 CodeEmitInfo* info = nullptr;
1147 if (x->state_before() != nullptr && x->state_before()->force_reexecute()) {
1148 info = state_for(x, x->state_before());
1149 info->set_force_reexecute();
1150 } else {
1151 info = state_for(x, x->state());
1152 }
1153
1154 LIRItem length(x->length(), this);
1155 length.load_item_force(FrameMap::rbx_opr);
1156
1157 LIR_Opr reg = result_register_for(x->type());
1158 LIR_Opr tmp1 = FrameMap::rcx_oop_opr;
1159 LIR_Opr tmp2 = FrameMap::rsi_oop_opr;
1160 LIR_Opr tmp3 = FrameMap::rdi_oop_opr;
1161 LIR_Opr tmp4 = reg;
1162 LIR_Opr klass_reg = FrameMap::rdx_metadata_opr;
1163 LIR_Opr len = length.result();
1164 BasicType elem_type = x->elt_type();
1177 LIRItem length(x->length(), this);
1178 // in case of patching (i.e., object class is not yet loaded), we need to reexecute the instruction
1179 // and therefore provide the state before the parameters have been consumed
1180 CodeEmitInfo* patching_info = nullptr;
1181 if (!x->klass()->is_loaded() || PatchALot) {
1182 patching_info = state_for(x, x->state_before());
1183 }
1184
1185 CodeEmitInfo* info = state_for(x, x->state());
1186
1187 const LIR_Opr reg = result_register_for(x->type());
1188 LIR_Opr tmp1 = FrameMap::rcx_oop_opr;
1189 LIR_Opr tmp2 = FrameMap::rsi_oop_opr;
1190 LIR_Opr tmp3 = FrameMap::rdi_oop_opr;
1191 LIR_Opr tmp4 = reg;
1192 LIR_Opr klass_reg = FrameMap::rdx_metadata_opr;
1193
1194 length.load_item_force(FrameMap::rbx_opr);
1195 LIR_Opr len = length.result();
1196
1197 CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info);
1198 ciKlass* obj = (ciKlass*) ciObjArrayKlass::make(x->klass());
1199 if (obj == ciEnv::unloaded_ciobjarrayklass()) {
1200 BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error");
1201 }
1202 klass2reg_with_patching(klass_reg, obj, patching_info);
1203 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path);
1204
1205 LIR_Opr result = rlock_result(x);
1206 __ move(reg, result);
1207 }
1208
1209
1210 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
1211 Values* dims = x->dims();
1212 int i = dims->length();
1213 LIRItemList* items = new LIRItemList(i, i, nullptr);
1214 while (i-- > 0) {
1215 LIRItem* size = new LIRItem(dims->at(i), this);
1216 items->at_put(i, size);
1217 }
1218
1219 // Evaluate state_for early since it may emit code.
1220 CodeEmitInfo* patching_info = nullptr;
1221 if (!x->klass()->is_loaded() || PatchALot) {
1222 patching_info = state_for(x, x->state_before());
1223
1278 CodeEmitInfo* info_for_exception =
1279 (x->needs_exception_state() ? state_for(x) :
1280 state_for(x, x->state_before(), true /*ignore_xhandler*/));
1281
1282 CodeStub* stub;
1283 if (x->is_incompatible_class_change_check()) {
1284 assert(patching_info == nullptr, "can't patch this");
1285 stub = new SimpleExceptionStub(StubId::c1_throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception);
1286 } else if (x->is_invokespecial_receiver_check()) {
1287 assert(patching_info == nullptr, "can't patch this");
1288 stub = new DeoptimizeStub(info_for_exception, Deoptimization::Reason_class_check, Deoptimization::Action_none);
1289 } else {
1290 stub = new SimpleExceptionStub(StubId::c1_throw_class_cast_exception_id, obj.result(), info_for_exception);
1291 }
1292 LIR_Opr reg = rlock_result(x);
1293 LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1294 tmp3 = new_register(objectType);
1295 __ checkcast(reg, obj.result(), x->klass(),
1296 new_register(objectType), new_register(objectType), tmp3,
1297 x->direct_compare(), info_for_exception, patching_info, stub,
1298 x->profiled_method(), x->profiled_bci());
1299 }
1300
1301
1302 void LIRGenerator::do_InstanceOf(InstanceOf* x) {
1303 LIRItem obj(x->obj(), this);
1304
1305 // result and test object may not be in same register
1306 LIR_Opr reg = rlock_result(x);
1307 CodeEmitInfo* patching_info = nullptr;
1308 if ((!x->klass()->is_loaded() || PatchALot)) {
1309 // must do this before locking the destination register as an oop register
1310 patching_info = state_for(x, x->state_before());
1311 }
1312 obj.load_item();
1313 LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1314 tmp3 = new_register(objectType);
1315 __ instanceof(reg, obj.result(), x->klass(),
1316 new_register(objectType), new_register(objectType), tmp3,
1317 x->direct_compare(), patching_info, x->profiled_method(), x->profiled_bci());
1318 }
1332
1333 LIRItem xitem(x->x(), this);
1334 LIRItem yitem(x->y(), this);
1335 LIRItem* xin = &xitem;
1336 LIRItem* yin = &yitem;
1337
1338 if (tag == longTag) {
1339 // for longs, only conditions "eql", "neq", "lss", "geq" are valid;
1340 // mirror for other conditions
1341 if (cond == If::gtr || cond == If::leq) {
1342 cond = Instruction::mirror(cond);
1343 xin = &yitem;
1344 yin = &xitem;
1345 }
1346 xin->set_destroys_register();
1347 }
1348 xin->load_item();
1349 if (tag == longTag && yin->is_constant() && yin->get_jlong_constant() == 0 && (cond == If::eql || cond == If::neq)) {
1350 // inline long zero
1351 yin->dont_load_item();
1352 } else if (tag == longTag || tag == floatTag || tag == doubleTag) {
1353 // longs cannot handle constants at right side
1354 yin->load_item();
1355 } else {
1356 yin->dont_load_item();
1357 }
1358
1359 LIR_Opr left = xin->result();
1360 LIR_Opr right = yin->result();
1361
1362 set_no_result(x);
1363
1364 // add safepoint before generating condition code so it can be recomputed
1365 if (x->is_safepoint()) {
1366 // increment backedge counter if needed
1367 increment_backedge_counter_conditionally(lir_cond(cond), left, right, state_for(x, x->state_before()),
1368 x->tsux()->bci(), x->fsux()->bci(), x->profiled_bci());
1369 __ safepoint(safepoint_poll_register(), state_for(x, x->state_before()));
1370 }
1371
1372 __ cmp(lir_cond(cond), left, right);
1373 // Generate branch profiling. Profiling code doesn't kill flags.
1374 profile_branch(x, cond);
1375 move_to_phi(x->state());
1376 if (x->x()->type()->is_float_kind()) {
1377 __ branch(lir_cond(cond), x->tsux(), x->usux());
1378 } else {
1379 __ branch(lir_cond(cond), x->tsux());
1380 }
1381 assert(x->default_sux() == x->fsux(), "wrong destination above");
1382 __ jump(x->default_sux());
1383 }
1384
1385
1386 LIR_Opr LIRGenerator::getThreadPointer() {
1387 return FrameMap::as_pointer_opr(r15_thread);
1388 }
1389
1390 void LIRGenerator::trace_block_entry(BlockBegin* block) {
1391 store_stack_parameter(LIR_OprFact::intConst(block->block_id()), in_ByteSize(0));
1392 LIR_OprList* args = new LIR_OprList();
|
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 *
23 */
24
25 #include "c1/c1_Compilation.hpp"
26 #include "c1/c1_FrameMap.hpp"
27 #include "c1/c1_Instruction.hpp"
28 #include "c1/c1_LIRAssembler.hpp"
29 #include "c1/c1_LIRGenerator.hpp"
30 #include "c1/c1_Runtime1.hpp"
31 #include "c1/c1_ValueStack.hpp"
32 #include "ci/ciArray.hpp"
33 #include "ci/ciInlineKlass.hpp"
34 #include "ci/ciObjArrayKlass.hpp"
35 #include "ci/ciTypeArrayKlass.hpp"
36 #include "gc/shared/c1/barrierSetC1.hpp"
37 #include "runtime/sharedRuntime.hpp"
38 #include "runtime/stubRoutines.hpp"
39 #include "utilities/powerOfTwo.hpp"
40 #include "vmreg_x86.inline.hpp"
41
42 #ifdef ASSERT
43 #define __ gen()->lir(__FILE__, __LINE__)->
44 #else
45 #define __ gen()->lir()->
46 #endif
47
48 // Item will be loaded into a byte register; Intel only
49 void LIRItem::load_byte_item() {
50 load_item();
51 LIR_Opr res = result();
52
53 if (!res->is_virtual() || !_gen->is_vreg_flag_set(res, LIRGenerator::byte_reg)) {
265 void LIRGenerator::array_store_check(LIR_Opr value, LIR_Opr array, CodeEmitInfo* store_check_info, ciMethod* profiled_method, int profiled_bci) {
266 LIR_Opr tmp1 = new_register(objectType);
267 LIR_Opr tmp2 = new_register(objectType);
268 LIR_Opr tmp3 = new_register(objectType);
269 __ store_check(value, array, tmp1, tmp2, tmp3, store_check_info, profiled_method, profiled_bci);
270 }
271
272 //----------------------------------------------------------------------
273 // visitor functions
274 //----------------------------------------------------------------------
275
276 void LIRGenerator::do_MonitorEnter(MonitorEnter* x) {
277 assert(x->is_pinned(),"");
278 LIRItem obj(x->obj(), this);
279 obj.load_item();
280
281 set_no_result(x);
282
283 // "lock" stores the address of the monitor stack slot, so this is not an oop
284 LIR_Opr lock = new_register(T_INT);
285 // Need a scratch register for inline types on x86
286 LIR_Opr scratch = new_register(T_ADDRESS);
287
288 CodeEmitInfo* info_for_exception = nullptr;
289 if (x->needs_null_check()) {
290 info_for_exception = state_for(x);
291 }
292
293 CodeStub* throw_ie_stub = x->maybe_inlinetype() ?
294 new SimpleExceptionStub(StubId::c1_throw_identity_exception_id,
295 obj.result(), state_for(x))
296 : nullptr;
297
298 // this CodeEmitInfo must not have the xhandlers because here the
299 // object is already locked (xhandlers expect object to be unlocked)
300 CodeEmitInfo* info = state_for(x, x->state(), true);
301 monitor_enter(obj.result(), lock, syncTempOpr(), scratch,
302 x->monitor_no(), info_for_exception, info, throw_ie_stub);
303 }
304
305
306 void LIRGenerator::do_MonitorExit(MonitorExit* x) {
307 assert(x->is_pinned(),"");
308
309 LIRItem obj(x->obj(), this);
310 obj.dont_load_item();
311
312 LIR_Opr lock = new_register(T_INT);
313 LIR_Opr obj_temp = new_register(T_INT);
314 set_no_result(x);
315 monitor_exit(obj_temp, lock, syncTempOpr(), LIR_OprFact::illegalOpr, x->monitor_no());
316 }
317
318 // _ineg, _lneg, _fneg, _dneg
319 void LIRGenerator::do_NegateOp(NegateOp* x) {
320 LIRItem value(x->x(), this);
321 value.set_destroys_register();
322 value.load_item();
1120 log2ArrayIndexScale.load_item_force(cc->at(3));
1121
1122 __ call_runtime_leaf(StubRoutines::vectorizedMismatch(), getThreadTemp(), result_reg, cc->args());
1123 __ move(result_reg, result);
1124 }
1125
1126 void LIRGenerator::do_Convert(Convert* x) {
1127 LIRItem value(x->value(), this);
1128 value.load_item();
1129 LIR_Opr input = value.result();
1130 LIR_Opr result = rlock(x);
1131 __ convert(x->op(), input, result);
1132 assert(result->is_virtual(), "result must be virtual register");
1133 set_result(x, result);
1134 }
1135
1136
1137 void LIRGenerator::do_NewInstance(NewInstance* x) {
1138 print_if_not_loaded(x);
1139
1140 CodeEmitInfo* info = state_for(x, x->needs_state_before() ? x->state_before() : x->state());
1141 LIR_Opr reg = result_register_for(x->type());
1142 new_instance(reg, x->klass(), x->is_unresolved(),
1143 !x->is_unresolved() && x->klass()->is_inlinetype(),
1144 FrameMap::rcx_oop_opr,
1145 FrameMap::rdi_oop_opr,
1146 FrameMap::rsi_oop_opr,
1147 LIR_OprFact::illegalOpr,
1148 FrameMap::rdx_metadata_opr, info);
1149 LIR_Opr result = rlock_result(x);
1150 __ move(reg, result);
1151 }
1152
1153 void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
1154 CodeEmitInfo* info = nullptr;
1155 if (x->state_before() != nullptr && x->state_before()->force_reexecute()) {
1156 info = state_for(x, x->state_before());
1157 info->set_force_reexecute();
1158 } else {
1159 info = state_for(x, x->state());
1160 }
1161
1162 LIRItem length(x->length(), this);
1163 length.load_item_force(FrameMap::rbx_opr);
1164
1165 LIR_Opr reg = result_register_for(x->type());
1166 LIR_Opr tmp1 = FrameMap::rcx_oop_opr;
1167 LIR_Opr tmp2 = FrameMap::rsi_oop_opr;
1168 LIR_Opr tmp3 = FrameMap::rdi_oop_opr;
1169 LIR_Opr tmp4 = reg;
1170 LIR_Opr klass_reg = FrameMap::rdx_metadata_opr;
1171 LIR_Opr len = length.result();
1172 BasicType elem_type = x->elt_type();
1185 LIRItem length(x->length(), this);
1186 // in case of patching (i.e., object class is not yet loaded), we need to reexecute the instruction
1187 // and therefore provide the state before the parameters have been consumed
1188 CodeEmitInfo* patching_info = nullptr;
1189 if (!x->klass()->is_loaded() || PatchALot) {
1190 patching_info = state_for(x, x->state_before());
1191 }
1192
1193 CodeEmitInfo* info = state_for(x, x->state());
1194
1195 const LIR_Opr reg = result_register_for(x->type());
1196 LIR_Opr tmp1 = FrameMap::rcx_oop_opr;
1197 LIR_Opr tmp2 = FrameMap::rsi_oop_opr;
1198 LIR_Opr tmp3 = FrameMap::rdi_oop_opr;
1199 LIR_Opr tmp4 = reg;
1200 LIR_Opr klass_reg = FrameMap::rdx_metadata_opr;
1201
1202 length.load_item_force(FrameMap::rbx_opr);
1203 LIR_Opr len = length.result();
1204
1205 ciKlass* obj = ciObjArrayKlass::make(x->klass());
1206
1207 // TODO 8265122 Implement a fast path for this
1208 bool is_flat = obj->is_loaded() && obj->is_flat_array_klass();
1209 bool is_null_free = obj->is_loaded() && obj->as_array_klass()->is_elem_null_free();
1210
1211 CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info, is_null_free);
1212 if (obj == ciEnv::unloaded_ciobjarrayklass()) {
1213 BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error");
1214 }
1215 klass2reg_with_patching(klass_reg, obj, patching_info);
1216 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path, true, is_null_free || is_flat);
1217
1218 LIR_Opr result = rlock_result(x);
1219 __ move(reg, result);
1220 }
1221
1222
1223 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
1224 Values* dims = x->dims();
1225 int i = dims->length();
1226 LIRItemList* items = new LIRItemList(i, i, nullptr);
1227 while (i-- > 0) {
1228 LIRItem* size = new LIRItem(dims->at(i), this);
1229 items->at_put(i, size);
1230 }
1231
1232 // Evaluate state_for early since it may emit code.
1233 CodeEmitInfo* patching_info = nullptr;
1234 if (!x->klass()->is_loaded() || PatchALot) {
1235 patching_info = state_for(x, x->state_before());
1236
1291 CodeEmitInfo* info_for_exception =
1292 (x->needs_exception_state() ? state_for(x) :
1293 state_for(x, x->state_before(), true /*ignore_xhandler*/));
1294
1295 CodeStub* stub;
1296 if (x->is_incompatible_class_change_check()) {
1297 assert(patching_info == nullptr, "can't patch this");
1298 stub = new SimpleExceptionStub(StubId::c1_throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception);
1299 } else if (x->is_invokespecial_receiver_check()) {
1300 assert(patching_info == nullptr, "can't patch this");
1301 stub = new DeoptimizeStub(info_for_exception, Deoptimization::Reason_class_check, Deoptimization::Action_none);
1302 } else {
1303 stub = new SimpleExceptionStub(StubId::c1_throw_class_cast_exception_id, obj.result(), info_for_exception);
1304 }
1305 LIR_Opr reg = rlock_result(x);
1306 LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1307 tmp3 = new_register(objectType);
1308 __ checkcast(reg, obj.result(), x->klass(),
1309 new_register(objectType), new_register(objectType), tmp3,
1310 x->direct_compare(), info_for_exception, patching_info, stub,
1311 x->profiled_method(), x->profiled_bci(), x->is_null_free());
1312 }
1313
1314
1315 void LIRGenerator::do_InstanceOf(InstanceOf* x) {
1316 LIRItem obj(x->obj(), this);
1317
1318 // result and test object may not be in same register
1319 LIR_Opr reg = rlock_result(x);
1320 CodeEmitInfo* patching_info = nullptr;
1321 if ((!x->klass()->is_loaded() || PatchALot)) {
1322 // must do this before locking the destination register as an oop register
1323 patching_info = state_for(x, x->state_before());
1324 }
1325 obj.load_item();
1326 LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1327 tmp3 = new_register(objectType);
1328 __ instanceof(reg, obj.result(), x->klass(),
1329 new_register(objectType), new_register(objectType), tmp3,
1330 x->direct_compare(), patching_info, x->profiled_method(), x->profiled_bci());
1331 }
1345
1346 LIRItem xitem(x->x(), this);
1347 LIRItem yitem(x->y(), this);
1348 LIRItem* xin = &xitem;
1349 LIRItem* yin = &yitem;
1350
1351 if (tag == longTag) {
1352 // for longs, only conditions "eql", "neq", "lss", "geq" are valid;
1353 // mirror for other conditions
1354 if (cond == If::gtr || cond == If::leq) {
1355 cond = Instruction::mirror(cond);
1356 xin = &yitem;
1357 yin = &xitem;
1358 }
1359 xin->set_destroys_register();
1360 }
1361 xin->load_item();
1362 if (tag == longTag && yin->is_constant() && yin->get_jlong_constant() == 0 && (cond == If::eql || cond == If::neq)) {
1363 // inline long zero
1364 yin->dont_load_item();
1365 } else if (tag == longTag || tag == floatTag || tag == doubleTag || x->substitutability_check()) {
1366 // longs cannot handle constants at right side
1367 yin->load_item();
1368 } else {
1369 yin->dont_load_item();
1370 }
1371
1372 LIR_Opr left = xin->result();
1373 LIR_Opr right = yin->result();
1374
1375 set_no_result(x);
1376
1377 // add safepoint before generating condition code so it can be recomputed
1378 if (x->is_safepoint()) {
1379 // increment backedge counter if needed
1380 increment_backedge_counter_conditionally(lir_cond(cond), left, right, state_for(x, x->state_before()),
1381 x->tsux()->bci(), x->fsux()->bci(), x->profiled_bci());
1382 __ safepoint(safepoint_poll_register(), state_for(x, x->state_before()));
1383 }
1384
1385 if (x->substitutability_check()) {
1386 substitutability_check(x, *xin, *yin);
1387 } else {
1388 __ cmp(lir_cond(cond), left, right);
1389 }
1390 // Generate branch profiling. Profiling code doesn't kill flags.
1391 profile_branch(x, cond);
1392 move_to_phi(x->state());
1393 if (x->x()->type()->is_float_kind()) {
1394 __ branch(lir_cond(cond), x->tsux(), x->usux());
1395 } else {
1396 __ branch(lir_cond(cond), x->tsux());
1397 }
1398 assert(x->default_sux() == x->fsux(), "wrong destination above");
1399 __ jump(x->default_sux());
1400 }
1401
1402
1403 LIR_Opr LIRGenerator::getThreadPointer() {
1404 return FrameMap::as_pointer_opr(r15_thread);
1405 }
1406
1407 void LIRGenerator::trace_block_entry(BlockBegin* block) {
1408 store_stack_parameter(LIR_OprFact::intConst(block->block_id()), in_ByteSize(0));
1409 LIR_OprList* args = new LIR_OprList();
|