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

src/share/vm/opto/gcm.cpp

Print this page
rev 7539 : 8011858: Use Compile::live_nodes() instead of Compile::unique() in appropriate places
Reviewed-by: kvn, vlivanov
Contributed-by: vlad.ureche@gmail.com


 101       uint max = pb->number_of_nodes();
 102       assert( max > 1, "" );
 103       uint start = max - pb->_num_succs;
 104       // Find which output path belongs to projection
 105       for (j = start; j < max; j++) {
 106         if( pb->get_node(j) == in0 )
 107           break;
 108       }
 109       assert( j < max, "must find" );
 110       // Change control to match head of successor basic block
 111       j -= start;
 112     }
 113     n->set_req(0, pb->_succs[j]->head());
 114   }
 115 }
 116 
 117 
 118 //------------------------------schedule_pinned_nodes--------------------------
 119 // Set the basic block for Nodes pinned into blocks
 120 void PhaseCFG::schedule_pinned_nodes(VectorSet &visited) {
 121   // Allocate node stack of size C->unique()+8 to avoid frequent realloc
 122   GrowableArray <Node *> spstack(C->unique() + 8);
 123   spstack.push(_root);
 124   while (spstack.is_nonempty()) {
 125     Node* node = spstack.pop();
 126     if (!visited.test_set(node->_idx)) { // Test node and flag it as visited
 127       if (node->pinned() && !has_block(node)) {  // Pinned?  Nail it down!
 128         assert(node->in(0), "pinned Node must have Control");
 129         // Before setting block replace block_proj control edge
 130         replace_block_proj_ctrl(node);
 131         Node* input = node->in(0);
 132         while (!input->is_block_start()) {
 133           input = input->in(0);
 134         }
 135         Block* block = get_block_for_node(input); // Basic block of controlling input
 136         schedule_node_into_block(node, block);
 137       }
 138 
 139       // process all inputs that are non NULL
 140       for (int i = node->req() - 1; i >= 0; --i) {
 141         if (node->in(i) != NULL) {
 142           spstack.push(node->in(i));


1268     tty->print("\n---- Start GlobalCodeMotion ----\n");
1269   }
1270 #endif
1271 
1272   // Initialize the node to block mapping for things on the proj_list
1273   for (uint i = 0; i < _matcher.number_of_projections(); i++) {
1274     unmap_node_from_block(_matcher.get_projection(i));
1275   }
1276 
1277   // Set the basic block for Nodes pinned into blocks
1278   Arena* arena = Thread::current()->resource_area();
1279   VectorSet visited(arena);
1280   schedule_pinned_nodes(visited);
1281 
1282   // Find the earliest Block any instruction can be placed in.  Some
1283   // instructions are pinned into Blocks.  Unpinned instructions can
1284   // appear in last block in which all their inputs occur.
1285   visited.Clear();
1286   Node_List stack(arena);
1287   // Pre-grow the list
1288   stack.map((C->unique() >> 1) + 16, NULL);
1289   if (!schedule_early(visited, stack)) {
1290     // Bailout without retry
1291     C->record_method_not_compilable("early schedule failed");
1292     return;
1293   }
1294 
1295   // Build Def-Use edges.
1296   // Compute the latency information (via backwards walk) for all the
1297   // instructions in the graph
1298   _node_latency = new GrowableArray<uint>(); // resource_area allocation
1299 
1300   if (C->do_scheduling()) {
1301     compute_latencies_backwards(visited, stack);
1302   }
1303 
1304   // Now schedule all codes as LATE as possible.  This is the LCA in the
1305   // dominator tree of all USES of a value.  Pick the block with the least
1306   // loop nesting depth that is lowest in the dominator tree.
1307   // ( visited.Clear() called in schedule_late()->Node_Backward_Iterator() )
1308   schedule_late(visited, stack);




 101       uint max = pb->number_of_nodes();
 102       assert( max > 1, "" );
 103       uint start = max - pb->_num_succs;
 104       // Find which output path belongs to projection
 105       for (j = start; j < max; j++) {
 106         if( pb->get_node(j) == in0 )
 107           break;
 108       }
 109       assert( j < max, "must find" );
 110       // Change control to match head of successor basic block
 111       j -= start;
 112     }
 113     n->set_req(0, pb->_succs[j]->head());
 114   }
 115 }
 116 
 117 
 118 //------------------------------schedule_pinned_nodes--------------------------
 119 // Set the basic block for Nodes pinned into blocks
 120 void PhaseCFG::schedule_pinned_nodes(VectorSet &visited) {
 121   // Allocate node stack of size C->live_nodes()+8 to avoid frequent realloc
 122   GrowableArray <Node *> spstack(C->live_nodes() + 8);
 123   spstack.push(_root);
 124   while (spstack.is_nonempty()) {
 125     Node* node = spstack.pop();
 126     if (!visited.test_set(node->_idx)) { // Test node and flag it as visited
 127       if (node->pinned() && !has_block(node)) {  // Pinned?  Nail it down!
 128         assert(node->in(0), "pinned Node must have Control");
 129         // Before setting block replace block_proj control edge
 130         replace_block_proj_ctrl(node);
 131         Node* input = node->in(0);
 132         while (!input->is_block_start()) {
 133           input = input->in(0);
 134         }
 135         Block* block = get_block_for_node(input); // Basic block of controlling input
 136         schedule_node_into_block(node, block);
 137       }
 138 
 139       // process all inputs that are non NULL
 140       for (int i = node->req() - 1; i >= 0; --i) {
 141         if (node->in(i) != NULL) {
 142           spstack.push(node->in(i));


1268     tty->print("\n---- Start GlobalCodeMotion ----\n");
1269   }
1270 #endif
1271 
1272   // Initialize the node to block mapping for things on the proj_list
1273   for (uint i = 0; i < _matcher.number_of_projections(); i++) {
1274     unmap_node_from_block(_matcher.get_projection(i));
1275   }
1276 
1277   // Set the basic block for Nodes pinned into blocks
1278   Arena* arena = Thread::current()->resource_area();
1279   VectorSet visited(arena);
1280   schedule_pinned_nodes(visited);
1281 
1282   // Find the earliest Block any instruction can be placed in.  Some
1283   // instructions are pinned into Blocks.  Unpinned instructions can
1284   // appear in last block in which all their inputs occur.
1285   visited.Clear();
1286   Node_List stack(arena);
1287   // Pre-grow the list
1288   stack.map((C->live_nodes() >> 1) + 16, NULL);
1289   if (!schedule_early(visited, stack)) {
1290     // Bailout without retry
1291     C->record_method_not_compilable("early schedule failed");
1292     return;
1293   }
1294 
1295   // Build Def-Use edges.
1296   // Compute the latency information (via backwards walk) for all the
1297   // instructions in the graph
1298   _node_latency = new GrowableArray<uint>(); // resource_area allocation
1299 
1300   if (C->do_scheduling()) {
1301     compute_latencies_backwards(visited, stack);
1302   }
1303 
1304   // Now schedule all codes as LATE as possible.  This is the LCA in the
1305   // dominator tree of all USES of a value.  Pick the block with the least
1306   // loop nesting depth that is lowest in the dominator tree.
1307   // ( visited.Clear() called in schedule_late()->Node_Backward_Iterator() )
1308   schedule_late(visited, stack);


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