Explorar o código

docs: finalize open-array M6 summary and gates

Eric Streit hai 2 días
pai
achega
c22e4aeab6

+ 5 - 5
README.md

@@ -47,20 +47,20 @@ docs/              STATUS.md, plan.md, plan-*.md, analysis_*.md, summary_*.md
 
 ## Status (2026-10-23)
 
-- Suite **299/299**; self-hosting **fixpoint OK** (byte-identical
-  stage2/stage3, 3,534,072 bytes); corpus **518/612 compile-OK,
+- Suite **300/300**; self-hosting **fixpoint OK** (byte-identical
+  stage2/stage3, 3,571,371 bytes); corpus **518/612 compile-OK,
   0 crashes** (`tools/v3-corpus`; the corpus is gm2's testsuite, so it
   mixes conforming Modula-2 with gm2 leniencies — see `docs/gaps/`).
   The remaining `except*`/`onebyte*`-style corpus files still hit V3's
   declaration-order policy.
-- Active branch **`master`**, feature state **`v3-open-arrays-m5`**.
+- Active branch **`master`**, feature state **`v3-open-arrays`**.
   Recent milestones: `PACKEDSET`, ISO exceptions (`EXCEPT`/`RETRY`,
   `EXCEPTIONS`, `M2EXCEPTION`, catchable language traps including
   `functionException`, module `FINALLY`), self-referential pointer
   records/chained fields, and multi-dimensional fixed/open arrays
   (M1–M4): flat payloads + per-level views, open-array calls, and
-  payload `SIZE`/view `ADR`, and flat multi-dimensional record fields
-  and constructors.
+  payload `SIZE`/view `ADR`, flat multi-dimensional record fields and
+  constructors, and pointer-based 1-D open views.
 
 Lowers today: program modules; `CONST`/`VAR`/`TYPE` (scalars,
 subranges, enums, arrays, records incl. variants and self-referential

+ 5 - 3
docs/INDEX.md

@@ -20,7 +20,7 @@ bisecting *why* a decision was made, not for reading end-to-end).
 - **`features.md`** — the feature list.
 - **`comparison-PIM4-gm2-V3.md`** — PIM4 / GNU Modula-2 / **M2R10** /
   **TopSpeed V3** / V3 feature comparison (2026-10-23; V3 at
-  `v3-open-arrays-m5`; filename kept for link stability).
+  `v3-open-arrays`; filename kept for link stability).
 - **`analysis_gaps.md`** — language gaps + corpus notes.
 - **`gaps/README.md`** — minimal reproducers, one per unsupported gap,
   and the gm2-extension policy.
@@ -45,8 +45,8 @@ bisecting *why* a decision was made, not for reading end-to-end).
 - **`design-open-arrays.md`** — multi-dimensional open-array ABI:
   per-level view descriptors over a flat backing block, payload
   `SIZE`/`ADR`, fixed/open 2-D and 3-D arrays, row/byte flattening,
-  records/constructors and corpus mapping.  M1–M5 are implemented;
-  only the optional pointer-based 1-D view and final M6 polish remain.
+  records/constructors and corpus mapping.  M1–M6 are implemented,
+  including pointer-based 1-D views and the final gate/tag.
 - `blaise-phases-map.md`, `language-report.md`, `grammar.md` — the
   grammar/phases reference.
 - `summary_l3_selfhost_fix.md` — the self-host root cause; also where
@@ -54,6 +54,8 @@ bisecting *why* a decision was made, not for reading end-to-end).
 
 ## Recent session summaries (newest first)
 
+- **`summary_session-2026-10-24-open-arrays-m6.md`** — M6 pointer-based
+  1-D views and final gates; tag `v3-open-arrays`.
 - **`summary_session-2026-10-24-open-arrays-m5.md`** — M5 record
   fields and constructors: inline flat payloads, synthesized field
   views, static/runtime constructors; tag `v3-open-arrays-m5`.

+ 4 - 5
docs/STATUS.md

@@ -4,9 +4,9 @@ This answers "where are we now?".
 
 ## Numbers
 
-- Suite **299/299** (`compiler/run_tests.sh`).
+- Suite **300/300** (`compiler/run_tests.sh`).
 - Self-hosting **FIXPOINT OK** — stage2 and stage3 images are
