< prev index next >

src/share/vm/opto/domgraph.cpp

Print this page




 196     Block* pop() { Block* b = _stack_top->block; _stack_top--; return b; }
 197     bool is_nonempty() { return (_stack_top >= _stack); }
 198     bool last_successor() { return (_stack_top->index == _stack_top->freq_idx); }
 199     Block* next_successor()  {
 200       int i = _stack_top->index;
 201       i++;
 202       if (i == _stack_top->freq_idx) i++;
 203       if (i >= (int)(_stack_top->block->_num_succs)) {
 204         i = _stack_top->freq_idx;   // process most frequent successor last
 205       }
 206       _stack_top->index = i;
 207       return _stack_top->block->_succs[ i ];
 208     }
 209 };
 210 
 211 // Find the index into the b->succs[] array of the most frequent successor.
 212 uint Block_Stack::most_frequent_successor( Block *b ) {
 213   uint freq_idx = 0;
 214   int eidx = b->end_idx();
 215   Node *n = b->get_node(eidx);
 216   int op = n->is_Mach() ? n->as_Mach()->ideal_Opcode() : n->Opcode();
 217   switch( op ) {
 218   case Op_CountedLoopEnd:
 219   case Op_If: {               // Split frequency amongst children
 220     float prob = n->as_MachIf()->_prob;
 221     // Is succ[0] the TRUE branch or the FALSE branch?
 222     if( b->get_node(eidx+1)->Opcode() == Op_IfFalse )
 223       prob = 1.0f - prob;
 224     freq_idx = prob < PROB_FAIR;      // freq=1 for succ[0] < 0.5 prob
 225     break;
 226   }
 227   case Op_Catch:                // Split frequency amongst children
 228     for( freq_idx = 0; freq_idx < b->_num_succs; freq_idx++ )
 229       if( b->get_node(eidx+1+freq_idx)->as_CatchProj()->_con == CatchProjNode::fall_through_index )
 230         break;
 231     // Handle case of no fall-thru (e.g., check-cast MUST throw an exception)
 232     if( freq_idx == b->_num_succs ) freq_idx = 0;
 233     break;
 234     // Currently there is no support for finding out the most
 235     // frequent successor for jumps, so lets just make it the first one
 236   case Op_Jump:
 237   case Op_Root:
 238   case Op_Goto:
 239   case Op_NeverBranch:
 240     freq_idx = 0;               // fall thru
 241     break;
 242   case Op_TailCall:
 243   case Op_TailJump:
 244   case Op_Return:
 245   case Op_Halt:
 246   case Op_Rethrow:
 247     break;
 248   default:
 249     ShouldNotReachHere();
 250   }
 251   return freq_idx;
 252 }
 253 
 254 // Perform DFS search.  Setup 'vertex' as DFS to vertex mapping.  Setup
 255 // 'semi' as vertex to DFS mapping.  Set 'parent' to DFS parent.
 256 uint PhaseCFG::do_DFS(Tarjan *tarjan, uint rpo_counter) {
 257   Block* root_block = get_root_block();
 258   uint pre_order = 1;
 259   // Allocate stack of size number_of_blocks() + 1 to avoid frequent realloc
 260   Block_Stack bstack(tarjan, number_of_blocks() + 1);
 261 
 262   // Push on stack the state for the first block
 263   bstack.push(pre_order, root_block);
 264   ++pre_order;
 265 
 266   while (bstack.is_nonempty()) {




 196     Block* pop() { Block* b = _stack_top->block; _stack_top--; return b; }
 197     bool is_nonempty() { return (_stack_top >= _stack); }
 198     bool last_successor() { return (_stack_top->index == _stack_top->freq_idx); }
 199     Block* next_successor()  {
 200       int i = _stack_top->index;
 201       i++;
 202       if (i == _stack_top->freq_idx) i++;
 203       if (i >= (int)(_stack_top->block->_num_succs)) {
 204         i = _stack_top->freq_idx;   // process most frequent successor last
 205       }
 206       _stack_top->index = i;
 207       return _stack_top->block->_succs[ i ];
 208     }
 209 };
 210 
 211 // Find the index into the b->succs[] array of the most frequent successor.
 212 uint Block_Stack::most_frequent_successor( Block *b ) {
 213   uint freq_idx = 0;
 214   int eidx = b->end_idx();
 215   Node *n = b->get_node(eidx);
 216   Opcodes op = n->is_Mach() ? n->as_Mach()->ideal_Opcode() : n->Opcode();
 217   switch( op ) {
 218   case Opcodes::Op_CountedLoopEnd:
 219   case Opcodes::Op_If: {               // Split frequency amongst children
 220     float prob = n->as_MachIf()->_prob;
 221     // Is succ[0] the TRUE branch or the FALSE branch?
 222     if( b->get_node(eidx+1)->Opcode() == Opcodes::Op_IfFalse )
 223       prob = 1.0f - prob;
 224     freq_idx = prob < PROB_FAIR;      // freq=1 for succ[0] < 0.5 prob
 225     break;
 226   }
 227   case Opcodes::Op_Catch:                // Split frequency amongst children
 228     for( freq_idx = 0; freq_idx < b->_num_succs; freq_idx++ )
 229       if( b->get_node(eidx+1+freq_idx)->as_CatchProj()->_con == CatchProjNode::fall_through_index )
 230         break;
 231     // Handle case of no fall-thru (e.g., check-cast MUST throw an exception)
 232     if( freq_idx == b->_num_succs ) freq_idx = 0;
 233     break;
 234     // Currently there is no support for finding out the most
 235     // frequent successor for jumps, so lets just make it the first one
 236   case Opcodes::Op_Jump:
 237   case Opcodes::Op_Root:
 238   case Opcodes::Op_Goto:
 239   case Opcodes::Op_NeverBranch:
 240     freq_idx = 0;               // fall thru
 241     break;
 242   case Opcodes::Op_TailCall:
 243   case Opcodes::Op_TailJump:
 244   case Opcodes::Op_Return:
 245   case Opcodes::Op_Halt:
 246   case Opcodes::Op_Rethrow:
 247     break;
 248   default:
 249     ShouldNotReachHere();
 250   }
 251   return freq_idx;
 252 }
 253 
 254 // Perform DFS search.  Setup 'vertex' as DFS to vertex mapping.  Setup
 255 // 'semi' as vertex to DFS mapping.  Set 'parent' to DFS parent.
 256 uint PhaseCFG::do_DFS(Tarjan *tarjan, uint rpo_counter) {
 257   Block* root_block = get_root_block();
 258   uint pre_order = 1;
 259   // Allocate stack of size number_of_blocks() + 1 to avoid frequent realloc
 260   Block_Stack bstack(tarjan, number_of_blocks() + 1);
 261 
 262   // Push on stack the state for the first block
 263   bstack.push(pre_order, root_block);
 264   ++pre_order;
 265 
 266   while (bstack.is_nonempty()) {


< prev index next >