comparison src/share/vm/opto/loopTransform.cpp @ 8779:a59625d96f71

8009181: [parfait] Null pointer deference in hotspot/src/share/vm/opto/loopTransform.cpp Summary: add guarantee() to insert_pre_post_loops() Reviewed-by: kvn
author morris
date Wed, 20 Mar 2013 07:05:40 -0700
parents b5cb079ecaa4
children bcc4f6f54d83
comparison
equal deleted inserted replaced
8778:653d0346aa80 8779:a59625d96f71
886 886
887 // Find common pieces of the loop being guarded with pre & post loops 887 // Find common pieces of the loop being guarded with pre & post loops
888 CountedLoopNode *main_head = loop->_head->as_CountedLoop(); 888 CountedLoopNode *main_head = loop->_head->as_CountedLoop();
889 assert( main_head->is_normal_loop(), "" ); 889 assert( main_head->is_normal_loop(), "" );
890 CountedLoopEndNode *main_end = main_head->loopexit(); 890 CountedLoopEndNode *main_end = main_head->loopexit();
891 guarantee(main_end != NULL, "no loop exit node");
891 assert( main_end->outcnt() == 2, "1 true, 1 false path only" ); 892 assert( main_end->outcnt() == 2, "1 true, 1 false path only" );
892 uint dd_main_head = dom_depth(main_head); 893 uint dd_main_head = dom_depth(main_head);
893 uint max = main_head->outcnt(); 894 uint max = main_head->outcnt();
894 895
895 Node *pre_header= main_head->in(LoopNode::EntryControl); 896 Node *pre_header= main_head->in(LoopNode::EntryControl);
2552 2553
2553 // store related values are ok 2554 // store related values are ok
2554 ok.set(store->_idx); 2555 ok.set(store->_idx);
2555 ok.set(store->in(MemNode::Memory)->_idx); 2556 ok.set(store->in(MemNode::Memory)->_idx);
2556 2557
2558 CountedLoopEndNode* loop_exit = head->loopexit();
2559 guarantee(loop_exit != NULL, "no loop exit node");
2560
2557 // Loop structure is ok 2561 // Loop structure is ok
2558 ok.set(head->_idx); 2562 ok.set(head->_idx);
2559 ok.set(head->loopexit()->_idx); 2563 ok.set(loop_exit->_idx);
2560 ok.set(head->phi()->_idx); 2564 ok.set(head->phi()->_idx);
2561 ok.set(head->incr()->_idx); 2565 ok.set(head->incr()->_idx);
2562 ok.set(head->loopexit()->cmp_node()->_idx); 2566 ok.set(loop_exit->cmp_node()->_idx);
2563 ok.set(head->loopexit()->in(1)->_idx); 2567 ok.set(loop_exit->in(1)->_idx);
2564 2568
2565 // Address elements are ok 2569 // Address elements are ok
2566 if (con) ok.set(con->_idx); 2570 if (con) ok.set(con->_idx);
2567 if (shift) ok.set(shift->_idx); 2571 if (shift) ok.set(shift->_idx);
2568 if (conv) ok.set(conv->_idx); 2572 if (conv) ok.set(conv->_idx);
2570 for (uint i = 0; msg == NULL && i < lpt->_body.size(); i++) { 2574 for (uint i = 0; msg == NULL && i < lpt->_body.size(); i++) {
2571 Node* n = lpt->_body.at(i); 2575 Node* n = lpt->_body.at(i);
2572 if (n->outcnt() == 0) continue; // Ignore dead 2576 if (n->outcnt() == 0) continue; // Ignore dead
2573 if (ok.test(n->_idx)) continue; 2577 if (ok.test(n->_idx)) continue;
2574 // Backedge projection is ok 2578 // Backedge projection is ok
2575 if (n->is_IfTrue() && n->in(0) == head->loopexit()) continue; 2579 if (n->is_IfTrue() && n->in(0) == loop_exit) continue;
2576 if (!n->is_AddP()) { 2580 if (!n->is_AddP()) {
2577 msg = "unhandled node"; 2581 msg = "unhandled node";
2578 msg_node = n; 2582 msg_node = n;
2579 break; 2583 break;
2580 } 2584 }
2583 // Make sure no unexpected values are used outside the loop 2587 // Make sure no unexpected values are used outside the loop
2584 for (uint i = 0; msg == NULL && i < lpt->_body.size(); i++) { 2588 for (uint i = 0; msg == NULL && i < lpt->_body.size(); i++) {
2585 Node* n = lpt->_body.at(i); 2589 Node* n = lpt->_body.at(i);
2586 // These values can be replaced with other nodes if they are used 2590 // These values can be replaced with other nodes if they are used
2587 // outside the loop. 2591 // outside the loop.
2588 if (n == store || n == head->loopexit() || n == head->incr() || n == store->in(MemNode::Memory)) continue; 2592 if (n == store || n == loop_exit || n == head->incr() || n == store->in(MemNode::Memory)) continue;
2589 for (SimpleDUIterator iter(n); iter.has_next(); iter.next()) { 2593 for (SimpleDUIterator iter(n); iter.has_next(); iter.next()) {
2590 Node* use = iter.get(); 2594 Node* use = iter.get();
2591 if (!lpt->_body.contains(use)) { 2595 if (!lpt->_body.contains(use)) {
2592 msg = "node is used outside loop"; 2596 msg = "node is used outside loop";
2593 // lpt->_body.dump(); 2597 // lpt->_body.dump();