Why is the JVM a stack based virtual machine? What exactly does that mean and what are the advantages over register based virtual machines? Are there any other major design / implementation choices for virtual machine builders?

有帮助吗?

解决方案

A stack based virtual machine is very simple, both as a concept and to implement. Just about anyone with a CS background can implement a simple fully functional VM in a few hundred lines of code.

You can think of the stack as an arbitrary large number of registers if the need arises. Adding registers from the start would be pre-mature optimization.

A simple concept then makes it simpler to do real magic like Hotspot on top of the model. That's not simple, but you can choose the level of complexity based on your ability from a straight interpreter to a simple JIT to Hotspot.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top