registers vs stacks

Implemented in hardware, a register-based machine is going to be more efficient simply because there are fewer accesses to the slower RAM. In software, however, even a register based architecture will most likely have the “registers” in RAM. A stack based machine is going to be just as efficient in that case.

In addition a stack-based VM is going to make it a lot easier to write compilers. You don’t have to deal with register allocation strategies. You have, essentially, an unlimited number of registers to work with.

Update: I wrote this answer assuming an interpreted VM. It may not hold true for a JIT compiled VM. I ran across this paper which seems to indicate that a JIT compiled VM may be more efficient using a register architecture.

Leave a Comment