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, N new_def )
| 166 | * |
| 167 | * @param new_def the new definition, appended to the end of existing definitions |
| 168 | * @return new_def for flow coding |
| 169 | */ |
| 170 | public Node addDef(Node new_def) { |
| 171 | unlock(); |
| 172 | // Add use->def edge |
| 173 | _inputs.add(new_def); |
| 174 | // If new def is not null, add the corresponding def->use edge |
| 175 | if( new_def != null ) |
| 176 | new_def.addUse(this); |
| 177 | return new_def; |
| 178 | } |
| 179 | |
| 180 | // Breaks the edge invariants, used temporarily |
| 181 | protected <N extends Node> void addUse(N n) { _outputs.add(n); } |
| 182 | |
| 183 | // Remove node 'use' from 'def's (i.e. our) output list, by compressing the list in-place. |
| 184 | // Return true if the output list is empty afterward. |
| 185 | // Error is 'use' does not exist; ok for 'use' to be null. |
| 186 | public boolean delUse( Node use ) { |
| 187 | _outputs.del(_outputs.find(use)); |
| 188 | moveDepsToWorklist(); // User-count and anti-dependence queries can now change. |
| 189 | return _outputs.isEmpty(); |
| 190 | } |
no test coverage detected