A folded %ELEM(array) is written as %ELEM(array), in a store and in a FOR limit over compile-time data #803
Loading…
Reference in a new issue
No description provided.
Delete branch "ldev3"
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?
A folded
%ELEM(array)is written as%ELEM(array), in a store and in a FOR limit over compile-time dataTwo development programs whose round trips compile with the same instructions
and the same control flow as the original, and differ in creation_instructions,
symbols, literals, constant_area and initialization only, have one cause: the
emit wrote the number for
size = %ELEM(list).What the dumps show (the symbol dumps of the original and the rebuild, a
statement-by-statement operand comparison of
statements.raw.txt, andsourcerer compareon the two stored directories):declared fields, the compile-time array, the arrays) is byte-identical in the
two objects, and so is the type table. The order of the declarations,
dim(*ctdata)againstdim(n) ctdata,packed(5:0)againstpacked(5), anunused field and an initial value are not a cause.
the array, the first decimal of the literal pool, that no operation loads.
That one symbol makes every later symbol number one lower in the rebuild
(each differing creation instruction differs in one operand, by exactly one),
the symbol rows that name symbols differ by one in those words, and the
literal offsets after it by the 3 bytes of the constant.
instructions,control_flow,imports,exports,relocations,typesandattributesof
sourcerer compareare equal; the remaining differences of the symbolrows (two 32-byte character constants that carry the identity of the source
member) differ in a matching round trip as well.
size = %ELEM(list)is folded by the compiler to27 K; 88 n; 61 5 0 0; 37 Fwith K an unsigned 8-byte constant of the count: the operations ofsize = 4. Our emit wrote the number, which leaves no packed head constant.The probes show the shape of the head constant (SC-ILE/EXPERIMENTS
lctd2-elem-star, lctd-loop, lr1-lf-up-*; the batteries lctd-ctdata and
lctd-ctdata-index of the loop captures, among them lctd2-perrcd, lctd2-whole-elem
and lctd2-two-arrays): one packed constant of the count for each
%ELEM,between the 1-character constants 'R', 'F', 'I' and the x'F0' of the character
literal '0'. A literal
size = 4ordim(4)puts its constant in the sortedrun, not there. A FOR whose limit is
%ELEMloads the head constant itself(the existing
elemLimit); a store of%ELEMloads the unsigned constant andleaves the head unloaded.
An unloaded decimal ahead of the x'F0' is not always
%ELEM:%SIZEand%LENleave one (ldsv-asyncprom, h-bifs-char), a fraction literal ofinz(.7)sorts there (d7-lits), and so does a negative literal (c8x-*). Sorpg_elem_count.zig(new) reads the unsigned 8-byte constant as the%ELEMof an array only when all of these hold:
loads are as many as the operations that name the constant, and the module
holds one such constant (a literal of the same value beside the builtin
makes the loads more than the heads: the number stays);
(
rpg_source_ctdata.unitAt:34 A 0; 29 N 0 T; ...; 27 K; 138; 78 4; 65 W,K + 1 elements);
that many bytes or digits long: the count could be its
%SIZEor%LEN.Known exposure: an unloaded head left by another builtin or literal, an
unrelated literal store of its value, and one array of that count together
pass the three facts. No committed twin does.
rpg_eval.loadwrites%ELEM(array)for such a constant at every load of it(a store and an expression use the same operation); the constant stays a
number everywhere else.
rpg_shape.elemLimitgets the same array finder as asecond way: the limit of a decimal FOR that is the head constant itself named
no array when only a variable index reaches the array (lctd-loop wrote
TO 3); it writesTO %ELEM(array)when the unit proves one array of thatcount and no character buffer of the program is that many bytes long (a
numeric field is not counted there: nobody loops to the size of an index).
scale_mod.runStartis public for the new module. When a compile-time arrayis refused a declaration (a data record that is blank or starts like a mark of
the source: lctd2-blank-mid, lctd2-dollar, lctd2-equal, lctd2-slash-first,
lctd2-star-first), the FOR header that names it fails too, with the failure
line of its body: those five emit 2 statements and 3 failure lines where they
emitted 4 and 1.
Tests:
rpg_elem_count_test.zig(a store of the folded count of the adoptedprobe lctd2-elem-star, which has the shape
size = %ELEM(list),FOR i = 1 TO size; the FOR limit of lctd-loop; the refusals on lctd-loop (aloaded head), d7-lits, h-bifs-char and ldsv-asyncprom; the table of the
evidence). The new
src/testdatadirectory is a matrix row: it is expected tomatch, the coordinator classes it if it does not.
Before and after, v0.1.517 against this build: the committed twins (889
programs) change in two emits, both read against their source
(
TO 3toTO %ELEM(A_00254)in lctd-loop,= 4to= %ELEM(A_00254)inlctd2-elem-star); counts of statements, emitted and failures are equal. The
census of the 649 committed stripped twins (774 unsigned 8-byte constants)
finds one store, in lctd2-elem-star. Over the batteries lctd-ctdata,
lctd-ctdata-index, lsrt-sorta, lsrt-sorta2 and the Async captures (77 cases)
15 emits change: nine write
TO %ELEM(array)for a literal limit, lctd2-elem-starwrites the store, and the five refused-array cases above fail two statements more.
agree.shover them: same 1681 to 1686, suspect 97 to 82, parameters wrong14 to 14. The predicted object of the new text has the head constant where the
original has it; a round trip is the open check.
Not in this change: the helper procedure
_QRNI_SORT_A_<name>ofSORTAisnamed for the array of the source, and the rebuild names it after our array.
No component that
sourcerer comparereports names it, and no matched roundtrip has a SORTA, so whether a rebuild with another name matches is open.
Two
%ELEMof equal counts of different arrays (lctd2-two-arrays) stay literal:no array is unique.
Gate (host round trips, base ~/bin/sourcerer v0.1.517)
1f605a8af47a4651ec1c