A pointer parameter that its calls pass without the 113 tag is written pointer value on both sides of the call (touches rpg_source.zig, rpg_eval.zig) #787

Manually merged
binjovi-bot merged 1 commit from lptr into trunk 2026-11-11 10:17:22 +00:00
Owner

Lane Lptr. A p pointer value parameter was written by reference (x int(10), char(N), likeds(TMPL)) with no failure line, and the call as TAKE(field): RNF7535 at the call, RNF7416 and RNF0553 in the body (the largest family of wrong text of the six Async programs, 41 compile errors). The new reader core/rpg_value_pointer.zig proves the form from the call sites of the module; rpg_eval.call writes the argument as the pointer (%ADDR(n), q), and the interface and declaration emitters write p pointer value with the field at it as a based local (dcl-s x int(10) based(p), dcl-ds NAME qualified based(p)). basedPart takes such a pointer. Tests: rpg_value_pointer_test.zig (nine; three adopted probes lpar-pv-val-var, lpar-pv-nop-val, lpar-pv-copy-val).

The question and the answer

Procedure and caller in one module: the callee does not hold the form (lane Lparm: same operations, same entry symbol, kind 9 class 5 length 16, word 28 80100000). The CALL SITE does, by one fact: the compiler follows the address of a variable that is passed by reference with 113 q 2, and does not follow a pointer value. The body does not hold it.

The 113 q 2 tag, measured

The stripped twins under src/testdata and the public captures under captures/, one object for each case id (1113 objects; 100 have a call, inside the module, of a procedure with a kind 9 class 5 length 16 parameter; 833 argument slots, 790 passed, 43 not passed by options(*nopass)). The stack walk is the one of rpg_source_byref.effects; the argument is the value at the call minus the last (the block that holds the count of the arguments). Pairing the argument with the parameter by position, without dropping that last block, put the block in a parameter slot and made every "untagged address" row look like a structure: that was the cause of the false rows below.

argument at the call followed by 113 not followed
33 X of a declared variable (a structure, a field, an array) 84 1 (%addr(orders), a 134-byte local, asyncprom)
33 X of a compiler temporary (flag word bit 0x1000) 0 238 (the copy that a CONST parameter takes: add(r: t: 'xyz'), 'xyz')
34 X 0 of a field 115 14 (%addr(n), %addr(ds))
29 P 0 T, P a pointer symbol (kind 9) 42 (take(bx), bx based on P; a parameter passed on) 159 (take(q); %addr(x) of a by-reference x is the same)
29 P 0 T; 27 K; 62 26 0
27 K, the null pointer constant (kind 0x18, length 0) 0 78 (*null to a by-value slot; *omit of an imported API is the same constant, h-ceeran)
anything the walk loses (a result, a loaded value) 0 33

The tag appears on every named variable, whatever its kind and place, and on a pointer that is the base of a variable passed by reference; it does not appear on a compiler temporary, on a null, or on a pointer that is passed as a value. d7-params corrects docs/changes/lparm.md: its bare 33 is slot 3, the 'xyz' temporary of the CONST parameter c; the structure r is 33 R; 113 as every other variable. The temporaries are the likely reason that "an address argument without 113" made 39 committed twins worse in the emit gate (not re-run here).

Per slot, and the proof

A slot is parameter K of a module procedure whose entry symbol is kind 9, class 5, length 16. The verdict of a slot reads every call of the module that passes it (rpg_value_pointer.analyze):

  • tagged, in the form 33, 34, 29 or 62 of a variable: by reference;
  • untagged, in the form 29 of a pointer, 34, 62 or 33 of a declared variable (not a temporary): a pointer by value;
  • a temporary (CONST copy), the null constant, or an argument the walk loses: no evidence either way (*omit passed to an imported API is this constant, h-ceeran: CEERAN0(I: F: *omit); for a by-reference options(*omit) parameter of a procedure of the module it is probably the same, but no twin shows it: d7c-forms declares one and passes a variable). A slot that such an argument reaches counts as passed;
  • both kinds at one slot: conflict: the parameter declaration is a failure line in the dcl-pi (no corpus slot is one, so the gate does not run that line; it is not tested beyond the table), and the call keeps the by-reference text. A by-value argument that is the address of a compiler temporary is refused by the call (rpg_eval.call, a failure line of the statement).

