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)) {
93 case objectTag: opr = FrameMap::rax_oop_opr; break;
94 case longTag: opr = FrameMap::long0_opr; break;
95 case floatTag: opr = FrameMap::xmm0_float_opr; break;
96 case doubleTag: opr = FrameMap::xmm0_double_opr; break;
97 case addressTag:
98 default: ShouldNotReachHere(); return LIR_OprFact::illegalOpr;
99 }
100
101 assert(opr->type_field() == as_OprType(as_BasicType(type)), "type mismatch");
102 return opr;
103 }
104
105
106 LIR_Opr LIRGenerator::rlock_byte(BasicType type) {
107 LIR_Opr reg = new_register(T_INT);
108 set_vreg_flag(reg, LIRGenerator::byte_reg);
109 return reg;
110 }
111
112
113 //--------- loading items into registers --------------------------------
114
115
116 // i486 instructions can inline constants
117 bool LIRGenerator::can_store_as_constant(Value v, BasicType type) const {
118 if (type == T_SHORT || type == T_CHAR) {
119 return false;
120 }
121 Constant* c = v->as_Constant();
122 if (c && c->state_before() == nullptr) {
123 // constants of any type can be stored directly, except for
124 // unloaded object constants.
125 return true;
126 }
127 return false;
128 }
129
130
131 bool LIRGenerator::can_inline_as_constant(Value v) const {
132 if (v->type()->tag() == longTag) return false;
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 = LockingMode == LM_LIGHTWEIGHT ? new_register(T_ADDRESS) : LIR_OprFact::illegalOpr;
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();
1106 log2ArrayIndexScale.load_item_force(cc->at(3));
1107
1108 __ call_runtime_leaf(StubRoutines::vectorizedMismatch(), getThreadTemp(), result_reg, cc->args());
1109 __ move(result_reg, result);
1110 }
1111
1112 void LIRGenerator::do_Convert(Convert* x) {
1113 LIRItem value(x->value(), this);
1114 value.load_item();
1115 LIR_Opr input = value.result();
1116 LIR_Opr result = rlock(x);
1117 __ convert(x->op(), input, result);
1118 assert(result->is_virtual(), "result must be virtual register");
1119 set_result(x, result);
1120 }
1121
1122
1123 void LIRGenerator::do_NewInstance(NewInstance* x) {
1124 print_if_not_loaded(x);
1125
1126 CodeEmitInfo* info = state_for(x, x->state());
1127 LIR_Opr reg = result_register_for(x->type());
1128 new_instance(reg, x->klass(), x->is_unresolved(),
1129 FrameMap::rcx_oop_opr,
1130 FrameMap::rdi_oop_opr,
1131 FrameMap::rsi_oop_opr,
1132 LIR_OprFact::illegalOpr,
1133 FrameMap::rdx_metadata_opr, info);
1134 LIR_Opr result = rlock_result(x);
1135 __ move(reg, result);
1136 }
1137
1138
1139 void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
1140 CodeEmitInfo* info = nullptr;
1141 if (x->state_before() != nullptr && x->state_before()->force_reexecute()) {
1142 info = state_for(x, x->state_before());
1143 info->set_force_reexecute();
1144 } else {
1145 info = state_for(x, x->state());
1146 }
1147
1148 LIRItem length(x->length(), this);
1149 length.load_item_force(FrameMap::rbx_opr);
1150
1151 LIR_Opr reg = result_register_for(x->type());
1152 LIR_Opr tmp1 = FrameMap::rcx_oop_opr;
1153 LIR_Opr tmp2 = FrameMap::rsi_oop_opr;
1154 LIR_Opr tmp3 = FrameMap::rdi_oop_opr;
1155 LIR_Opr tmp4 = reg;
1156 LIR_Opr klass_reg = FrameMap::rdx_metadata_opr;
1157 LIR_Opr len = length.result();
1158 BasicType elem_type = x->elt_type();
1171 LIRItem length(x->length(), this);
1172 // in case of patching (i.e., object class is not yet loaded), we need to reexecute the instruction
1173 // and therefore provide the state before the parameters have been consumed
1174 CodeEmitInfo* patching_info = nullptr;
1175 if (!x->klass()->is_loaded() || PatchALot) {
1176 patching_info = state_for(x, x->state_before());
1177 }
1178
1179 CodeEmitInfo* info = state_for(x, x->state());
1180
1181 const LIR_Opr reg = result_register_for(x->type());
1182 LIR_Opr tmp1 = FrameMap::rcx_oop_opr;
1183 LIR_Opr tmp2 = FrameMap::rsi_oop_opr;
1184 LIR_Opr tmp3 = FrameMap::rdi_oop_opr;
1185 LIR_Opr tmp4 = reg;
1186 LIR_Opr klass_reg = FrameMap::rdx_metadata_opr;
1187
1188 length.load_item_force(FrameMap::rbx_opr);
1189 LIR_Opr len = length.result();
1190
1191 CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info);
1192 ciKlass* obj = (ciKlass*) ciObjArrayKlass::make(x->klass());
1193 if (obj == ciEnv::unloaded_ciobjarrayklass()) {
1194 BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error");
1195 }
1196 klass2reg_with_patching(klass_reg, obj, patching_info);
1197 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path);
1198
1199 LIR_Opr result = rlock_result(x);
1200 __ move(reg, result);
1201 }
1202
1203
1204 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
1205 Values* dims = x->dims();
1206 int i = dims->length();
1207 LIRItemList* items = new LIRItemList(i, i, nullptr);
1208 while (i-- > 0) {
1209 LIRItem* size = new LIRItem(dims->at(i), this);
1210 items->at_put(i, size);
1211 }
1212
1213 // Evaluate state_for early since it may emit code.
1214 CodeEmitInfo* patching_info = nullptr;
1215 if (!x->klass()->is_loaded() || PatchALot) {
1216 patching_info = state_for(x, x->state_before());
1217
1274 state_for(x, x->state_before(), true /*ignore_xhandler*/));
1275
1276 CodeStub* stub;
1277 if (x->is_incompatible_class_change_check()) {
1278 assert(patching_info == nullptr, "can't patch this");
1279 stub = new SimpleExceptionStub(C1StubId::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception);
1280 } else if (x->is_invokespecial_receiver_check()) {
1281 assert(patching_info == nullptr, "can't patch this");
1282 stub = new DeoptimizeStub(info_for_exception, Deoptimization::Reason_class_check, Deoptimization::Action_none);
1283 } else {
1284 stub = new SimpleExceptionStub(C1StubId::throw_class_cast_exception_id, obj.result(), info_for_exception);
1285 }
1286 LIR_Opr reg = rlock_result(x);
1287 LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1288 if (!x->klass()->is_loaded() || UseCompressedClassPointers) {
1289 tmp3 = new_register(objectType);
1290 }
1291 __ checkcast(reg, obj.result(), x->klass(),
1292 new_register(objectType), new_register(objectType), tmp3,
1293 x->direct_compare(), info_for_exception, patching_info, stub,
1294 x->profiled_method(), x->profiled_bci());
1295 }
1296
1297
1298 void LIRGenerator::do_InstanceOf(InstanceOf* x) {
1299 LIRItem obj(x->obj(), this);
1300
1301 // result and test object may not be in same register
1302 LIR_Opr reg = rlock_result(x);
1303 CodeEmitInfo* patching_info = nullptr;
1304 if ((!x->klass()->is_loaded() || PatchALot)) {
1305 // must do this before locking the destination register as an oop register
1306 patching_info = state_for(x, x->state_before());
1307 }
1308 obj.load_item();
1309 LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1310 if (!x->klass()->is_loaded() || UseCompressedClassPointers) {
1311 tmp3 = new_register(objectType);
1312 }
1313 __ instanceof(reg, obj.result(), x->klass(),
1314 new_register(objectType), new_register(objectType), tmp3,
1330
1331 LIRItem xitem(x->x(), this);
1332 LIRItem yitem(x->y(), this);
1333 LIRItem* xin = &xitem;
1334 LIRItem* yin = &yitem;
1335
1336 if (tag == longTag) {
1337 // for longs, only conditions "eql", "neq", "lss", "geq" are valid;
1338 // mirror for other conditions
1339 if (cond == If::gtr || cond == If::leq) {
1340 cond = Instruction::mirror(cond);
1341 xin = &yitem;
1342 yin = &xitem;
1343 }
1344 xin->set_destroys_register();
1345 }
1346 xin->load_item();
1347 if (tag == longTag && yin->is_constant() && yin->get_jlong_constant() == 0 && (cond == If::eql || cond == If::neq)) {
1348 // inline long zero
1349 yin->dont_load_item();
1350 } else if (tag == longTag || tag == floatTag || tag == doubleTag) {
1351 // longs cannot handle constants at right side
1352 yin->load_item();
1353 } else {
1354 yin->dont_load_item();
1355 }
1356
1357 LIR_Opr left = xin->result();
1358 LIR_Opr right = yin->result();
1359
1360 set_no_result(x);
1361
1362 // add safepoint before generating condition code so it can be recomputed
1363 if (x->is_safepoint()) {
1364 // increment backedge counter if needed
1365 increment_backedge_counter_conditionally(lir_cond(cond), left, right, state_for(x, x->state_before()),
1366 x->tsux()->bci(), x->fsux()->bci(), x->profiled_bci());
1367 __ safepoint(safepoint_poll_register(), state_for(x, x->state_before()));
1368 }
1369
1370 __ cmp(lir_cond(cond), left, right);
1371 // Generate branch profiling. Profiling code doesn't kill flags.
1372 profile_branch(x, cond);
1373 move_to_phi(x->state());
1374 if (x->x()->type()->is_float_kind()) {
1375 __ branch(lir_cond(cond), x->tsux(), x->usux());
1376 } else {
1377 __ branch(lir_cond(cond), x->tsux());
1378 }
1379 assert(x->default_sux() == x->fsux(), "wrong destination above");
1380 __ jump(x->default_sux());
1381 }
1382
1383
1384 LIR_Opr LIRGenerator::getThreadPointer() {
1385 return FrameMap::as_pointer_opr(r15_thread);
1386 }
1387
1388 void LIRGenerator::trace_block_entry(BlockBegin* block) {
1389 store_stack_parameter(LIR_OprFact::intConst(block->block_id()), in_ByteSize(0));
1390 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)) {
94 case objectTag: opr = FrameMap::rax_oop_opr; break;
95 case longTag: opr = FrameMap::long0_opr; break;
96 case floatTag: opr = FrameMap::xmm0_float_opr; break;
97 case doubleTag: opr = FrameMap::xmm0_double_opr; break;
98 case addressTag:
99 default: ShouldNotReachHere(); return LIR_OprFact::illegalOpr;
100 }
101
102 assert(opr->type_field() == as_OprType(as_BasicType(type)), "type mismatch");
103 return opr;
104 }
105
106
107 LIR_Opr LIRGenerator::rlock_byte(BasicType type) {
108 LIR_Opr reg = new_register(T_INT);
109 set_vreg_flag(reg, LIRGenerator::byte_reg);
110 return reg;
111 }
112
113
114 void LIRGenerator::init_temps_for_substitutability_check(LIR_Opr& tmp1, LIR_Opr& tmp2) {
115 // We just need one 32-bit temp register for x86/x64, to check whether both
116 // oops have markWord::always_locked_pattern. See LIR_Assembler::emit_opSubstitutabilityCheck().
117 // @temp = %r10d
118 // mov $0x405, %r10d
119 // and (%left), %r10d /* if need to check left */
120 // and (%right), %r10d /* if need to check right */
121 // cmp $0x405, $r10d
122 // jne L_oops_not_equal
123 tmp1 = new_register(T_INT);
124 tmp2 = LIR_OprFact::illegalOpr;
125 }
126
127 //--------- loading items into registers --------------------------------
128
129
130 // i486 instructions can inline constants
131 bool LIRGenerator::can_store_as_constant(Value v, BasicType type) const {
132 if (type == T_SHORT || type == T_CHAR) {
133 return false;
134 }
135 Constant* c = v->as_Constant();
136 if (c && c->state_before() == nullptr) {
137 // constants of any type can be stored directly, except for
138 // unloaded object constants.
139 return true;
140 }
141 return false;
142 }
143
144
145 bool LIRGenerator::can_inline_as_constant(Value v) const {
146 if (v->type()->tag() == longTag) return false;
278 void LIRGenerator::array_store_check(LIR_Opr value, LIR_Opr array, CodeEmitInfo* store_check_info, ciMethod* profiled_method, int profiled_bci) {
279 LIR_Opr tmp1 = new_register(objectType);
280 LIR_Opr tmp2 = new_register(objectType);
281 LIR_Opr tmp3 = new_register(objectType);
282 __ store_check(value, array, tmp1, tmp2, tmp3, store_check_info, profiled_method, profiled_bci);
283 }
284
285 //----------------------------------------------------------------------
286 // visitor functions
287 //----------------------------------------------------------------------
288
289 void LIRGenerator::do_MonitorEnter(MonitorEnter* x) {
290 assert(x->is_pinned(),"");
291 LIRItem obj(x->obj(), this);
292 obj.load_item();
293
294 set_no_result(x);
295
296 // "lock" stores the address of the monitor stack slot, so this is not an oop
297 LIR_Opr lock = new_register(T_INT);
298 // Need a scratch register for inline types on x86
299 LIR_Opr scratch = LIR_OprFact::illegalOpr;
300 if ((LockingMode == LM_LIGHTWEIGHT) ||
301 (EnableValhalla && x->maybe_inlinetype())) {
302 scratch = new_register(T_ADDRESS);
303 }
304
305 CodeEmitInfo* info_for_exception = nullptr;
306 if (x->needs_null_check()) {
307 info_for_exception = state_for(x);
308 }
309
310 CodeStub* throw_ie_stub = x->maybe_inlinetype() ?
311 new SimpleExceptionStub(C1StubId::throw_identity_exception_id,
312 obj.result(), state_for(x))
313 : nullptr;
314
315 // this CodeEmitInfo must not have the xhandlers because here the
316 // object is already locked (xhandlers expect object to be unlocked)
317 CodeEmitInfo* info = state_for(x, x->state(), true);
318 monitor_enter(obj.result(), lock, syncTempOpr(), scratch,
319 x->monitor_no(), info_for_exception, info, throw_ie_stub);
320 }
321
322
323 void LIRGenerator::do_MonitorExit(MonitorExit* x) {
324 assert(x->is_pinned(),"");
325
326 LIRItem obj(x->obj(), this);
327 obj.dont_load_item();
328
329 LIR_Opr lock = new_register(T_INT);
330 LIR_Opr obj_temp = new_register(T_INT);
331 set_no_result(x);
332 monitor_exit(obj_temp, lock, syncTempOpr(), LIR_OprFact::illegalOpr, x->monitor_no());
333 }
334
335 // _ineg, _lneg, _fneg, _dneg
336 void LIRGenerator::do_NegateOp(NegateOp* x) {
337 LIRItem value(x->x(), this);
338 value.set_destroys_register();
339 value.load_item();
1131 log2ArrayIndexScale.load_item_force(cc->at(3));
1132
1133 __ call_runtime_leaf(StubRoutines::vectorizedMismatch(), getThreadTemp(), result_reg, cc->args());
1134 __ move(result_reg, result);
1135 }
1136
1137 void LIRGenerator::do_Convert(Convert* x) {
1138 LIRItem value(x->value(), this);
1139 value.load_item();
1140 LIR_Opr input = value.result();
1141 LIR_Opr result = rlock(x);
1142 __ convert(x->op(), input, result);
1143 assert(result->is_virtual(), "result must be virtual register");
1144 set_result(x, result);
1145 }
1146
1147
1148 void LIRGenerator::do_NewInstance(NewInstance* x) {
1149 print_if_not_loaded(x);
1150
1151 CodeEmitInfo* info = state_for(x, x->needs_state_before() ? x->state_before() : x->state());
1152 LIR_Opr reg = result_register_for(x->type());
1153 new_instance(reg, x->klass(), x->is_unresolved(),
1154 !x->is_unresolved() && x->klass()->is_inlinetype(),
1155 FrameMap::rcx_oop_opr,
1156 FrameMap::rdi_oop_opr,
1157 FrameMap::rsi_oop_opr,
1158 LIR_OprFact::illegalOpr,
1159 FrameMap::rdx_metadata_opr, info);
1160 LIR_Opr result = rlock_result(x);
1161 __ move(reg, result);
1162 }
1163
1164 void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
1165 CodeEmitInfo* info = nullptr;
1166 if (x->state_before() != nullptr && x->state_before()->force_reexecute()) {
1167 info = state_for(x, x->state_before());
1168 info->set_force_reexecute();
1169 } else {
1170 info = state_for(x, x->state());
1171 }
1172
1173 LIRItem length(x->length(), this);
1174 length.load_item_force(FrameMap::rbx_opr);
1175
1176 LIR_Opr reg = result_register_for(x->type());
1177 LIR_Opr tmp1 = FrameMap::rcx_oop_opr;
1178 LIR_Opr tmp2 = FrameMap::rsi_oop_opr;
1179 LIR_Opr tmp3 = FrameMap::rdi_oop_opr;
1180 LIR_Opr tmp4 = reg;
1181 LIR_Opr klass_reg = FrameMap::rdx_metadata_opr;
1182 LIR_Opr len = length.result();
1183 BasicType elem_type = x->elt_type();
1196 LIRItem length(x->length(), this);
1197 // in case of patching (i.e., object class is not yet loaded), we need to reexecute the instruction
1198 // and therefore provide the state before the parameters have been consumed
1199 CodeEmitInfo* patching_info = nullptr;
1200 if (!x->klass()->is_loaded() || PatchALot) {
1201 patching_info = state_for(x, x->state_before());
1202 }
1203
1204 CodeEmitInfo* info = state_for(x, x->state());
1205
1206 const LIR_Opr reg = result_register_for(x->type());
1207 LIR_Opr tmp1 = FrameMap::rcx_oop_opr;
1208 LIR_Opr tmp2 = FrameMap::rsi_oop_opr;
1209 LIR_Opr tmp3 = FrameMap::rdi_oop_opr;
1210 LIR_Opr tmp4 = reg;
1211 LIR_Opr klass_reg = FrameMap::rdx_metadata_opr;
1212
1213 length.load_item_force(FrameMap::rbx_opr);
1214 LIR_Opr len = length.result();
1215
1216 ciKlass* obj = ciArrayKlass::make(x->klass(), false, true, true);
1217
1218 // TODO 8265122 Implement a fast path for this
1219 bool is_flat = obj->is_loaded() && obj->is_flat_array_klass();
1220 bool is_null_free = obj->is_loaded() && obj->as_array_klass()->is_elem_null_free();
1221
1222 CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info, is_null_free);
1223 if (obj == ciEnv::unloaded_ciobjarrayklass()) {
1224 BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error");
1225 }
1226 klass2reg_with_patching(klass_reg, obj, patching_info);
1227 __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path, true, is_null_free || is_flat);
1228
1229 LIR_Opr result = rlock_result(x);
1230 __ move(reg, result);
1231 }
1232
1233
1234 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
1235 Values* dims = x->dims();
1236 int i = dims->length();
1237 LIRItemList* items = new LIRItemList(i, i, nullptr);
1238 while (i-- > 0) {
1239 LIRItem* size = new LIRItem(dims->at(i), this);
1240 items->at_put(i, size);
1241 }
1242
1243 // Evaluate state_for early since it may emit code.
1244 CodeEmitInfo* patching_info = nullptr;
1245 if (!x->klass()->is_loaded() || PatchALot) {
1246 patching_info = state_for(x, x->state_before());
1247
1304 state_for(x, x->state_before(), true /*ignore_xhandler*/));
1305
1306 CodeStub* stub;
1307 if (x->is_incompatible_class_change_check()) {
1308 assert(patching_info == nullptr, "can't patch this");
1309 stub = new SimpleExceptionStub(C1StubId::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception);
1310 } else if (x->is_invokespecial_receiver_check()) {
1311 assert(patching_info == nullptr, "can't patch this");
1312 stub = new DeoptimizeStub(info_for_exception, Deoptimization::Reason_class_check, Deoptimization::Action_none);
1313 } else {
1314 stub = new SimpleExceptionStub(C1StubId::throw_class_cast_exception_id, obj.result(), info_for_exception);
1315 }
1316 LIR_Opr reg = rlock_result(x);
1317 LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1318 if (!x->klass()->is_loaded() || UseCompressedClassPointers) {
1319 tmp3 = new_register(objectType);
1320 }
1321 __ checkcast(reg, obj.result(), x->klass(),
1322 new_register(objectType), new_register(objectType), tmp3,
1323 x->direct_compare(), info_for_exception, patching_info, stub,
1324 x->profiled_method(), x->profiled_bci(), x->is_null_free());
1325 }
1326
1327
1328 void LIRGenerator::do_InstanceOf(InstanceOf* x) {
1329 LIRItem obj(x->obj(), this);
1330
1331 // result and test object may not be in same register
1332 LIR_Opr reg = rlock_result(x);
1333 CodeEmitInfo* patching_info = nullptr;
1334 if ((!x->klass()->is_loaded() || PatchALot)) {
1335 // must do this before locking the destination register as an oop register
1336 patching_info = state_for(x, x->state_before());
1337 }
1338 obj.load_item();
1339 LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1340 if (!x->klass()->is_loaded() || UseCompressedClassPointers) {
1341 tmp3 = new_register(objectType);
1342 }
1343 __ instanceof(reg, obj.result(), x->klass(),
1344 new_register(objectType), new_register(objectType), tmp3,
1360
1361 LIRItem xitem(x->x(), this);
1362 LIRItem yitem(x->y(), this);
1363 LIRItem* xin = &xitem;
1364 LIRItem* yin = &yitem;
1365
1366 if (tag == longTag) {
1367 // for longs, only conditions "eql", "neq", "lss", "geq" are valid;
1368 // mirror for other conditions
1369 if (cond == If::gtr || cond == If::leq) {
1370 cond = Instruction::mirror(cond);
1371 xin = &yitem;
1372 yin = &xitem;
1373 }
1374 xin->set_destroys_register();
1375 }
1376 xin->load_item();
1377 if (tag == longTag && yin->is_constant() && yin->get_jlong_constant() == 0 && (cond == If::eql || cond == If::neq)) {
1378 // inline long zero
1379 yin->dont_load_item();
1380 } else if (tag == longTag || tag == floatTag || tag == doubleTag || x->substitutability_check()) {
1381 // longs cannot handle constants at right side
1382 yin->load_item();
1383 } else {
1384 yin->dont_load_item();
1385 }
1386
1387 LIR_Opr left = xin->result();
1388 LIR_Opr right = yin->result();
1389
1390 set_no_result(x);
1391
1392 // add safepoint before generating condition code so it can be recomputed
1393 if (x->is_safepoint()) {
1394 // increment backedge counter if needed
1395 increment_backedge_counter_conditionally(lir_cond(cond), left, right, state_for(x, x->state_before()),
1396 x->tsux()->bci(), x->fsux()->bci(), x->profiled_bci());
1397 __ safepoint(safepoint_poll_register(), state_for(x, x->state_before()));
1398 }
1399
1400 if (x->substitutability_check()) {
1401 substitutability_check(x, *xin, *yin);
1402 } else {
1403 __ cmp(lir_cond(cond), left, right);
1404 }
1405 // Generate branch profiling. Profiling code doesn't kill flags.
1406 profile_branch(x, cond);
1407 move_to_phi(x->state());
1408 if (x->x()->type()->is_float_kind()) {
1409 __ branch(lir_cond(cond), x->tsux(), x->usux());
1410 } else {
1411 __ branch(lir_cond(cond), x->tsux());
1412 }
1413 assert(x->default_sux() == x->fsux(), "wrong destination above");
1414 __ jump(x->default_sux());
1415 }
1416
1417
1418 LIR_Opr LIRGenerator::getThreadPointer() {
1419 return FrameMap::as_pointer_opr(r15_thread);
1420 }
1421
1422 void LIRGenerator::trace_block_entry(BlockBegin* block) {
1423 store_stack_parameter(LIR_OprFact::intConst(block->block_id()), in_ByteSize(0));
1424 LIR_OprList* args = new LIR_OprList();
|