1219 }
1220 }
1221 return false;
1222 }
1223
1224 bool IfNode::is_null_check(ProjNode* proj, PhaseIterGVN* igvn) {
1225 Node* other = in(1)->in(1)->in(2);
1226 if (other->in(MemNode::Address) != nullptr &&
1227 proj->in(0)->in(1) != nullptr &&
1228 proj->in(0)->in(1)->is_Bool() &&
1229 proj->in(0)->in(1)->in(1) != nullptr &&
1230 proj->in(0)->in(1)->in(1)->Opcode() == Op_CmpP &&
1231 proj->in(0)->in(1)->in(1)->in(2) != nullptr &&
1232 proj->in(0)->in(1)->in(1)->in(1) == other->in(MemNode::Address)->in(AddPNode::Address)->uncast() &&
1233 igvn->type(proj->in(0)->in(1)->in(1)->in(2)) == TypePtr::NULL_PTR) {
1234 return true;
1235 }
1236 return false;
1237 }
1238
1239 // Check that the If that is in between the 2 integer comparisons has
1240 // no side effect
1241 bool IfNode::is_side_effect_free_test(ProjNode* proj, PhaseIterGVN* igvn) {
1242 if (proj == nullptr) {
1243 return false;
1244 }
1245 CallStaticJavaNode* unc = proj->is_uncommon_trap_if_pattern();
1246 if (unc != nullptr && proj->outcnt() <= 2) {
1247 if (proj->outcnt() == 1 ||
1248 // Allow simple null check from LoadRange
1249 (is_cmp_with_loadrange(proj) && is_null_check(proj, igvn))) {
1250 CallStaticJavaNode* unc = proj->is_uncommon_trap_if_pattern();
1251 CallStaticJavaNode* dom_unc = proj->in(0)->in(0)->as_Proj()->is_uncommon_trap_if_pattern();
1252 assert(dom_unc != nullptr, "is_uncommon_trap_if_pattern returned null");
1253
1254 // reroute_side_effect_free_unc changes the state of this
1255 // uncommon trap to restart execution at the previous
1256 // CmpI. Check that this change in a previous compilation didn't
1257 // cause too many traps.
1258 int trap_request = unc->uncommon_trap_request();
|
1219 }
1220 }
1221 return false;
1222 }
1223
1224 bool IfNode::is_null_check(ProjNode* proj, PhaseIterGVN* igvn) {
1225 Node* other = in(1)->in(1)->in(2);
1226 if (other->in(MemNode::Address) != nullptr &&
1227 proj->in(0)->in(1) != nullptr &&
1228 proj->in(0)->in(1)->is_Bool() &&
1229 proj->in(0)->in(1)->in(1) != nullptr &&
1230 proj->in(0)->in(1)->in(1)->Opcode() == Op_CmpP &&
1231 proj->in(0)->in(1)->in(1)->in(2) != nullptr &&
1232 proj->in(0)->in(1)->in(1)->in(1) == other->in(MemNode::Address)->in(AddPNode::Address)->uncast() &&
1233 igvn->type(proj->in(0)->in(1)->in(1)->in(2)) == TypePtr::NULL_PTR) {
1234 return true;
1235 }
1236 return false;
1237 }
1238
1239 // Returns true if this IfNode belongs to a flat array check
1240 // and returns the corresponding array in the 'array' parameter.
1241 bool IfNode::is_flat_array_check(PhaseTransform* phase, Node** array) {
1242 Node* bol = in(1);
1243 if (!bol->is_Bool()) {
1244 return false;
1245 }
1246 Node* cmp = bol->in(1);
1247 if (cmp->isa_FlatArrayCheck()) {
1248 if (array != nullptr) {
1249 *array = cmp->in(FlatArrayCheckNode::ArrayOrKlass);
1250 }
1251 return true;
1252 }
1253 return false;
1254 }
1255
1256 // Check that the If that is in between the 2 integer comparisons has
1257 // no side effect
1258 bool IfNode::is_side_effect_free_test(ProjNode* proj, PhaseIterGVN* igvn) {
1259 if (proj == nullptr) {
1260 return false;
1261 }
1262 CallStaticJavaNode* unc = proj->is_uncommon_trap_if_pattern();
1263 if (unc != nullptr && proj->outcnt() <= 2) {
1264 if (proj->outcnt() == 1 ||
1265 // Allow simple null check from LoadRange
1266 (is_cmp_with_loadrange(proj) && is_null_check(proj, igvn))) {
1267 CallStaticJavaNode* unc = proj->is_uncommon_trap_if_pattern();
1268 CallStaticJavaNode* dom_unc = proj->in(0)->in(0)->as_Proj()->is_uncommon_trap_if_pattern();
1269 assert(dom_unc != nullptr, "is_uncommon_trap_if_pattern returned null");
1270
1271 // reroute_side_effect_free_unc changes the state of this
1272 // uncommon trap to restart execution at the previous
1273 // CmpI. Check that this change in a previous compilation didn't
1274 // cause too many traps.
1275 int trap_request = unc->uncommon_trap_request();
|