1268 }
1269 }
1270 return false;
1271 }
1272
1273 bool IfNode::is_null_check(IfProjNode* proj, PhaseIterGVN* igvn) const {
1274 Node* other = in(1)->in(1)->in(2);
1275 if (other->in(MemNode::Address) != nullptr &&
1276 proj->in(0)->in(1) != nullptr &&
1277 proj->in(0)->in(1)->is_Bool() &&
1278 proj->in(0)->in(1)->in(1) != nullptr &&
1279 proj->in(0)->in(1)->in(1)->Opcode() == Op_CmpP &&
1280 proj->in(0)->in(1)->in(1)->in(2) != nullptr &&
1281 proj->in(0)->in(1)->in(1)->in(1) == other->in(MemNode::Address)->in(AddPNode::Address)->uncast() &&
1282 igvn->type(proj->in(0)->in(1)->in(1)->in(2)) == TypePtr::NULL_PTR) {
1283 return true;
1284 }
1285 return false;
1286 }
1287
1288 // Check that the If that is in between the 2 integer comparisons has
1289 // no side effect
1290 bool IfNode::is_side_effect_free_test(IfProjNode* proj, PhaseIterGVN* igvn) const {
1291 if (proj == nullptr) {
1292 return false;
1293 }
1294 CallStaticJavaNode* unc = proj->is_uncommon_trap_if_pattern();
1295 if (unc != nullptr && proj->outcnt() <= 2) {
1296 if (proj->outcnt() == 1 ||
1297 // Allow simple null check from LoadRange
1298 (is_cmp_with_loadrange(proj) && is_null_check(proj, igvn))) {
1299 CallStaticJavaNode* unc = proj->is_uncommon_trap_if_pattern();
1300 CallStaticJavaNode* dom_unc = proj->in(0)->in(0)->as_Proj()->is_uncommon_trap_if_pattern();
1301 assert(dom_unc != nullptr, "is_uncommon_trap_if_pattern returned null");
1302
1303 // reroute_side_effect_free_unc changes the state of this
1304 // uncommon trap to restart execution at the previous
1305 // CmpI. Check that this change in a previous compilation didn't
1306 // cause too many traps.
1307 int trap_request = unc->uncommon_trap_request();
|
1268 }
1269 }
1270 return false;
1271 }
1272
1273 bool IfNode::is_null_check(IfProjNode* proj, PhaseIterGVN* igvn) const {
1274 Node* other = in(1)->in(1)->in(2);
1275 if (other->in(MemNode::Address) != nullptr &&
1276 proj->in(0)->in(1) != nullptr &&
1277 proj->in(0)->in(1)->is_Bool() &&
1278 proj->in(0)->in(1)->in(1) != nullptr &&
1279 proj->in(0)->in(1)->in(1)->Opcode() == Op_CmpP &&
1280 proj->in(0)->in(1)->in(1)->in(2) != nullptr &&
1281 proj->in(0)->in(1)->in(1)->in(1) == other->in(MemNode::Address)->in(AddPNode::Address)->uncast() &&
1282 igvn->type(proj->in(0)->in(1)->in(1)->in(2)) == TypePtr::NULL_PTR) {
1283 return true;
1284 }
1285 return false;
1286 }
1287
1288 // Returns true if this IfNode belongs to a flat array check
1289 // and returns the corresponding array in the 'array' parameter.
1290 bool IfNode::is_flat_array_check(PhaseTransform* phase, Node** array) {
1291 Node* bol = in(1);
1292 if (!bol->is_Bool()) {
1293 return false;
1294 }
1295 Node* cmp = bol->in(1);
1296 if (cmp->isa_FlatArrayCheck()) {
1297 if (array != nullptr) {
1298 *array = cmp->in(FlatArrayCheckNode::ArrayOrKlass);
1299 }
1300 return true;
1301 }
1302 return false;
1303 }
1304
1305 // Check that the If that is in between the 2 integer comparisons has
1306 // no side effect
1307 bool IfNode::is_side_effect_free_test(IfProjNode* proj, PhaseIterGVN* igvn) const {
1308 if (proj == nullptr) {
1309 return false;
1310 }
1311 CallStaticJavaNode* unc = proj->is_uncommon_trap_if_pattern();
1312 if (unc != nullptr && proj->outcnt() <= 2) {
1313 if (proj->outcnt() == 1 ||
1314 // Allow simple null check from LoadRange
1315 (is_cmp_with_loadrange(proj) && is_null_check(proj, igvn))) {
1316 CallStaticJavaNode* unc = proj->is_uncommon_trap_if_pattern();
1317 CallStaticJavaNode* dom_unc = proj->in(0)->in(0)->as_Proj()->is_uncommon_trap_if_pattern();
1318 assert(dom_unc != nullptr, "is_uncommon_trap_if_pattern returned null");
1319
1320 // reroute_side_effect_free_unc changes the state of this
1321 // uncommon trap to restart execution at the previous
1322 // CmpI. Check that this change in a previous compilation didn't
1323 // cause too many traps.
1324 int trap_request = unc->uncommon_trap_request();
|