All Projects → MrSmith33 → vox

MrSmith33 / vox

Licence: BSL-1.0 license
Vox language compiler. AOT / JIT / Linker. Zero dependencies

Programming Languages

d
599 projects

Projects that are alternatives of or similar to vox

cult
CPU Ultimate Latency Test.
Stars: ✭ 67 (-76.74%)
Mutual labels:  x86-64, jit
Jit Compiler
JIT compiler in Go
Stars: ✭ 70 (-75.69%)
Mutual labels:  x86-64, jit
Opensmalltalk Vm
Cross-platform virtual machine for Squeak, Pharo, Cuis, and Newspeak.
Stars: ✭ 345 (+19.79%)
Mutual labels:  x86-64, jit
AheuiJIT
Aheui JIT compiler for PC and web
Stars: ✭ 27 (-90.62%)
Mutual labels:  x86-64, jit
Asmjit
Machine code generation for C++
Stars: ✭ 2,874 (+897.92%)
Mutual labels:  x86-64, jit
kcs
Scripting in C with JIT(x64)/VM.
Stars: ✭ 25 (-91.32%)
Mutual labels:  x86-64, jit
Dynarmic
An ARM dynamic recompiler.
Stars: ✭ 475 (+64.93%)
Mutual labels:  x86-64, jit
Lightbeam
Lightbeam has moved and now lives in the Wasmtime repository!
Stars: ✭ 253 (-12.15%)
Mutual labels:  jit, codegen
Minijit
A basic x86-64 JIT compiler written from scratch in stock Python
Stars: ✭ 185 (-35.76%)
Mutual labels:  x86-64, jit
Zydis
Fast and lightweight x86/x86-64 disassembler and code generation library
Stars: ✭ 2,168 (+652.78%)
Mutual labels:  x86-64, codegen
dynarmic
An ARM dynamic recompiler.
Stars: ✭ 675 (+134.38%)
Mutual labels:  x86-64, jit
bf256
Brainfuck compiler under 256 bytes in size.
Stars: ✭ 21 (-92.71%)
Mutual labels:  x86-64, amd64
x86e
A simple x86 emulator, debugger, and editor in JavaScript.
Stars: ✭ 89 (-69.1%)
Mutual labels:  x86-64, amd64
docker-unms
All-in-one docker image for Ubiquiti UISP (formerly UNMS). Supports x86_64 and ARM (Raspberry Pi).
Stars: ✭ 153 (-46.87%)
Mutual labels:  x86-64, amd64
peekaboo
An standalone execution trace library built on DynamoRIO.
Stars: ✭ 17 (-94.1%)
Mutual labels:  x86-64, amd64
Dora
Dora VM
Stars: ✭ 371 (+28.82%)
Mutual labels:  x86-64, jit
Wasm Micro Runtime
WebAssembly Micro Runtime (WAMR)
Stars: ✭ 2,440 (+747.22%)
Mutual labels:  jit, aot
Cranelift
Cranelift code generator
Stars: ✭ 2,485 (+762.85%)
Mutual labels:  jit, codegen
Evoasm.rb
An AIMGP (Automatic Induction of Machine code by Genetic Programming) engine
Stars: ✭ 91 (-68.4%)
Mutual labels:  x86-64, jit
oberon-07-compiler
Oberon-07 compiler for x64 (Windows, Linux), x86 (Windows, Linux, KolibriOS), MSP430x{1,2}xx, STM32 Cortex-M3
Stars: ✭ 45 (-84.37%)
Mutual labels:  x86-64, amd64

Small and fast JIT/AOT compiler with zero dependencies

CI

Vox programming language

Vox is a multiparadigm programming language inspired by D (60%), Jai (30%), and Zig (10%).

Main features

  • Fast compilation
  • Strong metaprogramming
  • Can be used for scripting and standalone programs (both JIT and AOT compilation)
  • No dependencies (except D compiler)

Similarities to the D language

  • Same syntax for most portions of the language (struct, function, enum, for, while, if, UFCS, slices, arrays)
  • Conditional compilation
  • Templates, Variadic templates, and functions
  • C interoperability
  • Modules / Packages

