Skip to content

gen-host-js: --load flag support#418

Merged
guybedford merged 3 commits intobytecodealliance:mainfrom
guybedford:load-flag
Nov 8, 2022
Merged

gen-host-js: --load flag support#418
guybedford merged 3 commits intobytecodealliance:mainfrom
guybedford:load-flag

Conversation

@guybedford
Copy link
Copy Markdown
Contributor

@guybedford guybedford commented Nov 8, 2022

This unifies the core Wasm loading in instance mode under a single load model controlled by a --load flag 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=custom mode.

There are two loading functions - loadWasm and instantiateWasm.

instantiateWasm is always just declared as const instantiateWasm = WebAssembly.instantiate, unless using --load=custom which then will not define either loadWasm or instantiateWasm at all, and allow the user to define these functions via importing / concatenation or whatever means is suitable.

The --base64 option is then made available as --load=base64.

The nice thing about this structure is it opens up future load modes, like a --load=reflect for 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 loadWasm effectively being a noop and instantiateWasm wrapping the asm.js wiring.

@guybedford guybedford merged commit e7fd381 into bytecodealliance:main Nov 8, 2022
@guybedford guybedford deleted the load-flag branch November 8, 2022 22:30
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.

2 participants