Sources for writing VM for running bytecode

215 Views Asked by At

Hello!
I am starting a programming language compiler project which generates bytecode which is then run by a VM (something similar to Java's JavaVM). I tried to imitate JavaVM, but it's too complex for this project. I searched the web and couldn't find anything.

So, what sources would you recommend for writing VM (in C or C++) ?

1

There are 1 best solutions below

1
Ira Baxter On

Sounds like you want "simple".

This paper is about sophisticated byte code interpreters.
Generation of fast interpreters for Huffman compressed bytecode (by Latendresse, Feeley). But if you understand how to build sophisticated ones, a simple one should be simple.

There's actually a hard part: designing the instruction set. Mostly you do this by learning about stack machines and register machines, and then designing something which balances the conciseness of stack machines with the efficiency of register machines. This paper Virtual Machine Showdown: Stack Versus Registers (by Anton Ertl et al) explores the tradeoffs beautifully.