Skip to Main Content
Language Implementation Patterns
book

Language Implementation Patterns

by Terence Parr
December 2009
Intermediate to advanced content levelIntermediate to advanced
380 pages
9h 2m
English
Pragmatic Bookshelf
Content preview from Language Implementation Patterns

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.
Start your free trial

You might also like

Implementation Patterns

Implementation Patterns

Kent Beck

Publisher Resources

ISBN: 9781680500097Errata Page