summaryrefslogtreecommitdiff
path: root/chapter25
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-09-27 08:52:12 -0700
committerCliff Click <cliffc@acm.org>2026-09-27 08:52:12 -0700
commitc5ef4e52fd7d183861b33476db999fa04f777607 (patch)
treefae4a9fb155a2e60b4b4390cd0ad3d30851257c8 /chapter25
parent4391fcc03a214e6296e19ca42487de023ab12f6a (diff)
downloadSimple-c5ef4e52fd7d183861b33476db999fa04f777607.tar.gz
Simple-c5ef4e52fd7d183861b33476db999fa04f777607.zip
Remove -disablePeephole
Diffstat (limited to 'chapter25')
-rw-r--r--chapter25/src/test/java/com/seaofnodes/simple/Chapter02Test.java2
-rw-r--r--chapter25/src/test/java/com/seaofnodes/simple/Chapter03Test.java7
-rw-r--r--chapter25/src/test/java/com/seaofnodes/simple/Chapter11Test.java11
-rw-r--r--chapter25/src/test/java/com/seaofnodes/simple/Chapter18Test.java11
-rw-r--r--chapter25/src/test/java/com/seaofnodes/simple/Eval2.java1
-rw-r--r--chapter25/src/test/java/com/seaofnodes/simple/fuzzer/Fuzzer.java4
-rw-r--r--chapter25/src/test/java/com/seaofnodes/simple/fuzzer/FuzzerUtils.java2
-rw-r--r--chapter25/src/test/java/com/seaofnodes/simple/node/PrintTestSupport.java48
8 files changed, 5 insertions, 81 deletions
diff --git a/chapter25/src/test/java/com/seaofnodes/simple/Chapter02Test.java b/chapter25/src/test/java/com/seaofnodes/simple/Chapter02Test.java
index 631e1487..a51ac202 100644
--- a/chapter25/src/test/java/com/seaofnodes/simple/Chapter02Test.java
+++ b/chapter25/src/test/java/com/seaofnodes/simple/Chapter02Test.java
@@ -12,7 +12,7 @@ public class Chapter02Test {
@Test
public void testParseGrammar() {
CodeGen code = new CodeGen("return 1+2*3+-5;");
- code.parse(); // No more disable peepholes
+ code.parse();
assertEquals("return 2;", code.print());
}
diff --git a/chapter25/src/test/java/com/seaofnodes/simple/Chapter03Test.java b/chapter25/src/test/java/com/seaofnodes/simple/Chapter03Test.java
index c96acddc..f1e4af12 100644
--- a/chapter25/src/test/java/com/seaofnodes/simple/Chapter03Test.java
+++ b/chapter25/src/test/java/com/seaofnodes/simple/Chapter03Test.java
@@ -27,13 +27,6 @@ public class Chapter03Test {
}
@Test
- public void testVarScopeNoPeephole() {
- CodeGen code = new CodeGen("int a=1; int b=2; int !c=0; { int b=3; c=a+b; } return c; ");
- code.parse(); // Peepholes always run now
- assertEquals("return 4;", code.print());
- }
-
- @Test
public void testVarDist() {
CodeGen code = new CodeGen("int x0=1; int y0=2; int x1=3; int y1=4; return (x0-x1)*(x0-x1) + (y0-y1)*(y0-y1); ");
code.parse();
diff --git a/chapter25/src/test/java/com/seaofnodes/simple/Chapter11Test.java b/chapter25/src/test/java/com/seaofnodes/simple/Chapter11Test.java
index 60a31c40..2e661901 100644
--- a/chapter25/src/test/java/com/seaofnodes/simple/Chapter11Test.java
+++ b/chapter25/src/test/java/com/seaofnodes/simple/Chapter11Test.java
@@ -6,17 +6,6 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class Chapter11Test {
- @Test public void testPrintingPreservesGraph() throws Exception {
- var code = new CodeGen("while(arg < 10) arg = arg + 1; return arg;").parse().opto().typeCheck().GCM().localSched();
- var stop = code._stop;
- new com.seaofnodes.simple.node.ConstantNode(com.seaofnodes.simple.type.TypeInteger.constant(123456));
- com.seaofnodes.simple.node.PrintTestSupport.unchanged(stop, () -> {
- String first = stop.p(99);
- assertEquals(first,stop.p(99));
- stop.toString();
- });
- }
-
@Test
public void testPrimes() {
diff --git a/chapter25/src/test/java/com/seaofnodes/simple/Chapter18Test.java b/chapter25/src/test/java/com/seaofnodes/simple/Chapter18Test.java
index 82529019..815a035f 100644
--- a/chapter25/src/test/java/com/seaofnodes/simple/Chapter18Test.java
+++ b/chapter25/src/test/java/com/seaofnodes/simple/Chapter18Test.java
@@ -79,17 +79,6 @@ public class Chapter18Test {
org.junit.Assert.assertSame(declared,field.get(v));
}
- @Test public void testPrintingLazyMemory() throws Exception {
- var code = new CodeGen("return 0;").parse();
- var base = new ConstantNode(com.seaofnodes.simple.type.TypeMem.BOT);
- var outer = new ScopeNode();
- var inner = new ScopeNode();
- outer.addDef(null); outer.addDef(base);
- inner.addDef(null); inner.addDef(outer);
- var mem = new MemMergeNode(null,base,inner);
- PrintTestSupport.unchanged(mem, () -> org.junit.Assert.assertTrue(mem.toString().contains("Lazy_")));
- }
-
@Test
public void testJig() {
diff --git a/chapter25/src/test/java/com/seaofnodes/simple/Eval2.java b/chapter25/src/test/java/com/seaofnodes/simple/Eval2.java
index ea4ec326..5716c1b8 100644
--- a/chapter25/src/test/java/com/seaofnodes/simple/Eval2.java
+++ b/chapter25/src/test/java/com/seaofnodes/simple/Eval2.java
@@ -168,6 +168,7 @@ public abstract class Eval2 {
switch( prior ) {
case StartNode start: F = new Frame(F); break; // Frame for the call to main, as-if Called
case CallNode call : BB = call(call); break;
+ case NeverNode never: BB = never.cproj(0); break; // Synthetic exit is never taken.
case IfNode iff : Object p = val(iff.pred()); BB = iff.cproj( p==null || (p instanceof Long x && x==0L) ? 1 : 0); break;
case ReturnNode ret : if( clj(ret.rpc()).isStop() ) return exit(ret); else BB = ret(ret); break;
case FunNode fun : if( loopCnt++ > timeout ) return null; break; // Timeout
diff --git a/chapter25/src/test/java/com/seaofnodes/simple/fuzzer/Fuzzer.java b/chapter25/src/test/java/com/seaofnodes/simple/fuzzer/Fuzzer.java
index 223515f8..ec9e3910 100644
--- a/chapter25/src/test/java/com/seaofnodes/simple/fuzzer/Fuzzer.java
+++ b/chapter25/src/test/java/com/seaofnodes/simple/fuzzer/Fuzzer.java
@@ -16,7 +16,7 @@ import java.util.function.Consumer;
* randomly choose a variation the parser would parse and generate it.
* These scripts are the parsed by the parser and all exceptions are caught and filtered
* to only show one occurrence of one problem. This includes script which generate different
- * results when the compiled graph with and without peeps is executed.
+ * results when graphs optimized with different worklist seeds are executed.
* To aid debugging scripts that cause errors are then reduced by applying rules and checking
* that the same issue persists.
*/
@@ -73,7 +73,7 @@ public class Fuzzer {
}
/**
- * Run checks for script. Compile the script with peeps enabled and disabled.
+ * Run checks for script. Compile the script with two different optimizer worklist seeds.
* Check that exceptions raised in the parser by both methods are the same and only happens if the script may be invalid.
* If the script was successfully parsed check that both version behave the same.
* @param script The script to test
diff --git a/chapter25/src/test/java/com/seaofnodes/simple/fuzzer/FuzzerUtils.java b/chapter25/src/test/java/com/seaofnodes/simple/fuzzer/FuzzerUtils.java
index 7b3917f4..9fe2e405 100644
--- a/chapter25/src/test/java/com/seaofnodes/simple/fuzzer/FuzzerUtils.java
+++ b/chapter25/src/test/java/com/seaofnodes/simple/fuzzer/FuzzerUtils.java
@@ -92,7 +92,7 @@ class FuzzerUtils {
}
/**
- * Parse script with peepholes enabled or disabled
+ * Parse and optimize using the given worklist seed
*/
public static CodeGen parse(String script, long workListSeed, boolean resetTypes ) {
var err = System.err;
diff --git a/chapter25/src/test/java/com/seaofnodes/simple/node/PrintTestSupport.java b/chapter25/src/test/java/com/seaofnodes/simple/node/PrintTestSupport.java
deleted file mode 100644
index ceea1de5..00000000
--- a/chapter25/src/test/java/com/seaofnodes/simple/node/PrintTestSupport.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.seaofnodes.simple.node;
-import java.util.*;
-import static org.junit.Assert.*;
-
-// Inspect raw fields: the regression must not itself use lazy accessors.
-public class PrintTestSupport {
- public static void unchanged(Node root, Runnable print) throws Exception {
- var hash = Node.class.getDeclaredField("_hash");
- hash.setAccessible(true);
- var nodes = new ArrayList<Node>();
- var seen = new IdentityHashMap<Node,Boolean>();
- nodes.add(root);
- seen.put(root,true);
- for( int i=0; i<nodes.size(); i++ ) {
- Node n = nodes.get(i);
- for( Node def : n._inputs )
- if( def!=null && seen.put(def,true)==null ) nodes.add(def);
- for( Node use : n._outputs )
- if( use!=null && seen.put(use,true)==null ) nodes.add(use);
- }
- var ins = new IdentityHashMap<Node,Node[]>();
- var outs = new IdentityHashMap<Node,Node[]>();
- var hashes = new IdentityHashMap<Node,Integer>();
- var versions = new IdentityHashMap<Node,Integer>();
- var depths = new IdentityHashMap<Node,Integer>();
- for( Node n : nodes ) {
- ins.put(n,n._inputs.toArray(new Node[0]));
- outs.put(n,n._outputs.toArray(new Node[0]));
- hashes.put(n,hash.getInt(n));
- if( n instanceof CFGNode cfg ) {
- depths.put(n,(int)cfg._idepth);
- versions.put(n,(int)cfg._idepthVersion);
- }
- }
- print.run();
- for( Node n : nodes ) {
- assertEquals("hash of node "+n._nid,(int)hashes.get(n),hash.getInt(n));
- if( n instanceof CFGNode cfg ) {
- assertEquals("depth of node "+n._nid,(int)depths.get(n),cfg._idepth);
- assertEquals("depth version of node "+n._nid,(int)versions.get(n),cfg._idepthVersion);
- }
- assertEquals(ins.get(n).length,n.nIns());
- assertEquals(outs.get(n).length,n.nOuts());
- for( int i=0; i<n.nIns(); i++ ) assertSame(ins.get(n)[i],n.in(i));
- for( int i=0; i<n.nOuts(); i++ ) assertSame(outs.get(n)[i],n._outputs.get(i));
- }
- }
-}