WebAssembly / WebAssembly/binaryen

Add option to force table elements to be considered immutable

Open
#4,256 6 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

Binaryen has some optization that is unlocked when the table is immutable:

https://github.com/WebAssembly/binaryen/blob/0bec0a4bbaf4859bb4c7a2f1c4ecda60ccab72f2/src/passes/Directize.cpp#L174-L178

With emscripten however, the table is always either imported or exported so this optimization is never enabled in practice.

However, emscripten usage of the table from JS never actually mutates existing table elements. It will read from the table and add new elements but it will never mutate of remove table elements generated by C/C++ (wsam-ld).

Perhaps we could have an options such as --immutable-table-elems which would force binaryen to consider static table elements to be immutable? We should run some benchmarks to see if this is worth while.

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 reviewing the referenced Directize.cpp optimization and how Emscripten tables are imported or exported. Investigate whether static table elements can safely be treated as immutable despite JavaScript adding elements, then benchmark the relevant workloads. Done means a validated option such as --immutable-table-elems with evidence that the optimization is worthwhile.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.