From 0e9ae63d2c0486a7b23a53e1b4d660615354d195 Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Mon, 12 Oct 2026 18:35:49 +0100 Subject: [PATCH] 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. --- diff --git a/CLAUDE.md b/CLAUDE.md index d780f24..b4cbc1a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -89,7 +89,11 @@ steps 52-53), and v0.5.0, the library of report 2026-10.9, which the compiler says it follows, and v0.7.0, better code, and v0.7.1, the manual: `raz(1)`, `raz-tutorial(7)`, `raz(7)` and `raz-lib(3)`, made by `tools/Doc.raz` -from `lib/`. Under way, by `PLAN.md`: better code again (v0.8.0). +from `lib/`, and v0.8.0, better code again: slices in registers, +parameters left in rdi and rsi, operands as the machine has them, +`while` tested at the bottom, and one line table, DWARF's. `make +kernels` measures `test/bench` against FPC `-O2`. Next, by `PLAN.md`: +what the owner chooses. **The freeze.** Since v0.5.0 the language changes only to mend a defect, and the library grows only by what breaks no program written @@ -113,7 +117,7 @@ `.github/workflows/ci.yml`, which checks it and makes the GitHub release with a tarball of `raz` and `lib/`; it also checks every push to `main`. `README.md`'s "Versions" gives the commands. v0.3.0 is -the first; v0.7.1, report 2026-10.17, the latest. +the first; v0.8.0, report 2026-10.17, the latest. `test/libc` runs its programs over `lib/Sys.raz`, the C one, through a link in its `mods`. A test or example without `.expect` is only diff --git a/PLAN.md b/PLAN.md index 9757ea4..12b6721 100644 --- a/PLAN.md +++ b/PLAN.md @@ -5,45 +5,10 @@ stopping for the owner's review. A finished milestone is cut from this file: git keeps the history, and the report's section 12 the language's. -Better code again (v0.8.0) is under way, by the owner's word. v0.7.1, -the manual, is tagged, and all before v0.7.1 is approved by the owner. - -## Now: better code again (v0.8.0) - -For: on the same program, raz within 1.3 times the time of FPC `-O2` -with `check off;` (on `test/bench`'s kernels, which `make kernels` -measures against their Pascal twins: today 1.34 on a heap sort, 1.75 -on a sum over a slice, 1.2 on a search for a word in a text), and -every default program smaller; the compiler as clear as -v0.7.0 left it, and under 10,000 lines. No change to the language. -Each step is measured as v0.7.0's were, on rat and on its kernel, and -one that buys less than 2% on both is reverted and noted here. - -1. Done: **Slices in registers.** A slice parameter or variable whose address - isn't taken lives in two of the variables' registers, its pointer and - its length, chosen by the read-ahead as a single value is, and - counted as two. FPC's search keeps its slice in `rdi` and `rsi`; - raz's reads both from the frame on every round. -2. Done: **Parameters left where they arrive.** In a procedure that calls - nothing, copies no block and divides by no variable, as the - read-ahead can tell, a parameter stays in the register it came in, - and no register is saved for it. Most of rat's hot procedures are - such small ones (`unsplit`, `Width.cells`), and each call now saves - and restores what it uses. -3. Done: **Addresses and operands as the machine has them.** An element of a - slice in registers is `[base + i*8]`, read where it is used; a - compare or an addition takes its right operand from memory - (`cmp r8, [rbp - 16]`), not through a register first. Beyond the - plan, as the sum stayed at 1.75 without them: `t := t + e` and a - `for` loop's step are worked out in the variable's own register, - and a `for` loop's top is aligned to 32 bytes. -4. Done: **`while` tested at the bottom**, its test moved after the body and - jumped to first, as `for` is now. ulam found nothing in it, and lost - 3% where the test was long: measured, and kept only if it pays. -5. Done: **One table of lines, not two.** Rt finds a place in `.debug_line`, - loaded with the program, which gdb reads already, in place of the - places' own 16 bytes a line: about 7 KB off hello, more off a big - program, for a decoder of DWARF's line program in Rt. +No milestone is under way. v0.7.1, the manual, and v0.8.0, better code +again, are tagged, by the owner's word to finish both; all before +v0.7.1 is approved by the owner, and v0.7.1 and v0.8.0 wait for the owner's +review. Next comes what the owner chooses, of the list below. ## Next, when the owner says diff --git a/README.md b/README.md index caacbcf..2b7b3a4 100644 --- a/README.md +++ b/README.md @@ -188,16 +188,16 @@ The compiler says its own version and that of the report it follows: $ ./raz --version - raz 0.7.1, report 2026-10.17 + raz 0.8.0, report 2026-10.17 The compiler's version is git's name for the commit it was built from: -`0.7.1` at the tag `v0.7.1`, `0.7.1-5-g38d29a8` five commits past it. +`0.8.0` at the tag `v0.8.0`, `0.8.0-5-g38d29a8` five commits past it. To release, check `main` and tag it; the tag's message is what `raz --version` will print: $ make check - $ git tag -a v0.8.0 -m 'raz 0.8.0, report 2026-10.17' - $ git push origin v0.8.0 + $ git tag -a v0.8.1 -m 'raz 0.8.1, report 2026-10.17' + $ git push origin v0.8.1 GitHub then builds and checks the tag, and makes a release of it with a tarball of `raz`, its `lib/` and its manual pages. A tag pushed before the workflow diff --git a/doc/compiler.md b/doc/compiler.md index f66d08f..8ac32ce 100644 --- a/doc/compiler.md +++ b/doc/compiler.md @@ -260,7 +260,8 @@ `movsxd` reads a byte and makes an `I32` of it in two steps where one would do; and the four registers are saved and restored on every call, though this path uses one of them. Each could go, at the cost of lines -a reader would have to follow. +a reader would have to follow; v0.8.0 took the first, and the last +where the procedure calls nothing. ## Better code again, in v0.8.0 diff --git a/src/parse.pas b/src/parse.pas index faa493d..03324fb 100644 --- a/src/parse.pas +++ b/src/parse.pas @@ -1980,7 +1980,8 @@ if leaf then begin o := params; while o <> nil do begin - if RegFit(o) and (weight[Candidate(o^.name)] >= 0) then KeepArrived(o); + k := Candidate(o^.name); + if (k >= 0) and (weight[k] >= 0) then KeepArrived(o); { a candidate whose ADR isn't taken } o := o^.next; end; end;