Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: anton@mips.complang.tuwien.ac.at (Anton Ertl) Newsgroups: comp.lang.forth Subject: Stacks (was: Locals revisited) Date: Thu, 27 Mar 2025 07:58:47 GMT Organization: Institut fuer Computersprachen, Technische Universitaet Wien Lines: 42 Message-ID: <2025Mar27.085847@mips.complang.tuwien.ac.at> References: <87semzmwok.fsf@nightsong.com> <9c8702a2840990980f8146f09802688b@www.novabbs.com> Injection-Date: Thu, 27 Mar 2025 09:34:08 +0100 (CET) Injection-Info: dont-email.me; posting-host="6dc27607a058792cf53eb3d9de2b338d"; logging-data="4046022"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18GQL+QGEgT0sBgfZzH5z/z" Cancel-Lock: sha1:kogEnnmM9fjOe6117A02988dMMc= X-newsreader: xrn 10.11 Bytes: 3001 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 , 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 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/