src/share/vm/opto/lcm.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 7069452 Sdiff src/share/vm/opto

src/share/vm/opto/lcm.cpp

Print this page




 308   }
 309   // No candidate!
 310   if( !best ) return;
 311 
 312   // ---- Found an implicit null check
 313   extern int implicit_null_checks;
 314   implicit_null_checks++;
 315 
 316   if( is_decoden ) {
 317     // Check if we need to hoist decodeHeapOop_not_null first.
 318     Block *valb = cfg->_bbs[val->_idx];
 319     if( this != valb && this->_dom_depth < valb->_dom_depth ) {
 320       // Hoist it up to the end of the test block.
 321       valb->find_remove(val);
 322       this->add_inst(val);
 323       cfg->_bbs.map(val->_idx,this);
 324       // DecodeN on x86 may kill flags. Check for flag-killing projections
 325       // that also need to be hoisted.
 326       for (DUIterator_Fast jmax, j = val->fast_outs(jmax); j < jmax; j++) {
 327         Node* n = val->fast_out(j);
 328         if( n->Opcode() == Op_MachProj ) {
 329           cfg->_bbs[n->_idx]->find_remove(n);
 330           this->add_inst(n);
 331           cfg->_bbs.map(n->_idx,this);
 332         }
 333       }
 334     }
 335   }
 336   // Hoist the memory candidate up to the end of the test block.
 337   Block *old_block = cfg->_bbs[best->_idx];
 338   old_block->find_remove(best);
 339   add_inst(best);
 340   cfg->_bbs.map(best->_idx,this);
 341 
 342   // Move the control dependence
 343   if (best->in(0) && best->in(0) == old_block->_nodes[0])
 344     best->set_req(0, _nodes[0]);
 345 
 346   // Check for flag-killing projections that also need to be hoisted
 347   // Should be DU safe because no edge updates.
 348   for (DUIterator_Fast jmax, j = best->fast_outs(jmax); j < jmax; j++) {
 349     Node* n = best->fast_out(j);
 350     if( n->Opcode() == Op_MachProj ) {
 351       cfg->_bbs[n->_idx]->find_remove(n);
 352       add_inst(n);
 353       cfg->_bbs.map(n->_idx,this);
 354     }
 355   }
 356 
 357   Compile *C = cfg->C;
 358   // proj==Op_True --> ne test; proj==Op_False --> eq test.
 359   // One of two graph shapes got matched:
 360   //   (IfTrue  (If (Bool NE (CmpP ptr NULL))))
 361   //   (IfFalse (If (Bool EQ (CmpP ptr NULL))))
 362   // NULL checks are always branch-if-eq.  If we see a IfTrue projection
 363   // then we are replacing a 'ne' test with a 'eq' NULL check test.
 364   // We need to flip the projections to keep the same semantics.
 365   if( proj->Opcode() == Op_IfTrue ) {
 366     // Swap order of projections in basic block to swap branch targets
 367     Node *tmp1 = _nodes[end_idx()+1];
 368     Node *tmp2 = _nodes[end_idx()+2];
 369     _nodes.map(end_idx()+1, tmp2);
 370     _nodes.map(end_idx()+2, tmp1);


 522     Node *m = n->in(i);
 523     if( !m ) continue;  // must see all nodes in block that precede call
 524     if( bbs[m->_idx] == this )
 525       set_next_call( m, next_call, bbs );
 526   }
 527 }
 528 
 529 //------------------------------needed_for_next_call---------------------------
 530 // Set the flag 'next_call' for each Node that is needed for the next call to
 531 // be scheduled.  This flag lets me bias scheduling so Nodes needed for the
 532 // next subroutine call get priority - basically it moves things NOT needed
 533 // for the next call till after the call.  This prevents me from trying to
 534 // carry lots of stuff live across a call.
 535 void Block::needed_for_next_call(Node *this_call, VectorSet &next_call, Block_Array &bbs) {
 536   // Find the next control-defining Node in this block
 537   Node* call = NULL;
 538   for (DUIterator_Fast imax, i = this_call->fast_outs(imax); i < imax; i++) {
 539     Node* m = this_call->fast_out(i);
 540     if( bbs[m->_idx] == this && // Local-block user
 541         m != this_call &&       // Not self-start node
 542         m->is_Call() )
 543       call = m;
 544       break;
 545   }
 546   if (call == NULL)  return;    // No next call (e.g., block end is near)
 547   // Set next-call for all inputs to this call
 548   set_next_call(call, next_call, bbs);
 549 }
 550 
 551 //------------------------------sched_call-------------------------------------
 552 uint Block::sched_call( Matcher &matcher, Block_Array &bbs, uint node_cnt, Node_List &worklist, int *ready_cnt, MachCallNode *mcall, VectorSet &next_call ) {
 553   RegMask regs;
 554 
 555   // Schedule all the users of the call right now.  All the users are
 556   // projection Nodes, so they must be scheduled next to the call.
 557   // Collect all the defined registers.
 558   for (DUIterator_Fast imax, i = mcall->fast_outs(imax); i < imax; i++) {
 559     Node* n = mcall->fast_out(i);
 560     assert( n->Opcode()==Op_MachProj, "" );
 561     --ready_cnt[n->_idx];
 562     assert( !ready_cnt[n->_idx], "" );
 563     // Schedule next to call
 564     _nodes.map(node_cnt++, n);
 565     // Collect defined registers
 566     regs.OR(n->out_RegMask());
 567     // Check for scheduling the next control-definer
 568     if( n->bottom_type() == Type::CONTROL )
 569       // Warm up next pile of heuristic bits
 570       needed_for_next_call(n, next_call, bbs);
 571 
 572     // Children of projections are now all ready
 573     for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) {
 574       Node* m = n->fast_out(j); // Get user
 575       if( bbs[m->_idx] != this ) continue;
 576       if( m->is_Phi() ) continue;
 577       if( !--ready_cnt[m->_idx] )
 578         worklist.push(m);
 579     }
 580 


 958 //------------------------------catch_cleanup_inter_block---------------------
 959 // Fix all input edges in use that reference "def".  The use is in a different
 960 // block than the def.
 961 static void catch_cleanup_inter_block(Node *use, Block *use_blk, Node *def, Block *def_blk, Block_Array &bbs, int n_clone_idx) {
 962   if( !use_blk ) return;        // Can happen if the use is a precedence edge
 963 
 964   Node *new_def = catch_cleanup_find_cloned_def(use_blk, def, def_blk, bbs, n_clone_idx);
 965   catch_cleanup_fix_all_inputs(use, def, new_def);
 966 }
 967 
 968 //------------------------------call_catch_cleanup-----------------------------
 969 // If we inserted any instructions between a Call and his CatchNode,
 970 // clone the instructions on all paths below the Catch.
 971 void Block::call_catch_cleanup(Block_Array &bbs) {
 972 
 973   // End of region to clone
 974   uint end = end_idx();
 975   if( !_nodes[end]->is_Catch() ) return;
 976   // Start of region to clone
 977   uint beg = end;
 978   while( _nodes[beg-1]->Opcode() != Op_MachProj ||
 979         !_nodes[beg-1]->in(0)->is_Call() ) {
 980     beg--;
 981     assert(beg > 0,"Catch cleanup walking beyond block boundary");
 982   }
 983   // Range of inserted instructions is [beg, end)
 984   if( beg == end ) return;
 985 
 986   // Clone along all Catch output paths.  Clone area between the 'beg' and
 987   // 'end' indices.
 988   for( uint i = 0; i < _num_succs; i++ ) {
 989     Block *sb = _succs[i];
 990     // Clone the entire area; ignoring the edge fixup for now.
 991     for( uint j = end; j > beg; j-- ) {
 992       // It is safe here to clone a node with anti_dependence
 993       // since clones dominate on each path.
 994       Node *clone = _nodes[j-1]->clone();
 995       sb->_nodes.insert( 1, clone );
 996       bbs.map(clone->_idx,sb);
 997     }
 998   }
 999 




 308   }
 309   // No candidate!
 310   if( !best ) return;
 311 
 312   // ---- Found an implicit null check
 313   extern int implicit_null_checks;
 314   implicit_null_checks++;
 315 
 316   if( is_decoden ) {
 317     // Check if we need to hoist decodeHeapOop_not_null first.
 318     Block *valb = cfg->_bbs[val->_idx];
 319     if( this != valb && this->_dom_depth < valb->_dom_depth ) {
 320       // Hoist it up to the end of the test block.
 321       valb->find_remove(val);
 322       this->add_inst(val);
 323       cfg->_bbs.map(val->_idx,this);
 324       // DecodeN on x86 may kill flags. Check for flag-killing projections
 325       // that also need to be hoisted.
 326       for (DUIterator_Fast jmax, j = val->fast_outs(jmax); j < jmax; j++) {
 327         Node* n = val->fast_out(j);
 328         if( n->is_MachProj() ) {
 329           cfg->_bbs[n->_idx]->find_remove(n);
 330           this->add_inst(n);
 331           cfg->_bbs.map(n->_idx,this);
 332         }
 333       }
 334     }
 335   }
 336   // Hoist the memory candidate up to the end of the test block.
 337   Block *old_block = cfg->_bbs[best->_idx];
 338   old_block->find_remove(best);
 339   add_inst(best);
 340   cfg->_bbs.map(best->_idx,this);
 341 
 342   // Move the control dependence
 343   if (best->in(0) && best->in(0) == old_block->_nodes[0])
 344     best->set_req(0, _nodes[0]);
 345 
 346   // Check for flag-killing projections that also need to be hoisted
 347   // Should be DU safe because no edge updates.
 348   for (DUIterator_Fast jmax, j = best->fast_outs(jmax); j < jmax; j++) {
 349     Node* n = best->fast_out(j);
 350     if( n->is_MachProj() ) {
 351       cfg->_bbs[n->_idx]->find_remove(n);
 352       add_inst(n);
 353       cfg->_bbs.map(n->_idx,this);
 354     }
 355   }
 356 
 357   Compile *C = cfg->C;
 358   // proj==Op_True --> ne test; proj==Op_False --> eq test.
 359   // One of two graph shapes got matched:
 360   //   (IfTrue  (If (Bool NE (CmpP ptr NULL))))
 361   //   (IfFalse (If (Bool EQ (CmpP ptr NULL))))
 362   // NULL checks are always branch-if-eq.  If we see a IfTrue projection
 363   // then we are replacing a 'ne' test with a 'eq' NULL check test.
 364   // We need to flip the projections to keep the same semantics.
 365   if( proj->Opcode() == Op_IfTrue ) {
 366     // Swap order of projections in basic block to swap branch targets
 367     Node *tmp1 = _nodes[end_idx()+1];
 368     Node *tmp2 = _nodes[end_idx()+2];
 369     _nodes.map(end_idx()+1, tmp2);
 370     _nodes.map(end_idx()+2, tmp1);


 522     Node *m = n->in(i);
 523     if( !m ) continue;  // must see all nodes in block that precede call
 524     if( bbs[m->_idx] == this )
 525       set_next_call( m, next_call, bbs );
 526   }
 527 }
 528 
 529 //------------------------------needed_for_next_call---------------------------
 530 // Set the flag 'next_call' for each Node that is needed for the next call to
 531 // be scheduled.  This flag lets me bias scheduling so Nodes needed for the
 532 // next subroutine call get priority - basically it moves things NOT needed
 533 // for the next call till after the call.  This prevents me from trying to
 534 // carry lots of stuff live across a call.
 535 void Block::needed_for_next_call(Node *this_call, VectorSet &next_call, Block_Array &bbs) {
 536   // Find the next control-defining Node in this block
 537   Node* call = NULL;
 538   for (DUIterator_Fast imax, i = this_call->fast_outs(imax); i < imax; i++) {
 539     Node* m = this_call->fast_out(i);
 540     if( bbs[m->_idx] == this && // Local-block user
 541         m != this_call &&       // Not self-start node
 542         m->is_MachCall() )
 543       call = m;
 544       break;
 545   }
 546   if (call == NULL)  return;    // No next call (e.g., block end is near)
 547   // Set next-call for all inputs to this call
 548   set_next_call(call, next_call, bbs);
 549 }
 550 
 551 //------------------------------sched_call-------------------------------------
 552 uint Block::sched_call( Matcher &matcher, Block_Array &bbs, uint node_cnt, Node_List &worklist, int *ready_cnt, MachCallNode *mcall, VectorSet &next_call ) {
 553   RegMask regs;
 554 
 555   // Schedule all the users of the call right now.  All the users are
 556   // projection Nodes, so they must be scheduled next to the call.
 557   // Collect all the defined registers.
 558   for (DUIterator_Fast imax, i = mcall->fast_outs(imax); i < imax; i++) {
 559     Node* n = mcall->fast_out(i);
 560     assert( n->is_MachProj(), "" );
 561     --ready_cnt[n->_idx];
 562     assert( !ready_cnt[n->_idx], "" );
 563     // Schedule next to call
 564     _nodes.map(node_cnt++, n);
 565     // Collect defined registers
 566     regs.OR(n->out_RegMask());
 567     // Check for scheduling the next control-definer
 568     if( n->bottom_type() == Type::CONTROL )
 569       // Warm up next pile of heuristic bits
 570       needed_for_next_call(n, next_call, bbs);
 571 
 572     // Children of projections are now all ready
 573     for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) {
 574       Node* m = n->fast_out(j); // Get user
 575       if( bbs[m->_idx] != this ) continue;
 576       if( m->is_Phi() ) continue;
 577       if( !--ready_cnt[m->_idx] )
 578         worklist.push(m);
 579     }
 580 


 958 //------------------------------catch_cleanup_inter_block---------------------
 959 // Fix all input edges in use that reference "def".  The use is in a different
 960 // block than the def.
 961 static void catch_cleanup_inter_block(Node *use, Block *use_blk, Node *def, Block *def_blk, Block_Array &bbs, int n_clone_idx) {
 962   if( !use_blk ) return;        // Can happen if the use is a precedence edge
 963 
 964   Node *new_def = catch_cleanup_find_cloned_def(use_blk, def, def_blk, bbs, n_clone_idx);
 965   catch_cleanup_fix_all_inputs(use, def, new_def);
 966 }
 967 
 968 //------------------------------call_catch_cleanup-----------------------------
 969 // If we inserted any instructions between a Call and his CatchNode,
 970 // clone the instructions on all paths below the Catch.
 971 void Block::call_catch_cleanup(Block_Array &bbs) {
 972 
 973   // End of region to clone
 974   uint end = end_idx();
 975   if( !_nodes[end]->is_Catch() ) return;
 976   // Start of region to clone
 977   uint beg = end;
 978   while(!_nodes[beg-1]->is_MachProj() ||
 979         !_nodes[beg-1]->in(0)->is_MachCall() ) {
 980     beg--;
 981     assert(beg > 0,"Catch cleanup walking beyond block boundary");
 982   }
 983   // Range of inserted instructions is [beg, end)
 984   if( beg == end ) return;
 985 
 986   // Clone along all Catch output paths.  Clone area between the 'beg' and
 987   // 'end' indices.
 988   for( uint i = 0; i < _num_succs; i++ ) {
 989     Block *sb = _succs[i];
 990     // Clone the entire area; ignoring the edge fixup for now.
 991     for( uint j = end; j > beg; j-- ) {
 992       // It is safe here to clone a node with anti_dependence
 993       // since clones dominate on each path.
 994       Node *clone = _nodes[j-1]->clone();
 995       sb->_nodes.insert( 1, clone );
 996       bbs.map(clone->_idx,sb);
 997     }
 998   }
 999 


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