Bytecode Machine Architecture
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” ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access