Skip to content
This repository has been archived by the owner. It is now read-only.
a (tiny) VM project built with Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bench
cmd
vm
.gitignore
LICENSE
README.md
SYNTAX

README.md

Specter

Specter is an implementation of GenTiradentes' TinyVM in Go (the original is written in C).

This is very much to learn about virtual machines (this is my first attempt at a VM, so huge thanks to GenTiradentes for making a minimal one, easy to grasp).

The whole implementation takes about 500 lines of Go code.

Performance

It runs all examples available in TinyVM's repository, at roughly 30% slower than C, and at 7% slower with bounds-checking disabled. See more about the benchmarks in the bench subfolder.

Memory

Specter runs at a higher (but stable) memory footprint than its C counterpart, however note the following (copied from the mailing list, thanks to Carlos Castillo, edited):

BTW: The memory use [...] hovers at a high-ish number (70Mb in my case) because the garbage collection code doesn't run until memory use exceeds a given threshold. When it does, all the generated intermediate strings/slices are found but the memory is not returned to the OS, it is instead re-used for any following allocations, so the memory usage stat according to the OS stays at that threshold. If you set the environment variable GOGCTRACE=1 before running your code you can see when the garbage collector runs, and what happened during the run.

Thanks

The great Go community on the mailing list.

License

The BSD 3-Clause license.

You can’t perform that action at this time.