bytecodealliance / bytecodealliance/wasmtime

Analyze component instantiation to find constant values of immutable global imports

Open
#12,242 0 comments 0 reactions 0 assignees View on GitHub
performance wasm-proposal:component-model wasmtime
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 19h
Merged PRs (30d)
121

Description

After https://github.com/bytecodealliance/wasmtime/pull/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](https://github.com/bytecodealliance/wasmtime/blob/c1186f2db6908c534ad3922d876465df49d181cc/crates/environ/src/component/translate.rs#L550-L670)) 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 https://github.com/bytecodealliance/wasmtime/pull/12234#discussion_r2662297240_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.