Skip to content

Support cross-module calls properly in the interpreter #6823

Open

Description

@kripken

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: #6814 (comment)

Activity

  1. kripken commented on Aug 7, 2024

    @kripken
    MemberAuthor

    Another option would be to make such literals point to the Module the thing is in, and still refer to it by name.

  2. kripken commented on Feb 10, 2025

    @kripken
    MemberAuthor

    This affects not only cross-module calls but also in a single module when there are duplicate tags: imagine we import the same tag from JS twice, once as wasm name $a and once as $b. The Try instructions will refer to only one of them, as they refer to the name of the tag, so the behavior may not be right. For now we can work around this in the fuzzer by avoiding wasm files with such duplicate tag imports.

    (This becomes an issue now that we import jstag and wasmtag, tags from JS; and specifically the Merge fuzzer can hit this if it generates two wasms, each importing the same tag.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions