MCPcopy Create free account
hub / github.com/SeaOfNodes/Simple / setDef

Method setDef

chapter21/src/main/java/com/seaofnodes/simple/node/Node.java:165–184  ·  view source on GitHub ↗

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 )

Source from the content-addressed store, hash-verified

163 * @return new_def for flow coding
164 */
165 public <N extends Node> N setDef(int idx, N new_def ) {
166 unlock();
167 Node old_def = in(idx);
168 if( old_def == new_def ) return new_def; // No change
169 // If new def is not null, add the corresponding def->use edge
170 // This needs to happen before removing the old node's def->use edge as
171 // the new_def might get killed if the old node kills it recursively.
172 if( new_def != null )
173 new_def.addUse(this);
174 // Set the new_def over the old (killed) edge
175 _inputs.set(idx,new_def);
176 if( old_def != null ) { // If the old def exists, remove a def->use edge
177 if( old_def.delUse(this) ) // If we removed the last use, the old def is now dead
178 old_def.kill(); // Kill old def
179 else CODE.add(old_def); // Else old lost a use, so onto worklist
180 }
181 moveDepsToWorklist();
182 // Return new_def for easy flow-coding
183 return new_def;
184 }
185 public <N extends Node> N setDefX(int idx, N new_def ) {
186 while( nIns() <= idx ) addDef(null);
187 return setDef(idx,new_def);

Callers 15

parseBitwiseMethod · 0.95
parseShiftMethod · 0.95
parseAdditionMethod · 0.95
splitEmptyMaskByUseMethod · 0.95
setDefXMethod · 0.95
insertDefMethod · 0.95
setDefOrderedMethod · 0.95
widenMethod · 0.95
endLoopMethod · 0.95
parseFunctionBodyMethod · 0.45
parseComparisonMethod · 0.45

Calls 8

unlockMethod · 0.95
inMethod · 0.95
delUseMethod · 0.95
killMethod · 0.95
moveDepsToWorklistMethod · 0.95
addUseMethod · 0.45
setMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected