diff options
author | Alon Zakai <azakai@google.com> | 2019-06-21 09:14:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-21 09:14:06 -0700 |
commit | 3f797c82e49bb2a5e5f6bcd2393e369ef618a49b (patch) | |
tree | b71e6138626b60b721e83f7705e94486a671cb21 /test | |
parent | 06698d7a32cb4eeb24fea942e83d1b15e86a73e6 (diff) | |
download | binaryen-3f797c82e49bb2a5e5f6bcd2393e369ef618a49b.tar.gz binaryen-3f797c82e49bb2a5e5f6bcd2393e369ef618a49b.tar.bz2 binaryen-3f797c82e49bb2a5e5f6bcd2393e369ef618a49b.zip |
Bysyncify: add ignore-imports and ignore-indirect options (#2178)
ignore-imports makes it not assume that any import may unwind/rewind the stack. ignore-indirect makes it not assume any indirect call can reach an unwind/rewind (which means, it assumes there is not an indirect call on the stack while unwinding).
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/bysyncify_pass-arg=bysyncify-ignore-imports.txt | 226 | ||||
-rw-r--r-- | test/passes/bysyncify_pass-arg=bysyncify-ignore-imports.wast | 26 |
2 files changed, 252 insertions, 0 deletions
diff --git a/test/passes/bysyncify_pass-arg=bysyncify-ignore-imports.txt b/test/passes/bysyncify_pass-arg=bysyncify-ignore-imports.txt new file mode 100644 index 000000000..adfaf6df7 --- /dev/null +++ b/test/passes/bysyncify_pass-arg=bysyncify-ignore-imports.txt @@ -0,0 +1,226 @@ +(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 $__bysyncify_state (mut i32) (i32.const 0)) + (global $__bysyncify_data (mut i32) (i32.const 0)) + (export "bysyncify_start_unwind" (func $bysyncify_start_unwind)) + (export "bysyncify_stop_unwind" (func $bysyncify_stop_unwind)) + (export "bysyncify_start_rewind" (func $bysyncify_start_rewind)) + (export "bysyncify_stop_rewind" (func $bysyncify_stop_rewind)) + (func $calls-import (; 3 ;) (type $f) + (call $import) + ) + (func $calls-import2-drop (; 4 ;) (type $f) + (local $0 i32) + (local.set $0 + (call $import2) + ) + ) + (func $calls-import2-if-else (; 5 ;) (type $FUNCSIG$vi) (param $x i32) + (local $1 i32) + (if + (local.get $x) + (call $import3 + (i32.const 1) + ) + (call $import3 + (i32.const 2) + ) + ) + ) + (func $calls-indirect (; 6 ;) (type $FUNCSIG$vi) (param $x i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (if + (i32.eq + (global.get $__bysyncify_state) + (i32.const 2) + ) + (block + (i32.store + (global.get $__bysyncify_data) + (i32.add + (i32.load + (global.get $__bysyncify_data) + ) + (i32.const -8) + ) + ) + (local.set $4 + (i32.load + (global.get $__bysyncify_data) + ) + ) + (local.set $x + (i32.load + (local.get $4) + ) + ) + (local.set $1 + (i32.load offset=4 + (local.get $4) + ) + ) + ) + ) + (local.set $2 + (block $__bysyncify_unwind (result i32) + (block + (block + (if + (i32.eq + (global.get $__bysyncify_state) + (i32.const 2) + ) + (block + (i32.store + (global.get $__bysyncify_data) + (i32.add + (i32.load + (global.get $__bysyncify_data) + ) + (i32.const -4) + ) + ) + (local.set $3 + (i32.load + (i32.load + (global.get $__bysyncify_data) + ) + ) + ) + ) + ) + (if + (if (result i32) + (i32.eq + (global.get $__bysyncify_state) + (i32.const 0) + ) + (i32.const 1) + (i32.eq + (local.get $3) + (i32.const 0) + ) + ) + (block + (call_indirect (type $f) + (local.get $x) + ) + (if + (i32.eq + (global.get $__bysyncify_state) + (i32.const 1) + ) + (br $__bysyncify_unwind + (i32.const 0) + ) + ) + ) + ) + ) + (return) + ) + ) + ) + (block + (i32.store + (i32.load + (global.get $__bysyncify_data) + ) + (local.get $2) + ) + (i32.store + (global.get $__bysyncify_data) + (i32.add + (i32.load + (global.get $__bysyncify_data) + ) + (i32.const 4) + ) + ) + ) + (block + (local.set $5 + (i32.load + (global.get $__bysyncify_data) + ) + ) + (i32.store + (local.get $5) + (local.get $x) + ) + (i32.store offset=4 + (local.get $5) + (local.get $1) + ) + (i32.store + (global.get $__bysyncify_data) + (i32.add + (i32.load + (global.get $__bysyncify_data) + ) + (i32.const 8) + ) + ) + ) + ) + (func $bysyncify_start_unwind (; 7 ;) (param $0 i32) + (if + (i32.gt_u + (i32.load + (local.get $0) + ) + (i32.load offset=4 + (local.get $0) + ) + ) + (unreachable) + ) + (global.set $__bysyncify_state + (i32.const 1) + ) + (global.set $__bysyncify_data + (local.get $0) + ) + ) + (func $bysyncify_stop_unwind (; 8 ;) + (global.set $__bysyncify_state + (i32.const 0) + ) + ) + (func $bysyncify_start_rewind (; 9 ;) (param $0 i32) + (if + (i32.gt_u + (i32.load + (local.get $0) + ) + (i32.load offset=4 + (local.get $0) + ) + ) + (unreachable) + ) + (global.set $__bysyncify_state + (i32.const 2) + ) + (global.set $__bysyncify_data + (local.get $0) + ) + ) + (func $bysyncify_stop_rewind (; 10 ;) + (global.set $__bysyncify_state + (i32.const 0) + ) + ) +) diff --git a/test/passes/bysyncify_pass-arg=bysyncify-ignore-imports.wast b/test/passes/bysyncify_pass-arg=bysyncify-ignore-imports.wast new file mode 100644 index 000000000..33500baba --- /dev/null +++ b/test/passes/bysyncify_pass-arg=bysyncify-ignore-imports.wast @@ -0,0 +1,26 @@ +(module + (memory 1 2) + (type $f (func)) + (import "env" "import" (func $import)) + (import "env" "import2" (func $import2 (result i32))) + (import "env" "import3" (func $import3 (param i32))) + (table 1 1) + (func $calls-import + (call $import) + ) + (func $calls-import2-drop + (drop (call $import2)) + ) + (func $calls-import2-if-else (param $x i32) + (if (local.get $x) + (call $import3 (i32.const 1)) + (call $import3 (i32.const 2)) + ) + ) + (func $calls-indirect (param $x i32) + (call_indirect (type $f) + (local.get $x) + ) + ) +) + |