Skip to main content

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.

ModePerformanceDynamic module loadingRequirementsUse when
Interpreter🐢 Slow✅NoneThe default. Maximum portability, and the only mode that runs SIMD (v128) modules.
Runtime compiler🐇 Fast✅ASM dependency and reflectionModules are loaded dynamically and reflection is acceptable.
Build-time compiler🐇 Fast❌Maven or Gradle pluginModules 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.

ProposalInterpreterRuntime and build-time compilersRedline
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.