Mon, 27 May 2013 12:56:34 +0200
8015428: Remove unused CDS support from StringTable
Summary: The string in StringTable is not used by CDS anymore. Remove the unnecessary code in preparation for 8015422: Large performance hit when the StringTable is walked twice in Parallel Scavenge
Reviewed-by: pliden, tschatzl, coleenp
duke@435 | 1 | /* |
kvn@3882 | 2 | * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "compiler/oopMap.hpp" |
stefank@2314 | 27 | #include "memory/allocation.inline.hpp" |
stefank@2314 | 28 | #include "opto/addnode.hpp" |
stefank@2314 | 29 | #include "opto/block.hpp" |
stefank@2314 | 30 | #include "opto/callnode.hpp" |
stefank@2314 | 31 | #include "opto/cfgnode.hpp" |
stefank@2314 | 32 | #include "opto/chaitin.hpp" |
stefank@2314 | 33 | #include "opto/coalesce.hpp" |
stefank@2314 | 34 | #include "opto/connode.hpp" |
stefank@2314 | 35 | #include "opto/indexSet.hpp" |
stefank@2314 | 36 | #include "opto/machnode.hpp" |
stefank@2314 | 37 | #include "opto/memnode.hpp" |
stefank@2314 | 38 | #include "opto/opcodes.hpp" |
duke@435 | 39 | |
duke@435 | 40 | //============================================================================= |
duke@435 | 41 | //------------------------------IFG-------------------------------------------- |
duke@435 | 42 | PhaseIFG::PhaseIFG( Arena *arena ) : Phase(Interference_Graph), _arena(arena) { |
duke@435 | 43 | } |
duke@435 | 44 | |
duke@435 | 45 | //------------------------------init------------------------------------------- |
duke@435 | 46 | void PhaseIFG::init( uint maxlrg ) { |
duke@435 | 47 | _maxlrg = maxlrg; |
duke@435 | 48 | _yanked = new (_arena) VectorSet(_arena); |
duke@435 | 49 | _is_square = false; |
duke@435 | 50 | // Make uninitialized adjacency lists |
duke@435 | 51 | _adjs = (IndexSet*)_arena->Amalloc(sizeof(IndexSet)*maxlrg); |
duke@435 | 52 | // Also make empty live range structures |
duke@435 | 53 | _lrgs = (LRG *)_arena->Amalloc( maxlrg * sizeof(LRG) ); |
duke@435 | 54 | memset(_lrgs,0,sizeof(LRG)*maxlrg); |
duke@435 | 55 | // Init all to empty |
duke@435 | 56 | for( uint i = 0; i < maxlrg; i++ ) { |
duke@435 | 57 | _adjs[i].initialize(maxlrg); |
duke@435 | 58 | _lrgs[i].Set_All(); |
duke@435 | 59 | } |
duke@435 | 60 | } |
duke@435 | 61 | |
duke@435 | 62 | //------------------------------add-------------------------------------------- |
duke@435 | 63 | // Add edge between vertices a & b. These are sorted (triangular matrix), |
duke@435 | 64 | // then the smaller number is inserted in the larger numbered array. |
duke@435 | 65 | int PhaseIFG::add_edge( uint a, uint b ) { |
duke@435 | 66 | lrgs(a).invalid_degree(); |
duke@435 | 67 | lrgs(b).invalid_degree(); |
duke@435 | 68 | // Sort a and b, so that a is bigger |
duke@435 | 69 | assert( !_is_square, "only on triangular" ); |
duke@435 | 70 | if( a < b ) { uint tmp = a; a = b; b = tmp; } |
duke@435 | 71 | return _adjs[a].insert( b ); |
duke@435 | 72 | } |
duke@435 | 73 | |
duke@435 | 74 | //------------------------------add_vector------------------------------------- |
duke@435 | 75 | // Add an edge between 'a' and everything in the vector. |
duke@435 | 76 | void PhaseIFG::add_vector( uint a, IndexSet *vec ) { |
duke@435 | 77 | // IFG is triangular, so do the inserts where 'a' < 'b'. |
duke@435 | 78 | assert( !_is_square, "only on triangular" ); |
duke@435 | 79 | IndexSet *adjs_a = &_adjs[a]; |
duke@435 | 80 | if( !vec->count() ) return; |
duke@435 | 81 | |
duke@435 | 82 | IndexSetIterator elements(vec); |
duke@435 | 83 | uint neighbor; |
duke@435 | 84 | while ((neighbor = elements.next()) != 0) { |
duke@435 | 85 | add_edge( a, neighbor ); |
duke@435 | 86 | } |
duke@435 | 87 | } |
duke@435 | 88 | |
duke@435 | 89 | //------------------------------test------------------------------------------- |
duke@435 | 90 | // Is there an edge between a and b? |
duke@435 | 91 | int PhaseIFG::test_edge( uint a, uint b ) const { |
duke@435 | 92 | // Sort a and b, so that a is larger |
duke@435 | 93 | assert( !_is_square, "only on triangular" ); |
duke@435 | 94 | if( a < b ) { uint tmp = a; a = b; b = tmp; } |
duke@435 | 95 | return _adjs[a].member(b); |
duke@435 | 96 | } |
duke@435 | 97 | |
duke@435 | 98 | //------------------------------SquareUp--------------------------------------- |
duke@435 | 99 | // Convert triangular matrix to square matrix |
duke@435 | 100 | void PhaseIFG::SquareUp() { |
duke@435 | 101 | assert( !_is_square, "only on triangular" ); |
duke@435 | 102 | |
duke@435 | 103 | // Simple transpose |
duke@435 | 104 | for( uint i = 0; i < _maxlrg; i++ ) { |
duke@435 | 105 | IndexSetIterator elements(&_adjs[i]); |
duke@435 | 106 | uint datum; |
duke@435 | 107 | while ((datum = elements.next()) != 0) { |
duke@435 | 108 | _adjs[datum].insert( i ); |
duke@435 | 109 | } |
duke@435 | 110 | } |
duke@435 | 111 | _is_square = true; |
duke@435 | 112 | } |
duke@435 | 113 | |
duke@435 | 114 | //------------------------------Compute_Effective_Degree----------------------- |
duke@435 | 115 | // Compute effective degree in bulk |
duke@435 | 116 | void PhaseIFG::Compute_Effective_Degree() { |
duke@435 | 117 | assert( _is_square, "only on square" ); |
duke@435 | 118 | |
duke@435 | 119 | for( uint i = 0; i < _maxlrg; i++ ) |
duke@435 | 120 | lrgs(i).set_degree(effective_degree(i)); |
duke@435 | 121 | } |
duke@435 | 122 | |
duke@435 | 123 | //------------------------------test_edge_sq----------------------------------- |
duke@435 | 124 | int PhaseIFG::test_edge_sq( uint a, uint b ) const { |
duke@435 | 125 | assert( _is_square, "only on square" ); |
duke@435 | 126 | // Swap, so that 'a' has the lesser count. Then binary search is on |
duke@435 | 127 | // the smaller of a's list and b's list. |
duke@435 | 128 | if( neighbor_cnt(a) > neighbor_cnt(b) ) { uint tmp = a; a = b; b = tmp; } |
duke@435 | 129 | //return _adjs[a].unordered_member(b); |
duke@435 | 130 | return _adjs[a].member(b); |
duke@435 | 131 | } |
duke@435 | 132 | |
duke@435 | 133 | //------------------------------Union------------------------------------------ |
duke@435 | 134 | // Union edges of B into A |
duke@435 | 135 | void PhaseIFG::Union( uint a, uint b ) { |
duke@435 | 136 | assert( _is_square, "only on square" ); |
duke@435 | 137 | IndexSet *A = &_adjs[a]; |
duke@435 | 138 | IndexSetIterator b_elements(&_adjs[b]); |
duke@435 | 139 | uint datum; |
duke@435 | 140 | while ((datum = b_elements.next()) != 0) { |
duke@435 | 141 | if(A->insert(datum)) { |
duke@435 | 142 | _adjs[datum].insert(a); |
duke@435 | 143 | lrgs(a).invalid_degree(); |
duke@435 | 144 | lrgs(datum).invalid_degree(); |
duke@435 | 145 | } |
duke@435 | 146 | } |
duke@435 | 147 | } |
duke@435 | 148 | |
duke@435 | 149 | //------------------------------remove_node------------------------------------ |
duke@435 | 150 | // Yank a Node and all connected edges from the IFG. Return a |
duke@435 | 151 | // list of neighbors (edges) yanked. |
duke@435 | 152 | IndexSet *PhaseIFG::remove_node( uint a ) { |
duke@435 | 153 | assert( _is_square, "only on square" ); |
duke@435 | 154 | assert( !_yanked->test(a), "" ); |
duke@435 | 155 | _yanked->set(a); |
duke@435 | 156 | |
duke@435 | 157 | // I remove the LRG from all neighbors. |
duke@435 | 158 | IndexSetIterator elements(&_adjs[a]); |
duke@435 | 159 | LRG &lrg_a = lrgs(a); |
duke@435 | 160 | uint datum; |
duke@435 | 161 | while ((datum = elements.next()) != 0) { |
duke@435 | 162 | _adjs[datum].remove(a); |
duke@435 | 163 | lrgs(datum).inc_degree( -lrg_a.compute_degree(lrgs(datum)) ); |
duke@435 | 164 | } |
duke@435 | 165 | return neighbors(a); |
duke@435 | 166 | } |
duke@435 | 167 | |
duke@435 | 168 | //------------------------------re_insert-------------------------------------- |
duke@435 | 169 | // Re-insert a yanked Node. |
duke@435 | 170 | void PhaseIFG::re_insert( uint a ) { |
duke@435 | 171 | assert( _is_square, "only on square" ); |
duke@435 | 172 | assert( _yanked->test(a), "" ); |
duke@435 | 173 | (*_yanked) >>= a; |
duke@435 | 174 | |
duke@435 | 175 | IndexSetIterator elements(&_adjs[a]); |
duke@435 | 176 | uint datum; |
duke@435 | 177 | while ((datum = elements.next()) != 0) { |
duke@435 | 178 | _adjs[datum].insert(a); |
duke@435 | 179 | lrgs(datum).invalid_degree(); |
duke@435 | 180 | } |
duke@435 | 181 | } |
duke@435 | 182 | |
duke@435 | 183 | //------------------------------compute_degree--------------------------------- |
duke@435 | 184 | // Compute the degree between 2 live ranges. If both live ranges are |
duke@435 | 185 | // aligned-adjacent powers-of-2 then we use the MAX size. If either is |
duke@435 | 186 | // mis-aligned (or for Fat-Projections, not-adjacent) then we have to |
duke@435 | 187 | // MULTIPLY the sizes. Inspect Brigg's thesis on register pairs to see why |
duke@435 | 188 | // this is so. |
duke@435 | 189 | int LRG::compute_degree( LRG &l ) const { |
duke@435 | 190 | int tmp; |
duke@435 | 191 | int num_regs = _num_regs; |
duke@435 | 192 | int nregs = l.num_regs(); |
duke@435 | 193 | tmp = (_fat_proj || l._fat_proj) // either is a fat-proj? |
duke@435 | 194 | ? (num_regs * nregs) // then use product |
duke@435 | 195 | : MAX2(num_regs,nregs); // else use max |
duke@435 | 196 | return tmp; |
duke@435 | 197 | } |
duke@435 | 198 | |
duke@435 | 199 | //------------------------------effective_degree------------------------------- |
duke@435 | 200 | // Compute effective degree for this live range. If both live ranges are |
duke@435 | 201 | // aligned-adjacent powers-of-2 then we use the MAX size. If either is |
duke@435 | 202 | // mis-aligned (or for Fat-Projections, not-adjacent) then we have to |
duke@435 | 203 | // MULTIPLY the sizes. Inspect Brigg's thesis on register pairs to see why |
duke@435 | 204 | // this is so. |
duke@435 | 205 | int PhaseIFG::effective_degree( uint lidx ) const { |
duke@435 | 206 | int eff = 0; |
duke@435 | 207 | int num_regs = lrgs(lidx).num_regs(); |
duke@435 | 208 | int fat_proj = lrgs(lidx)._fat_proj; |
duke@435 | 209 | IndexSet *s = neighbors(lidx); |
duke@435 | 210 | IndexSetIterator elements(s); |
duke@435 | 211 | uint nidx; |
duke@435 | 212 | while((nidx = elements.next()) != 0) { |
duke@435 | 213 | LRG &lrgn = lrgs(nidx); |
duke@435 | 214 | int nregs = lrgn.num_regs(); |
duke@435 | 215 | eff += (fat_proj || lrgn._fat_proj) // either is a fat-proj? |
duke@435 | 216 | ? (num_regs * nregs) // then use product |
duke@435 | 217 | : MAX2(num_regs,nregs); // else use max |
duke@435 | 218 | } |
duke@435 | 219 | return eff; |
duke@435 | 220 | } |
duke@435 | 221 | |
duke@435 | 222 | |
duke@435 | 223 | #ifndef PRODUCT |
duke@435 | 224 | //------------------------------dump------------------------------------------- |
duke@435 | 225 | void PhaseIFG::dump() const { |
duke@435 | 226 | tty->print_cr("-- Interference Graph --%s--", |
duke@435 | 227 | _is_square ? "square" : "triangular" ); |
duke@435 | 228 | if( _is_square ) { |
duke@435 | 229 | for( uint i = 0; i < _maxlrg; i++ ) { |
duke@435 | 230 | tty->print( (*_yanked)[i] ? "XX " : " "); |
duke@435 | 231 | tty->print("L%d: { ",i); |
duke@435 | 232 | IndexSetIterator elements(&_adjs[i]); |
duke@435 | 233 | uint datum; |
duke@435 | 234 | while ((datum = elements.next()) != 0) { |
duke@435 | 235 | tty->print("L%d ", datum); |
duke@435 | 236 | } |
duke@435 | 237 | tty->print_cr("}"); |
duke@435 | 238 | |
duke@435 | 239 | } |
duke@435 | 240 | return; |
duke@435 | 241 | } |
duke@435 | 242 | |
duke@435 | 243 | // Triangular |
duke@435 | 244 | for( uint i = 0; i < _maxlrg; i++ ) { |
duke@435 | 245 | uint j; |
duke@435 | 246 | tty->print( (*_yanked)[i] ? "XX " : " "); |
duke@435 | 247 | tty->print("L%d: { ",i); |
duke@435 | 248 | for( j = _maxlrg; j > i; j-- ) |
duke@435 | 249 | if( test_edge(j - 1,i) ) { |
duke@435 | 250 | tty->print("L%d ",j - 1); |
duke@435 | 251 | } |
duke@435 | 252 | tty->print("| "); |
duke@435 | 253 | IndexSetIterator elements(&_adjs[i]); |
duke@435 | 254 | uint datum; |
duke@435 | 255 | while ((datum = elements.next()) != 0) { |
duke@435 | 256 | tty->print("L%d ", datum); |
duke@435 | 257 | } |
duke@435 | 258 | tty->print("}\n"); |
duke@435 | 259 | } |
duke@435 | 260 | tty->print("\n"); |
duke@435 | 261 | } |
duke@435 | 262 | |
duke@435 | 263 | //------------------------------stats------------------------------------------ |
duke@435 | 264 | void PhaseIFG::stats() const { |
duke@435 | 265 | ResourceMark rm; |
duke@435 | 266 | int *h_cnt = NEW_RESOURCE_ARRAY(int,_maxlrg*2); |
duke@435 | 267 | memset( h_cnt, 0, sizeof(int)*_maxlrg*2 ); |
duke@435 | 268 | uint i; |
duke@435 | 269 | for( i = 0; i < _maxlrg; i++ ) { |
duke@435 | 270 | h_cnt[neighbor_cnt(i)]++; |
duke@435 | 271 | } |
duke@435 | 272 | tty->print_cr("--Histogram of counts--"); |
duke@435 | 273 | for( i = 0; i < _maxlrg*2; i++ ) |
duke@435 | 274 | if( h_cnt[i] ) |
duke@435 | 275 | tty->print("%d/%d ",i,h_cnt[i]); |
duke@435 | 276 | tty->print_cr(""); |
duke@435 | 277 | } |
duke@435 | 278 | |
duke@435 | 279 | //------------------------------verify----------------------------------------- |
duke@435 | 280 | void PhaseIFG::verify( const PhaseChaitin *pc ) const { |
duke@435 | 281 | // IFG is square, sorted and no need for Find |
duke@435 | 282 | for( uint i = 0; i < _maxlrg; i++ ) { |
duke@435 | 283 | assert(!((*_yanked)[i]) || !neighbor_cnt(i), "Is removed completely" ); |
duke@435 | 284 | IndexSet *set = &_adjs[i]; |
duke@435 | 285 | IndexSetIterator elements(set); |
duke@435 | 286 | uint idx; |
duke@435 | 287 | uint last = 0; |
duke@435 | 288 | while ((idx = elements.next()) != 0) { |
neliasso@4949 | 289 | assert(idx != i, "Must have empty diagonal"); |
neliasso@4949 | 290 | assert(pc->_lrg_map.find_const(idx) == idx, "Must not need Find"); |
neliasso@4949 | 291 | assert(_adjs[idx].member(i), "IFG not square"); |
neliasso@4949 | 292 | assert(!(*_yanked)[idx], "No yanked neighbors"); |
neliasso@4949 | 293 | assert(last < idx, "not sorted increasing"); |
duke@435 | 294 | last = idx; |
duke@435 | 295 | } |
neliasso@4949 | 296 | assert(!lrgs(i)._degree_valid || effective_degree(i) == lrgs(i).degree(), "degree is valid but wrong"); |
duke@435 | 297 | } |
duke@435 | 298 | } |
duke@435 | 299 | #endif |
duke@435 | 300 | |
duke@435 | 301 | //------------------------------interfere_with_live---------------------------- |
duke@435 | 302 | // Interfere this register with everything currently live. Use the RegMasks |
duke@435 | 303 | // to trim the set of possible interferences. Return a count of register-only |
twisti@1040 | 304 | // interferences as an estimate of register pressure. |
duke@435 | 305 | void PhaseChaitin::interfere_with_live( uint r, IndexSet *liveout ) { |
duke@435 | 306 | uint retval = 0; |
duke@435 | 307 | // Interfere with everything live. |
duke@435 | 308 | const RegMask &rm = lrgs(r).mask(); |
duke@435 | 309 | // Check for interference by checking overlap of regmasks. |
duke@435 | 310 | // Only interfere if acceptable register masks overlap. |
duke@435 | 311 | IndexSetIterator elements(liveout); |
duke@435 | 312 | uint l; |
duke@435 | 313 | while( (l = elements.next()) != 0 ) |
duke@435 | 314 | if( rm.overlap( lrgs(l).mask() ) ) |
duke@435 | 315 | _ifg->add_edge( r, l ); |
duke@435 | 316 | } |
duke@435 | 317 | |
duke@435 | 318 | //------------------------------build_ifg_virtual------------------------------ |
duke@435 | 319 | // Actually build the interference graph. Uses virtual registers only, no |
duke@435 | 320 | // physical register masks. This allows me to be very aggressive when |
duke@435 | 321 | // coalescing copies. Some of this aggressiveness will have to be undone |
duke@435 | 322 | // later, but I'd rather get all the copies I can now (since unremoved copies |
duke@435 | 323 | // at this point can end up in bad places). Copies I re-insert later I have |
duke@435 | 324 | // more opportunity to insert them in low-frequency locations. |
duke@435 | 325 | void PhaseChaitin::build_ifg_virtual( ) { |
duke@435 | 326 | |
duke@435 | 327 | // For all blocks (in any order) do... |
duke@435 | 328 | for( uint i=0; i<_cfg._num_blocks; i++ ) { |
duke@435 | 329 | Block *b = _cfg._blocks[i]; |
duke@435 | 330 | IndexSet *liveout = _live->live(b); |
duke@435 | 331 | |
duke@435 | 332 | // The IFG is built by a single reverse pass over each basic block. |
duke@435 | 333 | // Starting with the known live-out set, we remove things that get |
duke@435 | 334 | // defined and add things that become live (essentially executing one |
duke@435 | 335 | // pass of a standard LIVE analysis). Just before a Node defines a value |
duke@435 | 336 | // (and removes it from the live-ness set) that value is certainly live. |
duke@435 | 337 | // The defined value interferes with everything currently live. The |
duke@435 | 338 | // value is then removed from the live-ness set and it's inputs are |
duke@435 | 339 | // added to the live-ness set. |
duke@435 | 340 | for( uint j = b->end_idx() + 1; j > 1; j-- ) { |
duke@435 | 341 | Node *n = b->_nodes[j-1]; |
duke@435 | 342 | |
duke@435 | 343 | // Get value being defined |
neliasso@4949 | 344 | uint r = _lrg_map.live_range_id(n); |
duke@435 | 345 | |
duke@435 | 346 | // Some special values do not allocate |
neliasso@4949 | 347 | if (r) { |
duke@435 | 348 | |
duke@435 | 349 | // Remove from live-out set |
duke@435 | 350 | liveout->remove(r); |
duke@435 | 351 | |
duke@435 | 352 | // Copies do not define a new value and so do not interfere. |
duke@435 | 353 | // Remove the copies source from the liveout set before interfering. |
duke@435 | 354 | uint idx = n->is_Copy(); |
neliasso@4949 | 355 | if (idx) { |
neliasso@4949 | 356 | liveout->remove(_lrg_map.live_range_id(n->in(idx))); |
neliasso@4949 | 357 | } |
duke@435 | 358 | |
duke@435 | 359 | // Interfere with everything live |
neliasso@4949 | 360 | interfere_with_live(r, liveout); |
duke@435 | 361 | } |
duke@435 | 362 | |
duke@435 | 363 | // Make all inputs live |
neliasso@4949 | 364 | if (!n->is_Phi()) { // Phi function uses come from prior block |
neliasso@4949 | 365 | for(uint k = 1; k < n->req(); k++) { |
neliasso@4949 | 366 | liveout->insert(_lrg_map.live_range_id(n->in(k))); |
neliasso@4949 | 367 | } |
duke@435 | 368 | } |
duke@435 | 369 | |
duke@435 | 370 | // 2-address instructions always have the defined value live |
duke@435 | 371 | // on entry to the instruction, even though it is being defined |
duke@435 | 372 | // by the instruction. We pretend a virtual copy sits just prior |
duke@435 | 373 | // to the instruction and kills the src-def'd register. |
duke@435 | 374 | // In other words, for 2-address instructions the defined value |
duke@435 | 375 | // interferes with all inputs. |
duke@435 | 376 | uint idx; |
duke@435 | 377 | if( n->is_Mach() && (idx = n->as_Mach()->two_adr()) ) { |
duke@435 | 378 | const MachNode *mach = n->as_Mach(); |
duke@435 | 379 | // Sometimes my 2-address ADDs are commuted in a bad way. |
duke@435 | 380 | // We generally want the USE-DEF register to refer to the |
duke@435 | 381 | // loop-varying quantity, to avoid a copy. |
duke@435 | 382 | uint op = mach->ideal_Opcode(); |
duke@435 | 383 | // Check that mach->num_opnds() == 3 to ensure instruction is |
duke@435 | 384 | // not subsuming constants, effectively excludes addI_cin_imm |
duke@435 | 385 | // Can NOT swap for instructions like addI_cin_imm since it |
duke@435 | 386 | // is adding zero to yhi + carry and the second ideal-input |
duke@435 | 387 | // points to the result of adding low-halves. |
duke@435 | 388 | // Checking req() and num_opnds() does NOT distinguish addI_cout from addI_cout_imm |
duke@435 | 389 | if( (op == Op_AddI && mach->req() == 3 && mach->num_opnds() == 3) && |
duke@435 | 390 | n->in(1)->bottom_type()->base() == Type::Int && |
duke@435 | 391 | // See if the ADD is involved in a tight data loop the wrong way |
duke@435 | 392 | n->in(2)->is_Phi() && |
duke@435 | 393 | n->in(2)->in(2) == n ) { |
duke@435 | 394 | Node *tmp = n->in(1); |
duke@435 | 395 | n->set_req( 1, n->in(2) ); |
duke@435 | 396 | n->set_req( 2, tmp ); |
duke@435 | 397 | } |
duke@435 | 398 | // Defined value interferes with all inputs |
neliasso@4949 | 399 | uint lidx = _lrg_map.live_range_id(n->in(idx)); |
neliasso@4949 | 400 | for (uint k = 1; k < n->req(); k++) { |
neliasso@4949 | 401 | uint kidx = _lrg_map.live_range_id(n->in(k)); |
neliasso@4949 | 402 | if (kidx != lidx) { |
neliasso@4949 | 403 | _ifg->add_edge(r, kidx); |
neliasso@4949 | 404 | } |
duke@435 | 405 | } |
duke@435 | 406 | } |
duke@435 | 407 | } // End of forall instructions in block |
duke@435 | 408 | } // End of forall blocks |
duke@435 | 409 | } |
duke@435 | 410 | |
duke@435 | 411 | //------------------------------count_int_pressure----------------------------- |
duke@435 | 412 | uint PhaseChaitin::count_int_pressure( IndexSet *liveout ) { |
duke@435 | 413 | IndexSetIterator elements(liveout); |
duke@435 | 414 | uint lidx; |
duke@435 | 415 | uint cnt = 0; |
duke@435 | 416 | while ((lidx = elements.next()) != 0) { |
duke@435 | 417 | if( lrgs(lidx).mask().is_UP() && |
duke@435 | 418 | lrgs(lidx).mask_size() && |
duke@435 | 419 | !lrgs(lidx)._is_float && |
kvn@3882 | 420 | !lrgs(lidx)._is_vector && |
duke@435 | 421 | lrgs(lidx).mask().overlap(*Matcher::idealreg2regmask[Op_RegI]) ) |
duke@435 | 422 | cnt += lrgs(lidx).reg_pressure(); |
duke@435 | 423 | } |
duke@435 | 424 | return cnt; |
duke@435 | 425 | } |
duke@435 | 426 | |
duke@435 | 427 | //------------------------------count_float_pressure--------------------------- |
duke@435 | 428 | uint PhaseChaitin::count_float_pressure( IndexSet *liveout ) { |
duke@435 | 429 | IndexSetIterator elements(liveout); |
duke@435 | 430 | uint lidx; |
duke@435 | 431 | uint cnt = 0; |
duke@435 | 432 | while ((lidx = elements.next()) != 0) { |
duke@435 | 433 | if( lrgs(lidx).mask().is_UP() && |
duke@435 | 434 | lrgs(lidx).mask_size() && |
kvn@3882 | 435 | (lrgs(lidx)._is_float || lrgs(lidx)._is_vector)) |
duke@435 | 436 | cnt += lrgs(lidx).reg_pressure(); |
duke@435 | 437 | } |
duke@435 | 438 | return cnt; |
duke@435 | 439 | } |
duke@435 | 440 | |
duke@435 | 441 | //------------------------------lower_pressure--------------------------------- |
duke@435 | 442 | // Adjust register pressure down by 1. Capture last hi-to-low transition, |
duke@435 | 443 | static void lower_pressure( LRG *lrg, uint where, Block *b, uint *pressure, uint *hrp_index ) { |
kvn@3882 | 444 | if (lrg->mask().is_UP() && lrg->mask_size()) { |
kvn@3882 | 445 | if (lrg->_is_float || lrg->_is_vector) { |
duke@435 | 446 | pressure[1] -= lrg->reg_pressure(); |
duke@435 | 447 | if( pressure[1] == (uint)FLOATPRESSURE ) { |
duke@435 | 448 | hrp_index[1] = where; |
neliasso@4867 | 449 | if( pressure[1] > b->_freg_pressure ) |
neliasso@4867 | 450 | b->_freg_pressure = pressure[1]+1; |
duke@435 | 451 | } |
duke@435 | 452 | } else if( lrg->mask().overlap(*Matcher::idealreg2regmask[Op_RegI]) ) { |
duke@435 | 453 | pressure[0] -= lrg->reg_pressure(); |
duke@435 | 454 | if( pressure[0] == (uint)INTPRESSURE ) { |
duke@435 | 455 | hrp_index[0] = where; |
neliasso@4867 | 456 | if( pressure[0] > b->_reg_pressure ) |
neliasso@4867 | 457 | b->_reg_pressure = pressure[0]+1; |
duke@435 | 458 | } |
duke@435 | 459 | } |
duke@435 | 460 | } |
duke@435 | 461 | } |
duke@435 | 462 | |
duke@435 | 463 | //------------------------------build_ifg_physical----------------------------- |
duke@435 | 464 | // Build the interference graph using physical registers when available. |
duke@435 | 465 | // That is, if 2 live ranges are simultaneously alive but in their acceptable |
duke@435 | 466 | // register sets do not overlap, then they do not interfere. |
duke@435 | 467 | uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) { |
duke@435 | 468 | NOT_PRODUCT( Compile::TracePhase t3("buildIFG", &_t_buildIFGphysical, TimeCompiler); ) |
duke@435 | 469 | |
duke@435 | 470 | uint spill_reg = LRG::SPILL_REG; |
duke@435 | 471 | uint must_spill = 0; |
duke@435 | 472 | |
duke@435 | 473 | // For all blocks (in any order) do... |
duke@435 | 474 | for( uint i = 0; i < _cfg._num_blocks; i++ ) { |
duke@435 | 475 | Block *b = _cfg._blocks[i]; |
duke@435 | 476 | // Clone (rather than smash in place) the liveout info, so it is alive |
duke@435 | 477 | // for the "collect_gc_info" phase later. |
duke@435 | 478 | IndexSet liveout(_live->live(b)); |
duke@435 | 479 | uint last_inst = b->end_idx(); |
kvn@1001 | 480 | // Compute first nonphi node index |
kvn@1001 | 481 | uint first_inst; |
kvn@1001 | 482 | for( first_inst = 1; first_inst < last_inst; first_inst++ ) |
kvn@1001 | 483 | if( !b->_nodes[first_inst]->is_Phi() ) |
duke@435 | 484 | break; |
duke@435 | 485 | |
kvn@1001 | 486 | // Spills could be inserted before CreateEx node which should be |
kvn@1001 | 487 | // first instruction in block after Phis. Move CreateEx up. |
kvn@1001 | 488 | for( uint insidx = first_inst; insidx < last_inst; insidx++ ) { |
kvn@1001 | 489 | Node *ex = b->_nodes[insidx]; |
kvn@1001 | 490 | if( ex->is_SpillCopy() ) continue; |
kvn@1001 | 491 | if( insidx > first_inst && ex->is_Mach() && |
kvn@1001 | 492 | ex->as_Mach()->ideal_Opcode() == Op_CreateEx ) { |
kvn@1001 | 493 | // If the CreateEx isn't above all the MachSpillCopies |
kvn@1001 | 494 | // then move it to the top. |
kvn@1001 | 495 | b->_nodes.remove(insidx); |
kvn@1001 | 496 | b->_nodes.insert(first_inst, ex); |
kvn@1001 | 497 | } |
kvn@1001 | 498 | // Stop once a CreateEx or any other node is found |
kvn@1001 | 499 | break; |
kvn@1001 | 500 | } |
kvn@1001 | 501 | |
duke@435 | 502 | // Reset block's register pressure values for each ifg construction |
duke@435 | 503 | uint pressure[2], hrp_index[2]; |
duke@435 | 504 | pressure[0] = pressure[1] = 0; |
duke@435 | 505 | hrp_index[0] = hrp_index[1] = last_inst+1; |
duke@435 | 506 | b->_reg_pressure = b->_freg_pressure = 0; |
duke@435 | 507 | // Liveout things are presumed live for the whole block. We accumulate |
duke@435 | 508 | // 'area' accordingly. If they get killed in the block, we'll subtract |
duke@435 | 509 | // the unused part of the block from the area. |
kvn@1001 | 510 | int inst_count = last_inst - first_inst; |
rasbold@804 | 511 | double cost = (inst_count <= 0) ? 0.0 : b->_freq * double(inst_count); |
rasbold@804 | 512 | assert(!(cost < 0.0), "negative spill cost" ); |
duke@435 | 513 | IndexSetIterator elements(&liveout); |
duke@435 | 514 | uint lidx; |
duke@435 | 515 | while ((lidx = elements.next()) != 0) { |
duke@435 | 516 | LRG &lrg = lrgs(lidx); |
duke@435 | 517 | lrg._area += cost; |
duke@435 | 518 | // Compute initial register pressure |
kvn@3882 | 519 | if (lrg.mask().is_UP() && lrg.mask_size()) { |
kvn@3882 | 520 | if (lrg._is_float || lrg._is_vector) { // Count float pressure |
duke@435 | 521 | pressure[1] += lrg.reg_pressure(); |
duke@435 | 522 | if( pressure[1] > b->_freg_pressure ) |
duke@435 | 523 | b->_freg_pressure = pressure[1]; |
duke@435 | 524 | // Count int pressure, but do not count the SP, flags |
duke@435 | 525 | } else if( lrgs(lidx).mask().overlap(*Matcher::idealreg2regmask[Op_RegI]) ) { |
duke@435 | 526 | pressure[0] += lrg.reg_pressure(); |
duke@435 | 527 | if( pressure[0] > b->_reg_pressure ) |
duke@435 | 528 | b->_reg_pressure = pressure[0]; |
duke@435 | 529 | } |
duke@435 | 530 | } |
duke@435 | 531 | } |
duke@435 | 532 | assert( pressure[0] == count_int_pressure (&liveout), "" ); |
duke@435 | 533 | assert( pressure[1] == count_float_pressure(&liveout), "" ); |
duke@435 | 534 | |
duke@435 | 535 | // The IFG is built by a single reverse pass over each basic block. |
duke@435 | 536 | // Starting with the known live-out set, we remove things that get |
duke@435 | 537 | // defined and add things that become live (essentially executing one |
duke@435 | 538 | // pass of a standard LIVE analysis). Just before a Node defines a value |
duke@435 | 539 | // (and removes it from the live-ness set) that value is certainly live. |
duke@435 | 540 | // The defined value interferes with everything currently live. The |
duke@435 | 541 | // value is then removed from the live-ness set and it's inputs are added |
duke@435 | 542 | // to the live-ness set. |
duke@435 | 543 | uint j; |
duke@435 | 544 | for( j = last_inst + 1; j > 1; j-- ) { |
duke@435 | 545 | Node *n = b->_nodes[j - 1]; |
duke@435 | 546 | |
duke@435 | 547 | // Get value being defined |
neliasso@4949 | 548 | uint r = _lrg_map.live_range_id(n); |
duke@435 | 549 | |
duke@435 | 550 | // Some special values do not allocate |
neliasso@4949 | 551 | if(r) { |
duke@435 | 552 | // A DEF normally costs block frequency; rematerialized values are |
duke@435 | 553 | // removed from the DEF sight, so LOWER costs here. |
duke@435 | 554 | lrgs(r)._cost += n->rematerialize() ? 0 : b->_freq; |
duke@435 | 555 | |
duke@435 | 556 | // If it is not live, then this instruction is dead. Probably caused |
duke@435 | 557 | // by spilling and rematerialization. Who cares why, yank this baby. |
duke@435 | 558 | if( !liveout.member(r) && n->Opcode() != Op_SafePoint ) { |
duke@435 | 559 | Node *def = n->in(0); |
duke@435 | 560 | if( !n->is_Proj() || |
duke@435 | 561 | // Could also be a flags-projection of a dead ADD or such. |
neliasso@4949 | 562 | (_lrg_map.live_range_id(def) && !liveout.member(_lrg_map.live_range_id(def)))) { |
duke@435 | 563 | b->_nodes.remove(j - 1); |
neliasso@4949 | 564 | if (lrgs(r)._def == n) { |
neliasso@4949 | 565 | lrgs(r)._def = 0; |
neliasso@4949 | 566 | } |
bharadwaj@4315 | 567 | n->disconnect_inputs(NULL, C); |
duke@435 | 568 | _cfg._bbs.map(n->_idx,NULL); |
duke@435 | 569 | n->replace_by(C->top()); |
duke@435 | 570 | // Since yanking a Node from block, high pressure moves up one |
duke@435 | 571 | hrp_index[0]--; |
duke@435 | 572 | hrp_index[1]--; |
duke@435 | 573 | continue; |
duke@435 | 574 | } |
duke@435 | 575 | |
duke@435 | 576 | // Fat-projections kill many registers which cannot be used to |
duke@435 | 577 | // hold live ranges. |
neliasso@4949 | 578 | if (lrgs(r)._fat_proj) { |
duke@435 | 579 | // Count the int-only registers |
duke@435 | 580 | RegMask itmp = lrgs(r).mask(); |
duke@435 | 581 | itmp.AND(*Matcher::idealreg2regmask[Op_RegI]); |
duke@435 | 582 | int iregs = itmp.Size(); |
duke@435 | 583 | if( pressure[0]+iregs > b->_reg_pressure ) |
duke@435 | 584 | b->_reg_pressure = pressure[0]+iregs; |
duke@435 | 585 | if( pressure[0] <= (uint)INTPRESSURE && |
duke@435 | 586 | pressure[0]+iregs > (uint)INTPRESSURE ) { |
duke@435 | 587 | hrp_index[0] = j-1; |
duke@435 | 588 | } |
duke@435 | 589 | // Count the float-only registers |
duke@435 | 590 | RegMask ftmp = lrgs(r).mask(); |
duke@435 | 591 | ftmp.AND(*Matcher::idealreg2regmask[Op_RegD]); |
duke@435 | 592 | int fregs = ftmp.Size(); |
duke@435 | 593 | if( pressure[1]+fregs > b->_freg_pressure ) |
duke@435 | 594 | b->_freg_pressure = pressure[1]+fregs; |
duke@435 | 595 | if( pressure[1] <= (uint)FLOATPRESSURE && |
duke@435 | 596 | pressure[1]+fregs > (uint)FLOATPRESSURE ) { |
duke@435 | 597 | hrp_index[1] = j-1; |
duke@435 | 598 | } |
duke@435 | 599 | } |
duke@435 | 600 | |
duke@435 | 601 | } else { // Else it is live |
duke@435 | 602 | // A DEF also ends 'area' partway through the block. |
duke@435 | 603 | lrgs(r)._area -= cost; |
rasbold@804 | 604 | assert(!(lrgs(r)._area < 0.0), "negative spill area" ); |
duke@435 | 605 | |
duke@435 | 606 | // Insure high score for immediate-use spill copies so they get a color |
duke@435 | 607 | if( n->is_SpillCopy() |
never@730 | 608 | && lrgs(r).is_singledef() // MultiDef live range can still split |
duke@435 | 609 | && n->outcnt() == 1 // and use must be in this block |
duke@435 | 610 | && _cfg._bbs[n->unique_out()->_idx] == b ) { |
duke@435 | 611 | // All single-use MachSpillCopy(s) that immediately precede their |
duke@435 | 612 | // use must color early. If a longer live range steals their |
duke@435 | 613 | // color, the spill copy will split and may push another spill copy |
duke@435 | 614 | // further away resulting in an infinite spill-split-retry cycle. |
duke@435 | 615 | // Assigning a zero area results in a high score() and a good |
duke@435 | 616 | // location in the simplify list. |
duke@435 | 617 | // |
duke@435 | 618 | |
duke@435 | 619 | Node *single_use = n->unique_out(); |
duke@435 | 620 | assert( b->find_node(single_use) >= j, "Use must be later in block"); |
duke@435 | 621 | // Use can be earlier in block if it is a Phi, but then I should be a MultiDef |
duke@435 | 622 | |
duke@435 | 623 | // Find first non SpillCopy 'm' that follows the current instruction |
duke@435 | 624 | // (j - 1) is index for current instruction 'n' |
duke@435 | 625 | Node *m = n; |
duke@435 | 626 | for( uint i = j; i <= last_inst && m->is_SpillCopy(); ++i ) { m = b->_nodes[i]; } |
duke@435 | 627 | if( m == single_use ) { |
duke@435 | 628 | lrgs(r)._area = 0.0; |
duke@435 | 629 | } |
duke@435 | 630 | } |
duke@435 | 631 | |
duke@435 | 632 | // Remove from live-out set |
duke@435 | 633 | if( liveout.remove(r) ) { |
duke@435 | 634 | // Adjust register pressure. |
duke@435 | 635 | // Capture last hi-to-lo pressure transition |
duke@435 | 636 | lower_pressure( &lrgs(r), j-1, b, pressure, hrp_index ); |
duke@435 | 637 | assert( pressure[0] == count_int_pressure (&liveout), "" ); |
duke@435 | 638 | assert( pressure[1] == count_float_pressure(&liveout), "" ); |
duke@435 | 639 | } |
duke@435 | 640 | |
duke@435 | 641 | // Copies do not define a new value and so do not interfere. |
duke@435 | 642 | // Remove the copies source from the liveout set before interfering. |
duke@435 | 643 | uint idx = n->is_Copy(); |
neliasso@4949 | 644 | if (idx) { |
neliasso@4949 | 645 | uint x = _lrg_map.live_range_id(n->in(idx)); |
neliasso@4949 | 646 | if (liveout.remove(x)) { |
duke@435 | 647 | lrgs(x)._area -= cost; |
duke@435 | 648 | // Adjust register pressure. |
neliasso@4949 | 649 | lower_pressure(&lrgs(x), j-1, b, pressure, hrp_index); |
duke@435 | 650 | assert( pressure[0] == count_int_pressure (&liveout), "" ); |
duke@435 | 651 | assert( pressure[1] == count_float_pressure(&liveout), "" ); |
duke@435 | 652 | } |
duke@435 | 653 | } |
duke@435 | 654 | } // End of if live or not |
duke@435 | 655 | |
duke@435 | 656 | // Interfere with everything live. If the defined value must |
duke@435 | 657 | // go in a particular register, just remove that register from |
duke@435 | 658 | // all conflicting parties and avoid the interference. |
duke@435 | 659 | |
duke@435 | 660 | // Make exclusions for rematerializable defs. Since rematerializable |
duke@435 | 661 | // DEFs are not bound but the live range is, some uses must be bound. |
duke@435 | 662 | // If we spill live range 'r', it can rematerialize at each use site |
duke@435 | 663 | // according to its bindings. |
duke@435 | 664 | const RegMask &rmask = lrgs(r).mask(); |
duke@435 | 665 | if( lrgs(r).is_bound() && !(n->rematerialize()) && rmask.is_NotEmpty() ) { |
duke@435 | 666 | // Check for common case |
duke@435 | 667 | int r_size = lrgs(r).num_regs(); |
duke@435 | 668 | OptoReg::Name r_reg = (r_size == 1) ? rmask.find_first_elem() : OptoReg::Physical; |
kvn@3882 | 669 | // Smear odd bits |
duke@435 | 670 | IndexSetIterator elements(&liveout); |
duke@435 | 671 | uint l; |
duke@435 | 672 | while ((l = elements.next()) != 0) { |
duke@435 | 673 | LRG &lrg = lrgs(l); |
duke@435 | 674 | // If 'l' must spill already, do not further hack his bits. |
duke@435 | 675 | // He'll get some interferences and be forced to spill later. |
duke@435 | 676 | if( lrg._must_spill ) continue; |
duke@435 | 677 | // Remove bound register(s) from 'l's choices |
duke@435 | 678 | RegMask old = lrg.mask(); |
duke@435 | 679 | uint old_size = lrg.mask_size(); |
duke@435 | 680 | // Remove the bits from LRG 'r' from LRG 'l' so 'l' no |
duke@435 | 681 | // longer interferes with 'r'. If 'l' requires aligned |
duke@435 | 682 | // adjacent pairs, subtract out bit pairs. |
kvn@3882 | 683 | assert(!lrg._is_vector || !lrg._fat_proj, "sanity"); |
kvn@3882 | 684 | if (lrg.num_regs() > 1 && !lrg._fat_proj) { |
kvn@3882 | 685 | RegMask r2mask = rmask; |
kvn@3882 | 686 | // Leave only aligned set of bits. |
kvn@3882 | 687 | r2mask.smear_to_sets(lrg.num_regs()); |
kvn@3882 | 688 | // It includes vector case. |
duke@435 | 689 | lrg.SUBTRACT( r2mask ); |
duke@435 | 690 | lrg.compute_set_mask_size(); |
kvn@3882 | 691 | } else if( r_size != 1 ) { // fat proj |
duke@435 | 692 | lrg.SUBTRACT( rmask ); |
duke@435 | 693 | lrg.compute_set_mask_size(); |
duke@435 | 694 | } else { // Common case: size 1 bound removal |
duke@435 | 695 | if( lrg.mask().Member(r_reg) ) { |
duke@435 | 696 | lrg.Remove(r_reg); |
duke@435 | 697 | lrg.set_mask_size(lrg.mask().is_AllStack() ? 65535:old_size-1); |
duke@435 | 698 | } |
duke@435 | 699 | } |
duke@435 | 700 | // If 'l' goes completely dry, it must spill. |
duke@435 | 701 | if( lrg.not_free() ) { |
duke@435 | 702 | // Give 'l' some kind of reasonable mask, so he picks up |
duke@435 | 703 | // interferences (and will spill later). |
duke@435 | 704 | lrg.set_mask( old ); |
duke@435 | 705 | lrg.set_mask_size(old_size); |
duke@435 | 706 | must_spill++; |
duke@435 | 707 | lrg._must_spill = 1; |
duke@435 | 708 | lrg.set_reg(OptoReg::Name(LRG::SPILL_REG)); |
duke@435 | 709 | } |
duke@435 | 710 | } |
duke@435 | 711 | } // End of if bound |
duke@435 | 712 | |
duke@435 | 713 | // Now interference with everything that is live and has |
duke@435 | 714 | // compatible register sets. |
duke@435 | 715 | interfere_with_live(r,&liveout); |
duke@435 | 716 | |
duke@435 | 717 | } // End of if normal register-allocated value |
duke@435 | 718 | |
rasbold@804 | 719 | // Area remaining in the block |
rasbold@804 | 720 | inst_count--; |
rasbold@804 | 721 | cost = (inst_count <= 0) ? 0.0 : b->_freq * double(inst_count); |
duke@435 | 722 | |
duke@435 | 723 | // Make all inputs live |
duke@435 | 724 | if( !n->is_Phi() ) { // Phi function uses come from prior block |
duke@435 | 725 | JVMState* jvms = n->jvms(); |
duke@435 | 726 | uint debug_start = jvms ? jvms->debug_start() : 999999; |
duke@435 | 727 | // Start loop at 1 (skip control edge) for most Nodes. |
duke@435 | 728 | // SCMemProj's might be the sole use of a StoreLConditional. |
duke@435 | 729 | // While StoreLConditionals set memory (the SCMemProj use) |
duke@435 | 730 | // they also def flags; if that flag def is unused the |
duke@435 | 731 | // allocator sees a flag-setting instruction with no use of |
duke@435 | 732 | // the flags and assumes it's dead. This keeps the (useless) |
duke@435 | 733 | // flag-setting behavior alive while also keeping the (useful) |
duke@435 | 734 | // memory update effect. |
neliasso@4949 | 735 | for (uint k = ((n->Opcode() == Op_SCMemProj) ? 0:1); k < n->req(); k++) { |
duke@435 | 736 | Node *def = n->in(k); |
neliasso@4949 | 737 | uint x = _lrg_map.live_range_id(def); |
neliasso@4949 | 738 | if (!x) { |
neliasso@4949 | 739 | continue; |
neliasso@4949 | 740 | } |
duke@435 | 741 | LRG &lrg = lrgs(x); |
duke@435 | 742 | // No use-side cost for spilling debug info |
neliasso@4949 | 743 | if (k < debug_start) { |
duke@435 | 744 | // A USE costs twice block frequency (once for the Load, once |
duke@435 | 745 | // for a Load-delay). Rematerialized uses only cost once. |
duke@435 | 746 | lrg._cost += (def->rematerialize() ? b->_freq : (b->_freq + b->_freq)); |
neliasso@4949 | 747 | } |
duke@435 | 748 | // It is live now |
neliasso@4949 | 749 | if (liveout.insert(x)) { |
duke@435 | 750 | // Newly live things assumed live from here to top of block |
duke@435 | 751 | lrg._area += cost; |
duke@435 | 752 | // Adjust register pressure |
kvn@3882 | 753 | if (lrg.mask().is_UP() && lrg.mask_size()) { |
kvn@3882 | 754 | if (lrg._is_float || lrg._is_vector) { |
duke@435 | 755 | pressure[1] += lrg.reg_pressure(); |
duke@435 | 756 | if( pressure[1] > b->_freg_pressure ) |
duke@435 | 757 | b->_freg_pressure = pressure[1]; |
duke@435 | 758 | } else if( lrg.mask().overlap(*Matcher::idealreg2regmask[Op_RegI]) ) { |
duke@435 | 759 | pressure[0] += lrg.reg_pressure(); |
duke@435 | 760 | if( pressure[0] > b->_reg_pressure ) |
duke@435 | 761 | b->_reg_pressure = pressure[0]; |
duke@435 | 762 | } |
duke@435 | 763 | } |
duke@435 | 764 | assert( pressure[0] == count_int_pressure (&liveout), "" ); |
duke@435 | 765 | assert( pressure[1] == count_float_pressure(&liveout), "" ); |
duke@435 | 766 | } |
rasbold@804 | 767 | assert(!(lrg._area < 0.0), "negative spill area" ); |
duke@435 | 768 | } |
duke@435 | 769 | } |
duke@435 | 770 | } // End of reverse pass over all instructions in block |
duke@435 | 771 | |
duke@435 | 772 | // If we run off the top of the block with high pressure and |
duke@435 | 773 | // never see a hi-to-low pressure transition, just record that |
duke@435 | 774 | // the whole block is high pressure. |
duke@435 | 775 | if( pressure[0] > (uint)INTPRESSURE ) { |
duke@435 | 776 | hrp_index[0] = 0; |
duke@435 | 777 | if( pressure[0] > b->_reg_pressure ) |
duke@435 | 778 | b->_reg_pressure = pressure[0]; |
duke@435 | 779 | } |
duke@435 | 780 | if( pressure[1] > (uint)FLOATPRESSURE ) { |
duke@435 | 781 | hrp_index[1] = 0; |
duke@435 | 782 | if( pressure[1] > b->_freg_pressure ) |
duke@435 | 783 | b->_freg_pressure = pressure[1]; |
duke@435 | 784 | } |
duke@435 | 785 | |
duke@435 | 786 | // Compute high pressure indice; avoid landing in the middle of projnodes |
duke@435 | 787 | j = hrp_index[0]; |
duke@435 | 788 | if( j < b->_nodes.size() && j < b->end_idx()+1 ) { |
duke@435 | 789 | Node *cur = b->_nodes[j]; |
duke@435 | 790 | while( cur->is_Proj() || (cur->is_MachNullCheck()) || cur->is_Catch() ) { |
duke@435 | 791 | j--; |
duke@435 | 792 | cur = b->_nodes[j]; |
duke@435 | 793 | } |
duke@435 | 794 | } |
duke@435 | 795 | b->_ihrp_index = j; |
duke@435 | 796 | j = hrp_index[1]; |
duke@435 | 797 | if( j < b->_nodes.size() && j < b->end_idx()+1 ) { |
duke@435 | 798 | Node *cur = b->_nodes[j]; |
duke@435 | 799 | while( cur->is_Proj() || (cur->is_MachNullCheck()) || cur->is_Catch() ) { |
duke@435 | 800 | j--; |
duke@435 | 801 | cur = b->_nodes[j]; |
duke@435 | 802 | } |
duke@435 | 803 | } |
duke@435 | 804 | b->_fhrp_index = j; |
duke@435 | 805 | |
duke@435 | 806 | #ifndef PRODUCT |
duke@435 | 807 | // Gather Register Pressure Statistics |
duke@435 | 808 | if( PrintOptoStatistics ) { |
duke@435 | 809 | if( b->_reg_pressure > (uint)INTPRESSURE || b->_freg_pressure > (uint)FLOATPRESSURE ) |
duke@435 | 810 | _high_pressure++; |
duke@435 | 811 | else |
duke@435 | 812 | _low_pressure++; |
duke@435 | 813 | } |
duke@435 | 814 | #endif |
duke@435 | 815 | } // End of for all blocks |
duke@435 | 816 | |
duke@435 | 817 | return must_spill; |
duke@435 | 818 | } |