WebAssembly / WebAssembly/binaryen

Support cross-module calls properly in the interpreter

Open
#6,823 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Right now some things like function and tag literals store a name. The Literal for a RefFunc stores the name of the function, for example. That means we may refer to the wrong thing if the value is used in another module with different internal names.

To fix this, we could add direct references from the Literal for a function to the Function it refers to. Maybe a good way to do that is to give it a shared_ptr<Function>, in which case we'd want to make Modules store their functions as a vector of such shared pointers and not unique_ptrs etc.

This may not be urgent as it is a long-standing issue. If we ever start to do testing of cross-module calls in our interpreter then we'd need to fix it.

Noticed here: https://github.com/WebAssembly/binaryen/pull/6814#discussion_r1705862342

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 tracing the interpreter's Literal handling for RefFunc, function and tag literals, and how Function and Module objects are represented. The work is done when cross-module calls resolve the referenced functions and tags directly rather than by potentially conflicting names; cross-module call tests would confirm this behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.