My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Featured
Downloads
Wiki pages
Links

Introduction

AsmJit is complete x86/x64 JIT-Assembler for C++ language. It supports 32/64-bit x86 processors including all usable extensions (FPU, MMX, 3dNow, SSE, SSE2, SSE3 and SSE4) through type-safe API that mimics Intel assembler syntax and eliminates nearly all common mistakes that can be done by developers.

AsmJit contains also high-level code generation classes that can be used as a portable way to create JIT code that should run on all supported architectures. High-level classes are designed to handle function calling-conventions, register allocation and 32/64-bit mode differences.

AsmJit has been successfully tested by various C++ compilers (including MSVC, GCC, Clang, and BorlandC++) under all major operating systems (including Windows, Linux and Mac). AsmJit has been also ported to other programming languages including Java, Delphi and Smalltalk, although these ports are not official part of AsmJit and was developed outside.

News

AsmJit-1.0 is coming! High-level code generation contains complete new code-base and there are also minor API changes in low-level code generation.

AsmJit-1.0 SVN repository is available at trunk/AsmJit-1.0/...

Features

  • Complete x86/x64 instruction set, including X87, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.
  • Compile time and run-time safety. C++ compiler is able to catch basic mistakes that can be done by developer.
  • Low-level and high-level code generation.
  • Built-in CPU detection.
  • Virtual memory management (API similar to malloc/free).
  • Configurable memory management, logging and error handling.
  • Small and embeddable (size of compiled AsmJit is about 200kB).
  • No dependencies to STL and other libraries.
  • No exceptions and RTTI.
  • Extensible design. The library can be extended by inheriting classes, it's not needed to modify AsmJit sources to fit into your project.

Usage Notes

The usage of AsmJit is not limited. The library was written primarily to work with multimedia (there is strong support for MMX/SSE2/SSSE3/...), but it can be used as a JIT backend for your virtual machine, mathematical expression parser, AI network or other performance critical task.

Although AsmJit is a low-level library, there are helper classes that were designed to simplify cross-platform development, code-generation and the usage of the library.

Assembler / Compiler

AsmJit library contains two main code-generation concepts - Assembler and Compiler. The first concept, called 'Assembler' is to use pure assembler without any additional tools. It's pure assembler with instructions and their operands (register, memory location, immediate, and label). This class can be used by tools which do not need register allocator or contains own.

The second concept, called 'Compiler', is a high-level code generation, which is using variables (virtual registers) instead of real registers. After the code serialization is finished, register allocator gathers the most important information about the usage of variables, their scope, and registers which might be used for each variable. Then all variables are translated into real registers or memory addresses. Compiler also contains built-in calling convention handling so it's portable between 32-bit and 64-bit architectures.

The Compiler is probably not the best tool which can handle register allocation (linear-scan register allocation is designed for fast-execution). There are some areas where it could be improved. However, it's built-in, and in the most cases the output is comparable to the code that is generated by the C/C++ compiler. The main advantage of AsmJit::Compiler compared to other tools is that it has complete statistics of variables and their scope, because the register allocator is run after the code was serialized. There are also some hints which might be used to improve the register allocation.

Configuring

AsmJit is designed to be easily embeddable into any project. It's only needed to add the C++ files into your project and sometimes to setup AsmJit/Config.h file. This file is designed for easy embedding to any environment and contains only necessary macros. To embed AsmJit into your project statically edit this file and uncomment // #define ASMJIT_API macro.

Another way to use AsmJit is to build shared library (dll, so, ...). This is now default. AsmJit contains cmake project file that can create platform specific makefiles and IDE project files. The goal is to use platform native tools for building and development.

See configuring section for details. If you don't know what cmake is, visit its homepage at www.cmake.org.

Upgrading

Please see upgrading notes for detailed information about upgrading to latest AsmJit version.

Examples

See examples section that contains code generation using AsmJit::Assembler and AsmJit::Compiler. You can compare these two different ways of code generation.

Contribution and Feedback

AsmJit is a new project. If you found a bug, please insert new issue or send description to AsmJit mailing list. All code generation issues are normally fixed until next day, complex issues can take some time to fix.

If you found incorrect or very brief documentation (that is not enough for you) please contact us through mailing list or contact AsmJit author directly. Fixing typos and incorrect English is also welcome.

All AsmJit changes and refactorization is also discussed through AsmJit mailing list. So if you are using AsmJit library, please join to have better experience and less troubles with new versions.

Download

Latest stable release of AsmJit can be downloaded in Downloads section.

Donate

Please donate to the future development of AsmJit library. See the ROADMAP for planned features.

Donations received from:

  • muParserSSE - Mathematical expression parser and JIT compiler (from the author of muParser).
  • PELock - PELock Software Protection.
  • Others, not mentioned here - thanks!

Related Projects

  • BlitJit - Just In Time Image Blitting Library that's using AsmJit to JIT compile graphics functions.
  • Fog-Framework - High performance 2d graphics library and GUI toolkit for C++.
  • MathPresso - Mathematical Expression Evaluator and JIT Compiler using AsmJit (currently it's only example, nothing serious).

Google Groups and Mailing Lists

AsmJit google group:

AsmJit mailing list:

  • asmjit-dev@googlegroups.com

Powered by Google Project Hosting