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
Loading…
Reference in a new issue
No description provided.
Delete branch "lptr"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Lane Lptr. A
p pointer valueparameter was written by reference (x int(10),char(N),likeds(TMPL)) with no failure line, and the call asTAKE(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 readercore/rpg_value_pointer.zigproves the form from the call sites of the module;rpg_eval.callwrites the argument as the pointer (%ADDR(n),q), and the interface and declaration emitters writep pointer valuewith the field at it as a based local (dcl-s x int(10) based(p),dcl-ds NAME qualified based(p)).basedParttakes such a pointer. Tests:rpg_value_pointer_test.zig(nine; three adopted probeslpar-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 with113 q 2, and does not follow a pointer value. The body does not hold it.The
113 q 2tag, measuredThe stripped twins under
src/testdataand the public captures undercaptures/, 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 byoptions(*nopass)). The stack walk is the one ofrpg_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.11333 Xof a declared variable (a structure, a field, an array)%addr(orders), a 134-byte local, asyncprom)33 Xof a compiler temporary (flag word bit 0x1000)add(r: t: 'xyz'),'xyz')34 X 0of a field%addr(n),%addr(ds))29 P 0 T, P a pointer symbol (kind 9)take(bx),bxbased on P; a parameter passed on)take(q);%addr(x)of a by-referencexis the same)29 P 0 T; 27 K; 6227 K, the null pointer constant (kind 0x18, length 0)*nullto a by-value slot;*omitof an imported API is the same constant,h-ceeran)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 bare33is slot 3, the'xyz'temporary of the CONST parameterc; the structureris33 R; 113as every other variable. The temporaries are the likely reason that "an address argument without113" 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):33,34,29or62of a variable: by reference;29of a pointer,34,62or33of a declared variable (not a temporary): a pointer by value;*omitpassed to an imported API is this constant,h-ceeran:CEERAN0(I: F: *omit); for a by-referenceoptions(*omit)parameter of a procedure of the module it is probably the same, but no twin shows it:d7c-formsdeclares one and passes a variable). A slot that such an argument reaches counts as passed;conflict: the parameter declaration is a failure line in thedcl-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 valueparameters 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 nopointer valueparameter: the 89 objects whose source has nopointer valuehave 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 ofdcl-procand 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-referencex, the text of the same object (pv-copy-refiskeep = %addr(x),pv-copy-valiskeep = p, one callee), so the parameter is written by value; repeated to a fixed point (propagate). The body alone proves nothing: after a load29 P 0 Tthe slots proved by value show27 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 show32(64),27 62(57),5 42(56),29 75(34),113(26),1 32, one37: the same shapes. A compare of P (7) and a store of P (37) were seen on slots proved by value and, for37, 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) andemit-all.shon the 849 committed twins.lpar-pv-val-int,-nop-val,-copy-val(the same counts, the parameterpointer value, the callTAKE(%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 failureCALLP TAKE(BASED(S256)) (not a record buffer), nowTAKE(A_00256)), the six Async programs. No other capture changed.DESTROYTASK(NEWTASK_00391),RUNDELAY(NEWTASK_00392),return STARTTHREAD(...),if (KEEPRESULT_00371 > 0 AND CAPTUREERROR_00331 <> *NULL)); in each Async program four of the fivequalified templatedeclarations are gone (the structure at a pointer by value is adcl-ds ... qualified based(p)of its procedure: 8 of them before, 13 now).emit-diff.shbase against head: worse [], better [], clean 592/592, failures 618/618, emitted 8082/8082.lpar-pv-val-intchanged its text and kept its counts (its testrpg_param_shape_test.zigasserted that the by-value and by-reference emits were one text; it asserts that they are two).wrong-params.shover 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 andlselcaptures: 14 and 10, the fourlpar-pv-*rows to 0, the array andlsel-for-arr-ifrows unchanged). Everypointer valuethat the head writes in adcl-piof the Async programs (73 of them) is apointer valueof the source: no false positive.sleepFor,untilCanceled,Async_Resolve'sresult: 2 or 3 per Async program) keep the by-reference text. The calls of these are in other modules.Seen, not in this change
if *off; // SOURCERER-TODO block_conditionordow *off, as before this change (4 and 4); not touched.dow 1;fordow '1';(RNF7423): not touched. A parameter declared twice in onedcl-pi(RNF3316): inSETTLE, 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.mdnamed a structurerpassed 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
b618068aagainst v0.1.503)b618068a: all gates passed (census 645/0, twins regressions none, emit worse none).emit-bytes-diff.sh): onlylpar-pv-val-intchanges.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.lpar-pv-copy-valfailed (compile), now different;lpar-pv-val-int,-val-var,-nop-val,-ref-int,-nop-refdifferent in both.b618068a246043b6a8a7