Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WASM 4kb limit #1

Closed
guybedford opened this issue Oct 6, 2018 · 7 comments
Closed

WASM 4kb limit #1

guybedford opened this issue Oct 6, 2018 · 7 comments

Comments

@guybedford
Copy link
Owner

guybedford commented Oct 6, 2018

The 4KB limit on new WebAssembly.instance means that this project cannot implement Web Assembly integration when hitting this limit unfortunately, as we would either (1) execute the Web Assembly too early before its imports are ready or (2) execute the Web Assembly too late as we can't ensure it happens synchronously in a module body as would be required for semantic support (any importer wouldn't be able to read the exports).

SystemJS could get around this by handling WebAssembly.instantiate as if it were a top-level await, but because this project executes only within native module bodies that isn't possible.

So unfortunately that may shatter any hopes of this project providing WASM polyfill-style workflow support, all because of this 4KB limit.

@xtuc
Copy link

xtuc commented Oct 7, 2018

For more details, see WebAssembly/esm-integration#1.

For your information, we could workaround that in Webpack by changing the binary ahead of time:

  • remove the start section
  • export the initial start function
  • instantiated the module and call the start function once we're ready.

@guybedford
Copy link
Owner Author

@xtuc ok, this could certainly be something that we support in the Rollup output for Web Assembly when targetting Rollup code splitting.

@guybedford
Copy link
Owner Author

(as an option)

@guybedford
Copy link
Owner Author

I think moving forward on this the best thing may just be to look into using an async function for execution, and then allowing webassembly execution to be a promise. This will mean that any WASM in the module graph will break the synchronous execution invariant for that WASM tick, but I think that is an ok tradeoff given WASM is basically unusable with the 4KB limit anyway and this won't affect graphs without WASM.

@guybedford
Copy link
Owner Author

The problem here of course is that we can't use an async function in the ES module execution until top-level await is supported.

I haven't worked out all the details but I believe it should be possible to "shim" top-level await support in this project too, in which case the Web Assembly work would be dependent on such a top-level await shim.

@guybedford
Copy link
Owner Author

guybedford commented Aug 21, 2019

Once #5 is implemented, this should be solved easily.

Although this can likely be implemented more easily than #5 and independently to it too since Web Assembly modules don't require code analysis to support top level await.

@guybedford
Copy link
Owner Author

Closing as Wasm has been removed for now in #84.

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

No branches or pull requests

2 participants