-  byte-identical (3,534,072 bytes).
+  byte-identical (3,571,371 bytes).
 - Corpus **518 / 612** sources compile with 0 errors, **0 crashes**
   (`tools/v3-corpus/corpus.sh` over the gm2 testsuite; the harness now
   resolves V3's own shipped libraries); the rest are genuine language
@@ -14,7 +14,7 @@ This answers "where are we now?".
   imports of gm2-only modules.  Open-array corpus cases `unbounded`,
   `unbounded2`, `unbounded3`, `unbounded4` and `array9` now compile;
   `unbounded`/`unbounded2`/`unbounded3`/`unbounded4` also run.
-- Branch **`master`**, feature state **`v3-open-arrays-m5`**; tree
+- Branch **`master`**, feature state **`v3-open-arrays`**; tree
   clean.
 
 ## Architecture (current)
@@ -179,8 +179,7 @@ declarations still work (`t_fwdproc`, `t_fwdok`).
    at the stop point.  The remaining `LANG` entries are mostly:
    **declaration order** cases V3 rejects by policy (`docs/gaps/`); ISO
    exceptions (coroutine/protection follow-ups — see
-   `docs/design-exceptions.md`); gm2-only extensions; and the optional
-   pointer-based 1-D view migration.  See
+   `docs/design-exceptions.md`) and gm2-only extensions.  See
    `docs/handoff-2026-10-23-next.md` and `docs/analysis_gaps.md`.
 2. ~~**The size-sensitive V3 miscompile**~~ — **root-caused and fixed**
    (2026-10-19; see `docs/summary_l3_selfhost_fix.md`).  It was never

+ 3 - 3
docs/comparison-PIM4-gm2-V3.md

@@ -1,7 +1,7 @@
 # PIM4 vs GNU Modula-2 vs M2R10 vs TopSpeed V3 vs V3 — feature comparison
 
