WebAssembly / WebAssembly/tool-conventions
Encoding multiple sections for JavaScript to read
Nobody has claimed this yet.
- Dominant language
- WebAssembly
- Stars
- 372
- Forks
- 75
- PR merge metrics
- No merged PRs in 30d
Description
This discussion originated in https://github.com/WebAssembly/binaryen/pull/2327 and @kripken suggested to discuss with the wider audience to see if there's any consensus.
We want to add a custom tool-specific section(s) that could be easily readable by JavaScript and, in our case, would contain names of exported functions. The JavaScript wrapper would read names of these functions and instrument corresponding exports.
Currently, I'm emitting a same-named custom section (called "asyncify") per each such export. My motivation was:
- Same-named custom sections are already allowed.
- There is
WebAssembly.customSections(module, "asyncify")API that already allows to easily enumerate all of such sections, which suggests that it wasn't a coincidence and that it's okay to duplicate sections when it makes sense. - Gzip / Brotli will already do a great job at deduplicating identifiers, so size shouldn't be a concern either.
Other potential alternatives could be either:
- Using some binary encoding for identifiers, but that needs more JS code to decode it back, than the current one-liner.
- Using some comma-separated format, but that wouldn't work well with arbitrary characters in export names.
- Using some well-established format like JSON, but that requires including JSON encoder in the C++ tool, if we want to properly support arbitrary characters.
Current solution seems to be the best of both worlds in that it's both very easy to encode on C++ side and very easy to decode on JS side, but the only concern is that it might be not very idiomatic to have duplicate sections.
Would love to hear any thoughts.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the linked Binaryen pull request 2327 and the discussion about repeated asyncify custom sections. Compare the proposed repeated sections with binary, comma-separated, and JSON encodings, then establish a consensus convention for JavaScript-readable exported-function metadata.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, wasm
- Domain
- devtools, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100