WebAssembly / WebAssembly/binaryen

Provide some way for C & JS to visit and transform module code

Open
#7,457 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
8.6k
Forks
885
Avg merge
1d 19h
Merged PRs (30d)
69

Description

Currently, Binaryen uses custom passes to transform Wasm (e.g. in wasm-merge). These passes are unavailable to C and JS, meaning that there's no built-in way for the users to transform the code.
In my project, I need to transform the code using Binaryen.js. Currently, I recursively gather all the information about expressions and reconstruct them with the required changes. My code is giant and repetative, as there's no way to convert from the JS object info format back to the original (or modified) expression.
I have two suggestions: either provide a way for JS to reconstruct expression from the corresponding info object, or provide a way for C (and add the corresponding JS bindings) to transform the code using callbacks or some other API.
I am willing to open a PR if we discuss this idea further!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading src/tools/wasm-merge.cpp and the existing Binaryen.js bindings to understand how custom passes and expression information are exposed. Compare the two proposed directions—reconstructing expressions from JS objects or adding C callbacks with JS bindings—and clarify the API scope before implementation. Done means C and JS users can visit and transform module code without manually rebuilding expressions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, javascript, wasm
Domain
api, compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.