PLAN: v0.8.0, better code again, released On test/bench's kernels, raz against FPC -O2: heap sort 1.34 -> 1.02 times, sum 1.75 -> 1.00, search 1.2 -> 1.01. Every default program is 20 to 25% smaller (hello 35,656 -> 28,424 bytes; rat 608 -> 505 KB). rat's workload: about 4% fewer cycles over the milestone, most steps within the noise of a laptop's clock; 8,896 lines of code.
| @@ -89,7 +89,11 @@ | ||
| 89 | 89 | steps 52-53), and v0.5.0, the library of report 2026-10.9, which the |
| 90 | 90 | compiler says it follows, and v0.7.0, better code, and v0.7.1, the manual: `raz(1)`, |
| 91 | 91 | `raz-tutorial(7)`, `raz(7)` and `raz-lib(3)`, made by `tools/Doc.raz` |
| 92 | -from `lib/`. Under way, by `PLAN.md`: better code again (v0.8.0). | |
| 92 | +from `lib/`, and v0.8.0, better code again: slices in registers, | |
| 93 | +parameters left in rdi and rsi, operands as the machine has them, | |
| 94 | +`while` tested at the bottom, and one line table, DWARF's. `make | |
| 95 | +kernels` measures `test/bench` against FPC `-O2`. Next, by `PLAN.md`: | |
| 96 | +what the owner chooses. | |
| 93 | 97 | |
| 94 | 98 | **The freeze.** Since v0.5.0 the language changes only to mend a |
| 95 | 99 | defect, and the library grows only by what breaks no program written |
| @@ -113,7 +117,7 @@ | ||
| 113 | 117 | `.github/workflows/ci.yml`, which checks it and makes the GitHub |
| 114 | 118 | release with a tarball of `raz` and `lib/`; it also checks every push |
| 115 | 119 | to `main`. `README.md`'s "Versions" gives the commands. v0.3.0 is |
| 116 | -the first; v0.7.1, report 2026-10.17, the latest. | |
| 120 | +the first; v0.8.0, report 2026-10.17, the latest. | |
| 117 | 121 | |
| 118 | 122 | `test/libc` runs its programs over `lib/Sys.raz`, the C one, through |
| 119 | 123 | a link in its `mods`. A test or example without `.expect` is only |
| @@ -5,45 +5,10 @@ | ||
| 5 | 5 | stopping for the owner's review. A finished milestone is cut from this |
| 6 | 6 | file: git keeps the history, and the report's section 12 the language's. |
| 7 | 7 | |
| 8 | -Better code again (v0.8.0) is under way, by the owner's word. v0.7.1, | |
| 9 | -the manual, is tagged, and all before v0.7.1 is approved by the owner. | |
| 10 | - | |
| 11 | -## Now: better code again (v0.8.0) | |
| 12 | - | |
| 13 | -For: on the same program, raz within 1.3 times the time of FPC `-O2` | |
| 14 | -with `check off;` (on `test/bench`'s kernels, which `make kernels` | |
| 15 | -measures against their Pascal twins: today 1.34 on a heap sort, 1.75 | |
| 16 | -on a sum over a slice, 1.2 on a search for a word in a text), and | |
| 17 | -every default program smaller; the compiler as clear as | |
| 18 | -v0.7.0 left it, and under 10,000 lines. No change to the language. | |
| 19 | -Each step is measured as v0.7.0's were, on rat and on its kernel, and | |
| 20 | -one that buys less than 2% on both is reverted and noted here. | |
| 21 | - | |
| 22 | -1. Done: **Slices in registers.** A slice parameter or variable whose address | |
| 23 | - isn't taken lives in two of the variables' registers, its pointer and | |
| 24 | - its length, chosen by the read-ahead as a single value is, and | |
| 25 | - counted as two. FPC's search keeps its slice in `rdi` and `rsi`; | |
| 26 | - raz's reads both from the frame on every round. | |
| 27 | -2. Done: **Parameters left where they arrive.** In a procedure that calls | |
| 28 | - nothing, copies no block and divides by no variable, as the | |
| 29 | - read-ahead can tell, a parameter stays in the register it came in, | |
| 30 | - and no register is saved for it. Most of rat's hot procedures are | |
| 31 | - such small ones (`unsplit`, `Width.cells`), and each call now saves | |
| 32 | - and restores what it uses. | |
| 33 | -3. Done: **Addresses and operands as the machine has them.** An element of a | |
| 34 | - slice in registers is `[base + i*8]`, read where it is used; a | |
| 35 | - compare or an addition takes its right operand from memory | |
| 36 | - (`cmp r8, [rbp - 16]`), not through a register first. Beyond the | |
| 37 | - plan, as the sum stayed at 1.75 without them: `t := t + e` and a | |
| 38 | - `for` loop's step are worked out in the variable's own register, | |
| 39 | - and a `for` loop's top is aligned to 32 bytes. | |
| 40 | -4. Done: **`while` tested at the bottom**, its test moved after the body and | |
| 41 | - jumped to first, as `for` is now. ulam found nothing in it, and lost | |
| 42 | - 3% where the test was long: measured, and kept only if it pays. | |
| 43 | -5. Done: **One table of lines, not two.** Rt finds a place in `.debug_line`, | |
| 44 | - loaded with the program, which gdb reads already, in place of the | |
| 45 | - places' own 16 bytes a line: about 7 KB off hello, more off a big | |
| 46 | - program, for a decoder of DWARF's line program in Rt. | |
| 8 | +No milestone is under way. v0.7.1, the manual, and v0.8.0, better code | |
| 9 | +again, are tagged, by the owner's word to finish both; all before | |
| 10 | +v0.7.1 is approved by the owner, and v0.7.1 and v0.8.0 wait for the owner's | |
| 11 | +review. Next comes what the owner chooses, of the list below. | |
| 47 | 12 | |
| 48 | 13 | ## Next, when the owner says |
| 49 | 14 |
| @@ -188,16 +188,16 @@ | ||
| 188 | 188 | The compiler says its own version and that of the report it follows: |
| 189 | 189 | |
| 190 | 190 | $ ./raz --version |
| 191 | - raz 0.7.1, report 2026-10.17 | |
| 191 | + raz 0.8.0, report 2026-10.17 | |
| 192 | 192 | |
| 193 | 193 | The compiler's version is git's name for the commit it was built from: |
| 194 | -`0.7.1` at the tag `v0.7.1`, `0.7.1-5-g38d29a8` five commits past it. | |
| 194 | +`0.8.0` at the tag `v0.8.0`, `0.8.0-5-g38d29a8` five commits past it. | |
| 195 | 195 | To release, check `main` and tag it; the tag's message is what |
| 196 | 196 | `raz --version` will print: |
| 197 | 197 | |
| 198 | 198 | $ make check |
| 199 | - $ git tag -a v0.8.0 -m 'raz 0.8.0, report 2026-10.17' | |
| 200 | - $ git push origin v0.8.0 | |
| 199 | + $ git tag -a v0.8.1 -m 'raz 0.8.1, report 2026-10.17' | |
| 200 | + $ git push origin v0.8.1 | |
| 201 | 201 | |
| 202 | 202 | GitHub then builds and checks the tag, and makes a release of it with |
| 203 | 203 | a tarball of `raz`, its `lib/` and its manual pages. A tag pushed before the workflow |
| @@ -260,7 +260,8 @@ | ||
| 260 | 260 | `movsxd` reads a byte and makes an `I32` of it in two steps where one |
| 261 | 261 | would do; and the four registers are saved and restored on every call, |
| 262 | 262 | though this path uses one of them. Each could go, at the cost of lines |
| 263 | -a reader would have to follow. | |
| 263 | +a reader would have to follow; v0.8.0 took the first, and the last | |
| 264 | +where the procedure calls nothing. | |
| 264 | 265 | |
| 265 | 266 | ## Better code again, in v0.8.0 |
| 266 | 267 |
| @@ -1980,7 +1980,8 @@ | ||
| 1980 | 1980 | if leaf then begin |
| 1981 | 1981 | o := params; |
| 1982 | 1982 | while o <> nil do begin |
| 1983 | - if RegFit(o) and (weight[Candidate(o^.name)] >= 0) then KeepArrived(o); | |
| 1983 | + k := Candidate(o^.name); | |
| 1984 | + if (k >= 0) and (weight[k] >= 0) then KeepArrived(o); { a candidate whose ADR isn't taken } | |
| 1984 | 1985 | o := o^.next; |
| 1985 | 1986 | end; |
| 1986 | 1987 | end; |