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