|Pattern 27||Stack-Based Bytecode Interpreter|
This pattern executes bytecode instructions that store temporary values on an operand stack.
A stack-based bytecode interpreter simulates a hardware processor with no general-purpose registers. That means that bytecode instructions must use an operand stack to hold temporary values. Temporary values include arithmetic operands, parameters, and return values. Because the introductory material for this chapter explained general bytecode interpreter architecture, we can focus on the details specific to stack machines.
Let’s look at the operand stack first, since it’s the key identifying feature. Any time we want to load a value from memory or compute a result, we push the result onto ...