117 use->remove(r);
118 }
119
120 // Push these live-in things to predecessors
121 for (uint l = 1; l < block->num_preds(); l++) {
122 Block* p = _cfg.get_block_for_node(block->pred(l));
123 add_liveout(p, use, first_pass);
124
125 // PhiNode uses go in the live-out set of prior blocks.
126 for (uint k = i; k > 0; k--) {
127 add_liveout(p, _names.at(block->get_node(k-1)->in(l)->_idx), first_pass);
128 }
129 }
130 freeset(block);
131 first_pass.set(block->_pre_order);
132
133 // Inner loop: blocks that picked up new live-out values to be propagated
134 while (_worklist->size()) {
135 Block* block = _worklist->pop();
136 IndexSet *delta = getset(block);
137 assert( delta->count(), "missing delta set" );
138
139 // Add new-live-in to predecessors live-out sets
140 for (uint l = 1; l < block->num_preds(); l++) {
141 Block* predecessor = _cfg.get_block_for_node(block->pred(l));
142 add_liveout(predecessor, delta, first_pass);
143 }
144
145 freeset(block);
146 } // End of while-worklist-not-empty
147
148 } // End of for-all-blocks-outer-loop
149
150 // We explicitly clear all of the IndexSets which we are about to release.
151 // This allows us to recycle their internal memory into IndexSet's free list.
152
153 for (i = 0; i < _cfg.number_of_blocks(); i++) {
154 _defs[i].clear();
155 if (_deltas[i]) {
156 // Is this always true?
157 _deltas[i]->clear();
170 void PhaseLive::stats(uint iters) const {
171 }
172 #endif
173
174 // Get an IndexSet for a block. Return existing one, if any. Make a new
175 // empty one if a prior one does not exist.
176 IndexSet *PhaseLive::getset( Block *p ) {
177 IndexSet *delta = _deltas[p->_pre_order-1];
178 if( !delta ) // Not on worklist?
179 // Get a free set; flag as being on worklist
180 delta = _deltas[p->_pre_order-1] = getfreeset();
181 return delta; // Return set of new live-out items
182 }
183
184 // Pull from free list, or allocate. Internal allocation on the returned set
185 // is always from thread local storage.
186 IndexSet *PhaseLive::getfreeset( ) {
187 IndexSet *f = _free_IndexSet;
188 if( !f ) {
189 f = new IndexSet;
190 // f->set_arena(Thread::current()->resource_area());
191 f->initialize(_maxlrg, Thread::current()->resource_area());
192 } else {
193 // Pull from free list
194 _free_IndexSet = f->next();
195 //f->_cnt = 0; // Reset to empty
196 // f->set_arena(Thread::current()->resource_area());
197 f->initialize(_maxlrg, Thread::current()->resource_area());
198 }
199 return f;
200 }
201
202 // Free an IndexSet from a block.
203 void PhaseLive::freeset( const Block *p ) {
204 IndexSet *f = _deltas[p->_pre_order-1];
205 f->set_next(_free_IndexSet);
206 _free_IndexSet = f; // Drop onto free list
207 _deltas[p->_pre_order-1] = NULL;
208 }
209
210 // Add a live-out value to a given blocks live-out set. If it is new, then
211 // also add it to the delta set and stick the block on the worklist.
212 void PhaseLive::add_liveout( Block *p, uint r, VectorSet &first_pass ) {
213 IndexSet *live = &_live[p->_pre_order-1];
214 if( live->insert(r) ) { // If actually inserted...
215 // We extended the live-out set. See if the value is generated locally.
216 // If it is not, then we must extend the live-in set.
217 if( !_defs[p->_pre_order-1].member( r ) ) {
221 getset(p)->insert(r);
222 }
223 }
224 }
225
226 // Add a vector of live-out values to a given blocks live-out set.
227 void PhaseLive::add_liveout( Block *p, IndexSet *lo, VectorSet &first_pass ) {
228 IndexSet *live = &_live[p->_pre_order-1];
229 IndexSet *defs = &_defs[p->_pre_order-1];
230 IndexSet *on_worklist = _deltas[p->_pre_order-1];
231 IndexSet *delta = on_worklist ? on_worklist : getfreeset();
232
233 IndexSetIterator elements(lo);
234 uint r;
235 while ((r = elements.next()) != 0) {
236 if( live->insert(r) && // If actually inserted...
237 !defs->member( r ) ) // and not defined locally
238 delta->insert(r); // Then add to live-in set
239 }
240
241 if( delta->count() ) { // If actually added things
242 _deltas[p->_pre_order-1] = delta; // Flag as on worklist now
243 if( !on_worklist && // Not on worklist?
244 first_pass.test(p->_pre_order) )
245 _worklist->push(p); // Actually go on worklist if already 1st pass
246 } else { // Nothing there; just free it
247 delta->set_next(_free_IndexSet);
248 _free_IndexSet = delta; // Drop onto free list
249 }
250 }
251
252 #ifndef PRODUCT
253 // Dump the live-out set for a block
254 void PhaseLive::dump( const Block *b ) const {
255 tty->print("Block %d: ",b->_pre_order);
256 tty->print("LiveOut: "); _live[b->_pre_order-1].dump();
257 uint cnt = b->number_of_nodes();
258 for( uint i=0; i<cnt; i++ ) {
259 tty->print("L%d/", _names.at(b->get_node(i)->_idx));
260 b->get_node(i)->dump();
261 }
|
117 use->remove(r);
118 }
119
120 // Push these live-in things to predecessors
121 for (uint l = 1; l < block->num_preds(); l++) {
122 Block* p = _cfg.get_block_for_node(block->pred(l));
123 add_liveout(p, use, first_pass);
124
125 // PhiNode uses go in the live-out set of prior blocks.
126 for (uint k = i; k > 0; k--) {
127 add_liveout(p, _names.at(block->get_node(k-1)->in(l)->_idx), first_pass);
128 }
129 }
130 freeset(block);
131 first_pass.set(block->_pre_order);
132
133 // Inner loop: blocks that picked up new live-out values to be propagated
134 while (_worklist->size()) {
135 Block* block = _worklist->pop();
136 IndexSet *delta = getset(block);
137 assert( !delta->is_empty(), "missing delta set" );
138
139 // Add new-live-in to predecessors live-out sets
140 for (uint l = 1; l < block->num_preds(); l++) {
141 Block* predecessor = _cfg.get_block_for_node(block->pred(l));
142 add_liveout(predecessor, delta, first_pass);
143 }
144
145 freeset(block);
146 } // End of while-worklist-not-empty
147
148 } // End of for-all-blocks-outer-loop
149
150 // We explicitly clear all of the IndexSets which we are about to release.
151 // This allows us to recycle their internal memory into IndexSet's free list.
152
153 for (i = 0; i < _cfg.number_of_blocks(); i++) {
154 _defs[i].clear();
155 if (_deltas[i]) {
156 // Is this always true?
157 _deltas[i]->clear();
170 void PhaseLive::stats(uint iters) const {
171 }
172 #endif
173
174 // Get an IndexSet for a block. Return existing one, if any. Make a new
175 // empty one if a prior one does not exist.
176 IndexSet *PhaseLive::getset( Block *p ) {
177 IndexSet *delta = _deltas[p->_pre_order-1];
178 if( !delta ) // Not on worklist?
179 // Get a free set; flag as being on worklist
180 delta = _deltas[p->_pre_order-1] = getfreeset();
181 return delta; // Return set of new live-out items
182 }
183
184 // Pull from free list, or allocate. Internal allocation on the returned set
185 // is always from thread local storage.
186 IndexSet *PhaseLive::getfreeset( ) {
187 IndexSet *f = _free_IndexSet;
188 if( !f ) {
189 f = new IndexSet;
190 f->initialize(_maxlrg);
191 } else {
192 // Pull from free list
193 _free_IndexSet = f->next();
194 f->initialize(_maxlrg);
195 }
196 return f;
197 }
198
199 // Free an IndexSet from a block.
200 void PhaseLive::freeset( const Block *p ) {
201 IndexSet *f = _deltas[p->_pre_order-1];
202 f->set_next(_free_IndexSet);
203 _free_IndexSet = f; // Drop onto free list
204 _deltas[p->_pre_order-1] = NULL;
205 }
206
207 // Add a live-out value to a given blocks live-out set. If it is new, then
208 // also add it to the delta set and stick the block on the worklist.
209 void PhaseLive::add_liveout( Block *p, uint r, VectorSet &first_pass ) {
210 IndexSet *live = &_live[p->_pre_order-1];
211 if( live->insert(r) ) { // If actually inserted...
212 // We extended the live-out set. See if the value is generated locally.
213 // If it is not, then we must extend the live-in set.
214 if( !_defs[p->_pre_order-1].member( r ) ) {
218 getset(p)->insert(r);
219 }
220 }
221 }
222
223 // Add a vector of live-out values to a given blocks live-out set.
224 void PhaseLive::add_liveout( Block *p, IndexSet *lo, VectorSet &first_pass ) {
225 IndexSet *live = &_live[p->_pre_order-1];
226 IndexSet *defs = &_defs[p->_pre_order-1];
227 IndexSet *on_worklist = _deltas[p->_pre_order-1];
228 IndexSet *delta = on_worklist ? on_worklist : getfreeset();
229
230 IndexSetIterator elements(lo);
231 uint r;
232 while ((r = elements.next()) != 0) {
233 if( live->insert(r) && // If actually inserted...
234 !defs->member( r ) ) // and not defined locally
235 delta->insert(r); // Then add to live-in set
236 }
237
238 if( !delta->is_empty() ) { // If actually added things
239 _deltas[p->_pre_order-1] = delta; // Flag as on worklist now
240 if( !on_worklist && // Not on worklist?
241 first_pass.test(p->_pre_order) )
242 _worklist->push(p); // Actually go on worklist if already 1st pass
243 } else { // Nothing there; just free it
244 delta->set_next(_free_IndexSet);
245 _free_IndexSet = delta; // Drop onto free list
246 }
247 }
248
249 #ifndef PRODUCT
250 // Dump the live-out set for a block
251 void PhaseLive::dump( const Block *b ) const {
252 tty->print("Block %d: ",b->_pre_order);
253 tty->print("LiveOut: "); _live[b->_pre_order-1].dump();
254 uint cnt = b->number_of_nodes();
255 for( uint i=0; i<cnt; i++ ) {
256 tty->print("L%d/", _names.at(b->get_node(i)->_idx));
257 b->get_node(i)->dump();
258 }
|