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