diff options
author | Alon Zakai <azakai@google.com> | 2022-11-11 10:16:32 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-11 10:16:32 -0800 |
commit | 3928189214e03430bbc9f2b51c6af3887b465160 (patch) | |
tree | 306cfddc749859a597ff1ca11bea52c24b836ebb /test/lit/array-new-seg-note-count.wast | |
parent | b7697808988037469d352b044bd6b2469f99da55 (diff) | |
download | binaryen-3928189214e03430bbc9f2b51c6af3887b465160.tar.gz binaryen-3928189214e03430bbc9f2b51c6af3887b465160.tar.bz2 binaryen-3928189214e03430bbc9f2b51c6af3887b465160.zip |
[Wasm GC] Add Monomorphize pass (#5238)
Monomorphization finds cases where we send more refined types to a function
than it declares. In such cases we can copy the function and refine the parameters:
// B is a subtype of A
foo(new B());
function foo(x : A) { ..}
=>
foo_B(new B()); // call redirected to refined copy
function foo(x : A) { ..} // unchanged
function foo_B(x : B) { ..} // refined copy
This increases code size so it may not be worth it in all cases. This initial PR is
hopefully enough to start experimenting with this on performance, and so it does
not enable the pass by default.
This adds two variations of monomorphization, one that always does it, and the
default which is "careful": it sees whether monomorphizing lets the refined function
actually be better than the original (say, by removing a cast). If there is no
improvement then we do not make any changes. This saves a significant amount
of code size - on j2wasm the careful version increases by 13% instead of 20% -
but it does run more slowly obviously.
Diffstat (limited to 'test/lit/array-new-seg-note-count.wast')
0 files changed, 0 insertions, 0 deletions