A generic jit library based on Asmjit with a focus on simplicity and performance.
Simple program
#include "jit/function.hpp"
int main()
{
using namespace supernova::jit;
const auto rt = std::make_shared<asmjit::JitRuntime>();
const std::shared_ptr<function_builder> builder = function_builder::create(rt, asmjit::FuncSignature::build<int>());
auto arg0 = builder->i32(39);
auto arg1 = builder->i32(40);
auto result = builder->i32(1);
const auto end = builder->label();
builder->jump_equal(arg0, arg1, end);
builder->move(result, builder->i32_const(0));
builder->bind(end);
builder->return_value(result);
if (const auto func = builder->build<int()>())
{
int r = func();
fmt::println(__FUNCTION__": func() = {}", r);
return 0;
}
return 1;
}
Depending on your operating system, you'll need the following tools to build and run Super Nova:
OS | Tools |
---|---|
Windows | Visual Studio, XMAKE |
*nix | XMAKE and a c++23 compiler |
To build the Super Nova VM and its associated tests, follow these steps:
- Install the necessary prerequisites for your operating system.
- Run
xmake build
in the project directory. - The compiled binaries,
supernova
(the VM) andsupernova-tests
(the tests), will be located in thebuild/OS/ARCH/release
directory.