Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce WAMR Fast JIT #1292

Open
wenyongh opened this issue Jul 14, 2022 · 0 comments
Open

Introduce WAMR Fast JIT #1292

wenyongh opened this issue Jul 14, 2022 · 0 comments
Labels
new feature New feature request WIP working in progress

Comments

@wenyongh
Copy link
Contributor

wenyongh commented Jul 14, 2022

Hi, recent days we are developing another WebAssembly JIT engine and make good progress by now, we call it WAMR Fast JIT, which a lightweight JIT. Currently it is under the development branch:
https://github.com/bytecodealliance/wasm-micro-runtime/tree/dev/fast_jit
We will do more test and merge it into main branch when it is stable. Developers were encouraged to help test it and report issue if found.

Motivation:

  1. Resolve issues of current LLVM based JIT
  • Long compilation time
  • Large footprint: large binary size and memory usage
  • Portability issue: not easy to port to IoT device, SGX platform, etc.
  1. Resolve issues in deploying AOT
  • Need to recompile and update AOT file when wasm application changes

Design goals:

  1. Short compilation time, quick startup
  2. Support Linux and SGX platform, support x86-64 target at the first stage
  3. Relatively good performance, 40+% of AOT performance epected
  4. Relatively small footprint, smaller than 300KB increased for binary size
  5. Good scalability
  • Easy to support more targets, normally only need to re-implement the codegen for a new target
  1. Good portability
  • Easy to port to other platforms, had better only rely on currently platform APIs
  1. Tier-up to LLVM JIT (long term goal)
  • Quick startup with Fast JIT and good performance with LLVM JIT

Typical scenarios of Fast JIT

  1. IoT devices
  2. SGX platform
  3. Mini apps
  4. Scenario which requires quick startup
  5. Quick startup and better performance with tier-up from Fast JIT to LLVM JIT

Compilation Pipeline

Currently there are three passes in the JIT compilation for x86-64 bit target:

  1. Frontend: translate wasm opcodes into JIT IRs
  2. Register Allocator
  3. Codegen (backend): translation JIT IRs into machine codes
    For 32-bit platforms, developer might need to implement another pass to translate JIT IRs containing 64-bit register operations into 32-bit register operations, e.g. using two 32-bit registers to simulate the operation of 64-bit add/sub/mul/div and so on.

Dependent Libraries

  1. asmjit: use asmjit as codegen encoding library, Assembler class is used
  2. zydis: use zydis to decode the machine code, only required when JIT dump is enabled

How to build

git clone https://github.com/bytecodealliance/wasm-micro-runtime.git
cd wasm-micro-runtime
git checkout dev/fast_jit
cd product-mini/platforms/linux
mkdir build
cd build
cmake .. -DWAMR_BUILD_FAST_JIT=1
make -j
#iwasm generated under current folder

Current progress:

Most of the WebAssembly mvp opcodes (features) are implemented similar to LLVM JIT, except threads and SIMD related opcodes. MVP spec cases and many standalone cases were tested.

Feature plans:

  1. Apply more optimizations
  2. Implement threads related opcodes
  3. Implement SIMD related opcodes
  4. Enable multi-module support
  5. Enable tier-up with LLVM JIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature request WIP working in progress
Projects
None yet
Development

No branches or pull requests

1 participant