diff options
Diffstat (limited to 'chapter25/src/main/java')
4 files changed, 18 insertions, 14 deletions
diff --git a/chapter25/src/main/java/com/seaofnodes/simple/Parser.java b/chapter25/src/main/java/com/seaofnodes/simple/Parser.java index b6feb809..37c43a7a 100644 --- a/chapter25/src/main/java/com/seaofnodes/simple/Parser.java +++ b/chapter25/src/main/java/com/seaofnodes/simple/Parser.java @@ -1249,6 +1249,7 @@ public class Parser { priv = new ProjNode(cend,2,"#selfMem").peephole(); } + priv.keep(); for( Field field : ts._fields ) { Type storage = field._t.makeStorage(); Field escaped = field._final ? field : Field.make(field._fname,storage,field._alias,true); @@ -1260,6 +1261,7 @@ public class Parser { pub.unkeep(); pub = next; } + priv.unkill(); ReturnNode ret = (ReturnNode)new ReturnNode(ctl,pub,self,rpc,fun).peephole(); fun.setRet(ret); fun._approxUIDs = _code.UID() - oldUID; @@ -1697,10 +1699,11 @@ public class Parser { int dir = parseCompDir(); // No compare if( dir==0 ) return lhs; + lhs.keep(); // Compare Node rhs = parseShift().keep(); - Node cmp = makeCompBool(dir,lhs,rhs); // Convert to a bool + Node cmp = makeCompBool(dir,lhs.unkeep(),rhs); // Convert to a bool // Stacked compares? int dir0 = parseCompDir(); @@ -1713,7 +1716,7 @@ public class Parser { // rhs is keeped() and becomes lhs // cmp is NOT keeped() and is the last test Node ifNode = new IfNode(ctrl(), cmp).peephole(); - Node ifT = new CProjNode(ifNode. keep(), 0, "True" ).peephole(); + Node ifT = new CProjNode(ifNode. keep(), 0, "True" ).peephole().keep(); Node ifF = new CProjNode(ifNode.unkeep(), 1, "False").peephole(); // False side does nothing but capture memory & side-effects ScopeNode fail = _scope.dup(); @@ -1726,12 +1729,12 @@ public class Parser { if( Math.abs(dir) != Math.abs(dir0) ) throw error("Mixing relational directions in a chained relational test"); // True side parses next arm of test - ctrl(ifT); + ctrl(ifT.unkeep()); lhs = rhs; // lhs is keeped() and is old RHS rhs = parseShift().keep(); cmp = makeCompBool(dir,lhs.unkeep(),rhs); // Convert to a bool ifNode = new IfNode(ctrl(), cmp).peephole(); - ifT = new CProjNode(ifNode. keep(), 0, "True" ).peephole(); + ifT = new CProjNode(ifNode. keep(), 0, "True" ).peephole().keep(); ifF = new CProjNode(ifNode.unkeep(), 1, "False").peephole(); // Merge result into the fail case ctrl(ifF); @@ -1740,7 +1743,7 @@ public class Parser { dir0 = parseCompDir(); } rhs.unkill(); - ctrl(ifT); + ctrl(ifT.unkeep()); RegionNode r = fail.mergeScopes(_scope, loc()).init(); _scope = fail; return new PhiNode("", r,_code.ZERO,con(1)).peephole(); diff --git a/chapter25/src/main/java/com/seaofnodes/simple/codegen/CodeGen.java b/chapter25/src/main/java/com/seaofnodes/simple/codegen/CodeGen.java index a83b82a1..24a12e6d 100644 --- a/chapter25/src/main/java/com/seaofnodes/simple/codegen/CodeGen.java +++ b/chapter25/src/main/java/com/seaofnodes/simple/codegen/CodeGen.java @@ -182,24 +182,24 @@ public class CodeGen { // --------------------------- // Test setup; no module nor file with specific argument - public CodeGen( String src ) { this(src, 126L ); } + public CodeGen( String src ) { this(src, 126L, true ); } // Test setup; no module nor file; can alter seed & argument; can re-run same CodeGen public CodeGen( String src, Type arg ) { - this(null,null,null,null, src, 126L, arg); + this(null,null,null,null, src, 126L, true, arg); } // Test setup; no module nor file; can alter seed & argument; can re-run same CodeGen - public CodeGen( String src, long workListSeed ) { - this(null,null,null,null, src, workListSeed, TypeInteger.BOT); + public CodeGen( String src, long workListSeed, boolean resetTypes ) { + this(null,null,null,null, src, workListSeed, resetTypes, TypeInteger.BOT); } // Generic CodeGen, including full module setup public CodeGen( String modDir, String buildDir, Ary<String> externPaths, - String srcName, String src, long workListSeed, Type arg ) { + String srcName, String src, long workListSeed, boolean resetTypes, Type arg ) { // Public singleton to avoid passing about this state to a huge count // of places. Probably becomes a TLS at some point. CODE = this; - Type.reset(); // Reset to recover from failed test + if( resetTypes ) Type.reset(); // Reset to recover from failed test _cwd = System.getProperty("user.dir")+"/"; _modDir = modDir == null ? _cwd : modDir; diff --git a/chapter25/src/main/java/com/seaofnodes/simple/node/FunNode.java b/chapter25/src/main/java/com/seaofnodes/simple/node/FunNode.java index 890a23b0..d9d3e451 100644 --- a/chapter25/src/main/java/com/seaofnodes/simple/node/FunNode.java +++ b/chapter25/src/main/java/com/seaofnodes/simple/node/FunNode.java @@ -411,9 +411,9 @@ public class FunNode extends RegionNode { } - // FunNodes must match signature (equivalent: no 2 FunNodes are ever GVN'able) + // no 2 FunNodes are ever GVN'able @Override public boolean eq( Node n ) { - return _sig == ((FunNode)n)._sig; + return this==n; } @Override public int hash() { diff --git a/chapter25/src/main/java/com/seaofnodes/simple/node/PhiNode.java b/chapter25/src/main/java/com/seaofnodes/simple/node/PhiNode.java index 78a2690a..2b6d2666 100644 --- a/chapter25/src/main/java/com/seaofnodes/simple/node/PhiNode.java +++ b/chapter25/src/main/java/com/seaofnodes/simple/node/PhiNode.java @@ -141,7 +141,8 @@ public class PhiNode extends Node { if( in(1).getClass() != op.getClass() || op.in(0)!=null || in(1).nIns() != op.nIns() ) return false; // Wrong class or CFG bound or mismatched inputs if( in(1) instanceof MemOpNode mem ) { - assert mem._alias == ((MemOpNode)op)._alias; + // Mismatched aliases + if( mem._alias != ((MemOpNode)op)._alias ) return false; // Load is clobbered somewhere, and can not be pulled forward past the Phi? if( mem instanceof LoadNode ) for( Node use : op.outs() ) |
