< prev index next >

src/hotspot/share/opto/ifnode.cpp

Print this page




1195     }
1196   }
1197   return false;
1198 }
1199 
1200 bool IfNode::is_null_check(ProjNode* proj, PhaseIterGVN* igvn) {
1201   Node* other = in(1)->in(1)->in(2);
1202   if (other->in(MemNode::Address) != NULL &&
1203       proj->in(0)->in(1) != NULL &&
1204       proj->in(0)->in(1)->is_Bool() &&
1205       proj->in(0)->in(1)->in(1) != NULL &&
1206       proj->in(0)->in(1)->in(1)->Opcode() == Op_CmpP &&
1207       proj->in(0)->in(1)->in(1)->in(2) != NULL &&
1208       proj->in(0)->in(1)->in(1)->in(1) == other->in(MemNode::Address)->in(AddPNode::Address)->uncast() &&
1209       igvn->type(proj->in(0)->in(1)->in(1)->in(2)) == TypePtr::NULL_PTR) {
1210     return true;
1211   }
1212   return false;
1213 }
1214 















































1215 // Check that the If that is in between the 2 integer comparisons has
1216 // no side effect
1217 bool IfNode::is_side_effect_free_test(ProjNode* proj, PhaseIterGVN* igvn) {
1218   if (proj == NULL) {
1219     return false;
1220   }
1221   CallStaticJavaNode* unc = proj->is_uncommon_trap_if_pattern(Deoptimization::Reason_none);
1222   if (unc != NULL && proj->outcnt() <= 2) {
1223     if (proj->outcnt() == 1 ||
1224         // Allow simple null check from LoadRange
1225         (is_cmp_with_loadrange(proj) && is_null_check(proj, igvn))) {
1226       CallStaticJavaNode* unc = proj->is_uncommon_trap_if_pattern(Deoptimization::Reason_none);
1227       CallStaticJavaNode* dom_unc = proj->in(0)->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none);
1228       assert(dom_unc != NULL, "is_uncommon_trap_if_pattern returned NULL");
1229 
1230       // reroute_side_effect_free_unc changes the state of this
1231       // uncommon trap to restart execution at the previous
1232       // CmpI. Check that this change in a previous compilation didn't
1233       // cause too many traps.
1234       int trap_request = unc->uncommon_trap_request();




1195     }
1196   }
1197   return false;
1198 }
1199 
1200 bool IfNode::is_null_check(ProjNode* proj, PhaseIterGVN* igvn) {
1201   Node* other = in(1)->in(1)->in(2);
1202   if (other->in(MemNode::Address) != NULL &&
1203       proj->in(0)->in(1) != NULL &&
1204       proj->in(0)->in(1)->is_Bool() &&
1205       proj->in(0)->in(1)->in(1) != NULL &&
1206       proj->in(0)->in(1)->in(1)->Opcode() == Op_CmpP &&
1207       proj->in(0)->in(1)->in(1)->in(2) != NULL &&
1208       proj->in(0)->in(1)->in(1)->in(1) == other->in(MemNode::Address)->in(AddPNode::Address)->uncast() &&
1209       igvn->type(proj->in(0)->in(1)->in(1)->in(2)) == TypePtr::NULL_PTR) {
1210     return true;
1211   }
1212   return false;
1213 }
1214 
1215 // Returns true if this IfNode belongs to a flattened array check
1216 // and returns the corresponding array in the 'array' parameter.
1217 bool IfNode::is_flattened_array_check(PhaseTransform* phase, Node*& array) {
1218   Node* bol = in(1);
1219   if (!bol->is_Bool() || bol->as_Bool()->_test._test != BoolTest::ne) {
1220     return false;
1221   }
1222   Node* cmp = bol->in(1);
1223   if (cmp->Opcode() != Op_CmpI) {
1224     return false;
1225   }
1226   Node* cmp_in1 = cmp->in(1);
1227   Node* cmp_in2 = cmp->in(2);
1228   if ((unsigned int)cmp_in2->find_int_con(0) != Klass::_lh_array_tag_vt_value) {
1229     return false;
1230   }
1231   if (cmp_in1->Opcode() != Op_RShiftI) {
1232     return false;
1233   }
1234   Node* shift_in1 = cmp_in1->in(1);
1235   Node* shift_in2 = cmp_in1->in(2);
1236   if ((unsigned int)shift_in2->find_int_con(0) != Klass::_lh_array_tag_shift) {
1237     return false;
1238   }
1239   if (shift_in1->Opcode() != Op_LoadI) {
1240     return false;
1241   }
1242   intptr_t offset;
1243   Node* ptr = shift_in1->in(MemNode::Address);
1244   Node* addr = AddPNode::Ideal_base_and_offset(ptr, phase, offset);
1245   if (addr == NULL || offset != in_bytes(Klass::layout_helper_offset())) {
1246     return false;
1247   }
1248   if (!phase->type(addr)->isa_klassptr()) {
1249     return false;
1250   }
1251   Node* klass_load = ptr->as_AddP()->in(AddPNode::Base)->uncast();
1252   if (klass_load->is_DecodeNKlass()) {
1253     klass_load = klass_load->in(1);
1254   }
1255   if (klass_load->is_Load()) {
1256     Node* address = klass_load->in(MemNode::Address);
1257     array = address->as_AddP()->in(AddPNode::Base);
1258   }
1259   return true;
1260 }
1261 
1262 // Check that the If that is in between the 2 integer comparisons has
1263 // no side effect
1264 bool IfNode::is_side_effect_free_test(ProjNode* proj, PhaseIterGVN* igvn) {
1265   if (proj == NULL) {
1266     return false;
1267   }
1268   CallStaticJavaNode* unc = proj->is_uncommon_trap_if_pattern(Deoptimization::Reason_none);
1269   if (unc != NULL && proj->outcnt() <= 2) {
1270     if (proj->outcnt() == 1 ||
1271         // Allow simple null check from LoadRange
1272         (is_cmp_with_loadrange(proj) && is_null_check(proj, igvn))) {
1273       CallStaticJavaNode* unc = proj->is_uncommon_trap_if_pattern(Deoptimization::Reason_none);
1274       CallStaticJavaNode* dom_unc = proj->in(0)->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none);
1275       assert(dom_unc != NULL, "is_uncommon_trap_if_pattern returned NULL");
1276 
1277       // reroute_side_effect_free_unc changes the state of this
1278       // uncommon trap to restart execution at the previous
1279       // CmpI. Check that this change in a previous compilation didn't
1280       // cause too many traps.
1281       int trap_request = unc->uncommon_trap_request();


< prev index next >