Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce the wasmtime-explorer crate #5975

Merged
merged 1 commit into from
Mar 11, 2023

Conversation

fitzgen
Copy link
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
Copy link
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
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!

crates/explorer/src/lib.rs Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
Copy link
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
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
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.

None yet

3 participants