Result over the 344 slots of the corpus: 152 by reference only; 21 by reference and a temporary; 67 by value (12 of them also with a null); 0 mixed; 104 with no evidence (a temporary only, or never passed). Against the source: the 67 by-value slots are the 63 pointer value parameters that the six Async programs call inside the module and four of the battery (lpar-pv-val-int, -val-var, -nop-val, -copy-val). The 173 slots proved by reference are no pointer value parameter: the 89 objects whose source has no pointer value have no by-value slot, and in the six Async programs and the battery the verdict agrees with the source at every slot (the Async programs checked by the order of dcl-proc and of the parameters). A first count of this table listed each adopted twin twice (as a capture and as a twin); the numbers here count each case id once.

A parameter that no call of the module passes at all (an export, a thread entry) has no verdict; a slot that a call passes only a temporary, a null or a lost value is not that. One more proof, by the body, closes part of the first kind: a pointer that the procedure loads as it is (29 P 0 T) and hands untagged to a slot proved by value. A by-reference parameter would be passed on tagged. The one other source of that object is %addr(x) of a by-reference x, the text of the same object (pv-copy-ref is keep = %addr(x), pv-copy-val is keep = p, one callee), so the parameter is written by value; repeated to a fixed point (propagate). The body alone proves nothing: after a load 29 P 0 T the slots proved by value show 27 62 (174 loads), 27 78 (48), 29 75 (9), 27 75, 27 8, 7 (6), 37 (6), 42, 32, and the slots proved by reference show 32 (64), 27 62 (57), 5 42 (56), 29 75 (34), 113 (26), 1 32, one 37: the same shapes. A compare of P (7) and a store of P (37) were seen on slots proved by value and, for 37, once on one proved by reference: too few and not exclusive, so no rule. A slot that no call and no pass-on proves keeps the by-reference text, which recompiles to the same callee object; the caller of such a slot is in another module, which compiles against its own prototype. No failure line is written for "no call site", for the same reason (the 39 twins).

Effects

