< prev index next >

src/share/vm/opto/loopnode.cpp

Print this page




3072             // only the control input
3073             if( !visited.test_set( in->_idx ) ) {
3074               worklist.push(in);      // Visit this guy later, using worklist
3075             }
3076             // Get next node from nstack:
3077             // - skip n's inputs processing by setting i > cnt;
3078             // - we also will not call set_early_ctrl(n) since
3079             //   has_node(n) == true (see the condition above).
3080             i = cnt + 1;
3081           }
3082         }
3083       } // if (i == 0)
3084 
3085       // Visit all inputs
3086       bool done = true;       // Assume all n's inputs will be processed
3087       while (i < cnt) {
3088         Node *in = n->in(i);
3089         ++i;
3090         if (in == NULL) continue;
3091         if (in->pinned() && !in->is_CFG())
3092           set_ctrl(in, in->in(0));
3093         int is_visited = visited.test_set( in->_idx );
3094         if (!has_node(in)) {  // No controlling input yet?
3095           assert( !in->is_CFG(), "CFG Node with no controlling input?" );
3096           assert( !is_visited, "visit only once" );
3097           nstack.push(n, i);  // Save parent node and next input's index.
3098           nstack_top_n = in;  // Process current input now.
3099           nstack_top_i = 0;
3100           done = false;       // Not all n's inputs processed.
3101           break; // continue while_nstack_nonempty;
3102         } else if (!is_visited) {
3103           // This guy has a location picked out for him, but has not yet
3104           // been visited.  Happens to all CFG nodes, for instance.
3105           // Visit him using the worklist instead of recursion, to break
3106           // cycles.  Since he has a location already we do not need to
3107           // find his location before proceeding with the current Node.
3108           worklist.push(in);  // Visit this guy later, using worklist
3109         }
3110       }
3111       if (done) {
3112         // All of n's inputs have been processed, complete post-processing.


3257   // This can produce false positives.
3258   if (n->is_Load() && LCA != early) {
3259     Node_List worklist;
3260 
3261     Node *mem = n->in(MemNode::Memory);
3262     for (DUIterator_Fast imax, i = mem->fast_outs(imax); i < imax; i++) {
3263       Node* s = mem->fast_out(i);
3264       worklist.push(s);
3265     }
3266     while(worklist.size() != 0 && LCA != early) {
3267       Node* s = worklist.pop();
3268       if (s->is_Load()) {
3269         continue;
3270       } else if (s->is_MergeMem()) {
3271         for (DUIterator_Fast imax, i = s->fast_outs(imax); i < imax; i++) {
3272           Node* s1 = s->fast_out(i);
3273           worklist.push(s1);
3274         }
3275       } else {
3276         Node *sctrl = has_ctrl(s) ? get_ctrl(s) : s->in(0);
3277         assert(sctrl != NULL || s->outcnt() == 0, "must have control");
3278         if (sctrl != NULL && !sctrl->is_top() && is_dominator(early, sctrl)) {
3279           LCA = dom_lca_for_get_late_ctrl(LCA, sctrl, n);
3280         }
3281       }
3282     }
3283   }
3284 
3285   assert(LCA == find_non_split_ctrl(LCA), "unexpected late control");
3286   return LCA;
3287 }
3288 
3289 // true if CFG node d dominates CFG node n
3290 bool PhaseIdealLoop::is_dominator(Node *d, Node *n) {
3291   if (d == n)
3292     return true;
3293   assert(d->is_CFG() && n->is_CFG(), "must have CFG nodes");
3294   uint dd = dom_depth(d);
3295   while (dom_depth(n) >= dd) {
3296     if (n == d)
3297       return true;


3478     case Op_ModD:
3479     case Op_LoadB:              // Same with Loads; they can sink
3480     case Op_LoadUB:             // during loop optimizations.
3481     case Op_LoadUS:
3482     case Op_LoadD:
3483     case Op_LoadF:
3484     case Op_LoadI:
3485     case Op_LoadKlass:
3486     case Op_LoadNKlass:
3487     case Op_LoadL:
3488     case Op_LoadS:
3489     case Op_LoadP:
3490     case Op_LoadN:
3491     case Op_LoadRange:
3492     case Op_LoadD_unaligned:
3493     case Op_LoadL_unaligned:
3494     case Op_StrComp:            // Does a bunch of load-like effects
3495     case Op_StrEquals:
3496     case Op_StrIndexOf:
3497     case Op_AryEq:


3498       pinned = false;
3499     }
3500     if( pinned ) {
3501       IdealLoopTree *chosen_loop = get_loop(n->is_CFG() ? n : get_ctrl(n));
3502       if( !chosen_loop->_child )       // Inner loop?
3503         chosen_loop->_body.push(n); // Collect inner loops
3504       return;
3505     }
3506   } else {                      // No slot zero
3507     if( n->is_CFG() ) {         // CFG with no slot 0 is dead
3508       _nodes.map(n->_idx,0);    // No block setting, it's globally dead
3509       return;
3510     }
3511     assert(!n->is_CFG() || n->outcnt() == 0, "");
3512   }
3513 
3514   // Do I have a "safe range" I can select over?
3515   Node *early = get_ctrl(n);// Early location already computed
3516 
3517   // Compute latest point this Node can go




