Questions tagged [stack]

Use the stack tag for questions relating to the implementation and design of stack-based languages.

Filter by
Sorted by
Tagged with
1 vote
0 answers
130 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 ...
FlatAssembler's user avatar
11 votes
5 answers
3k 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 ...
Foxy's user avatar
  • 213
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: ...
user avatar
16 votes
3 answers
1k 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 ...
CPlus's user avatar
  • 7,891
15 votes
3 answers
2k 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 ...
kouta-kun's user avatar
  • 1,349
2 votes
1 answer
165 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 ...
чистов_n - за Россию's user avatar
15 votes
1 answer
199 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 ...
WormholeX's user avatar
  • 153
7 votes
2 answers
270 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: ...
lyxal's user avatar
  • 1,775
10 votes
2 answers
406 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 ...
Bbrk24's user avatar
  • 8,907