Change a def into a Node. Keeps the edges correct, by removing the corresponding use->def edge. This may make the original def go dead. This function is co-recursive with #kill. This method is the normal path for altering a Node, because it does the proper d
(int idx, Node new_def )
| 144 | void popN(int n) { |
| 145 | for( int i=0; i<n; i++ ) { |
| 146 | Node old_def = _inputs.removeLast(); |
| 147 | if( old_def != null && // If it exists and |
| 148 | old_def.delUse(this) ) // If we removed the last use, the old def is now dead |
| 149 | old_def.kill(); // Kill old def |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * Kill a Node with no <em>uses</em>, by setting all of its <em>defs</em> |
| 155 | * to null. This may recursively kill more Nodes and is basically dead |
| 156 | * code elimination. This function is co-recursive with {@link #popN}. |
| 157 | */ |
| 158 | public void kill( ) { |
| 159 | assert isUnused(); // Has no uses, so it is dead |
| 160 | popN(nIns()); // Set all inputs to null, recursively killing unused Nodes |
| 161 | _type=null; // Flag as dead |
| 162 | assert isDead(); // Really dead now |
| 163 | } |
| 164 |