-**Date:** 2026-10-24 · **V3 state:** `v3-open-arrays-m5` (suite
-299/299, self-hosting fixpoint OK 3,534,072 bytes, corpus 518/612,
+**Date:** 2026-10-24 · **V3 state:** `v3-open-arrays` (suite
+300/300, self-hosting fixpoint OK 3,571,371 bytes, corpus 518/612,
 0 crashes).
 
 **Scope and sources.**
@@ -201,7 +201,7 @@ change individual cells.
 - V3: `docs/STATUS.md`, `docs/features.md`, `docs/gaps/README.md`,
   `docs/analysis_gaps.md`,
   `docs/summary_session-2026-10-23-open-arrays.md`; the gates in this
-  document were run at `v3-open-arrays-m5`.
+  document were run at `v3-open-arrays`.
 - gm2: the GCC Modula-2 testsuite and `gm2-libs`/`gm2-libs-iso`
   definition modules in the sibling `gcc-git` tree.
 - M2R10: the published R10 grammar (m2r10-grammar.gll) and

+ 21 - 5
docs/design-open-arrays.md

@@ -1,11 +1,11 @@
 # Design — multi-dimensional open arrays
 
-**Status: design + M1–M5 (2026-10-24).**  Rank-2/3 fixed and open
+**Status: M1–M6 complete (2026-10-24).**  Rank-2/3 fixed and open
 arrays use the view ABI; array `SIZE`/`TSIZE` and view `ADR` are
 implemented; multi-dimensional record fields and constructors use the
-flat layout.  The 1-D open descriptor still uses its legacy
-`{count,data}` layout at ABI boundaries.  Current gates: suite
-**299/299**, fixpoint OK **3,534,072 bytes**, corpus **518/612
+flat layout; 1-D open formals use pointer-based views internally, with
+legacy descriptors only at C ABI boundaries.  Current gates: suite
+**300/300**, fixpoint OK **3,571,371 bytes**, corpus **518/612
 compile-OK**, 0 crashes.
 
 Interactive decisions already taken:
@@ -442,7 +442,23 @@ Gates after each step: suite, fixpoint, corpus.
    - Tests: `t_record_multidim`, `t_record_multidim_ctor`,
      `t_record_multidim_const`, `t_record_multidim_arrctor`, plus
      `t_nestarr`; suite 299/299.
-6. **M6 — final docs/gates/tag `v3-open-arrays`.**
+6. **M6 — 1-D views and final polish** — **done (2026-10-24)**
+   - Internal 1-D open formals now receive a 40-byte view
+     (`count`, `elemBytes`, `stride`, `base`, `next=0`) built from a
+     fixed array, string literal, row/multi subview or byte-flattened
+     view.  Indexing, `HIGH`/`LEN`, payload `SIZE`, `ADR` and `VAR`
+     writes use the view directly; row `ADR` identity is preserved.
+   - External C functions still receive the legacy `{count,data}`
+     descriptor.  Calls to external procedures materialize/copy it and
+     copy back for `VAR`; fixed 1-D arrays passed directly to C keep
+     the old ABI.
+   - Compiler bootstrap uses `V3_LEGACY_OPEN1D=1`: compiler units are
+     built with the legacy 1-D call ABI, while the resulting compiler
+     emits pointer-based views for user programs.  This avoids a
+     stage-2 self-host miscompile; the suite runs without the variable
+     and exercises the view ABI.
+   - Added `t_open_row_adr`; suite **300/300**.
+   - Final tag **`v3-open-arrays`**.
 
 `unbounded5` remains a declaration-order case, not this feature.
 

+ 6 - 4
docs/features.md

@@ -1,4 +1,4 @@
-# m2compiler-V3 — feature status (2026-10-24; suite 299/299 green)
+# m2compiler-V3 — feature status (2026-10-24; suite 300/300 green)
 
 Pipeline: Coco/R `M2.atg` (1748 lines, 73 productions) → `gm2`-built
 `M2` → QBE `.ssa` → `qbe` → `cc` → run. `SymTab.mod` 1623 lines,
@@ -29,9 +29,11 @@ Legend: ✅ done · 🔄 partial · ⏸ not started / deferred.
   repeated-group form `ARRAY [lo..hi], [lo..hi] OF T`; fixed and open
   multi-dimensional formals (`ARRAY OF ARRAY OF …`) use flat payloads
   + per-level views, with row/subarray conversion and open-to-open
-  forwarding.  Record/class fields of rank 2/3 are inline flat payloads
-  with synthesized views; record and array-of-record constructors
-  support them.
+  forwarding.  Internal 1-D open formals use pointer-based views (row
+  `ADR` identity preserved); external C boundaries still receive the
+  legacy descriptor.  Record/class fields of rank 2/3 are inline flat
+  payloads with synthesized views; record and array-of-record
+  constructors support them.
 - ✅ ISO empty string literal: `""`/`''` is compatible with `CHAR`
   (value 0) in assignment, comparison, `CASE` labels, `FOR` bounds,
   actuals and `RETURN`; in an `ARRAY OF CHAR` context it stays the

+ 12 - 3
docs/handoff-2026-10-23-next.md

@@ -1,7 +1,7 @@
 # Next session — plan (from 2026-10-23)
 
 **Branch:** `master`.  **Feature state:** `v3-exceptions` + `v3-ptrchain` + `v3-function-exception` + `v3-finally` + open-array M1/M2/M3/M4.
-**Gates:** suite **299/299**, fixpoint **OK (3,534,072 bytes)**,
+**Gates:** suite **300/300**, fixpoint **OK (3,571,371 bytes)**,
 corpus **518/612, 0 crashes**.
 
 Read first: `docs/STATUS.md`, `docs/features.md`,
@@ -125,8 +125,17 @@ array-of-record constructors handle the flat fields.  Tests:
 `t_record_multidim`, `t_record_multidim_ctor`,
 `t_record_multidim_const`, `t_record_multidim_arrctor`, `t_nestarr`.
 Suite **299/299**, fixpoint **3,534,072 bytes**, corpus **518/612**.
-Remaining: optional pointer-based 1-D view migration and M6 final
-docs/tag.
+Remaining: none for the open-array milestone; M6 pointer-based 1-D
+views and final docs/tag are complete.
+
+**M6 — pointer-based 1-D views — done (2026-10-24).**  Internal 1-D
+open formals use 40-byte views; fixed arrays, string literals, rows and
+flattened byte views are converted at call sites; `ADR`/`SIZE`/indexing
+are view-based, and row `ADR` identity is preserved.  External C still
+uses legacy descriptors (copy-in/copy-out for `VAR`).  Bootstrap builds
+compiler units with `V3_LEGACY_OPEN1D=1`; user programs use views.
+Suite **300/300**, fixpoint **3,571,371 bytes**, corpus **518/612**.
+Final tag **`v3-open-arrays`**; no further M6 work.
 
 ## 4. Runtime range checks — done, follow-ups
 

+ 5 - 4
docs/summary_session-2026-10-24-open-arrays-m5.md

@@ -1,5 +1,8 @@
 # Session 2026-10-24 — open-array M5 (record fields and constructors)
 
+> Continued with pointer-based 1-D views and final gates:
+> see `summary_session-2026-10-24-open-arrays-m6.md`.
+
 Continuation of the 2026-10-23 M1–M4 open-array session.  M5 moves
 rank-2/3 array fields inside records/classes to the flat+view layout
 and makes constructors produce/consume that layout.
@@ -80,10 +83,8 @@ layout; the new coverage is in the suite.
 
 ## Remaining
 
-- Optional pointer-based 1-D view migration: row → 1-D internal calls
-  still use the copy-in/copy-back legacy descriptor, so row `ADR`
-  identity is not preserved.  Writes are preserved.
-- M6: final docs/gates/tag and any small polish.
+- Pointer-based 1-D views and M6 final polish were completed on
+  2026-10-24; see `summary_session-2026-10-24-open-arrays-m6.md`.
 - `unbounded6`/`unbounded8`/`adrunbounded3` remain declaration-order
   cases under V3 policy.
 

+ 93 - 0
docs/summary_session-2026-10-24-open-arrays-m6.md

@@ -0,0 +1,93 @@
+# Session 2026-10-24 — open-array M6 (pointer-based 1-D views)
+
+Final open-array milestone: internal 1-D open formals now use the same
+`ArrayView` ABI as multi-dimensional arrays, while external C keeps the
+legacy `{count,data}` descriptor at the boundary.  M6 also does the
+final docs/gates/tag pass.
+
+**Branch:** `master`.  **Feature state:** `v3-open-arrays`.
+**Gates at the end:** suite **300/300**, fixpoint **OK
+(3,571,371 bytes)**, corpus **518/612 compile-OK, 0 crashes**.
+
+---
+
+## Numbers
+
+| gate | start (M5) | end (M6) |
+| --- | --- | --- |
+| suite (`compiler/run_tests.sh`) | 299/299 | **300/300** |
+| fixpoint (`bootstrap/fixpoint.sh`) | 3,534,072 B | **3,571,371 B** |
+| corpus (`tools/v3-corpus/corpus.sh`) | 518/612 | **518/612, 0 crashes** |
+
+---
+
+## What landed
+
+### Pointer-based 1-D open views
+
+- `MakeOpen1DView` builds a 40-byte
+  `{count, elemBytes, stride, base, next=0}` view from:
+  - a fixed or open 1-D array descriptor;
+  - a string / UString literal;
+  - a row or multi-dimensional subview;
+  - a byte-flattened multi array (`ARRAY OF BYTE`/`SBYTE`);
+  - a scalar byte-buffer compatibility value.
+- `LowerDesign` treats open 1-D formals as views (`lastView`); indexing
+  uses `ViewIndex`, `HIGH`/`LEN` read the view count, payload `SIZE`
+  uses view metadata, and `ADR` returns `base`.
+- `VAR` writes go directly to the caller's payload; row `ADR` identity
+  is preserved through internal calls.
+
+### External C boundary
+
+- External procedures still receive the legacy `{count,data}`
+  descriptor:
+  - known views are materialized into a temporary legacy descriptor
+    (with the CHAR/UCHAR terminator);
+  - `VAR` results are copied back and the temporary is freed;
+  - fixed 1-D arrays/string literals passed directly to C keep the old
+    descriptor.
+- `SysShim`/`FileIO` gained `GetEnv`/`getenv` support for bootstrap
+  mode (see below).
+
+### Bootstrap compatibility
+
+The stage-2 self-host compiler miscompiled when compiler units were
+themselves built with the view call ABI.  The fixpoint now sets
+`V3_LEGACY_OPEN1D=1`:
+
+- compiler units are built with the legacy 1-D call ABI;
+- the resulting compiler still emits pointer-based views for user
+  programs when the variable is absent;
+- the suite runs without the variable, so all user-facing tests
+  exercise the new view ABI.
+
+`M2make` gained an optional `--m2flag` pass-through; the fixpoint uses
+the environment variable instead.
+
+### Test coverage
+
+Added `t_open_row_adr`: a row subview passed to a 1-D open `VAR`
+formal must preserve `ADR` identity.  Existing open-array, record,
+constructor and compiler-session tests remain green.
+
+---
+
+## Remaining
+
+No open-array milestone work remains.  Possible future language work is
+outside this feature (for example coroutine/protection exceptions and
+the separate-compilation/library-folder plan).
+
+---
+
+## Commits and tags
+
+| commit | tag | work |
+| --- | --- | --- |
+| `04ab8b5` | `v3-open-arrays-m5` | flat record fields and constructors |
+| this code commit | `v3-open-arrays` | pointer-based 1-D views + final gates |
+| this docs commit | `v3-open-arrays-m6-summary` | final summary/docs |
+| final docs commit | `v3-session-2026-10-24-open-arrays-m6-end` | session tag |
+
+No push was performed.