diff options
| author | Cliff Click <cliffc@acm.org> | 2026-10-28 16:14:30 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-10-28 16:14:30 -0700 |
| commit | 3df967056bf48bd9f87900f3a1ad9af2aedce948 (patch) | |
| tree | fdbdac5e5919deabb08d353147da32b7ccb741d8 /chapter28b/src/test/java | |
| parent | 50924bbe7cfeecfe7aec1885dae9bbda0013ac1b (diff) | |
| download | Simple-3df967056bf48bd9f87900f3a1ad9af2aedce948.tar.gz Simple-3df967056bf48bd9f87900f3a1ad9af2aedce948.zip | |
Backport some minor speedups
Diffstat (limited to 'chapter28b/src/test/java')
| -rw-r--r-- | chapter28b/src/test/java/com/seaofnodes/simple/PhaseTest.java | 23 | ||||
| -rw-r--r-- | chapter28b/src/test/java/com/seaofnodes/simple/SelectiveLoadingTest.java | 5 |
2 files changed, 27 insertions, 1 deletions
diff --git a/chapter28b/src/test/java/com/seaofnodes/simple/PhaseTest.java b/chapter28b/src/test/java/com/seaofnodes/simple/PhaseTest.java index ee262d6c..f2d09c7c 100644 --- a/chapter28b/src/test/java/com/seaofnodes/simple/PhaseTest.java +++ b/chapter28b/src/test/java/com/seaofnodes/simple/PhaseTest.java @@ -42,6 +42,29 @@ public class PhaseTest { } } + @Test public void testSchedulingScratchAcrossCompilations() { + String src = """ + int[] !xs = new int[2]; + xs[0] = arg; + int sum = 0; + for( int i=0; i<5; i++ ) { + int old = xs[arg&1]; + xs[0] = i; + sum += old; + } + return sum; + """; + for( int round=0; round<3; round++ ) { + CodeGen code = new CodeGen(src).driver(Phase.TypeCheck); + // A small graph after many earlier node allocations, then fresh + // compilations which reuse its IDs and scheduling scratch. + if( round==0 ) code._uid += 100_000; + assertEquals("6",Eval2.eval(code,0)); + assertEquals("0",Eval2.eval(code,1)); + assertEquals("8",Eval2.eval(code,2)); + } + } + @Test public void testExplicitSerializationAndMemoryExport() { CodeGen code = new CodeGen(SRC).driver(Phase.Serialize); assertNotNull(code._serial); diff --git a/chapter28b/src/test/java/com/seaofnodes/simple/SelectiveLoadingTest.java b/chapter28b/src/test/java/com/seaofnodes/simple/SelectiveLoadingTest.java index d56d5c89..fa14fc2c 100644 --- a/chapter28b/src/test/java/com/seaofnodes/simple/SelectiveLoadingTest.java +++ b/chapter28b/src/test/java/com/seaofnodes/simple/SelectiveLoadingTest.java @@ -134,7 +134,10 @@ public class SelectiveLoadingTest { @Test public void testUnknownCallbackEncoding() { for( String cpu : new String[]{"x86_64_v2","arm","riscv"} ) - new CodeGen("val apply = { {int->int} f,int n -> f(n); };") + new CodeGen(""" + val apply = { {int->int} f,int n -> f(n); }; + val apply_noInline = { {int->int} f,int n -> f(n); }; + """) .driver(CodeGen.Phase.Encoding,cpu,"SystemV"); } |
