comparison src/share/vm/opto/memnode.cpp @ 193:44a553b2809d

6714406: Node::dominates() does not always check for TOP Summary: Add missed checks for TOP and missed checks for non-dominating cases Reviewed-by: rasbold, jrose, never
author kvn
date Fri, 13 Jun 2008 15:08:56 -0700
parents 9148c65abefc
children d1605aabd0a1 1e026f8da827
comparison
equal deleted inserted replaced
192:6d13fcb3663f 193:44a553b2809d
251 // an allocation it wants to look past. 251 // an allocation it wants to look past.
252 bool MemNode::all_controls_dominate(Node* dom, Node* sub) { 252 bool MemNode::all_controls_dominate(Node* dom, Node* sub) {
253 if (dom == NULL || dom->is_top() || sub == NULL || sub->is_top()) 253 if (dom == NULL || dom->is_top() || sub == NULL || sub->is_top())
254 return false; // Conservative answer for dead code 254 return false; // Conservative answer for dead code
255 255
256 // Check 'dom'. 256 // Check 'dom'. Skip Proj and CatchProj nodes.
257 dom = dom->find_exact_control(dom); 257 dom = dom->find_exact_control(dom);
258 if (dom == NULL || dom->is_top()) 258 if (dom == NULL || dom->is_top())
259 return false; // Conservative answer for dead code 259 return false; // Conservative answer for dead code
260
261 if (dom == sub) {
262 // For the case when, for example, 'sub' is Initialize and the original
263 // 'dom' is Proj node of the 'sub'.
264 return false;
265 }
260 266
261 if (dom->is_Con() || dom->is_Start() || dom->is_Root() || dom == sub) 267 if (dom->is_Con() || dom->is_Start() || dom->is_Root() || dom == sub)
262 return true; 268 return true;
263 269
264 // 'dom' dominates 'sub' if its control edge and control edges 270 // 'dom' dominates 'sub' if its control edge and control edges
269 // 'sub' should have sub->in(0) != NULL. 275 // 'sub' should have sub->in(0) != NULL.
270 assert(sub->is_Allocate() || sub->is_Initialize() || sub->is_Start() || 276 assert(sub->is_Allocate() || sub->is_Initialize() || sub->is_Start() ||
271 sub->is_Region(), "expecting only these nodes"); 277 sub->is_Region(), "expecting only these nodes");
272 278
273 // Get control edge of 'sub'. 279 // Get control edge of 'sub'.
280 Node* orig_sub = sub;
274 sub = sub->find_exact_control(sub->in(0)); 281 sub = sub->find_exact_control(sub->in(0));
275 if (sub == NULL || sub->is_top()) 282 if (sub == NULL || sub->is_top())
276 return false; // Conservative answer for dead code 283 return false; // Conservative answer for dead code
277 284
278 assert(sub->is_CFG(), "expecting control"); 285 assert(sub->is_CFG(), "expecting control");
294 dom_list.push(dom); 301 dom_list.push(dom);
295 bool only_dominating_controls = false; 302 bool only_dominating_controls = false;
296 303
297 for (uint next = 0; next < dom_list.size(); next++) { 304 for (uint next = 0; next < dom_list.size(); next++) {
298 Node* n = dom_list.at(next); 305 Node* n = dom_list.at(next);
306 if (n == orig_sub)
307 return false; // One of dom's inputs dominated by sub.
299 if (!n->is_CFG() && n->pinned()) { 308 if (!n->is_CFG() && n->pinned()) {
300 // Check only own control edge for pinned non-control nodes. 309 // Check only own control edge for pinned non-control nodes.
301 n = n->find_exact_control(n->in(0)); 310 n = n->find_exact_control(n->in(0));
302 if (n == NULL || n->is_top()) 311 if (n == NULL || n->is_top())
303 return false; // Conservative answer for dead code 312 return false; // Conservative answer for dead code
304 assert(n->is_CFG(), "expecting control"); 313 assert(n->is_CFG(), "expecting control");
305 } 314 dom_list.push(n);
306 if (n->is_Con() || n->is_Start() || n->is_Root()) { 315 } else if (n->is_Con() || n->is_Start() || n->is_Root()) {
307 only_dominating_controls = true; 316 only_dominating_controls = true;
308 } else if (n->is_CFG()) { 317 } else if (n->is_CFG()) {
309 if (n->dominates(sub, nlist)) 318 if (n->dominates(sub, nlist))
310 only_dominating_controls = true; 319 only_dominating_controls = true;
311 else 320 else