366 // Instead, be sure we never again use the source table.
367 ((NodeHash*)&nh)->_table = (Node**)badAddress;
368 }
369
370
371 #endif
372
373
374 //=============================================================================
375 //------------------------------PhaseRemoveUseless-----------------------------
376 // 1) Use a breadthfirst walk to collect useful nodes reachable from root.
377 PhaseRemoveUseless::PhaseRemoveUseless( PhaseGVN *gvn, Unique_Node_List *worklist ) : Phase(Remove_Useless),
378 _useful(Thread::current()->resource_area()) {
379
380 // Implementation requires 'UseLoopSafepoints == true' and an edge from root
381 // to each SafePointNode at a backward branch. Inserted in add_safepoint().
382 if( !UseLoopSafepoints || !OptoRemoveUseless ) return;
383
384 // Identify nodes that are reachable from below, useful.
385 C->identify_useful_nodes(_useful);
386
387 // Remove all useless nodes from PhaseValues' recorded types
388 // Must be done before disconnecting nodes to preserve hash-table-invariant
389 gvn->remove_useless_nodes(_useful.member_set());
390
391 // Remove all useless nodes from future worklist
392 worklist->remove_useless_nodes(_useful.member_set());
393
394 // Disconnect 'useless' nodes that are adjacent to useful nodes
395 C->remove_useless_nodes(_useful);
396
397 // Remove edges from "root" to each SafePoint at a backward branch.
398 // They were inserted during parsing (see add_safepoint()) to make infinite
399 // loops without calls or exceptions visible to root, i.e., useful.
400 Node *root = C->root();
401 if( root != NULL ) {
402 for( uint i = root->req(); i < root->len(); ++i ) {
403 Node *n = root->in(i);
404 if( n != NULL && n->is_SafePoint() ) {
405 root->rm_prec(i);
1173 recurse = true;
1174 } else if (in->outcnt() == 1 &&
1175 in->has_special_unique_user()) {
1176 _worklist.push(in->unique_out());
1177 } else if (in->outcnt() <= 2 && dead->is_Phi()) {
1178 if( in->Opcode() == Op_Region )
1179 _worklist.push(in);
1180 else if( in->is_Store() ) {
1181 DUIterator_Fast imax, i = in->fast_outs(imax);
1182 _worklist.push(in->fast_out(i));
1183 i++;
1184 if(in->outcnt() == 2) {
1185 _worklist.push(in->fast_out(i));
1186 i++;
1187 }
1188 assert(!(i < imax), "sanity");
1189 }
1190 }
1191 }
1192 }
1193
1194 if (dead->is_macro()) {
1195 C->remove_macro_node(dead);
1196 }
1197
1198 if (recurse) {
1199 continue;
1200 }
1201 }
1202 }
1203
1204 // Aggressively kill globally dead uses
1205 // (Rather than pushing all the outs at once, we push one at a time,
1206 // plus the parent to resume later, because of the indefinite number
1207 // of edge deletions per loop trip.)
1208 if (dead->outcnt() > 0) {
1209 // Recursively remove
1210 _stack.push(dead->raw_out(0), PROCESS_INPUTS);
1211 } else {
1212 _stack.pop();
1213 }
1214 }
1215 }
1216
1217 //------------------------------subsume_node-----------------------------------
1218 // Remove users from node 'old' and add them to node 'nn'.
1219 void PhaseIterGVN::subsume_node( Node *old, Node *nn ) {
1220 assert( old != hash_find(old), "should already been removed" );
1221 assert( old != C->top(), "cannot subsume top node");
|
366 // Instead, be sure we never again use the source table.
367 ((NodeHash*)&nh)->_table = (Node**)badAddress;
368 }
369
370
371 #endif
372
373
374 //=============================================================================
375 //------------------------------PhaseRemoveUseless-----------------------------
376 // 1) Use a breadthfirst walk to collect useful nodes reachable from root.
377 PhaseRemoveUseless::PhaseRemoveUseless( PhaseGVN *gvn, Unique_Node_List *worklist ) : Phase(Remove_Useless),
378 _useful(Thread::current()->resource_area()) {
379
380 // Implementation requires 'UseLoopSafepoints == true' and an edge from root
381 // to each SafePointNode at a backward branch. Inserted in add_safepoint().
382 if( !UseLoopSafepoints || !OptoRemoveUseless ) return;
383
384 // Identify nodes that are reachable from below, useful.
385 C->identify_useful_nodes(_useful);
386 // Update dead node list
387 C->update_dead_node_list(_useful);
388
389 // Remove all useless nodes from PhaseValues' recorded types
390 // Must be done before disconnecting nodes to preserve hash-table-invariant
391 gvn->remove_useless_nodes(_useful.member_set());
392
393 // Remove all useless nodes from future worklist
394 worklist->remove_useless_nodes(_useful.member_set());
395
396 // Disconnect 'useless' nodes that are adjacent to useful nodes
397 C->remove_useless_nodes(_useful);
398
399 // Remove edges from "root" to each SafePoint at a backward branch.
400 // They were inserted during parsing (see add_safepoint()) to make infinite
401 // loops without calls or exceptions visible to root, i.e., useful.
402 Node *root = C->root();
403 if( root != NULL ) {
404 for( uint i = root->req(); i < root->len(); ++i ) {
405 Node *n = root->in(i);
406 if( n != NULL && n->is_SafePoint() ) {
407 root->rm_prec(i);
1175 recurse = true;
1176 } else if (in->outcnt() == 1 &&
1177 in->has_special_unique_user()) {
1178 _worklist.push(in->unique_out());
1179 } else if (in->outcnt() <= 2 && dead->is_Phi()) {
1180 if( in->Opcode() == Op_Region )
1181 _worklist.push(in);
1182 else if( in->is_Store() ) {
1183 DUIterator_Fast imax, i = in->fast_outs(imax);
1184 _worklist.push(in->fast_out(i));
1185 i++;
1186 if(in->outcnt() == 2) {
1187 _worklist.push(in->fast_out(i));
1188 i++;
1189 }
1190 assert(!(i < imax), "sanity");
1191 }
1192 }
1193 }
1194 }
1195 C->record_dead_node(dead->_idx);
1196 if (dead->is_macro()) {
1197 C->remove_macro_node(dead);
1198 }
1199
1200 if (recurse) {
1201 continue;
1202 }
1203 }
1204 // Constant node that has no out-edges and has only one in-edge from
1205 // root is usually dead. However, sometimes reshaping walk makes
1206 // it reachable by adding use edges. So, we will NOT count Con nodes
1207 // as dead to be conservative about the dead node count at any
1208 // given time.
1209 }
1210
1211 // Aggressively kill globally dead uses
1212 // (Rather than pushing all the outs at once, we push one at a time,
1213 // plus the parent to resume later, because of the indefinite number
1214 // of edge deletions per loop trip.)
1215 if (dead->outcnt() > 0) {
1216 // Recursively remove
1217 _stack.push(dead->raw_out(0), PROCESS_INPUTS);
1218 } else {
1219 _stack.pop();
1220 }
1221 }
1222 }
1223
1224 //------------------------------subsume_node-----------------------------------
1225 // Remove users from node 'old' and add them to node 'nn'.
1226 void PhaseIterGVN::subsume_node( Node *old, Node *nn ) {
1227 assert( old != hash_find(old), "should already been removed" );
1228 assert( old != C->top(), "cannot subsume top node");
|