summaryrefslogtreecommitdiff
path: root/test/unit/input
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2019-06-21 14:48:06 -0700
committerGitHub <noreply@github.com>2019-06-21 14:48:06 -0700
commitcbc7e868d85a81e1a2f802b633d3cf323a14338f (patch)
treed59a65d99f4d10b281da4ffe6612ea25b8f6e820 /test/unit/input
parent3f797c82e49bb2a5e5f6bcd2393e369ef618a49b (diff)
downloadbinaryen-cbc7e868d85a81e1a2f802b633d3cf323a14338f.tar.gz
binaryen-cbc7e868d85a81e1a2f802b633d3cf323a14338f.tar.bz2
binaryen-cbc7e868d85a81e1a2f802b633d3cf323a14338f.zip
Bysyncify: Don't instrument functions that call bysyncify_* directly (#2179)
Those functions are assumed to be part of the runtime. Instrumenting them would mean nothing can work. With this fix, bysyncify is useful with pure wasm, and not just through imports.
Diffstat (limited to 'test/unit/input')
-rw-r--r--test/unit/input/bysyncify-pure.txt17
-rw-r--r--test/unit/input/bysyncify-pure.wast59
2 files changed, 76 insertions, 0 deletions
diff --git a/test/unit/input/bysyncify-pure.txt b/test/unit/input/bysyncify-pure.txt
new file mode 100644
index 000000000..1f85db1f1
--- /dev/null
+++ b/test/unit/input/bysyncify-pure.txt
@@ -0,0 +1,17 @@
+(i32.const 100)
+(i32.const 10)
+(i32.const 1)
+(i32.const 20)
+(i32.const 1000)
+(i32.const 2000)
+(i32.const 4000)
+(i32.const 200)
+(i32.const 300)
+(i32.const 400)
+(i32.const 1000)
+(i32.const 3000)
+(i32.const 4000)
+(i32.const 30)
+(i32.const 2)
+(i32.const 40)
+(i32.const 500)
diff --git a/test/unit/input/bysyncify-pure.wast b/test/unit/input/bysyncify-pure.wast
new file mode 100644
index 000000000..b79bfe2b0
--- /dev/null
+++ b/test/unit/input/bysyncify-pure.wast
@@ -0,0 +1,59 @@
+(module
+ (memory 1 1)
+ (import "spectest" "print" (func $print (param i32)))
+ (import "bysyncify" "start_unwind" (func $bysyncify_start_unwind (param i32)))
+ (import "bysyncify" "stop_unwind" (func $bysyncify_stop_unwind))
+ (import "bysyncify" "start_rewind" (func $bysyncify_start_rewind (param i32)))
+ (import "bysyncify" "stop_rewind" (func $bysyncify_stop_rewind))
+ (global $sleeping (mut i32) (i32.const 0))
+ (start $runtime)
+ (func $main
+ (call $print (i32.const 10))
+ (call $before)
+ (call $print (i32.const 20))
+ (call $sleep)
+ (call $print (i32.const 30))
+ (call $after)
+ (call $print (i32.const 40))
+ )
+ (func $before
+ (call $print (i32.const 1))
+ )
+ (func $sleep
+ (call $print (i32.const 1000))
+ (if
+ (i32.eqz (global.get $sleeping))
+ (block
+ (call $print (i32.const 2000))
+ (global.set $sleeping (i32.const 1))
+ (i32.store (i32.const 16) (i32.const 24))
+ (i32.store (i32.const 20) (i32.const 1024))
+ (call $bysyncify_start_unwind (i32.const 16))
+ )
+ (block
+ (call $print (i32.const 3000))
+ (call $bysyncify_stop_rewind)
+ (global.set $sleeping (i32.const 0))
+ )
+ )
+ (call $print (i32.const 4000))
+ )
+ (func $after
+ (call $print (i32.const 2))
+ )
+ (func $runtime
+ (call $print (i32.const 100))
+ ;; call main the first time, let the stack unwind
+ (call $main)
+ (call $print (i32.const 200))
+ (call $bysyncify_stop_unwind)
+ (call $print (i32.const 300))
+ ;; ...can do some async stuff around here...
+ ;; set the rewind in motion
+ (call $bysyncify_start_rewind (i32.const 16))
+ (call $print (i32.const 400))
+ (call $main)
+ (call $print (i32.const 500))
+ )
+)
+