Questions tagged [stack]
Use the stack tag for questions relating to the implementation and design of stack-based languages.
12 questions
3
votes
1
answer
537
views
How are C11 compilers calculating by how much to change the stack pointer before `goto` if the program uses variable-length arrays?
So, obviously, the C compiler, when compiling gotos, before inserting the jump instruction, needs to insert ...
6
votes
0
answers
155
views
Function call in single pass compiler for B
I've been implementing a B compiler for x86 assembly for a while now and have been asking one or two questions in Retrocomputing.
My tools for implementing it is using flex/bison with C.
Recently I've ...
11
votes
3
answers
718
views
Delimited continuations and foreign functions
Guile Scheme has had support for delimited continuations for over a decade. Much was written about it in a 2012 blog post: guile and delimited continuations.
They have a limitation: continuations that ...
5
votes
1
answer
497
views
How is Rosetta 2 capable of translating x87 instructions (which are stack-based) to ARM machine code (where the FPU is register-based)?
Rosetta 2 is a program that enables the new ARM-based Macs to run programs for old x86-based Macs by translating x86 machine code to ARM machine code. But how does it do that? What seems especially ...
11
votes
5
answers
4k
views
Should a virtual machine stack have a limited size?
I'm writing a register- and stack-based virtual machine. My goal is to have something easy to use and general purpose, so I abstain from any form of hardware limitation in its design. Since my VM's ...
16
votes
11
answers
5k
views
What prevents languages from having arbitrary sized return data on the stack?
While programming, I often wonder what prevents languages from allowing arbitrary sized stack returns, like this:
...
20
votes
3
answers
5k
views
What are the implications of implementing variable-length arrays?
At first C did not have variable-length arrays; all array sizes must be compile times constants. Then, in C99, variable-length arrays, a controversial addition, were added, permitting runtime-sized ...
17
votes
3
answers
5k
views
What are the pros and cons of register-based VMs and stack-based VMs?
What are the pros and cons of choosing a register or stack based VM for a language implementation?
For example Python has stack-based virtual machine, while Lua has register-based VM.
What makes a ...
2
votes
1
answer
283
views
What are differences between stack- and register-based virtual machine's bytecode commands?
What are differences between stack- and register-based virtual machine's bytecode commands?
For example Python has stack-based virtual machine.
But Lua has register-based vm.
So, what are the ...
15
votes
1
answer
417
views
Segmented Stack Efficiency
Segmented stacks are one method to enable the growth of execution stacks in multi-threaded paradigms at runtime, instead of having to statically pre-allocate a fixed-sized stack at compile time.
Some ...
7
votes
2
answers
516
views
How to Add Static Typing to a Stack Language?
What level of static typing can be added to a stack-based language? I know it's impossible to fully statically type some stack languages:
...
10
votes
2
answers
589
views
What operations are common in stack-based languages?
A stack-based language necessarily contains at least "push" and "pop" instructions. However, these typically aren't the only ways to manipulate the stack. For example, several ...