zbigniew2011@gmail.com (LIT) writes:
Now I'm pondering about DO..LOOP construct; actually
probably it doesn't necessarily need to rely on return
stack.
There are many ways to skin this cat, and I have written at length
about that here. For performance you should keep those data in
registers that you update in the loop. E.g., a simple way is to have
the index and the limit around, and to update the index; then you
should keep the index in a register; leaving the unchanging limit in
memory is not so bad for performance on many CPUs.
You need to save the old index and old limit when entering another
do...loop, and restore them on exiting the do...loop, including when
you exit with UNLOOP or THROW. Both SwifthForth and VFX switched to
keeping the loop control parameters in registers in their 64-bit
ports, and at first forgot to restore the old loop control parameters
on THROW; they have fixed this bug as soon as it was found.
Instead of keeping index and limit, there are also variants that keep
other values around, to make +LOOP more efficient (sometimes at the
cost of a more expensive I).
<
2021Jan10.112340@mips.complang.tuwien.ac.at> discusses a number of
these variants.
- anton
--
M. Anton Ertl
http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs:
http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard:
https://forth-standard.org/
EuroForth 2023 proceedings:
http://www.euroforth.org/ef23/papers/
EuroForth 2024 proceedings:
http://www.euroforth.org/ef24/papers/
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)