Skip to content
 
 

Repository files navigation

angelscript-jit

English | Español

A JIT compiler for AngelScript, written in C++20 on top of the MIR runtime. In the x64 benchmarks, loops ran 26.5–44.3 times as fast as the interpreter and matmul ran 14.6 times as fast on both platforms. This maintained fork of asumagic/angelsea (BSD-2-Clause) keeps the JIT working on the current AngelScript release. It is alpha-quality software, like upstream.

The library, the CMake target (angelsea) and the C++ namespace keep their upstream names, so changes can go back upstream.

Supported releases

Interfaces: asIJITCompilerV2 (AngelScript 2.37.0 and later) and asIJITCompiler version 1 (2.31.2 to 2.36.1).

AngelScript Windows x64 Linux x64 Linux arm64 macOS arm64 macOS x64 32-bit x86
2.39.0 (current) ✅ ✅ ⚠️ ⚠️ ⚠️ AOT only
2.38.0 ✅ ✅ ⚠️ ⚠️ ⚠️ ❌
2.37.0 ✅ ✅ ⚠️ ⚠️ ⚠️ ❌
2.36.1 and 2.35.1 (interface V1) 🧪 🧪 ❌
2.34.0 to 2.31.2 (interface V1) 🧪 ❌
2.30.2 and earlier ❌ ❌ ❌ ❌ ❌ ❌

✅ covered by regular CI. ⚠️ experimental CI job. 🧪 checked outside CI. ❌ unsupported. AOT only loads a library built from Jit::ExportModuleC without a runtime compiler. Linux arm64 passed under QEMU. macOS x64 and arm64 still need CI verification. See Platforms for the script corpus coverage by SDK and target.

What this fork adds

  • Script exceptions raised by application functions are no longer lost.
  • aarch64 loads and stores at unaligned offsets, and three MIR defects, fixed in vendor/mir.
  • VM variables can live in registers. Resolved interface and function pointer calls can set up script frames inline.
  • Eager JIT batches and AOT exports can call known script functions from the same module directly.
  • Hosts can opt in to primitive array indexing with JitConfig::array_access. Strict suspension disables the fast path.
  • Interface V1 (2.31.2 to 2.36.1) and AOT. Jit::ExportModuleC writes the C of a module for gcc, clang or MSVC. Jit::LoadAot checks the export and installs compatible functions.
  • 32-bit x86 through AOT, with MSVC thiscall.
  • A random-program differential test (tests/differential).

Use

#include <angelsea.hpp>

engine->SetEngineProperty(asEP_INCLUDE_JIT_INSTRUCTIONS, true);
engine->SetEngineProperty(asEP_JIT_INTERFACE_VERSION, 2);
engine->SetEngineProperty(asEP_BUILD_WITHOUT_LINE_CUES, true);

angelsea::JitConfig config;
angelsea::Jit jit(config, *engine);
if (engine->SetJITCompiler(&jit) < 0) {
    // the engine rejected the JIT: check the interface version set above
}

Tunables, per-function callbacks and the thread-safety limit are in docs/USAGE.md. A complete project is in example/hello/.

Building from source

git clone --recurse-submodules https://github.com/angelscript-tools/angelscript-jit.git
cd angelscript-jit
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build

Use your own dependencies or add it as a CMake subdirectory: see docs/BUILDING.md.

Documentation

  • Building — dependencies, vendored or system, static library and subdirectory.
  • Usage — JitConfig, lazy and asynchronous compilation.
  • Platforms — supported systems and architectures.
  • Design — the C backend, calling conventions, MIR and the other JIT compilers.
  • Benchmarks — speed against the interpreter, native C++ and other JITs.
  • Tests — running the suite.
  • Roadmap — plans and limits, written for LLM agents.
  • CHANGELOG.md — release history.

Roadmap

  • Verify macOS x64 and arm64 in CI and add AOT with .dylib.
  • 32-bit x86: verify 2.37, 2.38 and interface V1.
  • Performance: inline small script functions, hoist array bounds checks, replace the remaining opcode fallbacks.

The full list is in docs/ROADMAP.md.

Support

Open an issue with the AngelScript release, the platform and a short script that reproduces it. Problems of the executable go to angelscript-cli. To help, read CONTRIBUTING.md.

Related

Project Use
angelscript-lsp Editor support for VS Code
angelscript-cli Run, check and debug scripts from the terminal. Its JIT builds use this repository
angelscript-mcp MCP server so AI agents check and navigate scripts
angelscript-agent-kit Skill and one-step installs for Claude Code, Codex, Gemini CLI and Antigravity
angelscript-dap Debugger core
angelscript-debugger-example A host that shows how to use the debugger
angelscript-engine Patched SDK builds of older AngelScript releases
tree-sitter-angelscript Tree-sitter grammar the language server uses
angelscript-api-dumper Writes .as.predefined stubs from a running engine

Similar projects

Credits

Third-party notices are in docs/THIRD_PARTY.md.

Project License Use
asumagic/angelsea BSD-2-Clause The JIT this repository forks
MIR by Vladimir Makarov MIT Runtime code generator and C compiler
AngelScript by Andreas Jönsson zlib The language and its runtime
{fmt} MIT Formatting
Catch2, nanobench BSL-1.0, MIT Tests and benchmarks

License

This repository is licensed under the BSD 2-Clause License, like upstream.

Releases

Packages

Contributors

Languages