1.1 --- a/src/share/vm/opto/block.cpp Wed Aug 10 14:06:57 2011 -0700 1.2 +++ b/src/share/vm/opto/block.cpp Thu Aug 11 12:08:11 2011 -0700 1.3 @@ -80,35 +80,37 @@ 1.4 1.5 uint Block::code_alignment() { 1.6 // Check for Root block 1.7 - if( _pre_order == 0 ) return CodeEntryAlignment; 1.8 + if (_pre_order == 0) return CodeEntryAlignment; 1.9 // Check for Start block 1.10 - if( _pre_order == 1 ) return InteriorEntryAlignment; 1.11 + if (_pre_order == 1) return InteriorEntryAlignment; 1.12 // Check for loop alignment 1.13 - if (has_loop_alignment()) return loop_alignment(); 1.14 + if (has_loop_alignment()) return loop_alignment(); 1.15 1.16 - return 1; // no particular alignment 1.17 + return relocInfo::addr_unit(); // no particular alignment 1.18 } 1.19 1.20 uint Block::compute_loop_alignment() { 1.21 Node *h = head(); 1.22 - if( h->is_Loop() && h->as_Loop()->is_inner_loop() ) { 1.23 + int unit_sz = relocInfo::addr_unit(); 1.24 + if (h->is_Loop() && h->as_Loop()->is_inner_loop()) { 1.25 // Pre- and post-loops have low trip count so do not bother with 1.26 // NOPs for align loop head. The constants are hidden from tuning 1.27 // but only because my "divide by 4" heuristic surely gets nearly 1.28 // all possible gain (a "do not align at all" heuristic has a 1.29 // chance of getting a really tiny gain). 1.30 - if( h->is_CountedLoop() && (h->as_CountedLoop()->is_pre_loop() || 1.31 - h->as_CountedLoop()->is_post_loop()) ) 1.32 - return (OptoLoopAlignment > 4) ? (OptoLoopAlignment>>2) : 1; 1.33 + if (h->is_CountedLoop() && (h->as_CountedLoop()->is_pre_loop() || 1.34 + h->as_CountedLoop()->is_post_loop())) { 1.35 + return (OptoLoopAlignment > 4*unit_sz) ? (OptoLoopAlignment>>2) : unit_sz; 1.36 + } 1.37 // Loops with low backedge frequency should not be aligned. 1.38 Node *n = h->in(LoopNode::LoopBackControl)->in(0); 1.39 - if( n->is_MachIf() && n->as_MachIf()->_prob < 0.01 ) { 1.40 - return 1; // Loop does not loop, more often than not! 1.41 + if (n->is_MachIf() && n->as_MachIf()->_prob < 0.01) { 1.42 + return unit_sz; // Loop does not loop, more often than not! 1.43 } 1.44 return OptoLoopAlignment; // Otherwise align loop head 1.45 } 1.46 1.47 - return 1; // no particular alignment 1.48 + return unit_sz; // no particular alignment 1.49 } 1.50 1.51 //----------------------------------------------------------------------------- 1.52 @@ -271,55 +273,55 @@ 1.53 1.54 //------------------------------dump------------------------------------------- 1.55 #ifndef PRODUCT 1.56 -void Block::dump_bidx(const Block* orig) const { 1.57 - if (_pre_order) tty->print("B%d",_pre_order); 1.58 - else tty->print("N%d", head()->_idx); 1.59 +void Block::dump_bidx(const Block* orig, outputStream* st) const { 1.60 + if (_pre_order) st->print("B%d",_pre_order); 1.61 + else st->print("N%d", head()->_idx); 1.62 1.63 if (Verbose && orig != this) { 1.64 // Dump the original block's idx 1.65 - tty->print(" ("); 1.66 - orig->dump_bidx(orig); 1.67 - tty->print(")"); 1.68 + st->print(" ("); 1.69 + orig->dump_bidx(orig, st); 1.70 + st->print(")"); 1.71 } 1.72 } 1.73 1.74 -void Block::dump_pred(const Block_Array *bbs, Block* orig) const { 1.75 +void Block::dump_pred(const Block_Array *bbs, Block* orig, outputStream* st) const { 1.76 if (is_connector()) { 1.77 for (uint i=1; i<num_preds(); i++) { 1.78 Block *p = ((*bbs)[pred(i)->_idx]); 1.79 - p->dump_pred(bbs, orig); 1.80 + p->dump_pred(bbs, orig, st); 1.81 } 1.82 } else { 1.83 - dump_bidx(orig); 1.84 - tty->print(" "); 1.85 + dump_bidx(orig, st); 1.86 + st->print(" "); 1.87 } 1.88 } 1.89 1.90 -void Block::dump_head( const Block_Array *bbs ) const { 1.91 +void Block::dump_head( const Block_Array *bbs, outputStream* st ) const { 1.92 // Print the basic block 1.93 - dump_bidx(this); 1.94 - tty->print(": #\t"); 1.95 + dump_bidx(this, st); 1.96 + st->print(": #\t"); 1.97 1.98 // Print the incoming CFG edges and the outgoing CFG edges 1.99 for( uint i=0; i<_num_succs; i++ ) { 1.100 - non_connector_successor(i)->dump_bidx(_succs[i]); 1.101 - tty->print(" "); 1.102 + non_connector_successor(i)->dump_bidx(_succs[i], st); 1.103 + st->print(" "); 1.104 } 1.105 - tty->print("<- "); 1.106 + st->print("<- "); 1.107 if( head()->is_block_start() ) { 1.108 for (uint i=1; i<num_preds(); i++) { 1.109 Node *s = pred(i); 1.110 if (bbs) { 1.111 Block *p = (*bbs)[s->_idx]; 1.112 - p->dump_pred(bbs, p); 1.113 + p->dump_pred(bbs, p, st); 1.114 } else { 1.115 while (!s->is_block_start()) 1.116 s = s->in(0); 1.117 - tty->print("N%d ", s->_idx ); 1.118 + st->print("N%d ", s->_idx ); 1.119 } 1.120 } 1.121 } else 1.122 - tty->print("BLOCK HEAD IS JUNK "); 1.123 + st->print("BLOCK HEAD IS JUNK "); 1.124 1.125 // Print loop, if any 1.126 const Block *bhead = this; // Head of self-loop 1.127 @@ -330,24 +332,24 @@ 1.128 while (bx->is_connector()) { 1.129 bx = (*bbs)[bx->pred(1)->_idx]; 1.130 } 1.131 - tty->print("\tLoop: B%d-B%d ", bhead->_pre_order, bx->_pre_order); 1.132 + st->print("\tLoop: B%d-B%d ", bhead->_pre_order, bx->_pre_order); 1.133 // Dump any loop-specific bits, especially for CountedLoops. 1.134 - loop->dump_spec(tty); 1.135 + loop->dump_spec(st); 1.136 } else if (has_loop_alignment()) { 1.137 - tty->print(" top-of-loop"); 1.138 + st->print(" top-of-loop"); 1.139 } 1.140 - tty->print(" Freq: %g",_freq); 1.141 + st->print(" Freq: %g",_freq); 1.142 if( Verbose || WizardMode ) { 1.143 - tty->print(" IDom: %d/#%d", _idom ? _idom->_pre_order : 0, _dom_depth); 1.144 - tty->print(" RegPressure: %d",_reg_pressure); 1.145 - tty->print(" IHRP Index: %d",_ihrp_index); 1.146 - tty->print(" FRegPressure: %d",_freg_pressure); 1.147 - tty->print(" FHRP Index: %d",_fhrp_index); 1.148 + st->print(" IDom: %d/#%d", _idom ? _idom->_pre_order : 0, _dom_depth); 1.149 + st->print(" RegPressure: %d",_reg_pressure); 1.150 + st->print(" IHRP Index: %d",_ihrp_index); 1.151 + st->print(" FRegPressure: %d",_freg_pressure); 1.152 + st->print(" FHRP Index: %d",_fhrp_index); 1.153 } 1.154 - tty->print_cr(""); 1.155 + st->print_cr(""); 1.156 } 1.157 1.158 -void Block::dump() const { dump(0); } 1.159 +void Block::dump() const { dump(NULL); } 1.160 1.161 void Block::dump( const Block_Array *bbs ) const { 1.162 dump_head(bbs); 1.163 @@ -441,9 +443,9 @@ 1.164 Block *bb = new (_bbs._arena) Block(_bbs._arena,p); 1.165 _bbs.map(p->_idx,bb); 1.166 _bbs.map(x->_idx,bb); 1.167 - if( x != p ) // Only for root is x == p 1.168 + if( x != p ) { // Only for root is x == p 1.169 bb->_nodes.push((Node*)x); 1.170 - 1.171 + } 1.172 // Now handle predecessors 1.173 ++sum; // Count 1 for self block 1.174 uint cnt = bb->num_preds();