I have always been intrigued and mystified by Virtual Machines and how they operate. I want to learn more about the inner workings of a virtual machine.

Are there any good books on Virtual Machines/Virtual machine designs/Tour of a sample machine?

How do I go about studying one? Do I pick up a spec for the JVM or start with the LLVM?

Please Advice.

Thank you.

+2  A: 

Virtual Machines, a decent survey book.

Lua Implementation Paper

I would strongly suggest the Lua virtual machine as a reference point - its very succinct and self-contained, and very high performance to boot. Note that Lua is a register based virtual machine, making it non-traditional (traditionally VMs are stack based)

Yann Ramin
Thnaks for the book recommendation. It seems pretty good.
+2  A: 

The Java Virtual Machine Specification is actually pretty good and very informative, even if specific.

Pascal Thivent
+1  A: 

Maybe start from something easier.

The most basic Virtual Machine for an imperative language is a set of rules for transitions of triples (commandStack, valueStack, memoryStack). First stack is used for sequencing commands, second for evaluating expressions step-by-step and the third stack remembers values of all variables.

for example the command: a=5;

([a=5,commandStack], valueStack, memoryStack) =>
([5,=(a),commandStack], valueStack, memoryStack) =>
([=(a),commandStack], [5,valueStack], memoryStack) =>
(commandStack, valueStack, memoryStack2)

where memoryStack2 = memupdate(a, 5, memoryStack);

You should read something about Semantics of Computer Languages, eg.

+2  A: 

If you're looking for an easy introduction into what a virtual machine is, you might want to consider The Elements of Computer Systems. You can skip chapters, so don't feel the need to read it all (although highly suggested).

More advanced VMs than the one presented in the book typically include garbage collection, JIT compilation, and a more full system library.

+4  A: 

I have some book recommendations, but be open to more than just books. For example:

To connect neurons and make all the right ideas fall into place, see these two MIT video lectures: Lectures 6 and 7

See also chapters 4 and 5 of Principles of Computer System Design, MIT Press, if there is a copy at your library, or I guess if you want to buy the whole book for the two chapters.

Here is a link to an authoritative IEEE article on the topic:

IEEE: Computer volume 38 Issue 5 "The architecture of virtual machines" Use a university library to retrieve and print it, or of course you can purchase it.

Two books pitched more toward industry than academia, findable on Amazon and such:

Smith and Nair, Virtual Machines: Versatile Platforms For Systems and Processes ISBN 1-55860-910-5

Craig, Virtual Machines ISBN 1-85233-969-1

Important: After some general reading, differentiate between process VMs and system VMs and pursue the one you find more interesting in more depth. If you're looking for new applications for the technologies, the local university library's CS journals are a good place to search. I usually search them online with my login (when I have one, or visit the actual location if I don't) and download the pdf's to read with my morning coffee.

+2  A: 

There are some free chapters of "Inside the Java Virtual Machine Introduction to Java's Architecture" by Bill Venners.

Looks like a good starting point for your interest.

Rene Luijk
+1  A: 

The book Shared Source CLI Essentials offers a guided tour in the SSCLI's implementation (open-source implementation of the CLI standard).