/sigma-vm

Sigma Virtual Machine.

Primary LanguageRustApache License 2.0Apache-2.0

Sigma Virtual Machine

Sigma Virtual Machine (Sigma VM) is a kind of high-level language virtual machine (HLLVM) that can provide a runtime environment for various of guest programming languages.

Supported Features

Sigma VM supports the following features:

  • Basic operations like arithmetic, control flow actions, etc.
  • Global variables and global initializer.
  • Tracing garbage collector (will stop the world for now).
  • Object destructor, called when an object needs to be collected.
  • Module loader and inter-module call support, support for loading modules from files or memory. All loaded modules are managed by the GC, and can be unloaded automatically.
  • System calls, support a variety of standard system calls, and provide interface for user-defined system calls in the VM library.
  • Native call, support for loading shared libraries and calling functions from them (based on C FFI). All loaded libraries are managed by the GC, and can be closed automatically.
  • VM library, including the VM itself, and interfaces for compiler front-ends used to parse and generate bytecode.

Usage of the VM Library

Sigma VM is written in Rust, so it provides Rust crate sigma_vm for interacting with the virtual machine.

For now, the sigma_vm crate has not been uploaded to the crates.io, you can read the documentation generated by rustdoc:

cargo doc --lib sigma_vm --open

VM Utilities

There are many utilities for the Sigma VM in this repository:

  • sigma: driver/front-end of the Sigma VM, provides command line interface for running bytecode files.
  • sbas: Sigma VM bytecode assembler, can generate bytecode files from assembly files.
  • sbdump: Sigma VM bytecode dumper, can display disassembly information from bytecode file.

When running the above program, you can use the command line option --help for usage, for example:

cargo run --bin sigma -- --help

Examples

There are also examples that demonstrate the capabilities of Sigma VM:

  • lisp: a Lisp compiler that generates Sigma VM bytecode.

For more information, see the README in the examples directory.

Copyright and License

Copyright (C) 2023 MaxXing. Licensed under either of Apache 2.0 or MIT at your option.