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