diff options
author | Alon Zakai <azakai@google.com> | 2022-06-01 07:17:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-01 14:17:21 +0000 |
commit | 623e08e88db3ebc913fe76e7f60e89fa030f884d (patch) | |
tree | 3e3ccd5c1b45ade4d7f65066dced5991cd294a71 /test/gtest/wat-lexer.cpp | |
parent | 49763aa9a7fb0f07588a9d19db6896356e52c5f8 (diff) | |
download | binaryen-623e08e88db3ebc913fe76e7f60e89fa030f884d.tar.gz binaryen-623e08e88db3ebc913fe76e7f60e89fa030f884d.tar.bz2 binaryen-623e08e88db3ebc913fe76e7f60e89fa030f884d.zip |
Global Struct Inference pass: Infer two constants in struct.get (#4659)
This optimizes constants in the megamorphic case of two: when we
know two function references are possible, we could in theory emit this:
(select
(ref.func A)
(ref.func B)
(ref.eq
(..ref value..) ;; globally, only 2 things are possible here, and one has
;; ref.func A as its value, and the other ref.func B
(ref.func A))
That is, compare to one of the values, and emit the two possible values there.
Other optimizations can then turn a call_ref on this select into an if over
two direct calls, leading to devirtualization.
We cannot compare a ref.func directly (since function references are not
comparable), and so instead we look at immutable global structs. If we
find a struct type that has only two possible values in some field, and
the structs are in immutable globals (which happens in the vtable case
in j2wasm for example), then we can compare the references of the struct
to decide between the two values in the field.
Diffstat (limited to 'test/gtest/wat-lexer.cpp')
0 files changed, 0 insertions, 0 deletions