Sujet : Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]
De : dxforth (at) *nospam* gmail.com (dxf)
Groupes : comp.lang.forthDate : 13. Sep 2024, 00:37:29
Autres entêtes
Organisation : Ausics - https://newsgroups.ausics.net
Message-ID : <66e37b37$1@news.ausics.net>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : Mozilla Thunderbird
On 12/09/2024 8:19 pm, Anton Ertl wrote:
dxf <dxforth@gmail.com> writes:
Using registers is appealing until
one realizes a call to an external function necessitates placing it back on
the stack.
Not if the stack item does not live across the call. And even if it
lives across the call and cannot be placed in a callee-saved register,
the save before and restore after the call is amortized typically
across more than one register access on each side of the call.
Register allocation is one of the most effective optimizations in
compilers. That's also true of Forth.
Costs multiply in the face of many small functions.
Register allocation is also effective for small functions.
Moore talked about registers. It's worth repeating for those who may be new
to forth.
"But such registers raises the question of local variables. There is a lot of
discussion about local variables. That is another aspect of your application
where you can save 100% of the code. I remain adamant that local variables
are not only useless, they are harmful. If you are writing code that needs
them you are writing, non-optimal code" - Chuck Moore 1999