summaryrefslogtreecommitdiff
path: root/chapter25
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-10-02 11:39:55 -0700
committerCliff Click <cliffc@acm.org>2026-10-02 11:39:55 -0700
commit6cd01a8d646750748a0af221073de8a7787472ad (patch)
tree4d4159f74efe288f51ca97c78252a8f77d9c69a9 /chapter25
parentd5352268a0a1355262eed78e3263c18486fb9d8a (diff)
downloadSimple-6cd01a8d646750748a0af221073de8a7787472ad.tar.gz
Simple-6cd01a8d646750748a0af221073de8a7787472ad.zip
Fix some older tests
Diffstat (limited to 'chapter25')
-rw-r--r--chapter25/README.md48
-rw-r--r--chapter25/src/test/java/com/seaofnodes/simple/spill/Chapter21AllocTest-testString.smp1
-rw-r--r--chapter25/src/test/java/com/seaofnodes/simple/spill/Chapter21Test-testStringExport.smp1
-rw-r--r--chapter25/src/test/java/com/seaofnodes/simple/spill/Chapter23AllocTest-testString.smp1
-rw-r--r--chapter25/src/test/java/com/seaofnodes/simple/spill/README.md7
5 files changed, 33 insertions, 25 deletions
diff --git a/chapter25/README.md b/chapter25/README.md
index b7925a1f..7ba16659 100644
--- a/chapter25/README.md
+++ b/chapter25/README.md
@@ -177,23 +177,18 @@ Chapter 21's adjacent-copy forwarding carries forward here as well: a copy
used only by the next instruction is removed when the operand accepts its
source register and is not tied to the instruction's result.
-The table below is the **earlier audit**, before adjacent-copy forwarding.
-The replay has ten String-constructor parse failures, also reproduced
-with the original allocator. On the identical 216 successful allocations,
-adjacent-copy forwarding reduced 2,563 / 5,496 moves / weighted moves to
-2,494 / 5,399. The subsequent memory corrections produce 2,488 / 5,379 on
-those same 216 successful allocations. These are partial comparisons, not
-replacement complete-suite totals. The
-current cohort 25 has 14 allocations, including later C return ABI checks;
-the historical table has ten. Native cohort-25 checks and fresh system-library
-encoding pass in both runs. See the [backport record](../docs/chapter-backports.md)
-for the pending fixture failures.
+The table below is the complete 2026-10-02 replay, after repairing three saved
+String sources with explicit constructors for their required `cs` field.
+All 212 historical entries now pass. This establishes a new baseline after the
+fixture adaptations and recent compiler corrections; it is not an allocator-only
+comparison with the earlier audit. The [backport record](../docs/chapter-backports.md)
+retains the older partial comparisons.
Run `make spill-stats`. Each row uses **Chapter 25's compiler**. The first five
rows preserve the earlier 212 program/target entries, adapted to this chapter's
syntax and library organization; the [fixture notes](src/test/java/com/seaofnodes/simple/spill/README.md)
list those adaptations and the measurement limits. They use optimizer seed 123.
-The last row includes nine allocations from `Chapter25Test` at its existing
+The last row includes thirteen recorded allocations from `Chapter25Test` at its existing
seeds plus a fresh system-library compilation at the driver's seed 456. Reusing
`sys.o` must not make that substantial workload disappear from the measurements.
These results are from Windows x86-64; earlier cohorts also include RISC-V/ARM
@@ -201,36 +196,39 @@ SystemV and x86 SystemV. The reporter prints per-target totals as well.
| Program cohort | Compilations | Split/move count | Loop-weighted count |
|---|---:|---:|---:|
-| Chapter 20 | 39 | 381 | 612 |
-| Chapter 21 | 52 | 464 | 1,185 |
-| Chapter 22 | 24 | 103 | 131 |
-| Chapter 23 | 30 | 122 | 346 |
-| Chapter 24 | 67 | 744 | 1,479 |
-| Chapter 25 | 10 | 783 | 1,826 |
-| **Total** | **222** | **2,597** | **5,579** |
+| Chapter 20 | 39 | 375 | 606 |
+| Chapter 21 | 52 | 479 | 1,172 |
+| Chapter 22 | 24 | 103 | 103 |
+| Chapter 23 | 30 | 129 | 353 |
+| Chapter 24 | 67 | 696 | 1,410 |
+| Chapter 25 | 14 | 786 | 1,815 |
+| **Total** | **226** | **2,568** | **5,459** |
`_spills` counts retained SplitNodes, including register-to-register moves;
`_spillScaled` applies the loop weight. Neither measures just memory traffic.
The old cohorts are allocation replays with register-legality checks, not reruns
-of their native harnesses. `Chapter25Test` still runs its native/result checks.
+of their native harnesses. All 23 `Chapter25Test` tests pass, including their
+native/result checks, with no spill-golden failures.
Use `make -j 4 tests` for the full chapter, including inherited emulator tests.
### Comments on the measurements
-There is no uniform improvement to claim. Substituting Chapter 24's ranking
-while keeping the rest of this compiler unchanged saves five moves on the 221
-client compilations (2,206 / 4,719 versus 2,211 / 4,724), but fails to allocate
+The earlier allocator audit found no uniform improvement. Substituting Chapter
+24's ranking while keeping the rest of that compiler unchanged saved five moves on the 221
+client compilations (2,206 / 4,719 versus 2,211 / 4,724), but failed to allocate
the system library within eight rounds. It is therefore an incomplete comparison,
not a lower valid whole-suite total. The existing area/cost ranking is retained;
the round limit and correctness checks are unchanged. The system library itself
-contributes 386 moves / 855 weighted moves.
+contributed 386 moves / 855 weighted moves in that audit; the current replay
+measures 373 / 828.
A trial that favored all multi-use cloneable constants saved one move against
the earlier ranking on those clients, but also failed the fresh library build.
It was rejected. This is why both aggregate statistics and complete compilation
and execution checks matter; a favorable subtotal cannot justify a change.
-The earlier-cohort total rises from Chapter 24's 1,332 / 2,956 to 1,814 / 3,753.
+In that earlier audit, the historical-cohort total rose from Chapter 24's
+1,332 / 2,956 to Chapter 25's 1,814 / 3,753.
Chapter 25 adds class initializers, module ownership, different escape analysis,
and syntax/library adaptations. These are different machine graphs; the increase
cannot be attributed to allocator quality alone. Compare a heuristic within one
diff --git a/chapter25/src/test/java/com/seaofnodes/simple/spill/Chapter21AllocTest-testString.smp b/chapter25/src/test/java/com/seaofnodes/simple/spill/Chapter21AllocTest-testString.smp
index dafa7456..86220b7a 100644
--- a/chapter25/src/test/java/com/seaofnodes/simple/spill/Chapter21AllocTest-testString.smp
+++ b/chapter25/src/test/java/com/seaofnodes/simple/spill/Chapter21AllocTest-testString.smp
@@ -2,6 +2,7 @@
struct String {
u8[] cs;
int _hashCode;
+ new String = { u8[] data -> cs=data; };
};
// Compare two Strings
diff --git a/chapter25/src/test/java/com/seaofnodes/simple/spill/Chapter21Test-testStringExport.smp b/chapter25/src/test/java/com/seaofnodes/simple/spill/Chapter21Test-testStringExport.smp
index 6cc28315..3a696d66 100644
--- a/chapter25/src/test/java/com/seaofnodes/simple/spill/Chapter21Test-testStringExport.smp
+++ b/chapter25/src/test/java/com/seaofnodes/simple/spill/Chapter21Test-testStringExport.smp
@@ -1,6 +1,7 @@
struct String {
u8[] cs;
int _hashCode;
+ new String = { u8[] data -> cs=data; };
};
// Compare two Strings
diff --git a/chapter25/src/test/java/com/seaofnodes/simple/spill/Chapter23AllocTest-testString.smp b/chapter25/src/test/java/com/seaofnodes/simple/spill/Chapter23AllocTest-testString.smp
index 3fa2174c..1a4d55c1 100644
--- a/chapter25/src/test/java/com/seaofnodes/simple/spill/Chapter23AllocTest-testString.smp
+++ b/chapter25/src/test/java/com/seaofnodes/simple/spill/Chapter23AllocTest-testString.smp
@@ -2,6 +2,7 @@
struct String {
u8[] cs;
int _hashCode;
+ new String = { u8[] data -> cs=data; };
};
// Compare two Strings
diff --git a/chapter25/src/test/java/com/seaofnodes/simple/spill/README.md b/chapter25/src/test/java/com/seaofnodes/simple/spill/README.md
index 6c78d46f..57435402 100644
--- a/chapter25/src/test/java/com/seaofnodes/simple/spill/README.md
+++ b/chapter25/src/test/java/com/seaofnodes/simple/spill/README.md
@@ -17,6 +17,13 @@ Chapter 25 cannot parse all earlier sources unchanged. Adaptations are explicit:
- String, Scan, and linked S constructors replace `new S { field=...; }` with
declared constructors and arguments. The explicit-receiver scanner functions
become instance methods, preserving their operations.
+- The saved `Chapter21Test-testStringExport`, `Chapter21AllocTest-testString`,
+ and `Chapter23AllocTest-testString` sources declare
+ `new String = { u8[] data -> cs=data; };` to initialize the required non-null
+ `cs` field. This repairs ten replay entries (four, three, and three), without
+ changing their equality/hash bodies or manifest membership. These adapted
+ sources are a new comparison baseline; their totals cannot be compared as
+ identical inputs with the earlier constructor-free fixtures.
- The two short-circuit RHS initializer loops become equivalent guarded blocks,
preserving allocation, side effects, and the final result.
- Simple I/O cases include the old `write` binding and print helper directly.