Conversation
…more exports creep in
|
Personally, I would like this for |
|
Yeah, I think it's reasonable to do this in But @nmrugg I'm curious where you saw it produce much faster code? I wouldn't expect that to be noticeable. |
|
In Stockfish.js I see a big difference. With I can post details if you want to investigate. |
|
Perhaps I should note that those numbers are for asm.js. When compiled to WASM, |
|
Got it, thanks. Makes sense to me now, I misunderstood what you wrote before. |
|
Feedback here and offline has been positive, merging. |
This starts to use binaryen's
wasm-metadcetool in-Osand-Oz, which lets us remove unused code along the boundary of wasm and JS. That is, it can remove things which doing DCE separately on each can't, like cycles between the two worlds.For example, if wasm imported a JS function, then if the wasm optimizer manages to remove all uses of it, this lets us remove it not just from wasm but also from the JS side too. And the same works the other way as well.
So far, in
-Osthis shrinks hello world's.jsby 3% and.wasmby 18%. This is less effective on large programs, since the removable runtime overhead is smaller - e.g. when using C++ iostreams, it shrinks by 7% / 1%. But where this really shines is on small programs like the testcase in #5836, that just do a little pure computation and don't need a runtime at all: this shrinks that.jsby 5% and the.wasmby 84% (mostly thanks to getting rid of malloc/free!). The absolute numbers are interesting for the wasm, it goes from 10,729 bytes to just 1,740, which is getting us most of the way to emitting a really minimal wasm for such inputs. This reason this doesn't get us all the way is because:On the other hand, this does increase compile times noticeably, mostly on tiny files: 47% for hello world and 23% for C++ iostreams. That's why I think this makes sense to do in
-Osand-Oz, but not other modes.