diff options
| author | Cliff Click <cliffc@acm.org> | 2025-01-09 12:08:51 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2025-01-15 15:07:30 -0800 |
| commit | 64ebe7529f9798ce036ab86ad4e09071152fe64d (patch) | |
| tree | e4b3bba870ff2f9b838ef3a00918f1ae5081449f /chapter18/src/test/java/com/seaofnodes | |
| parent | dd67005904ab8f93bacd595290159b20d10f75a5 (diff) | |
| download | Simple-64ebe7529f9798ce036ab86ad4e09071152fe64d.tar.gz Simple-64ebe7529f9798ce036ab86ad4e09071152fe64d.zip | |
Final vars and forced constants do not lazy-phi
Better comments on why a field is final
Diffstat (limited to 'chapter18/src/test/java/com/seaofnodes')
| -rw-r--r-- | chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java b/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java index 39edb352..8852537b 100644 --- a/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java +++ b/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java @@ -13,7 +13,7 @@ public class Chapter18Test { """ return 0; """); - code.parse().opto().typeCheck().GCM(); + code.parse().opto().typeCheck().GCM().localSched(); assertEquals("return 0;", code._stop.toString()); assertEquals("0", Eval2.eval(code, 0)); } @@ -179,6 +179,24 @@ return 2; assertEquals("1", Eval2.eval(code, 0)); } + @Test + public void testFcn8() { + CodeGen code = new CodeGen( +""" +{int -> int}? i2i = null; +var id = {{int->int} f-> return f;}; +for(;;) { + if (i2i) return i2i(arg); + var x = {int i-> return i;}; + arg = x(3); + i2i = id(x); +} +"""); + code.parse().opto().typeCheck().GCM().localSched(); + assertEquals("Stop[ return x( Phi(Loop,arg,x( 3))); return Parm_i(x,int,3,Phi_arg); ]", code._stop.toString()); + assertEquals("3", Eval2.eval(code, 0)); + } + // Function break @Test @@ -203,7 +221,7 @@ return 1; public void testErr2() { CodeGen code = new CodeGen( """ -{int -> int}? i2i = { int i -> return i; }; +{int -> int}? !i2i = { int i -> return i; }; for(;;) { if (i2i(2) == arg) break; i2i = null; |
