Skip to content

Introduce the wasmtime-explorer crate#5975

Merged
fitzgen merged 1 commit into
bytecodealliance:mainfrom
fitzgen:explorer
Mar 11, 2023
Merged

Introduce the wasmtime-explorer crate#5975
fitzgen merged 1 commit into
bytecodealliance:mainfrom
fitzgen:explorer

Conversation

@fitzgen
Copy link
Copy Markdown
Member

@fitzgen fitzgen commented Mar 10, 2023

This implements Godbolt Compiler Explorer-like functionality for Wasmtime and Cranelift. Given a Wasm module, it compiles the module to native code and then writes a standalone HTML file that gives a split pane view between the WAT and ASM disassemblies.

THIS IS VERY MUCH AN MVP!!! Tons of stuff we could do with this, very little it actually does so far.

Usage:

$ wasmtime explore test.wasm -o test.explore.html
$ xdg-open test.explore.html

Once visiting the HTML page, you can hover over lines of WAT or asm and the corresponding lines will be highlighted. You can also click to scroll the corresponding line into view.

Here is a little screen recording, although the mouse itself isn't captured so it is a little hard to see what is going on:

Screencast.from.2023-03-09.17-22-06.webm

@fitzgen fitzgen requested a review from alexcrichton March 10, 2023 01:28
@fitzgen
Copy link
Copy Markdown
Member Author

fitzgen commented Mar 10, 2023

Oh this also depends on publishing a new wasmprinter with the new Printer::offsets_and_lines method.

@fitzgen fitzgen changed the title Introduce the wasmstime-explorer crate Introduce the wasmtime-explorer crate Mar 10, 2023
Copy link
Copy Markdown
Contributor

@jameysharp jameysharp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth making this not be x86-specific, and of course the wasmprinter changes have to land, but overall this looks entirely reasonable to me. Also, it's super exciting!

Comment thread crates/explorer/src/lib.rs Outdated
Comment thread Cargo.toml Outdated
Copy link
Copy Markdown
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! If capstone could compile with wasi-libc then we could also make a web demo out of this :)

Copy link
Copy Markdown
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All seems reasonable to me! I'm not necessarily reviewing the code too closely but at a high level I like the idea and I like the integration into the wasmtime CLI.

Also FWIW this is sort of a hop-skip-and-a-jump away from getting source code with DWARF debugging information at this point too!

@fitzgen fitzgen added this pull request to the merge queue Mar 10, 2023
@fitzgen
Copy link
Copy Markdown
Member Author

fitzgen commented Mar 10, 2023

Also FWIW this is sort of a hop-skip-and-a-jump away from getting source code with DWARF debugging information at this point too!

Yep, as I said, lots we could do here! Will be nice to just get something landed first tho.

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 10, 2023
@fitzgen fitzgen enabled auto-merge March 10, 2023 23:18
@fitzgen fitzgen added this pull request to the merge queue Mar 10, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 10, 2023
This implements Godbolt Compiler Explorer-like functionality for Wasmtime and
Cranelift. Given a Wasm module, it compiles the module to native code and then
writes a standalone HTML file that gives a split pane view between the WAT and
ASM disassemblies.
@fitzgen fitzgen enabled auto-merge March 11, 2023 00:13
@fitzgen fitzgen added this pull request to the merge queue Mar 11, 2023
Merged via the queue into bytecodealliance:main with commit 9ed441e Mar 11, 2023
@fitzgen fitzgen deleted the explorer branch March 11, 2023 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants