diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-03-22 10:13:08 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-03-22 10:13:08 -0700 |
commit | 996416ccefc4f079b14495bcb4ac66e7aa705f4f (patch) | |
tree | d3ecc3db30c81896b1678f5d6fed8bbd6f429d35 /test | |
parent | 12a5d972ec7c5144cd54afe7bdee7351219aaca0 (diff) | |
download | binaryen-996416ccefc4f079b14495bcb4ac66e7aa705f4f.tar.gz binaryen-996416ccefc4f079b14495bcb4ac66e7aa705f4f.tar.bz2 binaryen-996416ccefc4f079b14495bcb4ac66e7aa705f4f.zip |
only reuse nameless blocks in blockify in asm2wasm - if they are named, they can be broken out of, which is bad for our loop constructs
Diffstat (limited to 'test')
-rw-r--r-- | test/unit.asm.js | 27 | ||||
-rw-r--r-- | test/unit.fromasm | 37 | ||||
-rw-r--r-- | test/unit.fromasm.imprecise | 37 |
3 files changed, 101 insertions, 0 deletions
diff --git a/test/unit.asm.js b/test/unit.asm.js index c600f714d..5bb84bdcd 100644 --- a/test/unit.asm.js +++ b/test/unit.asm.js @@ -55,6 +55,7 @@ function asm() { } function switcher(x) { x = x | 0; + var waka = 0; switch (x | 0) { case 1: return 1; case 2: return 2; @@ -79,6 +80,32 @@ function asm() { break; } } + + L1 : while (1) { + L3 : while (1) switch (x) { + case -1: + { + break L1; + break; + } + case 116: + { + waka = 1; + break; + } + case 110: + { + break L3; + break; + } + default: + { + break L1; + } + } + h(120); + } + return 0; } function blocker() { diff --git a/test/unit.fromasm b/test/unit.fromasm index e00c6b43b..3db25c78b 100644 --- a/test/unit.fromasm +++ b/test/unit.fromasm @@ -177,6 +177,7 @@ ) ) (func $switcher (param $x i32) (result i32) + (local $waka i32) (block $switch-default$3 (block $switch-case$2 (block $switch-case$1 @@ -243,6 +244,42 @@ (br $label$break$Lout) ) ) + (loop $label$break$L1 $label$continue$L1 + (loop $label$break$L3 $label$continue$L3 + (block $switch$17 + (block $switch-default$21 + (block $switch-default$21 + (block $switch-case$20 + (block $switch-case$19 + (block $switch-case$18 + (br_table $switch-case$18 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-case$20 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-case$19 $switch-default$21 + (i32.sub + (get_local $x) + (i32.const -1) + ) + ) + ) + (br $label$break$L1) + (br $switch$17) + ) + (set_local $waka + (i32.const 1) + ) + (br $switch$17) + ) + (br $label$break$L3) + (br $switch$17) + ) + (br $label$break$L1) + ) + ) + (br $label$continue$L3) + ) + (call_import $h + (i32.const 120) + ) + (br $label$continue$L1) + ) (return (i32.const 0) ) diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise index 9bfa1789c..ef9ccaa5d 100644 --- a/test/unit.fromasm.imprecise +++ b/test/unit.fromasm.imprecise @@ -173,6 +173,7 @@ ) ) (func $switcher (param $x i32) (result i32) + (local $waka i32) (block $switch-default$3 (block $switch-case$2 (block $switch-case$1 @@ -239,6 +240,42 @@ (br $label$break$Lout) ) ) + (loop $label$break$L1 $label$continue$L1 + (loop $label$break$L3 $label$continue$L3 + (block $switch$17 + (block $switch-default$21 + (block $switch-default$21 + (block $switch-case$20 + (block $switch-case$19 + (block $switch-case$18 + (br_table $switch-case$18 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-case$20 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-default$21 $switch-case$19 $switch-default$21 + (i32.sub + (get_local $x) + (i32.const -1) + ) + ) + ) + (br $label$break$L1) + (br $switch$17) + ) + (set_local $waka + (i32.const 1) + ) + (br $switch$17) + ) + (br $label$break$L3) + (br $switch$17) + ) + (br $label$break$L1) + ) + ) + (br $label$continue$L3) + ) + (call_import $h + (i32.const 120) + ) + (br $label$continue$L1) + ) (return (i32.const 0) ) |