diff options
author | Heejin Ahn <aheejin@gmail.com> | 2024-01-31 17:17:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-31 17:17:07 -0800 |
commit | 19fb1f44ccf91cf8d7268a047eb33b11b25fc1f0 (patch) | |
tree | ef09db7c2383ebfd9557d0a8ae73e7b5758771a5 /src/parser/lexer.cpp | |
parent | b5938499432a1251d94e8e7b534f14919fdaf81c (diff) | |
download | binaryen-19fb1f44ccf91cf8d7268a047eb33b11b25fc1f0.tar.gz binaryen-19fb1f44ccf91cf8d7268a047eb33b11b25fc1f0.tar.bz2 binaryen-19fb1f44ccf91cf8d7268a047eb33b11b25fc1f0.zip |
[EH] Test StackIR's local2stack on translator output (#6264)
This adds `STACKIR-OPT` filecheck lines to `translate-to-new-eh.wast`
to see if StackIR's `local2stack` optimization successfully removes some
of unnecessary `local.set`/`local.get`s.
While supporting the whole Binayren optimization pipeline for the new EH
instructions is not the goal for the very near-term future, StackIR's
`local2stack` optimization can help with a very common pattern generated
by this translator, which is:
```wast
(try $l
(do ... )
(catch_all
(call $destructor)
(rethrow $l)
)
)
```
is translated to
```wast
(block $outer
(local.set $exn ;; can be optimized away
(block $catch_all (result exnref)
(try_table (catch_all_ref $catch_all)
...
)
(br $outer)
)
)
(call $destructor)
(throw_ref
(local.get $exn) ;; can be optimized away
)
)
```
Here we don't really need `local.set $exn` and `local.get $exn`, and
these can be optimized away using StackIR's local2stack. After
optimizing them away in Stack IR, the code can be like
```wast
block $outer
block $catch_all (result exnref)
try_table (catch_all_ref $catch_all)
...
end
br $outer
end
call $destructor
throw_ref
end
```
This optimization alone reduces the code size increased caused by
translating significantly. For Adobe Photoshop, the code size increase
goes down from 4.2% to 2.8%, and for Binaryen, it goes down from 3.8% to
2.0%.
Diffstat (limited to 'src/parser/lexer.cpp')
0 files changed, 0 insertions, 0 deletions