Chasm is the fastest Wasm virtual machine on the J...
# feed
c
Chasm is the fastest Wasm virtual machine on the JVM, and one of the most feature complete runtimes in the world. Featuring popular proposals like WasmGC it allows you to take wasm binaries produced by any compiler and run them everywhere Kotlin multiplatform allows. Better yet it provides a Gradle plugin which generates a pure kotlin interface for you to interface with, in the latest version we now support Strings in the codegen! https://github.com/CharlieTap/chasm/releases/tag/1.1.0
👏 1
👏🏾 1
K 15
a
Do I understand correctly that, when given a
.wasm
file, chasm will generate a Kotlin file with equivalent functions? Like how for Kotlin Native the cinterop tool will generate Kotlin accessors from a
.h
header file?
c
Yeah exactly decodes the wasm binary and builds an equivalent interface from the exported functions
amaze 5
m
How does it compare speedwise to GraalWasm?
c
Hard to compare them 1:1, Graal has a JIT whilst Chasm is just an interpreter. If we were to compare Graal's interpreter vs Chasms interpreter Chasm was between 1.5 -2.5 faster last time I benchmarked, but Graal would be significantly faster in JIT. They serve quite different purposes, Chasm is designed to be embedded in mobile applications where things like JIT are not possible
a
Yeah exactly decodes the wasm binary and builds an equivalent interface from the exported functions
I'm very curious about how this works! Could you point to the code that parses the info out of the
.wasm
file? Is there a standalone tool?
c
Chasms binary decoder is here , but theres actually a public api call you can use to get type information about imports and exports here. Chasms Gradle plugin uses this api call to do all of its codegen
I'm currently working on an update to have the codegen abstract over a generic wasm vm, so I can generate one interface and impl but it will work across all of Chasms targets plus it will be able to use the Wasm VM in the browser for Js targets
👌 1
a
This is seriously impressive work!