Skip to content

Virtual Machine Architecture Strategy

FeatureStack VMRegister VM
ExamplesPython VM, JVMLua VM, Erlang BEAM
Execution ModelOperates on an implicit stackOperates on explicit registers
Instruction SimplicityHigh. Very small, simple instructionsLower. Instructions encode more information
Instruction CountHigh. More instructions for simple tasksLow. Fewer instructions needed
PerformanceModerate. Extra stack manipulation overheadHigh. Fewer memory accesses
Compiler ComplexityLow. Easy to generate codeHigher. Requires register allocation
VM ComplexityLow. Simple interpreter loopModerate. Instructions are richer
MaintainabilityHigh. Easy to reason aboutModerate. More moving parts

A stack VM uses an implicit operand stack. Instructions do not name operands explicitly; instead, they consume values from the top of the stack and push results back.

Typical code:

PUSH a
PUSH b
ADD
POPRET
  • Pros:

    • Simplicity. Instructions are small and uniform.
    • Easy to implement and debug.
    • Well-suited for simple compilers and educational languages.
  • Cons:

    • Instruction-heavy. Even simple expressions require multiple instructions.
    • Frequent stack pushes and pops introduce runtime overhead.
    • Harder to optimize aggressively due to implicit data flow.

Stack VMs are ideal when implementation speed and conceptual clarity are more important than raw performance.


A register VM operates on a fixed set of registers. Instructions explicitly specify their input and output operands.

Typical code:

ADD out, a, b
  • Pros:

    • Performance. Fewer instructions and reduced memory traffic.
    • More explicit data flow enables better optimizations.
    • Instructions are more expressive and versatile.
  • Cons:

    • Instructions are more complex.
    • The compiler must manage register allocation.
    • Slightly more complex VM implementation.

Register VMs trade simplicity for efficiency, making them well-suited for performance-critical systems.