Table of Contents

Enum WasmCallingConvention

Namespace
Apache.Ignite.Compute.Wasm
Assembly
Apache.Ignite.dll

WebAssembly calling conventions.

public enum WasmCallingConvention

Fields

ClangWasi = 3

Clang-specific calling convention that works with modules built using --target=wasm32-wasi.

To build a compatible module:

  • Install LLVM packages for WASM: wasi-libc libc++abi-dev-wasm32 libc++-dev-wasm32 libclang-rt-dev-wasm32.
  • Build and link the module with clang --target=wasm32-wasi --no-standard-libraries -nostartfiles -Wl,--no-entry -Wl,--export-all -fvisibility=hidden.
  • Use the generated .wasm file as the compute module.
Generic = 0

Generic calling convention. Aims to be language-agnostic.

  • Calls _start and/or __wasm_call_ctors for module initialization (if present).
  • Requires alloc and dealloc exports for memory management.
GenericCommand = 4

Generic command calling convention. Unlike "reactor" conventions which require an exported function to call ("library" mode), here we run the module as a command (program), passing the job argument to standard input and reading the result from the standard output.

NOTE: Only string arguments and results are supported in this mode.

For example, a Python program reading sys.stdin and writing to standard output, compiled with py2wasm --output hello.wasm hello.py, can be used as the compute module. Use CreateCommand<TArg>(string, IEnumerable<DeploymentUnit>?, JobExecutionOptions?, IMarshaller<TArg>?, IMarshaller<string>?) to create the job descriptor.

GoWasiReactor = 2

Go-specific calling convention that works with modules built using GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared.

To build a compatible module:

  • In Go code, use //go:wasmexport to mark functions for export.
  • Build the module: GOOS=wasip1 GOARCH=wasm go build -o addone.wasm -buildmode=c-shared.
  • Use the generated addone.wasm file as the compute module.
RustWasmBindgen = 1

Rust-specific calling convention that works with modules built using wasm-pack and wasm-bindgen.

To build a compatible module:

  • cargo install wasm-pack
  • cargo new --lib hello-wasm
  • Add crate-type = ["cdylib"] and a wasm-bindgen dependency to Cargo.toml.
  • Export functions in src/lib.rs with the #[wasm_bindgen] attribute.
  • Build the module: wasm-pack build.
  • Use the generated pkg/hello_wasm_bg.wasm file as the compute module.