Skip to content

Analyze component instantiation to find constant values of immutable global imports #12242

@fitzgen

Description

@fitzgen

After #12234, we will emit inline constants for immutable+defined globals, but we cannot do the same for immutable+imported without

  1. an analysis (similar to our known imported function analysis) to find the globals that the satisfy that import
  2. checking that the import is always satisfied with a global of the same value
  3. checking that the module is not exported (which would allow instantiating it in host code with a global of a different value)

One possible future extension (not for this PR of course) would be to do something similar to the inliner to record that, even for imported globals, if the definition is in-wasm itself then we can also use the constant value. (e.g. dynamic-linking-using modules in components have this use case a lot)

Originally posted by @alexcrichton in #12234 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancewasm-proposal:component-modelIssues related to the WebAssembly Component Model proposalwasmtimeIssues about wasmtime that don't fall into another label

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions