Busy Developer's Guide to Building A Bytecode Virtual Machine

Objectives

Building a virtual machine

Virtual Machine Implementation

How, exactly, do we build one of these?

Virtual Machine Implementation

What is a VM?

Virtual Machine Implementation

What does a VM provide?

Virtual Machine Implementation

What does a VM provide?

Architecture

Major moving parts of most virtual machines

Architecture

Simplified

Architecture

Simplified

Architecture

Code

Architecture

IP/PC register

Architecture

Call stack

Architecture

FP/SP register

Architecture

Global memory

Architecture

Global memory

Architecture

Processor

Architecture

Constants

Bytecode

Understanding/implementing one

Bytecode

What is bytecode?

Bytecode

Bytecode categories

Bytecode

Bytecode categories

Bytecode

Syntax/semantics

Bytecode

Opcodes take operands (parameters)

Bytecode

Opcode/operand format

Stack-based Virtual Machines

Everybody on, everybody off the stack

Stack-based Virtual Machines

Abstract operations stack

Stack-based Virtual Machines

"Abstract" is key

Stack-based Virtual Machines

Stack-manipulation Operations

Stack-based Virtual Machines

Mathematics Operations

Stack-based Virtual Machines

Bitwise Operations

Stack-based Virtual Machines

Comparison Opcodes

Stack-based Virtual Machines

Branching/"jumping" Operations

Stack-based Virtual Machines

Compare-then-branch is common

Stack-based Virtual Machines

Call frame Operations

Stack-based Virtual Machines

Call frame Operations

Register-based Virtual Machines

How many registers do you need?

Register-based Virtual Machines

Storage/work focuses on registers

Register-based Virtual Machines

Registers can hold single value

Register-based Virtual Machines

Value-manipulation

Register-based Virtual Machines

Stack-manipulation Operations

Register-based Virtual Machines

Mathematical operations

Register-based Virtual Machines

Bitwise Operations

Register-based Virtual Machines

Comparison Opcodes

Register-based Virtual Machines

Branching/"jumping" Operations

Register-based Virtual Machines

Compare-then-branch is common

Register-based Virtual Machines

Call frame Operations

Register-based Virtual Machines

Call frame Operations

Implementation

Build it already!

Implementation

Steps (1/2)

Implementation

Steps (2/2)

Summary

Wrapping up

Implementation

Futures

Resources

Where to go to get more

Resources

Production VM implementations

Resources

Academic VM implementations

Resources

Web

Resources

Books

Credentials

Who is this guy?