gen-host-js: --load flag support#418
Merged
guybedford merged 3 commits intobytecodealliance:mainfrom Nov 8, 2022
Merged
Conversation
alexcrichton
approved these changes
Nov 8, 2022
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.
This unifies the core Wasm loading in instance mode under a single load model controlled by a
--loadflag which defaults to--load=fetch. The reason for this was when working on creating asm.js output for the core Wasm binaries, this required a lot of custom code splicing which could be avoided by just having well-defined loading functions that can be overriddent when under a--load=custommode.There are two loading functions -
loadWasmandinstantiateWasm.instantiateWasmis always just declared asconst instantiateWasm = WebAssembly.instantiate, unless using--load=customwhich then will not define eitherloadWasmorinstantiateWasmat all, and allow the user to define these functions via importing / concatenation or whatever means is suitable.The
--base64option is then made available as--load=base64.The nice thing about this structure is it opens up future load modes, like a
--load=reflectfor if/when import reflection progresses (working on it!).Note the driving use case for this work was very much supporting asm.js component generation, and I have verified this all works correctly with
loadWasmeffectively being a noop andinstantiateWasmwrapping the asm.js wiring.