1239 }
1240 }
1241 return false;
1242 }
1243
1244 bool IfNode::is_null_check(ProjNode* proj, PhaseIterGVN* igvn) {
1245 Node* other = in(1)->in(1)->in(2);
1246 if (other->in(MemNode::Address) != nullptr &&
1247 proj->in(0)->in(1) != nullptr &&
1248 proj->in(0)->in(1)->is_Bool() &&
1249 proj->in(0)->in(1)->in(1) != nullptr &&
1250 proj->in(0)->in(1)->in(1)->Opcode() == Op_CmpP &&
1251 proj->in(0)->in(1)->in(1)->in(2) != nullptr &&
1252 proj->in(0)->in(1)->in(1)->in(1) == other->in(MemNode::Address)->in(AddPNode::Address)->uncast() &&
1253 igvn->type(proj->in(0)->in(1)->in(1)->in(2)) == TypePtr::NULL_PTR) {
1254 return true;
1255 }
1256 return false;
1257 }
1258
1259 // Check that the If that is in between the 2 integer comparisons has
1260 // no side effect
1261 bool IfNode::is_side_effect_free_test(ProjNode* proj, PhaseIterGVN* igvn) {
1262 if (proj == nullptr) {
1263 return false;
1264 }
1265 CallStaticJavaNode* unc = proj->is_uncommon_trap_if_pattern();
1266 if (unc != nullptr && proj->outcnt() <= 2) {
1267 if (proj->outcnt() == 1 ||
1268 // Allow simple null check from LoadRange
1269 (is_cmp_with_loadrange(proj) && is_null_check(proj, igvn))) {
1270 CallStaticJavaNode* unc = proj->is_uncommon_trap_if_pattern();
1271 CallStaticJavaNode* dom_unc = proj->in(0)->in(0)->as_Proj()->is_uncommon_trap_if_pattern();
1272 assert(dom_unc != nullptr, "is_uncommon_trap_if_pattern returned null");
1273
1274 // reroute_side_effect_free_unc changes the state of this
1275 // uncommon trap to restart execution at the previous
1276 // CmpI. Check that this change in a previous compilation didn't
1277 // cause too many traps.
1278 int trap_request = unc->uncommon_trap_request();
|
1239 }
1240 }
1241 return false;
1242 }
1243
1244 bool IfNode::is_null_check(ProjNode* proj, PhaseIterGVN* igvn) {
1245 Node* other = in(1)->in(1)->in(2);
1246 if (other->in(MemNode::Address) != nullptr &&
1247 proj->in(0)->in(1) != nullptr &&
1248 proj->in(0)->in(1)->is_Bool() &&
1249 proj->in(0)->in(1)->in(1) != nullptr &&
1250 proj->in(0)->in(1)->in(1)->Opcode() == Op_CmpP &&
1251 proj->in(0)->in(1)->in(1)->in(2) != nullptr &&
1252 proj->in(0)->in(1)->in(1)->in(1) == other->in(MemNode::Address)->in(AddPNode::Address)->uncast() &&
1253 igvn->type(proj->in(0)->in(1)->in(1)->in(2)) == TypePtr::NULL_PTR) {
1254 return true;
1255 }
1256 return false;
1257 }
1258
1259 // Returns true if this IfNode belongs to a flat array check
1260 // and returns the corresponding array in the 'array' parameter.
1261 bool IfNode::is_flat_array_check(PhaseTransform* phase, Node** array) {
1262 Node* bol = in(1);
1263 if (!bol->is_Bool()) {
1264 return false;
1265 }
1266 Node* cmp = bol->in(1);
1267 if (cmp->isa_FlatArrayCheck()) {
1268 if (array != nullptr) {
1269 *array = cmp->in(FlatArrayCheckNode::ArrayOrKlass);
1270 }
1271 return true;
1272 }
1273 return false;
1274 }
1275
1276 // Check that the If that is in between the 2 integer comparisons has
1277 // no side effect
1278 bool IfNode::is_side_effect_free_test(ProjNode* proj, PhaseIterGVN* igvn) {
1279 if (proj == nullptr) {
1280 return false;
1281 }
1282 CallStaticJavaNode* unc = proj->is_uncommon_trap_if_pattern();
1283 if (unc != nullptr && proj->outcnt() <= 2) {
1284 if (proj->outcnt() == 1 ||
1285 // Allow simple null check from LoadRange
1286 (is_cmp_with_loadrange(proj) && is_null_check(proj, igvn))) {
1287 CallStaticJavaNode* unc = proj->is_uncommon_trap_if_pattern();
1288 CallStaticJavaNode* dom_unc = proj->in(0)->in(0)->as_Proj()->is_uncommon_trap_if_pattern();
1289 assert(dom_unc != nullptr, "is_uncommon_trap_if_pattern returned null");
1290
1291 // reroute_side_effect_free_unc changes the state of this
1292 // uncommon trap to restart execution at the previous
1293 // CmpI. Check that this change in a previous compilation didn't
1294 // cause too many traps.
1295 int trap_request = unc->uncommon_trap_request();
|