diff options
| author | Cliff Click <cliffc@acm.org> | 2025-01-13 15:09:59 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2025-01-15 15:07:30 -0800 |
| commit | 3a3d469154846b648b09c708bfe3e8c16a203654 (patch) | |
| tree | 3b7b5ce189a0129da352d4106ee34f3fd7eafdee /chapter18/src/test/java/com/seaofnodes | |
| parent | e491c528e8d9380bdef823889f0b0a8e08a34f55 (diff) | |
| download | Simple-3a3d469154846b648b09c708bfe3e8c16a203654.tar.gz Simple-3a3d469154846b648b09c708bfe3e8c16a203654.zip | |
Some dead inf call bug fixes
More comments about meeting nil above the center line falls - but does not (can not) dual.
This implies have TFPs with *no* allowed functions that are below centerline; if allowed null then its basically an alternate null. If not allowed null and not allowed any functions, its basically a high value (not executable). IfNode folds.
Do not remove a dead infinite loop - it needs to remain as a CFG sink.
Diffstat (limited to 'chapter18/src/test/java/com/seaofnodes')
| -rw-r--r-- | chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java b/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java index 217c6275..3fc5c8de 100644 --- a/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java +++ b/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java @@ -115,7 +115,7 @@ var fcn = arg ? { int x -> x*x; } : { int x -> x+x; }; return fcn(3); """); code.parse().opto(); - assertEquals("Stop[ return Phi(Region,{ int -> int #1},{ int -> int #2})( 3); return (Parm_x($fun,int)*x); return (Parm_x($fun,int)*2); ]", code._stop.toString()); + assertEquals("Stop[ return Phi(Region,{ int -> int #1},{ int -> int #2})( 3); return (Parm_x($fun,int,3)*x); return (Parm_x($fun,int,3)*2); ]", code._stop.toString()); assertEquals("6", Eval2.eval(code, 0)); assertEquals("9", Eval2.eval(code, 1)); } @@ -180,6 +180,22 @@ for(;;) { } + @Test + public void testFcn9() { + CodeGen code = new CodeGen( +""" +{int -> int}? i2i = null; +for(;;) { + if (i2i) return i2i(arg); + var x = {int i-> return i;}; + arg = x(3); +} +"""); + code.parse().opto().typeCheck().GCM().localSched(); + assertEquals("Stop[ ]", code._stop.toString()); + assertEquals("0", Eval2.eval(code, 0)); + } + // Function break @Test public void testErr1() { |
