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

Method setDef

chapter11/src/main/java/com/seaofnodes/simple/node/Node.java:158–175  ·  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, Node new_def )

Source from the content-addressed store, hash-verified

156 * @return new_def for flow coding
157 */
158 public Node setDef(int idx, Node new_def ) {
159 unlock();
160 Node old_def = in(idx);
161 if( old_def == new_def ) return new_def; // No change
162 // If new def is not null, add the corresponding def->use edge
163 // This needs to happen before removing the old node's def->use edge as
164 // the new_def might get killed if the old node kills it recursively.
165 if( new_def != null )
166 new_def.addUse(this);
167 // Set the new_def over the old (killed) edge
168 _inputs.set(idx,new_def);
169 if( old_def != null && // If the old def exists, remove a def->use edge
170 old_def.delUse(this) ) // If we removed the last use, the old def is now dead
171 old_def.kill(); // Kill old def
172 moveDepsToWorklist();
173 // Return self for easy flow-coding
174 return new_def;
175 }
176
177 // Remove the numbered input, compressing the inputs in-place. This
178 // shuffles the order deterministically - which is suitable for Region and

Callers 13

parseAdditionMethod · 0.95
endLoopMethod · 0.95
_schedEarlyMethod · 0.45
schedLateMethod · 0.45
parseComparisonMethod · 0.45
parseMultiplicationMethod · 0.45
idealizeMethod · 0.45
updateMethod · 0.45
ctrlMethod · 0.45
mergeScopesMethod · 0.45
replaceMethod · 0.45
forceExitMethod · 0.45

Calls 7

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

Tested by

no test coverage detected