src/share/vm/opto/loopnode.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/opto

src/share/vm/opto/loopnode.cpp

Print this page
rev 5411 : 8024069: replace_in_map() should operate on parent maps
Summary: type information gets lost because replace_in_map() doesn't update parent maps
Reviewed-by:


 150   assert(ctl->is_CFG(), "expensive input 0 must be cfg");
 151   uint min_dom_depth = dom_depth(earliest);
 152 #ifdef ASSERT
 153   if (!is_dominator(ctl, earliest) && !is_dominator(earliest, ctl)) {
 154     dump_bad_graph("Bad graph detected in get_early_ctrl_for_expensive", n, earliest, ctl);
 155     assert(false, "Bad graph detected in get_early_ctrl_for_expensive");
 156   }
 157 #endif
 158   if (dom_depth(ctl) < min_dom_depth) {
 159     return earliest;
 160   }
 161 
 162   while (1) {
 163     Node *next = ctl;
 164     // Moving the node out of a loop on the projection of a If
 165     // confuses loop predication. So once we hit a Loop in a If branch
 166     // that doesn't branch to an UNC, we stop. The code that process
 167     // expensive nodes will notice the loop and skip over it to try to
 168     // move the node further up.
 169     if (ctl->is_CountedLoop() && ctl->in(1) != NULL && ctl->in(1)->in(0) != NULL && ctl->in(1)->in(0)->is_If()) {
 170       if (!is_uncommon_trap_if_pattern(ctl->in(1)->as_Proj(), Deoptimization::Reason_none)) {
 171         break;
 172       }
 173       next = idom(ctl->in(1)->in(0));
 174     } else if (ctl->is_Proj()) {
 175       // We only move it up along a projection if the projection is
 176       // the single control projection for its parent: same code path,
 177       // if it's a If with UNC or fallthrough of a call.
 178       Node* parent_ctl = ctl->in(0);
 179       if (parent_ctl == NULL) {
 180         break;
 181       } else if (parent_ctl->is_CountedLoopEnd() && parent_ctl->as_CountedLoopEnd()->loopnode() != NULL) {
 182         next = parent_ctl->as_CountedLoopEnd()->loopnode()->init_control();
 183       } else if (parent_ctl->is_If()) {
 184         if (!is_uncommon_trap_if_pattern(ctl->as_Proj(), Deoptimization::Reason_none)) {
 185           break;
 186         }
 187         assert(idom(ctl) == parent_ctl, "strange");
 188         next = idom(parent_ctl);
 189       } else if (ctl->is_CatchProj()) {
 190         if (ctl->as_Proj()->_con != CatchProjNode::fall_through_index) {
 191           break;
 192         }
 193         assert(parent_ctl->in(0)->in(0)->is_Call(), "strange graph");
 194         next = parent_ctl->in(0)->in(0)->in(0);
 195       } else {
 196         // Check if parent control has a single projection (this
 197         // control is the only possible successor of the parent
 198         // control). If so, we can try to move the node above the
 199         // parent control.
 200         int nb_ctl_proj = 0;
 201         for (DUIterator_Fast imax, i = parent_ctl->fast_outs(imax); i < imax; i++) {
 202           Node *p = parent_ctl->fast_out(i);
 203           if (p->is_Proj() && p->is_CFG()) {
 204             nb_ctl_proj++;




 150   assert(ctl->is_CFG(), "expensive input 0 must be cfg");
 151   uint min_dom_depth = dom_depth(earliest);
 152 #ifdef ASSERT
 153   if (!is_dominator(ctl, earliest) && !is_dominator(earliest, ctl)) {
 154     dump_bad_graph("Bad graph detected in get_early_ctrl_for_expensive", n, earliest, ctl);
 155     assert(false, "Bad graph detected in get_early_ctrl_for_expensive");
 156   }
 157 #endif
 158   if (dom_depth(ctl) < min_dom_depth) {
 159     return earliest;
 160   }
 161 
 162   while (1) {
 163     Node *next = ctl;
 164     // Moving the node out of a loop on the projection of a If
 165     // confuses loop predication. So once we hit a Loop in a If branch
 166     // that doesn't branch to an UNC, we stop. The code that process
 167     // expensive nodes will notice the loop and skip over it to try to
 168     // move the node further up.
 169     if (ctl->is_CountedLoop() && ctl->in(1) != NULL && ctl->in(1)->in(0) != NULL && ctl->in(1)->in(0)->is_If()) {
 170       if (!ctl->in(1)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none)) {
 171         break;
 172       }
 173       next = idom(ctl->in(1)->in(0));
 174     } else if (ctl->is_Proj()) {
 175       // We only move it up along a projection if the projection is
 176       // the single control projection for its parent: same code path,
 177       // if it's a If with UNC or fallthrough of a call.
 178       Node* parent_ctl = ctl->in(0);
 179       if (parent_ctl == NULL) {
 180         break;
 181       } else if (parent_ctl->is_CountedLoopEnd() && parent_ctl->as_CountedLoopEnd()->loopnode() != NULL) {
 182         next = parent_ctl->as_CountedLoopEnd()->loopnode()->init_control();
 183       } else if (parent_ctl->is_If()) {
 184         if (!ctl->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none)) {
 185           break;
 186         }
 187         assert(idom(ctl) == parent_ctl, "strange");
 188         next = idom(parent_ctl);
 189       } else if (ctl->is_CatchProj()) {
 190         if (ctl->as_Proj()->_con != CatchProjNode::fall_through_index) {
 191           break;
 192         }
 193         assert(parent_ctl->in(0)->in(0)->is_Call(), "strange graph");
 194         next = parent_ctl->in(0)->in(0)->in(0);
 195       } else {
 196         // Check if parent control has a single projection (this
 197         // control is the only possible successor of the parent
 198         // control). If so, we can try to move the node above the
 199         // parent control.
 200         int nb_ctl_proj = 0;
 201         for (DUIterator_Fast imax, i = parent_ctl->fast_outs(imax); i < imax; i++) {
 202           Node *p = parent_ctl->fast_out(i);
 203           if (p->is_Proj() && p->is_CFG()) {
 204             nb_ctl_proj++;


src/share/vm/opto/loopnode.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File