Thu, 12 Sep 2013 23:13:45 +0200
8024646: Remove LRG_List container, replace it with GrowableArray
Summary: We already have GrowableArray, use it instead of LRG_List
Reviewed-by: kvn
1.1 --- a/src/share/vm/opto/chaitin.cpp Wed Sep 11 09:34:00 2013 +0200 1.2 +++ b/src/share/vm/opto/chaitin.cpp Thu Sep 12 23:13:45 2013 +0200 1.3 @@ -122,40 +122,23 @@ 1.4 return score; 1.5 } 1.6 1.7 -LRG_List::LRG_List( uint max ) : _cnt(max), _max(max), _lidxs(NEW_RESOURCE_ARRAY(uint,max)) { 1.8 - memset( _lidxs, 0, sizeof(uint)*max ); 1.9 -} 1.10 - 1.11 -void LRG_List::extend( uint nidx, uint lidx ) { 1.12 - _nesting.check(); 1.13 - if( nidx >= _max ) { 1.14 - uint size = 16; 1.15 - while( size <= nidx ) size <<=1; 1.16 - _lidxs = REALLOC_RESOURCE_ARRAY( uint, _lidxs, _max, size ); 1.17 - _max = size; 1.18 - } 1.19 - while( _cnt <= nidx ) 1.20 - _lidxs[_cnt++] = 0; 1.21 - _lidxs[nidx] = lidx; 1.22 -} 1.23 - 1.24 #define NUMBUCKS 3 1.25 1.26 // Straight out of Tarjan's union-find algorithm 1.27 uint LiveRangeMap::find_compress(uint lrg) { 1.28 uint cur = lrg; 1.29 - uint next = _uf_map[cur]; 1.30 + uint next = _uf_map.at(cur); 1.31 while (next != cur) { // Scan chain of equivalences 1.32 assert( next < cur, "always union smaller"); 1.33 cur = next; // until find a fixed-point 1.34 - next = _uf_map[cur]; 1.35 + next = _uf_map.at(cur); 1.36 } 1.37 1.38 // Core of union-find algorithm: update chain of 1.39 // equivalences to be equal to the root. 1.40 while (lrg != next) { 1.41 - uint tmp = _uf_map[lrg]; 1.42 - _uf_map.map(lrg, next); 1.43 + uint tmp = _uf_map.at(lrg); 1.44 + _uf_map.at_put(lrg, next); 1.45 lrg = tmp; 1.46 } 1.47 return lrg; 1.48 @@ -165,10 +148,10 @@ 1.49 void LiveRangeMap::reset_uf_map(uint max_lrg_id) { 1.50 _max_lrg_id= max_lrg_id; 1.51 // Force the Union-Find mapping to be at least this large 1.52 - _uf_map.extend(_max_lrg_id, 0); 1.53 + _uf_map.at_put_grow(_max_lrg_id, 0); 1.54 // Initialize it to be the ID mapping. 1.55 for (uint i = 0; i < _max_lrg_id; ++i) { 1.56 - _uf_map.map(i, i); 1.57 + _uf_map.at_put(i, i); 1.58 } 1.59 } 1.60 1.61 @@ -176,12 +159,12 @@ 1.62 // the Union-Find mapping after this call. 1.63 void LiveRangeMap::compress_uf_map_for_nodes() { 1.64 // For all Nodes, compress mapping 1.65 - uint unique = _names.Size(); 1.66 + uint unique = _names.length(); 1.67 for (uint i = 0; i < unique; ++i) { 1.68 - uint lrg = _names[i]; 1.69 + uint lrg = _names.at(i); 1.70 uint compressed_lrg = find(lrg); 1.71 if (lrg != compressed_lrg) { 1.72 - _names.map(i, compressed_lrg); 1.73 + _names.at_put(i, compressed_lrg); 1.74 } 1.75 } 1.76 } 1.77 @@ -198,11 +181,11 @@ 1.78 return lrg; 1.79 } 1.80 1.81 - uint next = _uf_map[lrg]; 1.82 + uint next = _uf_map.at(lrg); 1.83 while (next != lrg) { // Scan chain of equivalences 1.84 assert(next < lrg, "always union smaller"); 1.85 lrg = next; // until find a fixed-point 1.86 - next = _uf_map[lrg]; 1.87 + next = _uf_map.at(lrg); 1.88 } 1.89 return next; 1.90 } 1.91 @@ -215,7 +198,7 @@ 1.92 NULL 1.93 #endif 1.94 ) 1.95 - , _lrg_map(unique) 1.96 + , _lrg_map(Thread::current()->resource_area(), unique) 1.97 , _live(0) 1.98 , _spilled_once(Thread::current()->resource_area()) 1.99 , _spilled_twice(Thread::current()->resource_area()) 1.100 @@ -692,6 +675,7 @@ 1.101 _lrg_map.map(n->_idx, rm.is_NotEmpty() ? lr_counter++ : 0); 1.102 } 1.103 } 1.104 + 1.105 // Reset the Union-Find mapping to be identity 1.106 _lrg_map.reset_uf_map(lr_counter); 1.107 }
2.1 --- a/src/share/vm/opto/chaitin.hpp Wed Sep 11 09:34:00 2013 +0200 2.2 +++ b/src/share/vm/opto/chaitin.hpp Thu Sep 12 23:13:45 2013 +0200 2.3 @@ -283,8 +283,8 @@ 2.4 2.5 // Straight out of Tarjan's union-find algorithm 2.6 uint find_compress(const Node *node) { 2.7 - uint lrg_id = find_compress(_names[node->_idx]); 2.8 - _names.map(node->_idx, lrg_id); 2.9 + uint lrg_id = find_compress(_names.at(node->_idx)); 2.10 + _names.at_put(node->_idx, lrg_id); 2.11 return lrg_id; 2.12 } 2.13 2.14 @@ -305,40 +305,40 @@ 2.15 } 2.16 2.17 uint size() const { 2.18 - return _names.Size(); 2.19 + return _names.length(); 2.20 } 2.21 2.22 uint live_range_id(uint idx) const { 2.23 - return _names[idx]; 2.24 + return _names.at(idx); 2.25 } 2.26 2.27 uint live_range_id(const Node *node) const { 2.28 - return _names[node->_idx]; 2.29 + return _names.at(node->_idx); 2.30 } 2.31 2.32 uint uf_live_range_id(uint lrg_id) const { 2.33 - return _uf_map[lrg_id]; 2.34 + return _uf_map.at(lrg_id); 2.35 } 2.36 2.37 void map(uint idx, uint lrg_id) { 2.38 - _names.map(idx, lrg_id); 2.39 + _names.at_put(idx, lrg_id); 2.40 } 2.41 2.42 void uf_map(uint dst_lrg_id, uint src_lrg_id) { 2.43 - _uf_map.map(dst_lrg_id, src_lrg_id); 2.44 + _uf_map.at_put(dst_lrg_id, src_lrg_id); 2.45 } 2.46 2.47 void extend(uint idx, uint lrg_id) { 2.48 - _names.extend(idx, lrg_id); 2.49 + _names.at_put_grow(idx, lrg_id); 2.50 } 2.51 2.52 void uf_extend(uint dst_lrg_id, uint src_lrg_id) { 2.53 - _uf_map.extend(dst_lrg_id, src_lrg_id); 2.54 + _uf_map.at_put_grow(dst_lrg_id, src_lrg_id); 2.55 } 2.56 2.57 - LiveRangeMap(uint unique) 2.58 - : _names(unique) 2.59 - , _uf_map(unique) 2.60 + LiveRangeMap(Arena* arena, uint unique) 2.61 + : _names(arena, unique, unique, 0) 2.62 + , _uf_map(arena, unique, unique, 0) 2.63 , _max_lrg_id(0) {} 2.64 2.65 uint find_id( const Node *n ) { 2.66 @@ -355,14 +355,14 @@ 2.67 void compress_uf_map_for_nodes(); 2.68 2.69 uint find(uint lidx) { 2.70 - uint uf_lidx = _uf_map[lidx]; 2.71 + uint uf_lidx = _uf_map.at(lidx); 2.72 return (uf_lidx == lidx) ? uf_lidx : find_compress(lidx); 2.73 } 2.74 2.75 // Convert a Node into a Live Range Index - a lidx 2.76 uint find(const Node *node) { 2.77 uint lidx = live_range_id(node); 2.78 - uint uf_lidx = _uf_map[lidx]; 2.79 + uint uf_lidx = _uf_map.at(lidx); 2.80 return (uf_lidx == lidx) ? uf_lidx : find_compress(node); 2.81 } 2.82 2.83 @@ -371,10 +371,10 @@ 2.84 2.85 // Like Find above, but no path compress, so bad asymptotic behavior 2.86 uint find_const(const Node *node) const { 2.87 - if(node->_idx >= _names.Size()) { 2.88 + if(node->_idx >= (uint)_names.length()) { 2.89 return 0; // not mapped, usual for debug dump 2.90 } 2.91 - return find_const(_names[node->_idx]); 2.92 + return find_const(_names.at(node->_idx)); 2.93 } 2.94 }; 2.95
3.1 --- a/src/share/vm/opto/coalesce.hpp Wed Sep 11 09:34:00 2013 +0200 3.2 +++ b/src/share/vm/opto/coalesce.hpp Thu Sep 12 23:13:45 2013 +0200 3.3 @@ -29,7 +29,6 @@ 3.4 3.5 class LoopTree; 3.6 class LRG; 3.7 -class LRG_List; 3.8 class Matcher; 3.9 class PhaseIFG; 3.10 class PhaseCFG;
4.1 --- a/src/share/vm/opto/live.cpp Wed Sep 11 09:34:00 2013 +0200 4.2 +++ b/src/share/vm/opto/live.cpp Thu Sep 12 23:13:45 2013 +0200 4.3 @@ -91,7 +91,7 @@ 4.4 break; 4.5 } 4.6 4.7 - uint r = _names[n->_idx]; 4.8 + uint r = _names.at(n->_idx); 4.9 assert(!def_outside->member(r), "Use of external LRG overlaps the same LRG defined in this block"); 4.10 def->insert( r ); 4.11 use->remove( r ); 4.12 @@ -100,7 +100,7 @@ 4.13 Node *nk = n->in(k); 4.14 uint nkidx = nk->_idx; 4.15 if (_cfg.get_block_for_node(nk) != block) { 4.16 - uint u = _names[nkidx]; 4.17 + uint u = _names.at(nkidx); 4.18 use->insert(u); 4.19 DEBUG_ONLY(def_outside->insert(u);) 4.20 } 4.21 @@ -112,7 +112,7 @@ 4.22 #endif 4.23 // Remove anything defined by Phis and the block start instruction 4.24 for (uint k = i; k > 0; k--) { 4.25 - uint r = _names[block->get_node(k - 1)->_idx]; 4.26 + uint r = _names.at(block->get_node(k - 1)->_idx); 4.27 def->insert(r); 4.28 use->remove(r); 4.29 } 4.30 @@ -124,7 +124,7 @@ 4.31 4.32 // PhiNode uses go in the live-out set of prior blocks. 4.33 for (uint k = i; k > 0; k--) { 4.34 - add_liveout(p, _names[block->get_node(k-1)->in(l)->_idx], first_pass); 4.35 + add_liveout(p, _names.at(block->get_node(k-1)->in(l)->_idx), first_pass); 4.36 } 4.37 } 4.38 freeset(block); 4.39 @@ -256,7 +256,7 @@ 4.40 tty->print("LiveOut: "); _live[b->_pre_order-1].dump(); 4.41 uint cnt = b->number_of_nodes(); 4.42 for( uint i=0; i<cnt; i++ ) { 4.43 - tty->print("L%d/", _names[b->get_node(i)->_idx] ); 4.44 + tty->print("L%d/", _names.at(b->get_node(i)->_idx)); 4.45 b->get_node(i)->dump(); 4.46 } 4.47 tty->print("\n");
5.1 --- a/src/share/vm/opto/live.hpp Wed Sep 11 09:34:00 2013 +0200 5.2 +++ b/src/share/vm/opto/live.hpp Thu Sep 12 23:13:45 2013 +0200 5.3 @@ -40,27 +40,7 @@ 5.4 //------------------------------LRG_List--------------------------------------- 5.5 // Map Node indices to Live RanGe indices. 5.6 // Array lookup in the optimized case. 5.7 -class LRG_List : public ResourceObj { 5.8 - friend class VMStructs; 5.9 - uint _cnt, _max; 5.10 - uint* _lidxs; 5.11 - ReallocMark _nesting; // assertion check for reallocations 5.12 -public: 5.13 - LRG_List( uint max ); 5.14 - 5.15 - uint lookup( uint nidx ) const { 5.16 - return _lidxs[nidx]; 5.17 - } 5.18 - uint operator[] (uint nidx) const { return lookup(nidx); } 5.19 - 5.20 - void map( uint nidx, uint lidx ) { 5.21 - assert( nidx < _cnt, "oob" ); 5.22 - _lidxs[nidx] = lidx; 5.23 - } 5.24 - void extend( uint nidx, uint lidx ); 5.25 - 5.26 - uint Size() const { return _cnt; } 5.27 -}; 5.28 +typedef GrowableArray<uint> LRG_List; 5.29 5.30 //------------------------------PhaseLive-------------------------------------- 5.31 // Compute live-in/live-out