diff options
Diffstat (limited to 'chapter25')
4 files changed, 18 insertions, 9 deletions
diff --git a/chapter25/Makefile b/chapter25/Makefile index 2bae14fb..f07f5d4b 100644 --- a/chapter25/Makefile +++ b/chapter25/Makefile @@ -195,7 +195,7 @@ fuzzer: $(CLZDIR)/main/.mtag $(CLZDIR)/test/.ttag @echo "fuzzing " @$(JVM) org.junit.runner.JUnitCore com.seaofnodes.simple.FuzzerWrap -tests: $(CLZDIR)/main/.mtag $(CLZDIR)/test/.ttag tests_raw0 tests_raw1 tests_alone tests_sys +tests: $(CLZDIR)/main/.mtag $(CLZDIR)/test/.ttag tests_raw0 tests_raw1 tests_alone tests_sys fuzzer @echo "All tests" @[ -d $(OBJS) ] || mkdir -p $(OBJS) @$(JVM) org.junit.runner.JUnitCore $(test_cp) diff --git a/chapter25/src/main/java/com/seaofnodes/simple/Parser.java b/chapter25/src/main/java/com/seaofnodes/simple/Parser.java index 2b6e5ddf..5453ee05 100644 --- a/chapter25/src/main/java/com/seaofnodes/simple/Parser.java +++ b/chapter25/src/main/java/com/seaofnodes/simple/Parser.java @@ -849,8 +849,9 @@ public class Parser { // Immediately fail e.g. `arg ? 7 : ptr` ParseException err; if( !fside.equals("else") && (err=ret.err()) !=null ) throw err; + ret.keep(); r.peephole(); - return ret; + return ret.unkeep(); } /** 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 4112a977..70f678cb 100644 --- a/chapter25/src/main/java/com/seaofnodes/simple/node/PhiNode.java +++ b/chapter25/src/main/java/com/seaofnodes/simple/node/PhiNode.java @@ -144,19 +144,23 @@ public class PhiNode extends Node { return null; if( !(r.in(3-nzIdx) instanceof CProjNode z && z._idx==1 && z.ctrl()==iff) ) return null; - Node n = cast.in(1); - while( n instanceof GuardNode guard ) { + // Predicate was guarded? + Node n = cast.in(1), tested = null; + while( true ) { + if( iff.pred()==n ) tested = n; + if( !(n instanceof GuardNode guard && guard._nonZero) ) break; n = guard.in(1); - throw Utils.TODO("test and remove TODO"); } CFGNode early = CFGNode.earlyCFG(n); - return iff.pred()==cast.in(1) && (early==null || early.dominates(r)) ? n : null; + return tested!=null && (early==null || early.dominates(r)) ? n : null; } // Same op on all Phi paths; all ops have only the Phi as a use. // None have a control input. private boolean same_op() { Node busy=null; + if( in(1) instanceof ConstantNode ) + return false; for( int i=1; i<nIns(); i++ ) { Node op = in(i); if( in(1).getClass() != op.getClass() || op.in(0)!=null || in(1).nIns() != op.nIns() ) diff --git a/chapter25/src/test/java/com/seaofnodes/simple/FuzzerWrap.java b/chapter25/src/test/java/com/seaofnodes/simple/FuzzerWrap.java index a4532eb2..3aaa290a 100644 --- a/chapter25/src/test/java/com/seaofnodes/simple/FuzzerWrap.java +++ b/chapter25/src/test/java/com/seaofnodes/simple/FuzzerWrap.java @@ -20,12 +20,16 @@ public class FuzzerWrap { -6359653295501938199L, // monotonicity, escape is dead 6506797708065910879L, // missing ModeNode._mode is optimistic 650692970082394944L, // recursive bulk mem split + 8335100609598232836L, // ternary result killed by region cleanup + 2520958273643234516L, // nested guard merge + -3772838984504063325L, // fuzzer regression }; private static final long[] OPEN_FAILING_SEEDS = { - 8335100609598232836L, - 2520958273643234516L, - -3772838984504063325L, + -4628356252269023530L, + -4022199781524079249L, + 8824787517620928178L, + -673501011619761901L, }; |
