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

Method kill

chapter16/src/main/java/com/seaofnodes/simple/node/Node.java:241–255  ·  view source on GitHub ↗

Kill a Node with no uses , by setting all of its defs to null. This may recursively kill more Nodes, and is basically dead code elimination.

( )

Source from the content-addressed store, hash-verified

239 * code elimination.
240 */
241 public void kill( ) {
242 unlock();
243 moveDepsToWorklist();
244 assert isUnused(); // Has no uses, so it is dead
245 _type=null; // Flag as dead
246 while( nIns()>0 ) { // Set all inputs to null, recursively killing unused Nodes
247 Node old_def = _inputs.removeLast();
248 if( old_def != null ) {
249 IterPeeps.add(old_def);// Revisit neighbor because removed use
250 if( old_def.delUse(this) ) // If we removed the last use, the old def is now dead
251 old_def.kill(); // Kill old def
252 }
253 }
254 assert isDead(); // Really dead now
255 }
256
257 // Mostly used for asserts and printing.
258 public boolean isDead() { return isUnused() && nIns()==0 && _type==null; }

Callers 11

iterateMethod · 0.95
setDefMethod · 0.95
delDefMethod · 0.95
popUntilMethod · 0.95
subsumeMethod · 0.95
deadCodeElimMethod · 0.95
widenMethod · 0.95
parseMethod · 0.45
parseWhileMethod · 0.45
mergeScopesMethod · 0.45
endLoopMethod · 0.45

Calls 8

unlockMethod · 0.95
moveDepsToWorklistMethod · 0.95
isUnusedMethod · 0.95
nInsMethod · 0.95
addMethod · 0.95
delUseMethod · 0.95
isDeadMethod · 0.95
removeLastMethod · 0.45

Tested by

no test coverage detected