From 8ac5cc6bd3b2d30af64a2c12e38b83af618af3c6 Mon Sep 17 00:00:00 2001 From: Symious <14933944+symious@users.noreply.github.com> Date: Thu, 10 Sep 2026 02:52:50 +0800 Subject: Fix typo: spline -> spine in AddNode (chapters 4-8) (#248) The add canonicalization builds a left-leaning chain of AddNodes -- the "spine" -- with off-spine operands hanging off each in(2). The comparator and its comments were spelled "spline" (a curve / mechanical part), which was already inconsistent with the goal comment in the same method: // Goal: a left-spine set of adds, with constants on the rhs Chapters 9 and later already use "spine" / "spine_cmp"; this brings the earlier chapters in line. Comment and private-method-name only, no behavior change. Co-authored-by: Claude Opus 5 --- .../src/main/java/com/seaofnodes/simple/node/AddNode.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'chapter04') diff --git a/chapter04/src/main/java/com/seaofnodes/simple/node/AddNode.java b/chapter04/src/main/java/com/seaofnodes/simple/node/AddNode.java index 5720aca4..7e08a207 100644 --- a/chapter04/src/main/java/com/seaofnodes/simple/node/AddNode.java +++ b/chapter04/src/main/java/com/seaofnodes/simple/node/AddNode.java @@ -63,7 +63,7 @@ public class AddNode extends Node { // Now we might see (add add non) or (add non non) but never (add non add) nor (add add add) if( !(lhs instanceof AddNode) ) - return spline_cmp(lhs,rhs) ? swap12() : null; + return spine_cmp(lhs,rhs) ? swap12() : null; // Now we only see (add add non) @@ -72,22 +72,22 @@ public class AddNode extends Node { if( lhs.in(2)._type.isConstant() && t2.isConstant() ) return new AddNode(lhs.in(1),new AddNode(lhs.in(2),rhs).peephole()); - // Now we sort along the spline via rotates, to gather similar things together. + // Now we sort along the spine via rotates, to gather similar things together. // Do we rotate (x + y) + z // into (x + z) + y ? - if( spline_cmp(lhs.in(2),rhs) ) + if( spine_cmp(lhs.in(2),rhs) ) return new AddNode(new AddNode(lhs.in(1),rhs).peephole(),lhs.in(2)); return null; } - // Compare two off-spline nodes and decide what order they should be in. + // Compare two off-spine nodes and decide what order they should be in. // Do we rotate ((x + hi) + lo) into ((x + lo) + hi) ? // Generally constants always go right, then others. // Ties with in a category sort by node ID. // TRUE if swapping hi and lo. - static boolean spline_cmp( Node hi, Node lo ) { + static boolean spine_cmp( Node hi, Node lo ) { if( lo._type.isConstant() ) return false; if( hi._type.isConstant() ) return true ; -- cgit v1.2.3 From 6b4ed4d07831f738755cb8162eff24d6d9a695fc Mon Sep 17 00:00:00 2001 From: Symious <14933944+symious@users.noreply.github.com> Date: Thu, 10 Sep 2026 04:50:36 +0800 Subject: Docs: Proj is not always a data node (#250) The node recap tables in chapters 4 and 5 classify `Proj` as "Data", but `ProjNode.isCFG()` has returned true for control projections since chapter 4: ch4: return _idx==0; ch5+: return _idx==0 || ctrl() instanceof IfNode; So `Proj#0` off `Start` is a control node, and from chapter 5 both projections off an `If` are too -- which is exactly why the dominator walk in `IfNode.compute()` can step through them. Change the Type column to "Data / Control" and add a note under each table pointing at `isCFG()`. Table alignment is unchanged: "Data / Control" is the same width as "Abstract class". Docs-only change. Co-authored-by: Claude Opus 5 --- chapter04/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'chapter04') diff --git a/chapter04/README.md b/chapter04/README.md index a7b223b4..272d0b8d 100644 --- a/chapter04/README.md +++ b/chapter04/README.md @@ -39,10 +39,13 @@ Following are revised or new nodes |-----------|----------------|------------------------------------------------|-----------------------|----------------------------------------------------------------------------| | MultiNode | Abstract class | A node that has a tuple result | | A tuple | | Start | Control | Start of function, now a MultiNode | | A tuple with a ctrl token and an `arg` data node | -| Proj | Data | Projection nodes extract values from MultiNode | A MultiNode and index | Result is the extracted value from the input MultiNode at offset index | +| Proj | Data / Control | Projection nodes extract values from MultiNode | A MultiNode and index | Result is the extracted value from the input MultiNode at offset index | | Bool | Data | Represents results of a comparison operator | Two data nodes | Result is a comparison, represented as integer value where 1=true, 0=false | | Not | Data | Logical not | One data node | Result converts 0 to 1 and vice versa | +> A `Proj` is a control node when it projects the control slot: `Proj#0` off `Start`. +> Every other projection is a data node. See `ProjNode.isCFG()`. + Below is our list of Nodes from [Chapter 3](../chapter03/README.md): | Node Name | Type | Description | Inputs | Value | -- cgit v1.2.3