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

src/share/vm/opto/gcm.cpp

Print this page
rev 8016 : 8069191: moving predicate out of loops may cause array accesses to bypass null check
Summary: Remove CastPP nodes only during final graph reshape
Reviewed-by:


  83     Block *pb = get_block_for_node(in0); // Block-projection already has basic block
  84     uint j = 0;
  85     if (pb->_num_succs != 1) {  // More then 1 successor?
  86       // Search for successor
  87       uint max = pb->number_of_nodes();
  88       assert( max > 1, "" );
  89       uint start = max - pb->_num_succs;
  90       // Find which output path belongs to projection
  91       for (j = start; j < max; j++) {
  92         if( pb->get_node(j) == in0 )
  93           break;
  94       }
  95       assert( j < max, "must find" );
  96       // Change control to match head of successor basic block
  97       j -= start;
  98     }
  99     n->set_req(0, pb->_succs[j]->head());
 100   }
 101 }
 102 



 103 
 104 //------------------------------schedule_pinned_nodes--------------------------
 105 // Set the basic block for Nodes pinned into blocks
 106 void PhaseCFG::schedule_pinned_nodes(VectorSet &visited) {
 107   // Allocate node stack of size C->unique()+8 to avoid frequent realloc
 108   GrowableArray <Node *> spstack(C->unique() + 8);
 109   spstack.push(_root);
 110   while (spstack.is_nonempty()) {
 111     Node* node = spstack.pop();
 112     if (!visited.test_set(node->_idx)) { // Test node and flag it as visited
 113       if (node->pinned() && !has_block(node)) {  // Pinned?  Nail it down!
 114         assert(node->in(0), "pinned Node must have Control");
 115         // Before setting block replace block_proj control edge
 116         replace_block_proj_ctrl(node);
 117         Node* input = node->in(0);
 118         while (!input->is_block_start()) {
 119           input = input->in(0);
 120         }
 121         Block* block = get_block_for_node(input); // Basic block of controlling input
 122         schedule_node_into_block(node, block);






























 123       }
 124 
 125       // process all inputs that are non NULL
 126       for (int i = node->req() - 1; i >= 0; --i) {
 127         if (node->in(i) != NULL) {
 128           spstack.push(node->in(i));
 129         }
 130       }
 131     }
 132   }
 133 }
 134 
 135 #ifdef ASSERT
 136 // Assert that new input b2 is dominated by all previous inputs.
 137 // Check this by by seeing that it is dominated by b1, the deepest
 138 // input observed until b2.
 139 static void assert_dom(Block* b1, Block* b2, Node* n, const PhaseCFG* cfg) {
 140   if (b1 == NULL)  return;
 141   assert(b1->_dom_depth < b2->_dom_depth, "sanity");
 142   Block* tmp = b2;




  83     Block *pb = get_block_for_node(in0); // Block-projection already has basic block
  84     uint j = 0;
  85     if (pb->_num_succs != 1) {  // More then 1 successor?
  86       // Search for successor
  87       uint max = pb->number_of_nodes();
  88       assert( max > 1, "" );
  89       uint start = max - pb->_num_succs;
  90       // Find which output path belongs to projection
  91       for (j = start; j < max; j++) {
  92         if( pb->get_node(j) == in0 )
  93           break;
  94       }
  95       assert( j < max, "must find" );
  96       // Change control to match head of successor basic block
  97       j -= start;
  98     }
  99     n->set_req(0, pb->_succs[j]->head());
 100   }
 101 }
 102 
 103 static bool is_dominator(Block* d, Block* n) {
 104   return d->dom_lca(n) == d;
 105 }
 106 
 107 //------------------------------schedule_pinned_nodes--------------------------
 108 // Set the basic block for Nodes pinned into blocks
 109 void PhaseCFG::schedule_pinned_nodes(VectorSet &visited) {
 110   // Allocate node stack of size C->unique()+8 to avoid frequent realloc
 111   GrowableArray <Node *> spstack(C->unique() + 8);
 112   spstack.push(_root);
 113   while (spstack.is_nonempty()) {
 114     Node* node = spstack.pop();
 115     if (!visited.test_set(node->_idx)) { // Test node and flag it as visited
 116       if (node->pinned() && !has_block(node)) {  // Pinned?  Nail it down!
 117         assert(node->in(0), "pinned Node must have Control");
 118         // Before setting block replace block_proj control edge
 119         replace_block_proj_ctrl(node);
 120         Node* input = node->in(0);
 121         while (!input->is_block_start()) {
 122           input = input->in(0);
 123         }
 124         Block* block = get_block_for_node(input); // Basic block of controlling input
 125         schedule_node_into_block(node, block);
 126       }
 127 
 128       // If the node has precedence edges (added when CastPP nodes are
 129       // removed in final_graph_reshaping), fix the control of the
 130       // node to cover the precedence edges and remove the
 131       // dependencies.
 132       Node* n = NULL;
 133       for (uint i = node->len()-1; i >= node->req(); i--) {
 134         Node* m = node->in(i);
 135         if (m == NULL) continue;
 136         // See Compile::final_graph_reshaping_impl(): we expect a test
 137         // or a Region here.
 138         if (m->is_block_proj() || m->is_block_start()) {
 139           node->rm_prec(i);
 140           if (n == NULL) {
 141             n = m;
 142           } else {
 143             Block* bn = get_block_for_node(n);
 144             Block* bm = get_block_for_node(m);
 145             n = is_dominator(bn, bm) ? m : n;
 146           }
 147         }
 148       }
 149       if (n != NULL) {
 150         assert(node->in(0), "control should have been set");
 151         Block* bn = get_block_for_node(n);
 152         Block* bnode = get_block_for_node(node->in(0));
 153         if (!is_dominator(bn, bnode)) {
 154           node->set_req(0, n);
 155         }
 156       }
 157 
 158       // process all inputs that are non NULL
 159       for (int i = node->req() - 1; i >= 0; --i) {
 160         if (node->in(i) != NULL) {
 161           spstack.push(node->in(i));
 162         }
 163       }
 164     }
 165   }
 166 }
 167 
 168 #ifdef ASSERT
 169 // Assert that new input b2 is dominated by all previous inputs.
 170 // Check this by by seeing that it is dominated by b1, the deepest
 171 // input observed until b2.
 172 static void assert_dom(Block* b1, Block* b2, Node* n, const PhaseCFG* cfg) {
 173   if (b1 == NULL)  return;
 174   assert(b1->_dom_depth < b2->_dom_depth, "sanity");
 175   Block* tmp = b2;


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