raz / commit a65f701e

commit
a65f701eb11206ac42f1a12592b1e7434a0a6c9f
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
84647412
PROPOSALS: inlining a procedure that only returns

Measured by hand: Grep 20% faster with zeros and lowest in place.
Kept for later, by the owner's word.

patch · log

1 file changed, +25 -0

PROPOSALS.md modified +25 -0

@@ -146,3 +146,28 @@
146146 argument `operand` would give next, after what options are left; so
147147 that the arguments from there on are `Files.arg(i)` for `i` from
148148 `at(p)` to `ARGC() - 1`, as they are. It breaks no program.
149+
150+## Inlining a procedure that only returns
151+
152+Not the language's but the compiler's: a call of a procedure whose
153+body is `return` and an expression, as `Grep.zeros` and
154+`Scan.tokPos` are, made in place of the call. One pass keeps no
155+tree to copy, but it can read source again, as `while` reads its
156+condition again (`saveScan`, `restoreScan`): the arguments go to
157+temporaries, each evaluated once and in order, a scope names the
158+parameters as them, and the expression is read again from where the
159+procedure's begins, in its own module's scope.
160+
161+Measured by hand on the kernels: Grep with `zeros` and `lowest`
162+written in place is 20% faster, 0.88 times FPC `-O2`'s time where it
163+is 1.14 now. The compiler has 78 such procedures and the library 28;
164+the compiler's profile names the calls of small routines as what is
165+left (doc/compiler.md).
166+
167+Kept narrow: scalars passed by value, no recursion, no code
168+procedure (a square root has its own way), a procedure taken as a
169+value still called. What it costs: an inlined procedure is not in
170+the trap report's list of procedures, nor in gdb's backtrace, though
171+a failed check in it is still told at its line; 60 to 100 lines of
172+the 164 left below 11,000; and, across modules, the imported module's
173+text kept to be read again, which is to be checked.