diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/coalesce-locals-learning.txt | 3 | ||||
-rw-r--r-- | test/passes/coalesce-locals.txt | 3 | ||||
-rw-r--r-- | test/unit.asm.js | 22 | ||||
-rw-r--r-- | test/unit.fromasm | 29 | ||||
-rw-r--r-- | test/unit.fromasm.imprecise | 29 | ||||
-rw-r--r-- | test/unit.fromasm.imprecise.no-opts | 35 | ||||
-rw-r--r-- | test/unit.fromasm.no-opts | 35 |
7 files changed, 153 insertions, 3 deletions
diff --git a/test/passes/coalesce-locals-learning.txt b/test/passes/coalesce-locals-learning.txt index 14091cb98..aa3c8c9c0 100644 --- a/test/passes/coalesce-locals-learning.txt +++ b/test/passes/coalesce-locals-learning.txt @@ -318,9 +318,10 @@ (func $params (param $0 i32) (param $1 f32) (local $2 i32) (local $3 i32) - (get_local $0) + (local $4 i32) (get_local $2) (get_local $3) + (get_local $4) ) (func $interfere-in-dead (local $0 i32) diff --git a/test/passes/coalesce-locals.txt b/test/passes/coalesce-locals.txt index 3c1632f68..d0edbd71d 100644 --- a/test/passes/coalesce-locals.txt +++ b/test/passes/coalesce-locals.txt @@ -318,9 +318,10 @@ (func $params (param $0 i32) (param $1 f32) (local $2 i32) (local $3 i32) - (get_local $0) + (local $4 i32) (get_local $2) (get_local $3) + (get_local $4) ) (func $interfere-in-dead (local $0 i32) diff --git a/test/unit.asm.js b/test/unit.asm.js index 8fb28b990..2f307e085 100644 --- a/test/unit.asm.js +++ b/test/unit.asm.js @@ -227,6 +227,26 @@ function asm(global, env, buffer) { return 0; } + function forgetMe() { + 123.456; + } + function exportMe() { + -3.14159; + } + + function zeroInit(x) { + x = x | 0; + var y = 0; // reusing this with x is dangerous - x has a value, and y needs to start at 0! + if (lb(0) | 0) { + if (lb(1) | 0) y = 3; + } else { + y = 3; + } + if ((y | 0) == 3) { + lb(2) | 0; + } + } + function z() { } function w() { @@ -236,6 +256,6 @@ function asm(global, env, buffer) { var FUNCTION_TABLE_b = [ w, w, importedDoubles, w ]; var FUNCTION_TABLE_c = [ z, cneg ]; - return { big_negative: big_negative }; + return { big_negative: big_negative, pick: forgetMe, pick: exportMe }; } diff --git a/test/unit.fromasm b/test/unit.fromasm index 288b3af3b..3fb76981d 100644 --- a/test/unit.fromasm +++ b/test/unit.fromasm @@ -11,6 +11,7 @@ (import $f64-to-int "asm2wasm" "f64-to-int" (param f64) (result i32)) (import $f64-rem "asm2wasm" "f64-rem" (param f64 f64) (result f64)) (export "big_negative" $big_negative) + (export "pick" $big_negative) (table $big_negative $big_negative $big_negative $big_negative $big_negative $big_negative $importedDoubles $big_negative $big_negative $cneg) (func $big_negative (nop) @@ -424,4 +425,32 @@ ) (i32.const 0) ) + (func $zeroInit (param $0 i32) + (local $1 i32) + (if + (call $lb + (i32.const 0) + ) + (if + (call $lb + (i32.const 1) + ) + (set_local $1 + (i32.const 3) + ) + ) + (set_local $1 + (i32.const 3) + ) + ) + (if + (i32.eq + (get_local $1) + (i32.const 3) + ) + (call $lb + (i32.const 2) + ) + ) + ) ) diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise index 303a0cabf..a4716941d 100644 --- a/test/unit.fromasm.imprecise +++ b/test/unit.fromasm.imprecise @@ -9,6 +9,7 @@ (import $h "env" "h" (param i32)) (import $f64-rem "asm2wasm" "f64-rem" (param f64 f64) (result f64)) (export "big_negative" $big_negative) + (export "pick" $big_negative) (table $big_negative $big_negative $big_negative $big_negative $big_negative $big_negative $importedDoubles $big_negative $big_negative $cneg) (func $big_negative (nop) @@ -416,4 +417,32 @@ ) (i32.const 0) ) + (func $zeroInit (param $0 i32) + (local $1 i32) + (if + (call $lb + (i32.const 0) + ) + (if + (call $lb + (i32.const 1) + ) + (set_local $1 + (i32.const 3) + ) + ) + (set_local $1 + (i32.const 3) + ) + ) + (if + (i32.eq + (get_local $1) + (i32.const 3) + ) + (call $lb + (i32.const 2) + ) + ) + ) ) diff --git a/test/unit.fromasm.imprecise.no-opts b/test/unit.fromasm.imprecise.no-opts index 70f8d286b..c3da01359 100644 --- a/test/unit.fromasm.imprecise.no-opts +++ b/test/unit.fromasm.imprecise.no-opts @@ -9,6 +9,7 @@ (import $h "env" "h" (param i32)) (import $f64-rem "asm2wasm" "f64-rem" (param f64 f64) (result f64)) (export "big_negative" $big_negative) + (export "pick" $exportMe) (table $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg) (func $big_negative (local $temp f64) @@ -686,6 +687,40 @@ (i32.const 0) ) ) + (func $forgetMe + (f64.const 123.456) + ) + (func $exportMe + (f64.const -3.14159) + ) + (func $zeroInit (param $x i32) + (local $y i32) + (if + (call $lb + (i32.const 0) + ) + (if + (call $lb + (i32.const 1) + ) + (set_local $y + (i32.const 3) + ) + ) + (set_local $y + (i32.const 3) + ) + ) + (if + (i32.eq + (get_local $y) + (i32.const 3) + ) + (call $lb + (i32.const 2) + ) + ) + ) (func $z (nop) ) diff --git a/test/unit.fromasm.no-opts b/test/unit.fromasm.no-opts index 07311b00e..92d2d2add 100644 --- a/test/unit.fromasm.no-opts +++ b/test/unit.fromasm.no-opts @@ -11,6 +11,7 @@ (import $f64-to-int "asm2wasm" "f64-to-int" (param f64) (result i32)) (import $f64-rem "asm2wasm" "f64-rem" (param f64 f64) (result f64)) (export "big_negative" $big_negative) + (export "pick" $exportMe) (table $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg) (func $big_negative (local $temp f64) @@ -690,6 +691,40 @@ (i32.const 0) ) ) + (func $forgetMe + (f64.const 123.456) + ) + (func $exportMe + (f64.const -3.14159) + ) + (func $zeroInit (param $x i32) + (local $y i32) + (if + (call $lb + (i32.const 0) + ) + (if + (call $lb + (i32.const 1) + ) + (set_local $y + (i32.const 3) + ) + ) + (set_local $y + (i32.const 3) + ) + ) + (if + (i32.eq + (get_local $y) + (i32.const 3) + ) + (call $lb + (i32.const 2) + ) + ) + ) (func $z (nop) ) |