WebAssembly / binaryen

Optimizer and compiler/toolchain library for WebAssembly
Apache License 2.0
7.47k stars 740 forks source link

Provide a way to detect asyncified exports #2322

Open RReverser opened 5 years ago

RReverser commented 5 years ago

Currently, Asyncify pass transforms only functions that call into potentially asynchronous imports (directly or indirectly) and leaves others untouched.

However, from the JavaScript wrapper side, it's impossible to know which exports ended up being asyncified and which not, and so all exported functions end up being transformed into async ones even if it's unnecessary.

In order to improve efficiency and provide an async API only for exports that actually require it, Asyncify pass should somehow mark the transformed exports.

There are two potential ways to go about this: 1) add custom prefix or suffix to export names which would be detected as a marker and stripped by the JS wrapper or 2) add a custom section(s?) listing all such export names that could be read by JS wrapper using WebAssembly.customSections('asyncify').

RReverser commented 5 years ago

(I'm working on this and have a PoC implementation locally)