3072             // only the control input
3073             if( !visited.test_set( in->_idx ) ) {
3074               worklist.push(in);      // Visit this guy later, using worklist
3075             }
3076             // Get next node from nstack:
3077             // - skip n's inputs processing by setting i > cnt;
3078             // - we also will not call set_early_ctrl(n) since
3079             //   has_node(n) == true (see the condition above).
3080             i = cnt + 1;
3081           }
3082         }
3083       } // if (i == 0)
3084 
3085       // Visit all inputs
3086       bool done = true;       // Assume all n's inputs will be processed
3087       while (i < cnt) {
3088         Node *in = n->in(i);
3089         ++i;
3090         if (in == NULL) continue;
3091         if (in->pinned() && !in->is_CFG())
3092           set_ctrl(in, in->Opcode() == Op_ShenandoahWBMemProj ? in->in(0)->in(0) : in->in(0));
3093         int is_visited = visited.test_set( in->_idx );
3094         if (!has_node(in)) {  // No controlling input yet?
3095           assert( !in->is_CFG(), "CFG Node with no controlling input?" );
3096           assert( !is_visited, "visit only once" );
3097           nstack.push(n, i);  // Save parent node and next input's index.
3098           nstack_top_n = in;  // Process current input now.
3099           nstack_top_i = 0;
3100           done = false;       // Not all n's inputs processed.
3101           break; // continue while_nstack_nonempty;
3102         } else if (!is_visited) {
3103           // This guy has a location picked out for him, but has not yet
3104           // been visited.  Happens to all CFG nodes, for instance.
3105           // Visit him using the worklist instead of recursion, to break
3106           // cycles.  Since he has a location already we do not need to
3107           // find his location before proceeding with the current Node.
3108           worklist.push(in);  // Visit this guy later, using worklist
3109         }
3110       }
3111       if (done) {
3112         // All of n's inputs have been processed, complete post-processing.


3257   // This can produce false positives.
3258   if (n->is_Load() && LCA != early) {
3259     Node_List worklist;
3260 
3261     Node *mem = n->in(MemNode::Memory);
3262     for (DUIterator_Fast imax, i = mem->fast_outs(imax); i < imax; i++) {
3263       Node* s = mem->fast_out(i);
3264       worklist.push(s);
3265     }
3266     while(worklist.size() != 0 && LCA != early) {
3267       Node* s = worklist.pop();
3268       if (s->is_Load()) {
3269         continue;
3270       } else if (s->is_MergeMem()) {
3271         for (DUIterator_Fast imax, i = s->fast_outs(imax); i < imax; i++) {
3272           Node* s1 = s->fast_out(i);
3273           worklist.push(s1);
3274         }
3275       } else {
3276         Node *sctrl = has_ctrl(s) ? get_ctrl(s) : s->in(0);
3277         assert(sctrl != NULL || s->outcnt() == 0 || s->is_ShenandoahBarrier(), "must have control");
3278         if (sctrl != NULL && !sctrl->is_top() && is_dominator(early, sctrl)) {
3279           LCA = dom_lca_for_get_late_ctrl(LCA, sctrl, n);
3280         }
3281       }
3282     }
3283   }
3284 
3285   assert(LCA == find_non_split_ctrl(LCA), "unexpected late control");
3286   return LCA;
3287 }
3288 
3289 // true if CFG node d dominates CFG node n
3290 bool PhaseIdealLoop::is_dominator(Node *d, Node *n) {
3291   if (d == n)
3292     return true;
3293   assert(d->is_CFG() && n->is_CFG(), "must have CFG nodes");
3294   uint dd = dom_depth(d);
3295   while (dom_depth(n) >= dd) {
3296     if (n == d)
3297       return true;


3478     case Op_ModD:
3479     case Op_LoadB:              // Same with Loads; they can sink
3480     case Op_LoadUB:             // during loop optimizations.
3481     case Op_LoadUS:
3482     case Op_LoadD:
3483     case Op_LoadF:
3484     case Op_LoadI:
3485     case Op_LoadKlass:
3486     case Op_LoadNKlass:
3487     case Op_LoadL:
3488     case Op_LoadS:
3489     case Op_LoadP:
3490     case Op_LoadN:
3491     case Op_LoadRange:
3492     case Op_LoadD_unaligned:
3493     case Op_LoadL_unaligned:
3494     case Op_StrComp:            // Does a bunch of load-like effects
3495     case Op_StrEquals:
3496     case Op_StrIndexOf:
3497     case Op_AryEq:
3498     case Op_ShenandoahReadBarrier:
3499     case Op_ShenandoahWriteBarrier:
3500       pinned = false;
3501     }
3502     if( pinned ) {
3503       IdealLoopTree *chosen_loop = get_loop(n->is_CFG() ? n : get_ctrl(n));
3504       if( !chosen_loop->_child )       // Inner loop?
3505         chosen_loop->_body.push(n); // Collect inner loops
3506       return;
3507     }
3508   } else {                      // No slot zero
3509     if( n->is_CFG() ) {         // CFG with no slot 0 is dead
3510       _nodes.map(n->_idx,0);    // No block setting, it's globally dead
3511       return;
3512     }
3513     assert(!n->is_CFG() || n->outcnt() == 0, "");
3514   }
3515 
3516   // Do I have a "safe range" I can select over?
3517   Node *early = get_ctrl(n);// Early location already computed
3518 
3519   // Compute latest point this Node can go


< prev index next >