diff options
author | Alon Zakai <azakai@google.com> | 2024-06-20 15:24:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-20 15:24:14 -0700 |
commit | c3089b3b553536ece3b1d6a9cffe82cda1b813e5 (patch) | |
tree | 21c27a8dd7515dc4f04e6cd6391bd728e50d8729 /test/wasm2js/refs.2asm.js | |
parent | 1079a9e34599e65ee25fb5f32caa57bd21737593 (diff) | |
download | binaryen-c3089b3b553536ece3b1d6a9cffe82cda1b813e5.tar.gz binaryen-c3089b3b553536ece3b1d6a9cffe82cda1b813e5.tar.bz2 binaryen-c3089b3b553536ece3b1d6a9cffe82cda1b813e5.zip |
GlobalStructInference: Un-nest struct.news in globals when that is helpful (#6688)
If we have
(global $g (struct.new $S
(i32.const 1)
(struct.new $T ..)
(ref.func $f)
))
then before this PR if we wanted to read the middle field we'd stop, as it is non-constant.
However, we can un-nest it, making it constant:
(global $g.unnested (struct.new $T ..))
(global $g (struct.new $S
(i32.const 1)
(global.get $g.unnested)
(ref.func $f)
))
Now the field is a global.get of an immutable global, which is constant. Using this
technique we can handle anything in a struct field, constant or not. The cost of adding
a global is likely offset by the benefit of being able to refer to it directly, as that opens
up more opportunities later.
Concretely, this replaces the constant values we look for in GSI with a variant over
constants or expressions (we do still want to group constants, as multiple globals
with the same constant field can be treated as a whole). And we note cases where we
need to un-nest, and handle those at the end.
Diffstat (limited to 'test/wasm2js/refs.2asm.js')
0 files changed, 0 insertions, 0 deletions