GraalvmHostFunctionInstaller

Emscripten / WASI Preview 1 module installer.

This class is responsible for installing Emscripten and WASI Preview 1 host functions. It prepares the environment and installs WebAssembly modules with the Emscripten env host functions and WASI Preview 1 host functions into the GraalVM context.

To create a new instance, use either GraalvmHostFunctionInstaller() or Builder.

Usage example:

// Setup host
val embedderHost = EmbeddeerHost {

}

// Setup modules
val installer = GraalvmHostFunctionInstaller(context) {
host = embedderHost

}
installer.setupWasiPreview1Module()
val emscriptenInstaller = installer.setupEmscriptenFunctions()

// Evaluate the WebAssembly module
context.eval(source)

// Finish initialization after module instantiation
emscriptenInstaller.finalize(moduleName).use { emscriptenEnv ->
// Initialize Emscripten runtime environment
emscriptenEnv.emscriptenRuntime.initMainThread()

// Execute code
run(context)
}

Types

Link copied to clipboard
class Builder(val wasmContext: Context)
Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun setupEmscriptenFunctions(moduleName: String = ENV_MODULE_NAME, memory: MemorySource = ExportedMemory(spec = DEFAULT_MEMORY_SPEC)): GraalvmHostFunctionInstaller.GraalvmEmscriptenFinalizer
Link copied to clipboard
fun setupWasiPreview1Module(moduleName: String = WASI_SNAPSHOT_PREVIEW1_MODULE_NAME, memory: MemorySource.ImportedMemory? = ImportedMemory())