From 0dcd3513a633479ce228f24826db4f09e4c0fc8b Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Mon, 16 Nov 2026 14:25:14 -0800 Subject: Phi fix Fix Phi/Add refactoring peephole to canonicalize regardless of peephole order. Treat class fcns as having `self` be the class pointer --- chapter28b/README.md | 9 +- .../main/java/com/seaofnodes/simple/Parser.java | 101 ++++++++++----------- .../java/com/seaofnodes/simple/node/CallNode.java | 11 ++- .../java/com/seaofnodes/simple/node/PhiNode.java | 38 ++++++-- .../com/seaofnodes/simple/node/RegionNode.java | 2 +- .../com/seaofnodes/simple/node/SummaryNode.java | 11 ++- .../java/com/seaofnodes/simple/Chapter05Test.java | 24 +++++ .../java/com/seaofnodes/simple/Chapter09Test.java | 2 +- .../java/com/seaofnodes/simple/Chapter20Test.java | 6 +- .../java/com/seaofnodes/simple/Chapter21Test.java | 8 +- .../java/com/seaofnodes/simple/Chapter22Test.java | 6 +- .../seaofnodes/simple/GlobalAssignmentTest.java | 71 +++++++++++++++ .../java/com/seaofnodes/simple/ReceiverTest.java | 94 +++++++++++++++++++ 13 files changed, 304 insertions(+), 79 deletions(-) create mode 100644 chapter28b/src/test/java/com/seaofnodes/simple/GlobalAssignmentTest.java create mode 100644 chapter28b/src/test/java/com/seaofnodes/simple/ReceiverTest.java (limited to 'chapter28b') diff --git a/chapter28b/README.md b/chapter28b/README.md index 84e538ea..5d8cbdf9 100644 --- a/chapter28b/README.md +++ b/chapter28b/README.md @@ -120,7 +120,14 @@ those exclusions by owner and slot, then restores the complement. Treating this set as FULL would expose private library functions. Unknown callback arguments, results, and unloaded summaries use the evolving Start/Stop state; no frozen public-function list supplies their bounds. Hidden class receivers -default to the defining class singleton even after import. The +default to the defining class singleton even after import, following +[chapter 28a's receiver model](../chapter28a/README.md#globals-use-the-same-receiver-as-fields). +`SummaryNode` excludes that hidden receiver from its conservative argument-escape +scan: the caller supplies no class object through the ABI, and actual publication +of the callee's class fields is already represented by the saved summary state. +Instance receivers remain ordinary arguments and participate in that scan. +[ReceiverTest](src/test/java/com/seaofnodes/simple/ReceiverTest.java) checks a +callback forwarded by another compiled class with a different field value. The [escape-flow implementation notes](../chapter29/docs/escape-flow.md) explain the shared design and the identity-remapping checks in more detail. diff --git a/chapter28b/src/main/java/com/seaofnodes/simple/Parser.java b/chapter28b/src/main/java/com/seaofnodes/simple/Parser.java index cef7091a..0e8eb5a9 100644 --- a/chapter28b/src/main/java/com/seaofnodes/simple/Parser.java +++ b/chapter28b/src/main/java/com/seaofnodes/simple/Parser.java @@ -291,8 +291,16 @@ public class Parser { // All args, "as-if" called externally for( int i=0; i