[js-api] Fix ExecuteModule export bindings - #125
Merged
Merged
Conversation
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
approved these changes
Sep 24, 2026
guybedford
left a comment
Collaborator
There was a problem hiding this comment.
Thanks so much for putting this together.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ExecuteModule rebound the executing core module on a Wasm import, then instantiated and exported that other module. The export loop read
externvalandstorefrom the import loop, stored a core instance where a JS Instance is required, and initializedexnrefglobals.This keeps the executing module. Wasm-to-wasm imports call
instance_exporton 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.v128andexnrefglobals stay in TDZ.The import loop walks
module_importsand appends builtin and string-constant externvals in that order.get the external importsomits those entries, andmodule_instantiateneeds one externval per core import.Fixes #123
exnrefTDZ coverage: web-platform-tests/wpt#62353