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” ...

Get Language Implementation Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.