Просмотр исходного кода

docs: L7 hang was a Lower ProcInfo guard bug; remaining work is lookup speed + size bug

Eric Streit 1 неделя назад
Родитель
Сommit
33ec69dc68
1 измененных файлов с 24 добавлено и 22 удалено
  1. 24 22
      docs/summary_lower_l7.md

+ 24 - 22
docs/summary_lower_l7.md

@@ -59,25 +59,27 @@ Suite **204/204**; FIXPOINT OK (3,405,813 bytes).
    `ProcLink` fails after scopes close.
 3. Definition-module proc replay (done), nested globals (done).
 
-## Per-unit emission attempted — blocked by parse-time state
-
-Tried plan item 3 (Lower emits each unit at its END, with the legacy
-output suppressed via `SetNoEmit`).  Small sessions and every `lower_ok`
-single-file test byte-match, **but the compiler's session hangs/differs**:
-
-- The grammar's inline `QbeGen` calls still run during parse; `noEmit`
-  only suppresses the *output*, not the **state**.  So `nTemp` (stuck at
-  211), `inBody` (stuck TRUE, so `main`'s header is dropped), `nLoc`,
-  `funcDepth`, … are all corrupted before Lower's per-unit emit.
-- `EndModule` had to respect `noEmit` too, or it closed the session.
-
-Conclusion: per-unit Lower needs the grammar's parse-time `QbeGen`
-**state** neutralised — which is exactly the flip.  Options:
-1. **Remove/replace the grammar's 533 `QbeGen.*` calls.**  The blockers
-   are the ~20 semantic checks that read `QbeGen` values (`IsImm`,
-   `ConstInt`, `Fold`); they must be reworked to use `SymTab`/the AST.
-2. **Two `QbeGen` states** — but a second 4 MiB `sessBuf` pushes the
-   compiler image past its own buffer, so this does not self-host.
-
-So the flip is a grammar rewrite of the emit actions, gated by the
-fixpoint.  Reverted to the green session-re-emit state (`ce2fc67`).
+## The "hang" was a Lower bug, not a miscompile
+`LowerDecls` emitted a procedure's parameter loop even when `ProcInfo`
+failed, using an uninitialised `np` — so the loop ran ~forever inside
+`FindProc`.  (`MaxProc = 64` is far too small for a whole session, so
+`ProcInfo` failed for most of the compiler's procs.)  **Fixed**
+(`a9a8ecd`): the proc is skipped unless `ProcInfo` succeeds, and each
+`ParamInfo` is guarded.  Also grew the AST arena/pool (`caeeeb5`) — the
+arena/pool data lines are compact `z` runs, so this is nearly free.
+
+## What remains for the session re-emit
+- **Correctness:** `MaxProc`/`MaxSym` must be ≥ the session's proc/var
+  counts (the compiler has hundreds of procs; 64 is too small), so
+  procs beyond the cap are currently skipped.
+- **Performance:** `FindSym`/`FindProc` are linear scans, and `Lower`
+  looks up per node — O(nodes × table size).  A whole-session re-emit is
+  very slow.  A hash index (or reusing `SymTab` for module-level names)
+  would fix it.
+- **Size-dependent behaviour:** with `MaxProc = 1024` the same run
+  **segfaults** (in `CopySpan` via `ParamInfo`) — a size/layout-sensitive
+  latent bug, the same family as the earlier `ASTDUMP` fragility.
+
+So the session re-emit is capacity-fixable but needs (a) a fast lookup
+and (b) the size-dependent bug isolated.  The grammar rewrite remains the
+alternative flip path.