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

src/share/vm/opto/lcm.cpp

Print this page




 402     if( n->is_MachProj() ) {
 403       get_block_for_node(n)->find_remove(n);
 404       block->add_inst(n);
 405       map_node_to_block(n, block);
 406     }
 407   }
 408 
 409   // proj==Op_True --> ne test; proj==Op_False --> eq test.
 410   // One of two graph shapes got matched:
 411   //   (IfTrue  (If (Bool NE (CmpP ptr NULL))))
 412   //   (IfFalse (If (Bool EQ (CmpP ptr NULL))))
 413   // NULL checks are always branch-if-eq.  If we see a IfTrue projection
 414   // then we are replacing a 'ne' test with a 'eq' NULL check test.
 415   // We need to flip the projections to keep the same semantics.
 416   if( proj->Opcode() == Op_IfTrue ) {
 417     // Swap order of projections in basic block to swap branch targets
 418     Node *tmp1 = block->get_node(block->end_idx()+1);
 419     Node *tmp2 = block->get_node(block->end_idx()+2);
 420     block->map_node(tmp2, block->end_idx()+1);
 421     block->map_node(tmp1, block->end_idx()+2);
 422     Node *tmp = new (C) Node(C->top()); // Use not NULL input
 423     tmp1->replace_by(tmp);
 424     tmp2->replace_by(tmp1);
 425     tmp->replace_by(tmp2);
 426     tmp->destruct();
 427   }
 428 
 429   // Remove the existing null check; use a new implicit null check instead.
 430   // Since schedule-local needs precise def-use info, we need to correct
 431   // it as well.
 432   Node *old_tst = proj->in(0);
 433   MachNode *nul_chk = new (C) MachNullCheckNode(old_tst->in(0),best,bidx);
 434   block->map_node(nul_chk, block->end_idx());
 435   map_node_to_block(nul_chk, block);
 436   // Redirect users of old_test to nul_chk
 437   for (DUIterator_Last i2min, i2 = old_tst->last_outs(i2min); i2 >= i2min; --i2)
 438     old_tst->last_out(i2)->set_req(0, nul_chk);
 439   // Clean-up any dead code
 440   for (uint i3 = 0; i3 < old_tst->req(); i3++)
 441     old_tst->set_req(i3, NULL);
 442 
 443   latency_from_uses(nul_chk);
 444   latency_from_uses(best);
 445 }
 446 
 447 
 448 //------------------------------select-----------------------------------------
 449 // Select a nice fellow from the worklist to schedule next. If there is only
 450 // one choice, then use it. Projections take top priority for correctness
 451 // reasons - if I see a projection, then it is next.  There are a number of
 452 // other special cases, for instructions that consume condition codes, et al.
 453 // These are chosen immediately. Some instructions are required to immediately


 654       Node* m = n->fast_out(j); // Get user
 655       if(get_block_for_node(m) != block) {
 656         continue;
 657       }
 658       if( m->is_Phi() ) continue;
 659       int m_cnt = ready_cnt.at(m->_idx)-1;
 660       ready_cnt.at_put(m->_idx, m_cnt);
 661       if( m_cnt == 0 )
 662         worklist.push(m);
 663     }
 664 
 665   }
 666 
 667   // Act as if the call defines the Frame Pointer.
 668   // Certainly the FP is alive and well after the call.
 669   regs.Insert(_matcher.c_frame_pointer());
 670 
 671   // Set all registers killed and not already defined by the call.
 672   uint r_cnt = mcall->tf()->range()->cnt();
 673   int op = mcall->ideal_Opcode();
 674   MachProjNode *proj = new (C) MachProjNode( mcall, r_cnt+1, RegMask::Empty, MachProjNode::fat_proj );
 675   map_node_to_block(proj, block);
 676   block->insert_node(proj, node_cnt++);
 677 
 678   // Select the right register save policy.
 679   const char * save_policy;
 680   switch (op) {
 681     case Op_CallRuntime:
 682     case Op_CallLeaf:
 683     case Op_CallLeafNoFP:
 684       // Calling C code so use C calling convention
 685       save_policy = _matcher._c_reg_save_policy;
 686       break;
 687 
 688     case Op_CallStaticJava:
 689     case Op_CallDynamicJava:
 690       // Calling Java code so use Java calling convention
 691       save_policy = _matcher._register_save_policy;
 692       break;
 693 
 694     default:


 883         for( uint i=0; i<worklist.size(); i++ ) { // Inspect entire worklist
 884           Node *n = worklist[i];      // Get Node on worklist
 885           tty->print(" %d", n->_idx);
 886         }
 887         tty->cr();
 888       }
 889     }
 890 
 891 #endif
 892     if( n->is_MachCall() ) {
 893       MachCallNode *mcall = n->as_MachCall();
 894       phi_cnt = sched_call(block, phi_cnt, worklist, ready_cnt, mcall, next_call);
 895       continue;
 896     }
 897 
 898     if (n->is_Mach() && n->as_Mach()->has_call()) {
 899       RegMask regs;
 900       regs.Insert(_matcher.c_frame_pointer());
 901       regs.OR(n->out_RegMask());
 902 
 903       MachProjNode *proj = new (C) MachProjNode( n, 1, RegMask::Empty, MachProjNode::fat_proj );
 904       map_node_to_block(proj, block);
 905       block->insert_node(proj, phi_cnt++);
 906 
 907       add_call_kills(proj, regs, _matcher._c_reg_save_policy, false);
 908     }
 909 
 910     // Children are now all ready
 911     for (DUIterator_Fast i5max, i5 = n->fast_outs(i5max); i5 < i5max; i5++) {
 912       Node* m = n->fast_out(i5); // Get user
 913       if (get_block_for_node(m) != block) {
 914         continue;
 915       }
 916       if( m->is_Phi() ) continue;
 917       if (m->_idx >= max_idx) { // new node, skip it
 918         assert(m->is_MachProj() && n->is_Mach() && n->as_Mach()->has_call(), "unexpected node types");
 919         continue;
 920       }
 921       int m_cnt = ready_cnt.at(m->_idx)-1;
 922       ready_cnt.at_put(m->_idx, m_cnt);
 923       if( m_cnt == 0 )




 402     if( n->is_MachProj() ) {
 403       get_block_for_node(n)->find_remove(n);
 404       block->add_inst(n);
 405       map_node_to_block(n, block);
 406     }
 407   }
 408 
 409   // proj==Op_True --> ne test; proj==Op_False --> eq test.
 410   // One of two graph shapes got matched:
 411   //   (IfTrue  (If (Bool NE (CmpP ptr NULL))))
 412   //   (IfFalse (If (Bool EQ (CmpP ptr NULL))))
 413   // NULL checks are always branch-if-eq.  If we see a IfTrue projection
 414   // then we are replacing a 'ne' test with a 'eq' NULL check test.
 415   // We need to flip the projections to keep the same semantics.
 416   if( proj->Opcode() == Op_IfTrue ) {
 417     // Swap order of projections in basic block to swap branch targets
 418     Node *tmp1 = block->get_node(block->end_idx()+1);
 419     Node *tmp2 = block->get_node(block->end_idx()+2);
 420     block->map_node(tmp2, block->end_idx()+1);
 421     block->map_node(tmp1, block->end_idx()+2);
 422     Node *tmp = new Node(C->top()); // Use not NULL input
 423     tmp1->replace_by(tmp);
 424     tmp2->replace_by(tmp1);
 425     tmp->replace_by(tmp2);
 426     tmp->destruct();
 427   }
 428 
 429   // Remove the existing null check; use a new implicit null check instead.
 430   // Since schedule-local needs precise def-use info, we need to correct
 431   // it as well.
 432   Node *old_tst = proj->in(0);
 433   MachNode *nul_chk = new MachNullCheckNode(old_tst->in(0),best,bidx);
 434   block->map_node(nul_chk, block->end_idx());
 435   map_node_to_block(nul_chk, block);
 436   // Redirect users of old_test to nul_chk
 437   for (DUIterator_Last i2min, i2 = old_tst->last_outs(i2min); i2 >= i2min; --i2)
 438     old_tst->last_out(i2)->set_req(0, nul_chk);
 439   // Clean-up any dead code
 440   for (uint i3 = 0; i3 < old_tst->req(); i3++)
 441     old_tst->set_req(i3, NULL);
 442 
 443   latency_from_uses(nul_chk);
 444   latency_from_uses(best);
 445 }
 446 
 447 
 448 //------------------------------select-----------------------------------------
 449 // Select a nice fellow from the worklist to schedule next. If there is only
 450 // one choice, then use it. Projections take top priority for correctness
 451 // reasons - if I see a projection, then it is next.  There are a number of
 452 // other special cases, for instructions that consume condition codes, et al.
 453 // These are chosen immediately. Some instructions are required to immediately


 654       Node* m = n->fast_out(j); // Get user
 655       if(get_block_for_node(m) != block) {
 656         continue;
 657       }
 658       if( m->is_Phi() ) continue;
 659       int m_cnt = ready_cnt.at(m->_idx)-1;
 660       ready_cnt.at_put(m->_idx, m_cnt);
 661       if( m_cnt == 0 )
 662         worklist.push(m);
 663     }
 664 
 665   }
 666 
 667   // Act as if the call defines the Frame Pointer.
 668   // Certainly the FP is alive and well after the call.
 669   regs.Insert(_matcher.c_frame_pointer());
 670 
 671   // Set all registers killed and not already defined by the call.
 672   uint r_cnt = mcall->tf()->range()->cnt();
 673   int op = mcall->ideal_Opcode();
 674   MachProjNode *proj = new MachProjNode( mcall, r_cnt+1, RegMask::Empty, MachProjNode::fat_proj );
 675   map_node_to_block(proj, block);
 676   block->insert_node(proj, node_cnt++);
 677 
 678   // Select the right register save policy.
 679   const char * save_policy;
 680   switch (op) {
 681     case Op_CallRuntime:
 682     case Op_CallLeaf:
 683     case Op_CallLeafNoFP:
 684       // Calling C code so use C calling convention
 685       save_policy = _matcher._c_reg_save_policy;
 686       break;
 687 
 688     case Op_CallStaticJava:
 689     case Op_CallDynamicJava:
 690       // Calling Java code so use Java calling convention
 691       save_policy = _matcher._register_save_policy;
 692       break;
 693 
 694     default:


 883         for( uint i=0; i<worklist.size(); i++ ) { // Inspect entire worklist
 884           Node *n = worklist[i];      // Get Node on worklist
 885           tty->print(" %d", n->_idx);
 886         }
 887         tty->cr();
 888       }
 889     }
 890 
 891 #endif
 892     if( n->is_MachCall() ) {
 893       MachCallNode *mcall = n->as_MachCall();
 894       phi_cnt = sched_call(block, phi_cnt, worklist, ready_cnt, mcall, next_call);
 895       continue;
 896     }
 897 
 898     if (n->is_Mach() && n->as_Mach()->has_call()) {
 899       RegMask regs;
 900       regs.Insert(_matcher.c_frame_pointer());
 901       regs.OR(n->out_RegMask());
 902 
 903       MachProjNode *proj = new MachProjNode( n, 1, RegMask::Empty, MachProjNode::fat_proj );
 904       map_node_to_block(proj, block);
 905       block->insert_node(proj, phi_cnt++);
 906 
 907       add_call_kills(proj, regs, _matcher._c_reg_save_policy, false);
 908     }
 909 
 910     // Children are now all ready
 911     for (DUIterator_Fast i5max, i5 = n->fast_outs(i5max); i5 < i5max; i5++) {
 912       Node* m = n->fast_out(i5); // Get user
 913       if (get_block_for_node(m) != block) {
 914         continue;
 915       }
 916       if( m->is_Phi() ) continue;
 917       if (m->_idx >= max_idx) { // new node, skip it
 918         assert(m->is_MachProj() && n->is_Mach() && n->as_Mach()->has_call(), "unexpected node types");
 919         continue;
 920       }
 921       int m_cnt = ready_cnt.at(m->_idx)-1;
 922       ready_cnt.at_put(m->_idx, m_cnt);
 923       if( m_cnt == 0 )


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