Differences from the D language

  • No GC, minimal runtime, no classes (only structs), no exceptions
  • More compile-time features, faster CTFE
  • Using templates for heavy calculations is discouraged, instead, CTFE can be used for introspection, and code generation.
  • Macros (WIP)
  • No C++ interoperability

Platforms

Supported:

  • windows-x64 - host and target
  • linux-x64 - host and target
  • macos-x64 - only jit-mode

Planned:

  • linux-arm64
  • wasm
  • windows-arm64?
  • spirv (Vulkan/OpenCL/OpenGL shaders)

Project goals

  • Strong focus on application extensions
  • Maximize user productivity
  • Maximize application performance
  • AOT and JIT, plugin support, runtime compilation, embedded compiler, tiered compilation
  • Static typing
  • Great error messages
  • Fast / Incremental compilation
  • Minimize effort needed for installation, setup, integration
    • Minimal dependencies/encapsulate dependency into module or package
    • Runtime as a library/minimal runtime/no runtime
    • Embedding/extern C
    • Code driven compilation, extending compiler from inside of the program being compiled
  • Processor intrinsics
  • Conditional compilation
  • CTFE, Templates, Introspection, Code generation

Syntax examples

i32 fib(i32 number) {
    if (number < 1) return 0;
    if (number < 3) return 1;
    return fib(number-1) + fib(number-2);
}

struct Point {
    i32 x;
    i32 y;
}

T min[T](T a, T b) {
    if (a < b) return a;
    return b;
}

Running & testing

In main.d uncomment one of the following lines:

//version = bench; // Runs benchmark
//version = devtest; // Run single test with fine-tuned logging. Useful for development. Uses tester.runDevTests(). Toggle options there for precise analisys while developing.
//version = test; // Runs test suite. Uses tester.runAllTests().

and run with: source> dmd -m64 -i main.d && main

Benchmarking:

ldc2 -d-version=bench -m64 -O3 -release -boundscheck=off -enable-inlining -flto=full -i main.d && main

Debug CLI build:

dmd -i -g -m64 -version=cli main.d -of=vox.exe

Release CLI build:

ldc2 -d-version=cli -m64 -O3 -release -boundscheck=off -enable-inlining -flto=full -mcpu=native -i main.d -of=vox.exe

Debug shared library build:

ldc2 -m64 -shared -g -d-debug -fvisibility=hidden -link-defaultlib-shared=false -i c_api.d -of=libvox.dll

Compiling with Profile Guided Optimization:

ldc2 -d-version=test -m64 -release -fprofile-instr-generate -mcpu=native -i main.d -of=vox_instrumented.exe
vox_instrumented
ldc-profdata merge default.profraw -output vox.profdata
ldc2 -d-version=cli -m64 -O3 -release -boundscheck=off -enable-inlining -flto=full -mcpu=native -fprofile-instr-use=vox.profdata -i main.d -of=vox.exe

Using Commandline interface

Getting help

Gives the full list of flags

vox --help

Input files

Each file must begin with --- <path>, three dashes, space, and name.

Files can be nested inside directories --- dir/dir2/file.txt.

Example:

--- main.vx
import kernel32;
void main() { ExitProcess(42); }
--- kernel32.vx
@extern(module, "kernel32")
noreturn ExitProcess(u32 uExitCode);

Can be compiled with vox program.har

CLI Tools

The compiler contains embedded tools:

PDB dump

Prints content of vox.pdb file into stdout.

vox pdb-dump vox.pdb

Syntax highlighting

GitHub

To get some syntax highlighting on GitHub define .gitattributes file in the repository with the following content (docs):

*.vx linguist-language=D

All .vx files will be highlighted and classified as D.

Editor

Compiler overview

Stats

  • Impl size: 40k LoC of D, 3MB exe
  • Time to compile: 4s debug / 45s release
  • Test suite: 95ms for 361 tests
  • Time to compile 10MLoC of fibonacci: 8s on Windows, 7.5s on Linux

For more in detail description of implementation see internals.md

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].