Compilation
Endive can run a Wasm module in three ways: interpreted, compiled to JVM bytecode when the instance is created, or compiled to JVM bytecode at build time.
| Mode | Performance | Dynamic module loading | Requirements | Use when |
|---|---|---|---|---|
| Interpreter | 🐢 Slow | ✅ | None | The default. Maximum portability, and the only mode that runs SIMD (v128) modules. |
| Runtime compiler | 🐇 Fast | ✅ | ASM dependency and reflection | Modules are loaded dynamically and reflection is acceptable. |
| Build-time compiler | 🐇 Fast | ❌ | Maven or Gradle plugin | Modules are known at build time. Best startup, no extra runtime dependency, works with native-image. |
The interpreter needs nothing beyond run.endive:runtime.
Both compilers translate each Wasm function to a JVM method and can leave functions too large to compile to the interpreter.
Neither supports SIMD. The interpreter's SIMD support relies on validation, so do not disable it for modules that use v128.
Redline is an experimental fourth option that compiles the module to native code at build time.
Feature support
The compilers pass the same specification test suite as the interpreter, with SIMD as the one exception.
| Proposal | Interpreter | Runtime and build-time compilers | Redline |
|---|---|---|---|
| Core specification | ✅ | ✅ | ✅ |
| Bulk memory and reference types | ✅ | ✅ | ✅ |
| Tail calls | ✅ | ✅ | ✅ |
| Threads and atomics | ✅ | ✅ | ✅ |
| Typed function references | ✅ | ✅ | ❌ |
| Garbage collection | ✅ | ✅ | ❌ |
| Exception handling | ✅ | ✅ | ❌ |
| Multi-memory | ✅ | ✅ | ❌ |
| SIMD | ✅ | ❌ | ❌ |
GC types cross the host boundary as Java objects, see GC Types. WASI Preview 1 is a separate module and works with every mode.