Measured with the host build of this branch against v0.1.503 (capture-emit-diff.sh, 56 captures: lparm-param-shapes, lsel-select-head, lsel-cyc-export, the six Async programs) and emit-all.sh on the 849 committed twins.

  • Changed emits: lpar-pv-val-int, -nop-val, -copy-val (the same counts, the parameter pointer value, the call TAKE(%ADDR(n)), the field based on the pointer, keep = p), lpar-pv-val-var (statements emitted 6 to 7, failures 2 to 1: take(q) was the failure CALLP TAKE(BASED(S256)) (not a record buffer), now TAKE(A_00256)), the six Async programs. No other capture changed.
  • Emitted statements fell in no case. Async, emitted / failures at v0.1.503 and now: asyncage 313/281 and 322/269, asyncdemo 333/297 and 344/284, asyncbg 316/291 and 326/277, asynccncl 329/287 and 335/280, asyncprom 320/309 and 330/295, asynctime 342/297 and 352/285. The new statements are calls and conditions that passed a pointer parameter (DESTROYTASK(NEWTASK_00391), RUNDELAY(NEWTASK_00392), return STARTTHREAD(...), if (KEEPRESULT_00371 > 0 AND CAPTUREERROR_00331 <> *NULL)); in each Async program four of the five qualified template declarations are gone (the structure at a pointer by value is a dcl-ds ... qualified based(p) of its procedure: 8 of them before, 13 now).
  • Committed twins: emit-diff.sh base against head: worse [], better [], clean 592/592, failures 618/618, emitted 8082/8082. lpar-pv-val-int changed its text and kept its counts (its test rpg_param_shape_test.zig asserted that the by-value and by-reference emits were one text; it asserts that they are two).
  • wrong-params.sh over the 56 captures (lparm-param-shapes, lsel-select-head, lsel-cyc-export, six Async): base 80 of 496, head 24 of 512 (the six Async programs: 66 of 426 and 14 of 442; the battery and lsel captures: 14 and 10, the four lpar-pv-* rows to 0, the array and lsel-for-arr-if rows unchanged). Every pointer value that the head writes in a dcl-pi of the Async programs (73 of them) is a pointer value of the source: no false positive.
  • Left, by the rules above: the thread-entry procedures and exports that nothing in the module calls and passes on (sleepFor, untilCanceled, Async_Resolve's result: 2 or 3 per Async program) keep the by-reference text. The calls of these are in other modules.

Seen, not in this change

  • An IF whose head is refused while its ELSE and ENDIF are written (RNF5142, RNF5141): in each Async program four heads are written if *off; // SOURCERER-TODO block_condition or dow *off, as before this change (4 and 4); not touched.
  • dow 1; for dow '1'; (RNF7423): not touched. A parameter declared twice in one dcl-pi (RNF3316): in SETTLE, which has two pointer parameters, both were mapped to the one field symbol at the pointers, so one name stood twice (five of the six Async programs at v0.1.503; the sixth, asynctime, has none in either). With the pointers by value they are two parameters and none of the six has a duplicate now. That is the cause here; other instances in other programs are not shown by this measure.
  • lparm.md named a structure r passed bare in d7-params: corrected above (the CONST temporary).

Requests

None. The measure used committed twins and captures only. A host compile of the four changed lpar-pv-* emits and of the six Async emits (they still have failure lines) would show whether the call sites compile (RNF7535).

Release gate (coordinator, build of b618068a against v0.1.503)

  • Ship row b618068a: all gates passed (census 645/0, twins regressions none, emit worse none).
  • Development emits: byte-identical. L10-test direction: unchanged.
  • Committed twins (emit-bytes-diff.sh): only lpar-pv-val-int changes.
  • 87 public captures (capture-emit-diff.sh): 10 change, none with fewer emitted statements or more failures.
  • wrong-params.sh (parameter text that disagrees with the source and has no failure line): 80 of 504 at v0.1.503, 24 of 520 with this build; in the six public Async programs 66 to 14.
  • Host round trips, v0.1.503 then this build: lpar-pv-copy-val failed (compile), now different; lpar-pv-val-int, -val-var, -nop-val, -ref-int, -nop-ref different in both.
  • The six public Async programs with this build still fail to compile, with fewer errors. Severity-30 messages over the six programs, v0.1.503 then this build: RNF7535 18 to 0, RNF7416 11 to 3, RNF3316 12 to 0, RNF5415 54 to 51; RNF7423 13, RNF5142 12, RNF5141 12, RNF0553 12 unchanged.
Lane Lptr. A `p pointer value` parameter was written by reference (`x int(10)`, `char(N)`, `likeds(TMPL)`) with no failure line, and the call as `TAKE(field)`: RNF7535 at the call, RNF7416 and RNF0553 in the body (the largest family of wrong text of the six Async programs, 41 compile errors). The new reader `core/rpg_value_pointer.zig` proves the form from the call sites of the module; `rpg_eval.call` writes the argument as the pointer (`%ADDR(n)`, `q`), and the interface and declaration emitters write `p pointer value` with the field at it as a based local (`dcl-s x int(10) based(p)`, `dcl-ds NAME qualified based(p)`). `basedPart` takes such a pointer. Tests: `rpg_value_pointer_test.zig` (nine; three adopted probes `lpar-pv-val-var`, `lpar-pv-nop-val`, `lpar-pv-copy-val`). ## The question and the answer Procedure and caller in one module: the callee does not hold the form (lane Lparm: same operations, same entry symbol, kind 9 class 5 length 16, word 28 `80100000`). The CALL SITE does, by one fact: the compiler follows the address of a variable that is passed by reference with `113 q 2`, and does not follow a pointer value. The body does not hold it. ### The `113 q 2` tag, measured The stripped twins under `src/testdata` and the public captures under `captures/`, one object for each case id (1113 objects; 100 have a call, inside the module, of a procedure with a kind 9 class 5 length 16 parameter; 833 argument slots, 790 passed, 43 not passed by `options(*nopass)`). The stack walk is the one of `rpg_source_byref.effects`; the argument is the value at the call minus the last (the block that holds the count of the arguments). Pairing the argument with the parameter by position, without dropping that last block, put the block in a parameter slot and made every "untagged address" row look like a structure: that was the cause of the false rows below. | argument at the call | followed by `113` | not followed | |---|---:|---:| | `33 X` of a declared variable (a structure, a field, an array) | 84 | 1 (`%addr(orders)`, a 134-byte local, asyncprom) | | `33 X` of a compiler temporary (flag word bit 0x1000) | 0 | 238 (the copy that a CONST parameter takes: `add(r: t: 'xyz')`, `'xyz'`) | | `34 X 0` of a field | 115 | 14 (`%addr(n)`, `%addr(ds)`) | | `29 P 0 T`, P a pointer symbol (kind 9) | 42 (`take(bx)`, `bx` based on P; a parameter passed on) | 159 (`take(q)`; `%addr(x)` of a by-reference `x` is the same) | | `29 P 0 T; 27 K; 62` | 26 | 0 | | `27 K`, the null pointer constant (kind 0x18, length 0) | 0 | 78 (`*null` to a by-value slot; `*omit` of an imported API is the same constant, `h-ceeran`) | | anything the walk loses (a result, a loaded value) | 0 | 33 | The tag appears on every named variable, whatever its kind and place, and on a pointer that is the base of a variable passed by reference; it does not appear on a compiler temporary, on a null, or on a pointer that is passed as a value. d7-params corrects `docs/changes/lparm.md`: its bare `33` is slot 3, the `'xyz'` temporary of the CONST parameter `c`; the structure `r` is `33 R; 113` as every other variable. The temporaries are the likely reason that "an address argument without `113`" made 39 committed twins worse in the emit gate (not re-run here). ### Per slot, and the proof A slot is parameter K of a module procedure whose entry symbol is kind 9, class 5, length 16. The verdict of a slot reads every call of the module that passes it (`rpg_value_pointer.analyze`): - tagged, in the form `33`, `34`, `29` or `62` of a variable: by reference; - untagged, in the form `29` of a pointer, `34`, `62` or `33` of a declared variable (not a temporary): a pointer by value; - a temporary (CONST copy), the null constant, or an argument the walk loses: no evidence either way (`*omit` passed to an imported API is this constant, `h-ceeran`: `CEERAN0(I: F: *omit)`; for a by-reference `options(*omit)` parameter of a procedure of the module it is probably the same, but no twin shows it: `d7c-forms` declares one and passes a variable). A slot that such an argument reaches counts as passed; - both kinds at one slot: `conflict`: the parameter declaration is a failure line in the `dcl-pi` (no corpus slot is one, so the gate does not run that line; it is not tested beyond the table), and the call keeps the by-reference text. A by-value argument that is the address of a compiler temporary is refused by the call (`rpg_eval.call`, a failure line of the statement). Result over the 344 slots of the corpus: 152 by reference only; 21 by reference and a temporary; 67 by value (12 of them also with a null); 0 mixed; 104 with no evidence (a temporary only, or never passed). Against the source: the 67 by-value slots are the 63 `pointer value` parameters that the six Async programs call inside the module and four of the battery (`lpar-pv-val-int`, `-val-var`, `-nop-val`, `-copy-val`). The 173 slots proved by reference are no `pointer value` parameter: the 89 objects whose source has no `pointer value` have no by-value slot, and in the six Async programs and the battery the verdict agrees with the source at every slot (the Async programs checked by the order of `dcl-proc` and of the parameters). A first count of this table listed each adopted twin twice (as a capture and as a twin); the numbers here count each case id once. A parameter that no call of the module passes at all (an export, a thread entry) has no verdict; a slot that a call passes only a temporary, a null or a lost value is not that. One more proof, by the body, closes part of the first kind: a pointer that the procedure loads as it is (`29 P 0 T`) and hands untagged to a slot proved by value. A by-reference parameter would be passed on tagged. The one other source of that object is `%addr(x)` of a by-reference `x`, the text of the same object (`pv-copy-ref` is `keep = %addr(x)`, `pv-copy-val` is `keep = p`, one callee), so the parameter is written by value; repeated to a fixed point (`propagate`). The body alone proves nothing: after a load `29 P 0 T` the slots proved by value show `27 62` (174 loads), `27 78` (48), `29 75` (9), `27 75`, `27 8`, `7` (6), `37` (6), `42`, `32`, and the slots proved by reference show `32` (64), `27 62` (57), `5 42` (56), `29 75` (34), `113` (26), `1 32`, one `37`: the same shapes. A compare of P (`7`) and a store of P (`37`) were seen on slots proved by value and, for `37`, once on one proved by reference: too few and not exclusive, so no rule. A slot that no call and no pass-on proves keeps the by-reference text, which recompiles to the same callee object; the caller of such a slot is in another module, which compiles against its own prototype. No failure line is written for "no call site", for the same reason (the 39 twins). ## Effects Measured with the host build of this branch against v0.1.503 (`capture-emit-diff.sh`, 56 captures: `lparm-param-shapes`, `lsel-select-head`, `lsel-cyc-export`, the six Async programs) and `emit-all.sh` on the 849 committed twins. - Changed emits: `lpar-pv-val-int`, `-nop-val`, `-copy-val` (the same counts, the parameter `pointer value`, the call `TAKE(%ADDR(n))`, the field based on the pointer, `keep = p`), `lpar-pv-val-var` (statements emitted 6 to 7, failures 2 to 1: `take(q)` was the failure `CALLP TAKE(BASED(S256)) (not a record buffer)`, now `TAKE(A_00256)`), the six Async programs. No other capture changed. - Emitted statements fell in no case. Async, emitted / failures at v0.1.503 and now: asyncage 313/281 and 322/269, asyncdemo 333/297 and 344/284, asyncbg 316/291 and 326/277, asynccncl 329/287 and 335/280, asyncprom 320/309 and 330/295, asynctime 342/297 and 352/285. The new statements are calls and conditions that passed a pointer parameter (`DESTROYTASK(NEWTASK_00391)`, `RUNDELAY(NEWTASK_00392)`, `return STARTTHREAD(...)`, `if (KEEPRESULT_00371 > 0 AND CAPTUREERROR_00331 <> *NULL)`); in each Async program four of the five `qualified template` declarations are gone (the structure at a pointer by value is a `dcl-ds ... qualified based(p)` of its procedure: 8 of them before, 13 now). - Committed twins: `emit-diff.sh` base against head: worse [], better [], clean 592/592, failures 618/618, emitted 8082/8082. `lpar-pv-val-int` changed its text and kept its counts (its test `rpg_param_shape_test.zig` asserted that the by-value and by-reference emits were one text; it asserts that they are two). - `wrong-params.sh` over the 56 captures (`lparm-param-shapes`, `lsel-select-head`, `lsel-cyc-export`, six Async): base 80 of 496, head 24 of 512 (the six Async programs: 66 of 426 and 14 of 442; the battery and `lsel` captures: 14 and 10, the four `lpar-pv-*` rows to 0, the array and `lsel-for-arr-if` rows unchanged). Every `pointer value` that the head writes in a `dcl-pi` of the Async programs (73 of them) is a `pointer value` of the source: no false positive. - Left, by the rules above: the thread-entry procedures and exports that nothing in the module calls and passes on (`sleepFor`, `untilCanceled`, `Async_Resolve`'s `result`: 2 or 3 per Async program) keep the by-reference text. The calls of these are in other modules. ## Seen, not in this change - An IF whose head is refused while its ELSE and ENDIF are written (RNF5142, RNF5141): in each Async program four heads are written `if *off; // SOURCERER-TODO block_condition` or `dow *off`, as before this change (4 and 4); not touched. - `dow 1;` for `dow '1';` (RNF7423): not touched. A parameter declared twice in one `dcl-pi` (RNF3316): in `SETTLE`, which has two pointer parameters, both were mapped to the one field symbol at the pointers, so one name stood twice (five of the six Async programs at v0.1.503; the sixth, asynctime, has none in either). With the pointers by value they are two parameters and none of the six has a duplicate now. That is the cause here; other instances in other programs are not shown by this measure. - `lparm.md` named a structure `r` passed bare in d7-params: corrected above (the CONST temporary). ## Requests None. The measure used committed twins and captures only. A host compile of the four changed `lpar-pv-*` emits and of the six Async emits (they still have failure lines) would show whether the call sites compile (`RNF7535`). ## Release gate (coordinator, build of b618068a against v0.1.503) - Ship row b618068a: all gates passed (census 645/0, twins regressions none, emit worse none). - Development emits: byte-identical. L10-test direction: unchanged. - Committed twins (`emit-bytes-diff.sh`): only `lpar-pv-val-int` changes. - 87 public captures (`capture-emit-diff.sh`): 10 change, none with fewer emitted statements or more failures. - `wrong-params.sh` (parameter text that disagrees with the source and has no failure line): 80 of 504 at v0.1.503, 24 of 520 with this build; in the six public Async programs 66 to 14. - Host round trips, v0.1.503 then this build: `lpar-pv-copy-val` failed (compile), now different; `lpar-pv-val-int`, `-val-var`, `-nop-val`, `-ref-int`, `-nop-ref` different in both. - The six public Async programs with this build still fail to compile, with fewer errors. Severity-30 messages over the six programs, v0.1.503 then this build: RNF7535 18 to 0, RNF7416 11 to 3, RNF3316 12 to 0, RNF5415 54 to 51; RNF7423 13, RNF5142 12, RNF5141 12, RNF0553 12 unchanged.
Write a pointer parameter that its calls pass without the 113 tag as pointer value, on both sides of the call
Some checks reported errors
binjovi/ci A newer source or plan superseded this Build
b618068a24
A slot (kind 9, class 5, length 16) of a module procedure is a pointer by
value when a call passes a pointer, a %addr or a declared variable that
the compiler did not follow with 113 q 2, and no call passes a tagged
variable. The parameter is written `p pointer value`, the field at it is a
based local, the argument is %ADDR(x) or the pointer. A pointer that is
only passed on, untagged, to a slot proved by value is by value too.
The 113 tag is measured on every public twin and capture (fragment).
sean force-pushed lptr from b618068a24
Some checks reported errors
binjovi/ci A newer source or plan superseded this Build
to 6043b6a8a7
All checks were successful
binjovi/ci Binjovi completed the frozen plan
2026-11-11 10:07:56 +00:00
Compare
binjovi-bot manually merged commit 6043b6a8a7 into trunk 2026-11-11 10:17:22 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sean/sourcerer!787
No description provided.