Sujet : Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]
De : anton (at) *nospam* mips.complang.tuwien.ac.at (Anton Ertl)
Groupes : comp.lang.forthDate : 08. Sep 2024, 17:27:47
Autres entêtes
Organisation : Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID : <2024Sep8.182747@mips.complang.tuwien.ac.at>
References : 1 2 3 4 5
User-Agent : xrn 10.11
Stephen Pelc <
stephen@vfxforth.com> writes:
Don't. You will only become dependent on locals. Use of locals should
be a considered decision.
When is it necessary? dxf showed a word w/o locals to have ~%30 fewer
instructions than a word with locals. Is that a common occurrence?
>
We (MPE) converted much of our TCP/IP stack not to use locals. This
was mostly on ARM7 devices, but the figures for other 32 bit CPUs of
the period (say 15 years ago) were similar. Code density improved by
about 25% and performance by about 50%.
So MPE (and Forth, Inc.) discourage the use of locals because they
implement locals inefficiently, and they implement locals
inefficiently because there are so few uses of locals around. A
chicken-and-egg problem.
Concerning the conversion of the TCP/IP stack: Have you considered the
alternative of spending MPE's time on making the locals implementation
more efficient?
See also:
@InProceedings{ertl22-locals,
author = {M. Anton Ertl},
title = {Are Locals Inevitably Slow?},
crossref = {euroforth22},
pages = {48--49},
url = {
http://www.euroforth.org/ef22/papers/ertl-locals.pdf},
url-slides = {
http://www.euroforth.org/ef22/papers/ertl-locals-slides.pdf},
video = {
https://www.youtube.com/watch?v=tPjSKetEJn0},
OPTnote = {presentation slides},
abstract = {Code quality of locals on two code examples on
various systems}
}
An update on the table for the example:
: 3dup.3 {: a b c :} a b c a b c ;
instr. bytes system
31 117 Gforth AMD64
16 44 iforth 5.0.27 (plus 20 bytes entry and return code)
7 19 lxf 1.6-982-823 32-bit
32 127 SwiftForth 4.0.0-RC89 (calls LSPACE)
26 92 VFX Forth 64 5.11 RC2
- anton
-- M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.htmlcomp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html New standard: https://forth-standard.org/ EuroForth 2024: https://euro.theforth.net