Stream: wasmtime

Topic: Compiler Explorer Support


view this post on Zulip Afonso Bordado (Jun 12 2024 at 20:25):

:wave: Hey,

A few months ago I added support for WASM and Wasmtime to Compiler Explorer. It's made it's way through the review pipeline and is now on the live website! (Example)

It doesen't have all of the nice features that wasmtime explore has, but my main goal was to quickly be able to look at what other engines emit for any given piece of wasm. I'm planning on adding support for a few more engines in the future.

Currently we only have version 20.0.1 which was the latest when I started this work, but now that It's in, it should be fairly easy to add new versions.

(module (func $square (param i32) (result i32) local.get 0 ;; pull the input value and push it to the stack local.get 0 ;; square function needs the same number twice i32.mul ;; mul operation expects two numbers from the stack ) ;; factorial(n) returns the factorial of n. (func $factorial (export "factorial") (param $n i32) (result i32) (if (result i32) (i32.le_s (local.get $n) (i32.const 1)) (then (i32.const 1)) (else (i32.mul (local.get $n) (call $factorial (i32.sub (local.get $n) (i32.const 1))))) ) ) )

view this post on Zulip Alex Crichton (Jun 12 2024 at 20:37):

Whoa that's awesome!

view this post on Zulip Alex Crichton (Jun 12 2024 at 20:37):

I've actually wanted something like this in the past where I'd start with a small Rust function and then pipe it through both llvm and wasmtime and see what pops out, and this makes that even closer to a reality :)

view this post on Zulip Alex Crichton (Jun 12 2024 at 20:38):

Thanks so much for working on this! Also if you know of anything we can do upstream to help this let us know

view this post on Zulip Afonso Bordado (Jun 12 2024 at 20:45):

The only thing it's missing is debug info to match line numbers to assembly instructions, like we have in wasmtime explore. I haven't been keeping up with developments on that, so not sure how easy it is to port that.

I'd also like at some point to get a way to view the CLIF IR output, but I think that's just wiring stuff up in the CE side.

Otherwise it's pretty much "done"


Last updated: Dec 23 2024 at 13:07 UTC