< prev index next >

src/hotspot/cpu/x86/c1_LIRGenerator_x86.cpp

Print this page

  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 = 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 

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   if (!x->klass()->is_loaded() || UseCompressedClassPointers) {
1295     tmp3 = new_register(objectType);
1296   }
1297   __ checkcast(reg, obj.result(), x->klass(),
1298                new_register(objectType), new_register(objectType), tmp3,
1299                x->direct_compare(), info_for_exception, patching_info, stub,
1300                x->profiled_method(), x->profiled_bci());
1301 }
1302 
1303 
1304 void LIRGenerator::do_InstanceOf(InstanceOf* x) {
1305   LIRItem obj(x->obj(), this);
1306 
1307   // result and test object may not be in same register
1308   LIR_Opr reg = rlock_result(x);
1309   CodeEmitInfo* patching_info = nullptr;
1310   if ((!x->klass()->is_loaded() || PatchALot)) {
1311     // must do this before locking the destination register as an oop register
1312     patching_info = state_for(x, x->state_before());
1313   }
1314   obj.load_item();
1315   LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1316   if (!x->klass()->is_loaded() || UseCompressedClassPointers) {
1317     tmp3 = new_register(objectType);
1318   }
1319   __ instanceof(reg, obj.result(), x->klass(),
1320                 new_register(objectType), new_register(objectType), tmp3,

1336 
1337   LIRItem xitem(x->x(), this);
1338   LIRItem yitem(x->y(), this);
1339   LIRItem* xin = &xitem;
1340   LIRItem* yin = &yitem;
1341 
1342   if (tag == longTag) {
1343     // for longs, only conditions "eql", "neq", "lss", "geq" are valid;
1344     // mirror for other conditions
1345     if (cond == If::gtr || cond == If::leq) {
1346       cond = Instruction::mirror(cond);
1347       xin = &yitem;
1348       yin = &xitem;
1349     }
1350     xin->set_destroys_register();
1351   }
1352   xin->load_item();
1353   if (tag == longTag && yin->is_constant() && yin->get_jlong_constant() == 0 && (cond == If::eql || cond == If::neq)) {
1354     // inline long zero
1355     yin->dont_load_item();
1356   } else if (tag == longTag || tag == floatTag || tag == doubleTag) {
1357     // longs cannot handle constants at right side
1358     yin->load_item();
1359   } else {
1360     yin->dont_load_item();
1361   }
1362 
1363   LIR_Opr left = xin->result();
1364   LIR_Opr right = yin->result();
1365 
1366   set_no_result(x);
1367 
1368   // add safepoint before generating condition code so it can be recomputed
1369   if (x->is_safepoint()) {
1370     // increment backedge counter if needed
1371     increment_backedge_counter_conditionally(lir_cond(cond), left, right, state_for(x, x->state_before()),
1372         x->tsux()->bci(), x->fsux()->bci(), x->profiled_bci());
1373     __ safepoint(safepoint_poll_register(), state_for(x, x->state_before()));
1374   }
1375 
1376   __ cmp(lir_cond(cond), left, right);




1377   // Generate branch profiling. Profiling code doesn't kill flags.
1378   profile_branch(x, cond);
1379   move_to_phi(x->state());
1380   if (x->x()->type()->is_float_kind()) {
1381     __ branch(lir_cond(cond), x->tsux(), x->usux());
1382   } else {
1383     __ branch(lir_cond(cond), x->tsux());
1384   }
1385   assert(x->default_sux() == x->fsux(), "wrong destination above");
1386   __ jump(x->default_sux());
1387 }
1388 
1389 
1390 LIR_Opr LIRGenerator::getThreadPointer() {
1391   return FrameMap::as_pointer_opr(r15_thread);
1392 }
1393 
1394 void LIRGenerator::trace_block_entry(BlockBegin* block) {
1395   store_stack_parameter(LIR_OprFact::intConst(block->block_id()), in_ByteSize(0));
1396   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 = new_register(T_ADDRESS);
 300 
 301   CodeEmitInfo* info_for_exception = nullptr;
 302   if (x->needs_null_check()) {
 303     info_for_exception = state_for(x);
 304   }
 305 
 306   CodeStub* throw_ie_stub = x->maybe_inlinetype() ?
 307       new SimpleExceptionStub(StubId::c1_throw_identity_exception_id,
 308                               obj.result(), state_for(x))
 309     : nullptr;
 310 
 311   // this CodeEmitInfo must not have the xhandlers because here the
 312   // object is already locked (xhandlers expect object to be unlocked)
 313   CodeEmitInfo* info = state_for(x, x->state(), true);
 314   monitor_enter(obj.result(), lock, syncTempOpr(), scratch,
 315                 x->monitor_no(), info_for_exception, info, throw_ie_stub);

 316 }
 317 
 318 
 319 void LIRGenerator::do_MonitorExit(MonitorExit* x) {
 320   assert(x->is_pinned(),"");
 321 
 322   LIRItem obj(x->obj(), this);
 323   obj.dont_load_item();
 324 
 325   LIR_Opr lock = new_register(T_INT);
 326   LIR_Opr obj_temp = new_register(T_INT);
 327   set_no_result(x);
 328   monitor_exit(obj_temp, lock, syncTempOpr(), LIR_OprFact::illegalOpr, x->monitor_no());
 329 }
 330 
 331 // _ineg, _lneg, _fneg, _dneg
 332 void LIRGenerator::do_NegateOp(NegateOp* x) {
 333   LIRItem value(x->x(), this);
 334   value.set_destroys_register();
 335   value.load_item();

1133   log2ArrayIndexScale.load_item_force(cc->at(3));
1134 
1135   __ call_runtime_leaf(StubRoutines::vectorizedMismatch(), getThreadTemp(), result_reg, cc->args());
1136   __ move(result_reg, result);
1137 }
1138 
1139 void LIRGenerator::do_Convert(Convert* x) {
1140   LIRItem value(x->value(), this);
1141   value.load_item();
1142   LIR_Opr input = value.result();
1143   LIR_Opr result = rlock(x);
1144   __ convert(x->op(), input, result);
1145   assert(result->is_virtual(), "result must be virtual register");
1146   set_result(x, result);
1147 }
1148 
1149 
1150 void LIRGenerator::do_NewInstance(NewInstance* x) {
1151   print_if_not_loaded(x);
1152 
1153   CodeEmitInfo* info = state_for(x, x->needs_state_before() ? x->state_before() : x->state());
1154   LIR_Opr reg = result_register_for(x->type());
1155   new_instance(reg, x->klass(), x->is_unresolved(),
1156                !x->is_unresolved() && x->klass()->is_inlinetype(),
1157                FrameMap::rcx_oop_opr,
1158                FrameMap::rdi_oop_opr,
1159                FrameMap::rsi_oop_opr,
1160                LIR_OprFact::illegalOpr,
1161                FrameMap::rdx_metadata_opr, info);
1162   LIR_Opr result = rlock_result(x);
1163   __ move(reg, result);
1164 }
1165 

1166 void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
1167   CodeEmitInfo* info = nullptr;
1168   if (x->state_before() != nullptr && x->state_before()->force_reexecute()) {
1169     info = state_for(x, x->state_before());
1170     info->set_force_reexecute();
1171   } else {
1172     info = state_for(x, x->state());
1173   }
1174 
1175   LIRItem length(x->length(), this);
1176   length.load_item_force(FrameMap::rbx_opr);
1177 
1178   LIR_Opr reg = result_register_for(x->type());
1179   LIR_Opr tmp1 = FrameMap::rcx_oop_opr;
1180   LIR_Opr tmp2 = FrameMap::rsi_oop_opr;
1181   LIR_Opr tmp3 = FrameMap::rdi_oop_opr;
1182   LIR_Opr tmp4 = reg;
1183   LIR_Opr klass_reg = FrameMap::rdx_metadata_opr;
1184   LIR_Opr len = length.result();
1185   BasicType elem_type = x->elt_type();

1198   LIRItem length(x->length(), this);
1199   // in case of patching (i.e., object class is not yet loaded), we need to reexecute the instruction
1200   // and therefore provide the state before the parameters have been consumed
1201   CodeEmitInfo* patching_info = nullptr;
1202   if (!x->klass()->is_loaded() || PatchALot) {
1203     patching_info =  state_for(x, x->state_before());
1204   }
1205 
1206   CodeEmitInfo* info = state_for(x, x->state());
1207 
1208   const LIR_Opr reg = result_register_for(x->type());
1209   LIR_Opr tmp1 = FrameMap::rcx_oop_opr;
1210   LIR_Opr tmp2 = FrameMap::rsi_oop_opr;
1211   LIR_Opr tmp3 = FrameMap::rdi_oop_opr;
1212   LIR_Opr tmp4 = reg;
1213   LIR_Opr klass_reg = FrameMap::rdx_metadata_opr;
1214 
1215   length.load_item_force(FrameMap::rbx_opr);
1216   LIR_Opr len = length.result();
1217 
1218   ciKlass* obj = ciArrayKlass::make(x->klass(), false, true, true);
1219 
1220   // TODO 8265122 Implement a fast path for this
1221   bool is_flat = obj->is_loaded() && obj->is_flat_array_klass();
1222   bool is_null_free = obj->is_loaded() && obj->as_array_klass()->is_elem_null_free();
1223 
1224   CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info, is_null_free);
1225   if (obj == ciEnv::unloaded_ciobjarrayklass()) {
1226     BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error");
1227   }
1228   klass2reg_with_patching(klass_reg, obj, patching_info);
1229   __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path, true, is_null_free || is_flat);
1230 
1231   LIR_Opr result = rlock_result(x);
1232   __ move(reg, result);
1233 }
1234 
1235 
1236 void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
1237   Values* dims = x->dims();
1238   int i = dims->length();
1239   LIRItemList* items = new LIRItemList(i, i, nullptr);
1240   while (i-- > 0) {
1241     LIRItem* size = new LIRItem(dims->at(i), this);
1242     items->at_put(i, size);
1243   }
1244 
1245   // Evaluate state_for early since it may emit code.
1246   CodeEmitInfo* patching_info = nullptr;
1247   if (!x->klass()->is_loaded() || PatchALot) {
1248     patching_info = state_for(x, x->state_before());
1249 

1306                                     state_for(x, x->state_before(), true /*ignore_xhandler*/));
1307 
1308   CodeStub* stub;
1309   if (x->is_incompatible_class_change_check()) {
1310     assert(patching_info == nullptr, "can't patch this");
1311     stub = new SimpleExceptionStub(StubId::c1_throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception);
1312   } else if (x->is_invokespecial_receiver_check()) {
1313     assert(patching_info == nullptr, "can't patch this");
1314     stub = new DeoptimizeStub(info_for_exception, Deoptimization::Reason_class_check, Deoptimization::Action_none);
1315   } else {
1316     stub = new SimpleExceptionStub(StubId::c1_throw_class_cast_exception_id, obj.result(), info_for_exception);
1317   }
1318   LIR_Opr reg = rlock_result(x);
1319   LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1320   if (!x->klass()->is_loaded() || UseCompressedClassPointers) {
1321     tmp3 = new_register(objectType);
1322   }
1323   __ checkcast(reg, obj.result(), x->klass(),
1324                new_register(objectType), new_register(objectType), tmp3,
1325                x->direct_compare(), info_for_exception, patching_info, stub,
1326                x->profiled_method(), x->profiled_bci(), x->is_null_free());
1327 }
1328 
1329 
1330 void LIRGenerator::do_InstanceOf(InstanceOf* x) {
1331   LIRItem obj(x->obj(), this);
1332 
1333   // result and test object may not be in same register
1334   LIR_Opr reg = rlock_result(x);
1335   CodeEmitInfo* patching_info = nullptr;
1336   if ((!x->klass()->is_loaded() || PatchALot)) {
1337     // must do this before locking the destination register as an oop register
1338     patching_info = state_for(x, x->state_before());
1339   }
1340   obj.load_item();
1341   LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
1342   if (!x->klass()->is_loaded() || UseCompressedClassPointers) {
1343     tmp3 = new_register(objectType);
1344   }
1345   __ instanceof(reg, obj.result(), x->klass(),
1346                 new_register(objectType), new_register(objectType), tmp3,

1362 
1363   LIRItem xitem(x->x(), this);
1364   LIRItem yitem(x->y(), this);
1365   LIRItem* xin = &xitem;
1366   LIRItem* yin = &yitem;
1367 
1368   if (tag == longTag) {
1369     // for longs, only conditions "eql", "neq", "lss", "geq" are valid;
1370     // mirror for other conditions
1371     if (cond == If::gtr || cond == If::leq) {
1372       cond = Instruction::mirror(cond);
1373       xin = &yitem;
1374       yin = &xitem;
1375     }
1376     xin->set_destroys_register();
1377   }
1378   xin->load_item();
1379   if (tag == longTag && yin->is_constant() && yin->get_jlong_constant() == 0 && (cond == If::eql || cond == If::neq)) {
1380     // inline long zero
1381     yin->dont_load_item();
1382   } else if (tag == longTag || tag == floatTag || tag == doubleTag || x->substitutability_check()) {
1383     // longs cannot handle constants at right side
1384     yin->load_item();
1385   } else {
1386     yin->dont_load_item();
1387   }
1388 
1389   LIR_Opr left = xin->result();
1390   LIR_Opr right = yin->result();
1391 
1392   set_no_result(x);
1393 
1394   // add safepoint before generating condition code so it can be recomputed
1395   if (x->is_safepoint()) {
1396     // increment backedge counter if needed
1397     increment_backedge_counter_conditionally(lir_cond(cond), left, right, state_for(x, x->state_before()),
1398         x->tsux()->bci(), x->fsux()->bci(), x->profiled_bci());
1399     __ safepoint(safepoint_poll_register(), state_for(x, x->state_before()));
1400   }
1401 
1402   if (x->substitutability_check()) {
1403     substitutability_check(x, *xin, *yin);
1404   } else {
1405     __ cmp(lir_cond(cond), left, right);
1406   }
1407   // Generate branch profiling. Profiling code doesn't kill flags.
1408   profile_branch(x, cond);
1409   move_to_phi(x->state());
1410   if (x->x()->type()->is_float_kind()) {
1411     __ branch(lir_cond(cond), x->tsux(), x->usux());
1412   } else {
1413     __ branch(lir_cond(cond), x->tsux());
1414   }
1415   assert(x->default_sux() == x->fsux(), "wrong destination above");
1416   __ jump(x->default_sux());
1417 }
1418 
1419 
1420 LIR_Opr LIRGenerator::getThreadPointer() {
1421   return FrameMap::as_pointer_opr(r15_thread);
1422 }
1423 
1424 void LIRGenerator::trace_block_entry(BlockBegin* block) {
1425   store_stack_parameter(LIR_OprFact::intConst(block->block_id()), in_ByteSize(0));
1426   LIR_OprList* args = new LIR_OprList();
< prev index next >