diff options
author | Alon Zakai <azakai@google.com> | 2019-09-13 16:51:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-13 16:51:50 -0700 |
commit | 6a9aceaae7480aa9034243614600634beb350316 (patch) | |
tree | 4227dc8afdeada8f5cdf7eea8354a26fe73f87a4 /test/passes/asyncify_pass-arg=asyncify-asserts_pass-arg=asyncify-whitelist@waka.txt | |
parent | 19bc69abe34d61771cffd0171a57dc027086f541 (diff) | |
download | binaryen-6a9aceaae7480aa9034243614600634beb350316.tar.gz binaryen-6a9aceaae7480aa9034243614600634beb350316.tar.bz2 binaryen-6a9aceaae7480aa9034243614600634beb350316.zip |
Add asserts in Asyncify (#2338)
With the optional asserts, we throw if we see an unwind begin in code that we thought could never unwind (say, because the user incorrectly blacklisted it).
Helps with emscripten-core/emscripten#9389
Diffstat (limited to 'test/passes/asyncify_pass-arg=asyncify-asserts_pass-arg=asyncify-whitelist@waka.txt')
-rw-r--r-- | test/passes/asyncify_pass-arg=asyncify-asserts_pass-arg=asyncify-whitelist@waka.txt | 207 |
1 files changed, 207 insertions, 0 deletions
diff --git a/test/passes/asyncify_pass-arg=asyncify-asserts_pass-arg=asyncify-whitelist@waka.txt b/test/passes/asyncify_pass-arg=asyncify-asserts_pass-arg=asyncify-whitelist@waka.txt new file mode 100644 index 000000000..2caa76d8e --- /dev/null +++ b/test/passes/asyncify_pass-arg=asyncify-asserts_pass-arg=asyncify-whitelist@waka.txt @@ -0,0 +1,207 @@ +(module + (type $f (func)) + (type $FUNCSIG$i (func (result i32))) + (type $FUNCSIG$vi (func (param i32))) + (import "env" "import" (func $import)) + (import "env" "import2" (func $import2 (result i32))) + (import "env" "import3" (func $import3 (param i32))) + (memory $0 1 2) + (table $0 2 2 funcref) + (elem (i32.const 0) $calls-import2-drop $calls-import2-drop) + (global $__asyncify_state (mut i32) (i32.const 0)) + (global $__asyncify_data (mut i32) (i32.const 0)) + (export "asyncify_start_unwind" (func $asyncify_start_unwind)) + (export "asyncify_stop_unwind" (func $asyncify_stop_unwind)) + (export "asyncify_start_rewind" (func $asyncify_start_rewind)) + (export "asyncify_stop_rewind" (func $asyncify_stop_rewind)) + (func $calls-import (; 3 ;) (type $f) + (local $0 i32) + (local.set $0 + (global.get $__asyncify_state) + ) + (block + (block + (call $import) + (if + (i32.ne + (global.get $__asyncify_state) + (local.get $0) + ) + (unreachable) + ) + ) + (nop) + ) + ) + (func $calls-import2-drop (; 4 ;) (type $f) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local.set $1 + (global.get $__asyncify_state) + ) + (block + (local.set $0 + (block (result i32) + (local.set $2 + (call $import2) + ) + (if + (i32.ne + (global.get $__asyncify_state) + (local.get $1) + ) + (unreachable) + ) + (local.get $2) + ) + ) + (drop + (local.get $0) + ) + (nop) + ) + ) + (func $returns (; 5 ;) (type $FUNCSIG$i) (result i32) + (local $x i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local.set $5 + (global.get $__asyncify_state) + ) + (block + (block + (local.set $1 + (block (result i32) + (local.set $6 + (call $import2) + ) + (if + (i32.ne + (global.get $__asyncify_state) + (local.get $5) + ) + (unreachable) + ) + (local.get $6) + ) + ) + (local.set $x + (local.get $1) + ) + (nop) + (local.set $2 + (local.get $x) + ) + (local.set $3 + (local.get $2) + ) + ) + (local.set $4 + (local.get $3) + ) + (return + (local.get $4) + ) + ) + ) + (func $calls-indirect (; 6 ;) (type $FUNCSIG$vi) (param $x i32) + (local $1 i32) + (local $2 i32) + (local.set $2 + (global.get $__asyncify_state) + ) + (block + (local.set $1 + (local.get $x) + ) + (block + (call_indirect (type $f) + (local.get $1) + ) + (if + (i32.ne + (global.get $__asyncify_state) + (local.get $2) + ) + (unreachable) + ) + ) + (nop) + ) + ) + (func $asyncify_start_unwind (; 7 ;) (param $0 i32) + (global.set $__asyncify_state + (i32.const 1) + ) + (global.set $__asyncify_data + (local.get $0) + ) + (if + (i32.gt_u + (i32.load + (global.get $__asyncify_data) + ) + (i32.load offset=4 + (global.get $__asyncify_data) + ) + ) + (unreachable) + ) + ) + (func $asyncify_stop_unwind (; 8 ;) + (global.set $__asyncify_state + (i32.const 0) + ) + (if + (i32.gt_u + (i32.load + (global.get $__asyncify_data) + ) + (i32.load offset=4 + (global.get $__asyncify_data) + ) + ) + (unreachable) + ) + ) + (func $asyncify_start_rewind (; 9 ;) (param $0 i32) + (global.set $__asyncify_state + (i32.const 2) + ) + (global.set $__asyncify_data + (local.get $0) + ) + (if + (i32.gt_u + (i32.load + (global.get $__asyncify_data) + ) + (i32.load offset=4 + (global.get $__asyncify_data) + ) + ) + (unreachable) + ) + ) + (func $asyncify_stop_rewind (; 10 ;) + (global.set $__asyncify_state + (i32.const 0) + ) + (if + (i32.gt_u + (i32.load + (global.get $__asyncify_data) + ) + (i32.load offset=4 + (global.get $__asyncify_data) + ) + ) + (unreachable) + ) + ) +) |