5

I'm looking for an open source virtual machine that's:

  • fast and as lightweight as possible
  • supports a minimal set of bytecode (like LLVM IR)
  • easily embedable from a C++ application
  • Cross platform (Linux, Windows and OS X)
  • x86 support
Cœur
  • 37,241
  • 25
  • 195
  • 267
Alon Gubkin
  • 56,458
  • 54
  • 195
  • 288

4 Answers4

6

Lua is famous for being ridiculously easy to embed in C/C++. Its VM is open source and cross-platform, very small (both exe size and bytecode instruction set) and at the same time quite fast. But its bytecode may be not suitable for your language. The bytecode format is documented here.

  • 1
    Lua's VM is not general purpose VM but it may work for your custom language if your language and Lua are not too far apart semantically. A short description of Lua's VM is at http://www.lua.org/source/5.1/lopcodes.h.html#OP_MOVE . If you go this way, I suggest you first try to compile your language to Lua source code. – lhf Aug 20 '10 at 14:00
5

NekoVM is a programming language and a lightweight virtual machine designed as a generic target for compiler writers. The documentation makes it seem really easy to embed the VM in a C or C++ application, but it seems the VM API is not yet documented.

Jon Purdy
  • 53,300
  • 8
  • 96
  • 166
4

Why filter out LLVM ? It's a set of C libraries

I guess it's not as easy to embed than Lua, but LLVM is so great that it would probably overcome the hassle of integrating it. See this SO question, does it help ?

Community
  • 1
  • 1
Calvin1602
  • 9,413
  • 2
  • 44
  • 55
2

Other possible answer : why not output assembler instead ? it's fast and lightweight, and you don't need a VM at all. Since you target x86 only, it could make sense, depending on what you're trying to do.

Calvin1602
  • 9,413
  • 2
  • 44
  • 55