Skip to content

[js-api] Fix ExecuteModule export bindings - #125

Merged
guybedford merged 1 commit into
WebAssembly:mainfrom
chicoxyzzy:execute-module-bindings
Sep 24, 2026
Merged

guybedford merged 1 commit into
WebAssembly:mainfrom
chicoxyzzy:execute-module-bindings

Conversation

@chicoxyzzy

Copy link
Copy Markdown
Member

ExecuteModule rebound the executing core module on a Wasm import, then instantiated and exported that other module. The export loop read externval and store from the import loop, stored a core instance where a JS Instance is required, and initialized exnref globals.

This keeps the executing module. Wasm-to-wasm imports call instance_export on the imported JS Instance's core instance. After instantiating the core, the algorithm stores a JS Instance on the module record. Each export is read from that core instance and the agent store. v128 and exnref globals stay in TDZ.

The import loop walks module_imports and appends builtin and string-constant externvals in that order. get the external imports omits those entries, and module_instantiate needs one externval per core import.

Fixes #123

exnref TDZ coverage: web-platform-tests/wpt#62353

ExecuteModule rebound the executing core module on a Wasm import, then
instantiated and exported that other module. The export loop read
externval and store from the import loop, stored a core instance where
a JS Instance is required, and initialized exnref globals.

Keep the executing module. Export through instance_export on the core
instance and the agent store. Store a JS Instance on the module record.
Leave v128 and exnref bindings in TDZ.

Walk module_imports so builtin and string-constant externvals are
appended in order. get the external imports omits those entries, and
module_instantiate needs one externval per core import.

Fixes WebAssembly#123

@guybedford guybedford left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for putting this together.

@guybedford
guybedford merged commit 38aef62 into WebAssembly:main Sep 24, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ExecuteModule export loop uses unbound names and skips only v128

2 participants