diff options
author | Alon Zakai <azakai@google.com> | 2021-01-15 18:13:05 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-15 10:13:05 -0800 |
commit | e2dc4c338476aedff8d95c7549ab0f39d1aaf6d1 (patch) | |
tree | fa6fc4184c5ee762ccdc861a1f1c52188a7a3dc5 /scripts/test/generate_lld_tests.py | |
parent | d808e900b8b8a0bc99d77fd38e94426df73c3afa (diff) | |
download | binaryen-e2dc4c338476aedff8d95c7549ab0f39d1aaf6d1.tar.gz binaryen-e2dc4c338476aedff8d95c7549ab0f39d1aaf6d1.tar.bz2 binaryen-e2dc4c338476aedff8d95c7549ab0f39d1aaf6d1.zip |
[GC] Read and lower Let instructions (#3485)
For now we don't support non-nullability, and can therefore lower a let into
simpler things. That is,
(let $x = ...
;;
)
=>
(block
$x = ...
;;
)
This lets us handle wasm binaries with let, so that we can optimize them
(with the current downside of losing non-nullability).
This is still not trivial to do, sadly, because the indexing of lets is somewhat
odd in the binary. A let modifies the indexes of other things declared before it,
which means that index "0" means different things at different times. And this
is trickier for us because we add more locals as needed for tuples and stacky
code. So this PR makes us track the absolute local indexes from which each
let started to allocate its locals.
The binary testcase was created from this wat using wasp:
(module
(type $vector (array (field (mut f64))))
(func $main
(local $x i32)
(local $y i32)
(drop (local.get $x)) ;; 0 is the index appearing in the binary
;; first let
(array.new_with_rtt $vector
(f64.const 3.14159)
(i32.const 1)
(rtt.canon $vector)
)
(let (local $v (ref $vector))
(drop (local.get $v)) ;; 0
(drop (local.get $x)) ;; 1
;; another one, nested
(array.new_with_rtt $vector
(f64.const 1234)
(i32.const 2)
(rtt.canon $vector)
)
(let (local $w (ref $vector))
(drop (local.get $v)) ;; 1
(drop (local.get $w)) ;; 0
(drop (local.get $x)) ;; 2
)
)
;; another one, later
(array.new_with_rtt $vector
(f64.const 2.1828)
(i32.const 3)
(rtt.canon $vector)
)
(let (local $v (ref $vector))
(drop (local.get $v)) ;; 0
(drop (local.get $x)) ;; 1
)
(drop (local.get $x)) ;; 0
)
)
Diffstat (limited to 'scripts/test/generate_lld_tests.py')
0 files changed, 0 insertions, 0 deletions