December 2009
Intermediate to advanced
380 pages
9h 2m
English
A bytecode interpreter simulates a computer with the following components:
Code memory: This byte array holds a program’s bytecode instructions (bytecodes plus operands). Addresses are integers.
ip register: The instruction pointer is a special-purpose “register” that points into code memory at the next instruction to execute.
Global memory: Global memory holds a fixed number of slots for variables. The memory slots can point at Integer, Float, String, and struct instances. Unlike the high-level interpreters from the previous chapter, we access variables by integer address rather than name.
CPU: To execute instructions, the interpreter has a simulated CPU that amounts to a loop around a giant “switch on bytecode” ...