-
Notifications
You must be signed in to change notification settings - Fork 792
Description
The Dart team is experimenting with using binaryen tools to support our deferred loading feature for users targeting wasm. We currently have experimental support for the feature by having the compiler emit multiple modules.
Typically, when emitting a single module, we use wasm-opt with the --closed-world
flag to optimize the wasm module that dart2wasm is emitting. This works well for us and sometimes produces 3x code size improvements as well as other structural improvements like inlining, devirtualization, DCE, etc.
Now with deferred loading we are now splitting that single module into many modules that collectively represent the same program. So we technically still have a closed world... but split across multiple modules. Ideally we could specify all these modules to wasm-opt and it would perform the same (or close to the same) optimizations collectively across all these modules. Today wasm-opt doesn't support anything like this.
I've tried implementing this using a combination of wasm-merge
-> wasm-opt
-> wasm-split
but ran into several issues where the code didn't load and the code size didn't improve much.