Stacks (was: Locals revisited)

Liste des GroupesRevenir à cl forth 
Sujet : Stacks (was: Locals revisited)
De : anton (at) *nospam* mips.complang.tuwien.ac.at (Anton Ertl)
Groupes : comp.lang.forth
Date : 27. Mar 2025, 08:58:47
Autres entêtes
Organisation : Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID : <2025Mar27.085847@mips.complang.tuwien.ac.at>
References : 1 2 3
User-Agent : xrn 10.11
mhx@iae.nl (mhx) writes:
Anyway, it is hard to come up with code that needs more than 4+1
stacks in its critical path.

What are the 4+1 stacks you have in mind?

In Gforth, we have data, return, FP, and locals stack.

One could also imagine a SIMD stack (with, e.g., 512-bit entries on a
system with AVX-512) and a vector or object stack (probably one stack
for both purposes); that would make 6.  Although, given the
commonality between SIMD and FP registers in most architectures, one
could also imagine using one stack for both (with the disadvantage
that each FP stack item needs as much space as the largest SIMD item).

In <http://www.euroforth.org/ef22/papers/ertl.pdf>, figure 1 shows:
data stack, objects stack, control-flow stack (rarely accessed, i.e.,
does not merit a stack pointer in a register), system r-stack,
optional data r-stack, optional object r-stack, and an FP stack.  If
you include the optional stacks and add a SIMD stack and a locals
stack, that would need 8 stack pointers.

A problem with having many stacks is that you then need additional
stack-manipulation words, transfer words, and possibly inter-stack
operation words, so despite having a number of discussions about
adding more stacks for, e.g., addresses or objects, this usually has
only happened when the data types are non-overlapping (i.e., the FP
stack), and for the return stack.

On the other hand, in
<http://www.euroforth.org/ef13/papers/ertl-paf.pdf> I point out that
for a large subset of Forth, only one stack pointer is needed; that
stack contains locals and items from the various logical stacks (data
stack, return stack, etc.), when they no longer fit in registers.

- 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/

Date Sujet#  Auteur
25 Mar 25 * Locals revisited12albert
26 Mar 25 `* Re: Locals revisited11Paul Rubin
27 Mar 25  +* Re: Locals revisited2mhx
27 Mar 25  i`- Stacks (was: Locals revisited)1Anton Ertl
27 Mar 25  +* Re: Locals revisited4Anton Ertl
27 Mar 25  i+- Re: Locals revisited1albert
27 Mar 25  i`* Re: Locals revisited2Paul Rubin
28 Mar 25  i `- Re: Locals revisited1Anton Ertl
28 Mar 25  `* Re: Locals revisited4dxf
30 Mar 25   `* Re: Locals revisited3dxf
30 Mar 25    `* Re: Locals revisited2dxf
31 Mar 25     `- Re: Locals revisited1sjack

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal