LightSun / minivm

A VM That is Dynamic and Fast

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The MiniVM Logo, a blueish grey brick

MiniVM

MiniVM is a small and portable language virtual machine (VM) written in C, meaning it can compile and run just about anywhere.

Some reasons to use MiniVM are:

  • MiniVM is fast
    • LuaJIT's interpreter, known for its speed, takes nearly twice as long as MiniVM to execute similar code.
    • Types are gone at runtime. Data has no type associated with it.
      • Sanitization could be used to catch type errors.
  • MiniVM is small
    • 34KiB when building with make -B OPT='-O2 -fno-ssa-phiopt -s -fuse-ld=lld -Wl,--gc-sections' CC=gcc-11
    • Single binary to assemble and run.
  • MiniVM is portable
    • uses about 10 libc functions in total
    • MiniVM can compile with gcc, clang, tcc and many more

History

MiniVM started its life as an example of how to write a VM. It all started in a discord call, when the question of "how do i write a virtual machine" came up. Shaw wrote the first prototye in a couple hours and sent it on github as an example.

Development went along for several months, with many frontends being written, most notably, Paka. Paka was originally written in Dlang, but was converted to be self hosted on minivm soon after.

Then came the Hacker News Post... MiniVM was #1 on hacker news for a few hours.

MiniVM has gone through many stages.

  • Stack Based Prototype
  • Conversion to Registers Machine
  • Pauseless GC based on Ring Buffers
    • Loading a value, but pauses were gone
  • Removal of arrays, in favor of the Cons Cell
  • Floatng point operations
  • Assembler added

Benchmarks

TODO: add benchmarks TODO: automatic benchmarks

Roadmap

  • Continue Development of MiniVM
  • Reduce dependancy to LibC
  • Better Validators
  • Continue to improve performance

About

A VM That is Dynamic and Fast

License:MIT License


Languages

Language:C 96.8%Language:JavaScript 1.0%Language:Makefile 0.7%Language:Lua 0.6%Language:Batchfile 0.3%Language:Python 0.3%Language:CMake 0.3%