Skip to content

Introduce the javy-profiler-lib crate#1208

Open
saulecabrera wants to merge 3 commits into
bytecodealliance:mainfrom
saulecabrera:grp-lib
Open

Introduce the javy-profiler-lib crate#1208
saulecabrera wants to merge 3 commits into
bytecodealliance:mainfrom
saulecabrera:grp-lib

Conversation

@saulecabrera
Copy link
Copy Markdown
Member

Part of #1206

This is the first change towards a Wasm-native profiler for Javy generated modules.

Particularly, this change introduces the profiler library crate, which will be used as a user-provided library by
Whamm.

The library will be compiled to wasm32-wasip1 and will have the following responsibilities:

  • Detecting the Wasm function in the target app holding the interpreter dispatch loop
  • Detecting the byte-load provenance used to dispatch to the next opcode (index argument to br_table)
  • Holing the necessary state to construct the JS execution trace
  • Generating the execution trace output for analysis

This change includes, point 1 and 2. The remaining functionality will be done in separate pull requests.

Note that, as stated in the issue above, this work is deemed experimental for the time being and this crate will be included through a feature flag when added to the CLI.

  • I've updated the default plugin import namespace and incremented the major version of javy-plugin-api if the QuickJS bytecode has changed.
  • I've updated the relevant CHANGELOG files if necessary. Changes to javy-cli, javy-plugin, and javy-plugin-processing do not require updating CHANGELOG files.
  • I've updated the relevant crate versions if necessary. Versioning policy for library crates
  • I've updated documentation including crate documentation if necessary.

Part of bytecodealliance#1206

This is the first change towards a Wasm-native profiler for Javy
generated modules.

Particularly, this change introduces the profiler library crate, which
will be used as a user-provided library by
[Whamm](https://github.com/ejrgilbert/whamm).

The library will be compiled to wasm32-wasip1 and will have the
following responsibilities:

* Detecting the Wasm function in the target app holding the interpreter dispatch loop
* Detecting the byte-load provenance used to dispatch to the next
opcode (index argument to `br_table`)
* Holing the necessary state to construct the JS execution trace
* Generating the execution trace output for analysis

This change includes, point 1 and 2. The remaining functionality will
be done in separate pull requests.

Note that, as stated in the issue above, this work is deemed
experimental for the time being and this crate will be included
through a feature flag when added to the CLI.
@saulecabrera saulecabrera requested a review from jeffcharles May 12, 2026 17:49
use state::State;
use std::sync::LazyLock;

// TODO: Passing empty bytes is temporary. Whamm currently does not
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I am currently working on adding support for this upstream.

@saulecabrera
Copy link
Copy Markdown
Member Author

Hmm, taking a look at the clippy failures, I was not able to repro locally.

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.

1 participant