< prev index next >

src/hotspot/share/opto/replacednodes.cpp

Print this page

128   }
129   for (int i = 0; i < _replaced_nodes->length(); i++) {
130     ReplacedNode replaced = _replaced_nodes->at(i);
131     Node* initial = replaced.initial();
132     Node* improved = replaced.improved();
133     assert (ctl != NULL && !ctl->is_top(), "replaced node should have actual control");
134 
135     ResourceMark rm;
136     Unique_Node_List work;
137     // Go over all the uses of the node that is considered for replacement...
138     for (DUIterator j = initial->outs(); initial->has_out(j); j++) {
139       Node* use = initial->out(j);
140 
141       if (use == improved || use->outcnt() == 0) {
142         continue;
143       }
144       work.clear();
145       enqueue_use(initial, use, work);
146       bool replace = true;
147       // Check that this use is dominated by ctl. Go ahead with the replacement if it is.

148       while (work.size() != 0 && replace) {
149         Node* n = work.pop();
150         if (use->outcnt() == 0) {
151           continue;
152         }
153         if (n->is_CFG() || (n->in(0) != NULL && !n->in(0)->is_top())) {
154           // Skip projections, since some of the multi nodes aren't CFG (e.g., LoadStore and SCMemProj).
155           if (n->is_Proj()) {
156             n = n->in(0);
157           }
158           if (!n->is_CFG()) {
159             n = n->in(0);
160           }
161           assert(n->is_CFG(), "should be CFG now");
162           int depth = 0;
163           while(n != ctl) {
164             n = IfNode::up_one_dom(n);
165             depth++;
166             // limit search depth
167             if (depth >= 100 || n == NULL) {
168               replace = false;
169               break;
170             }
171           }
172         } else {
173           for (DUIterator k = n->outs(); n->has_out(k); k++) {
174             enqueue_use(n, n->out(k), work);
175           }
176         }

177       }
178       if (replace) {
179         bool is_in_table = C->initial_gvn()->hash_delete(use);
180         int replaced = use->replace_edge(initial, improved);
181         if (is_in_table) {
182           C->initial_gvn()->hash_find_insert(use);
183         }
184         C->record_for_igvn(use);
185 
186         assert(replaced > 0, "inconsistent");
187         --j;
188       }
189     }
190   }
191 }
192 
193 void ReplacedNodes::dump(outputStream *st) const {
194   if (!is_empty()) {
195     st->print("replaced nodes: ");
196     for (int i = 0; i < _replaced_nodes->length(); i++) {

128   }
129   for (int i = 0; i < _replaced_nodes->length(); i++) {
130     ReplacedNode replaced = _replaced_nodes->at(i);
131     Node* initial = replaced.initial();
132     Node* improved = replaced.improved();
133     assert (ctl != NULL && !ctl->is_top(), "replaced node should have actual control");
134 
135     ResourceMark rm;
136     Unique_Node_List work;
137     // Go over all the uses of the node that is considered for replacement...
138     for (DUIterator j = initial->outs(); initial->has_out(j); j++) {
139       Node* use = initial->out(j);
140 
141       if (use == improved || use->outcnt() == 0) {
142         continue;
143       }
144       work.clear();
145       enqueue_use(initial, use, work);
146       bool replace = true;
147       // Check that this use is dominated by ctl. Go ahead with the replacement if it is.
148       DEBUG_ONLY(uint loop_count = 0);
149       while (work.size() != 0 && replace) {
150         Node* n = work.pop();
151         if (use->outcnt() == 0) {
152           continue;
153         }
154         if (n->is_CFG() || (n->in(0) != NULL && !n->in(0)->is_top())) {
155           // Skip projections, since some of the multi nodes aren't CFG (e.g., LoadStore and SCMemProj).
156           if (n->is_Proj()) {
157             n = n->in(0);
158           }
159           if (!n->is_CFG()) {
160             n = n->in(0);
161           }
162           assert(n->is_CFG(), "should be CFG now");
163           int depth = 0;
164           while(n != ctl) {
165             n = IfNode::up_one_dom(n);
166             depth++;
167             // limit search depth
168             if (depth >= 100 || n == NULL) {
169               replace = false;
170               break;
171             }
172           }
173         } else {
174           for (DUIterator k = n->outs(); n->has_out(k); k++) {
175             enqueue_use(n, n->out(k), work);
176           }
177         }
178         assert(loop_count++ < K, "infinite loop in ReplacedNodes::apply");
179       }
180       if (replace) {
181         bool is_in_table = C->initial_gvn()->hash_delete(use);
182         int replaced = use->replace_edge(initial, improved);
183         if (is_in_table) {
184           C->initial_gvn()->hash_find_insert(use);
185         }
186         C->record_for_igvn(use);
187 
188         assert(replaced > 0, "inconsistent");
189         --j;
190       }
191     }
192   }
193 }
194 
195 void ReplacedNodes::dump(outputStream *st) const {
196   if (!is_empty()) {
197     st->print("replaced nodes: ");
198     for (int i = 0; i < _replaced_nodes->length(); i++) {
< prev index next >