parrt / simple-virtual-machine

A simple VM for a talk on building VMs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

simple-virtual-machine

A simple VM for a talk on building VMs in Java. See video and slides.

There are multiple branches:

  • master. Basic instructions only (no function calls).
  • add-functions. Includes CALL/RET instructions, runs factorial test function.
  • split-stack. Split into operand stack and function call stack.
  • func-meta-info. CALL bytecode instruction takes an index into a metadata table for functions rather than an address and the number of arguments. This makes it much easier for bytecode compiler to generate code because it doesn't need to worry about forward references. This branch also properly allocates space for local variables.
  • shatter-stack. Broke apart the Context[] stack into a linked-list with invokingContext as parent pointer to caller. added call stack for trace.

See also a C version derived from split-stack. Parts derived from codyebberson's C implementation.

About

A simple VM for a talk on building VMs

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Java 100.0%