Stream: wasmtime

Topic: Possible to create in-memory representation of Wasm?


view this post on Zulip McCoy (Oct 07 2021 at 22:15):

I'm curious (e.g. similar to LLVM or LLVM C APIs) if it is possible to create modules, functions, etc via an API and invoke the runtime through an API?

view this post on Zulip Alex Crichton (Oct 07 2021 at 23:20):

Wasmtime itself doesn't provide the ability to create a WebAssembly module, but there a number of other projects which can help you create a wasm module. That module can then be fed into Wasmtime to run it

view this post on Zulip McCoy (Oct 08 2021 at 01:04):

Cool - will search around!

view this post on Zulip McCoy (Oct 08 2021 at 01:17):

@Alex Crichton I assume you mean, projects which create a .wat file (for example).

I’m looking for something different. E.g. if I write an intermediate form, and want to create a transpiler, I think I have to emit a .wat file to use the runtime. Versus, with MLIR or LLVM - I can just create a representation of the IR in memory and invoke their respective runtimes/execution engines.

view this post on Zulip Alex Crichton (Oct 08 2021 at 01:57):

Ah no wasmtime doesn't have an API for directly doing that, for something like that though using cranelift itself may make sense

view this post on Zulip McCoy (Oct 08 2021 at 16:05):

@Alex Crichton That was an incredible suggestion. I did not know how far Cranelift had come since I last took a look at the project! Looks great!

I also discovered the https://github.com/bytecodealliance/cranelift-jit-demo -- is there an equivalent for faerie? I'll have to poke around, as I'm also curious about module compilation (versus compiling single functions).

JIT compiler and runtime for a toy language, using Cranelift - GitHub - bytecodealliance/cranelift-jit-demo: JIT compiler and runtime for a toy language, using Cranelift

view this post on Zulip Alex Crichton (Oct 08 2021 at 16:09):

Sorry I don't know a ton about using cranelift raw, I'd recommend asking in #cranelift perhaps?


Last updated: Dec 23 2024 at 14:03 UTC