summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lit/passes/jspi-args.wast69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/lit/passes/jspi-args.wast b/test/lit/passes/jspi-args.wast
new file mode 100644
index 000000000..237b31213
--- /dev/null
+++ b/test/lit/passes/jspi-args.wast
@@ -0,0 +1,69 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
+;; RUN: wasm-opt %s --jspi --pass-arg=jspi-imports@js.sleep_async --pass-arg=jspi-exports@update_state_async -all -S -o - | filecheck %s
+
+(module
+ ;; sleep_async should have a wrapper function built.
+ ;; CHECK: (type $f64_=>_i32 (func (param f64) (result i32)))
+
+ ;; CHECK: (type $externref_f64_=>_i32 (func (param externref f64) (result i32)))
+
+ ;; CHECK: (import "js" "sleep_sync" (func $sleep_sync (param f64) (result i32)))
+ (import "js" "sleep_async" (func $sleep_async (param f64) (result i32)))
+ ;; CHECK: (import "js" "sleep_async" (func $import$sleep_async (param externref f64) (result i32)))
+ (import "js" "sleep_sync" (func $sleep_sync (param f64) (result i32)))
+ ;; CHECK: (global $suspender (mut externref) (ref.null noextern))
+
+ ;; CHECK: (export "update_state_async" (func $export$update_state_async))
+ (export "update_state_async" (func $update_state_async))
+ ;; CHECK: (export "update_state_sync" (func $update_state_sync))
+ (export "update_state_sync" (func $update_state_sync))
+ ;; This function calls an async sleep so a wrapper should be created for it.
+ ;; CHECK: (func $update_state_async (param $param f64) (result i32)
+ ;; CHECK-NEXT: (call $sleep_async
+ ;; CHECK-NEXT: (f64.sub
+ ;; CHECK-NEXT: (f64.const 1.1)
+ ;; CHECK-NEXT: (local.get $param)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $update_state_async (param $param f64) (result i32)
+ (call $sleep_async (f64.sub (f64.const 1.1) (local.get $param)))
+ )
+ ;; CHECK: (func $update_state_sync (param $param f64) (result i32)
+ ;; CHECK-NEXT: (call $sleep_sync
+ ;; CHECK-NEXT: (f64.sub
+ ;; CHECK-NEXT: (f64.const 1.1)
+ ;; CHECK-NEXT: (local.get $param)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $update_state_sync (param $param f64) (result i32)
+ (call $sleep_sync (f64.sub (f64.const 1.1) (local.get $param)))
+ )
+)
+;; CHECK: (func $export$update_state_async (param $susp externref) (param $param f64) (result i32)
+;; CHECK-NEXT: (global.set $suspender
+;; CHECK-NEXT: (local.get $susp)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: (call $update_state_async
+;; CHECK-NEXT: (local.get $param)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: )
+
+;; CHECK: (func $sleep_async (param $0 f64) (result i32)
+;; CHECK-NEXT: (local $1 externref)
+;; CHECK-NEXT: (local $2 i32)
+;; CHECK-NEXT: (local.set $1
+;; CHECK-NEXT: (global.get $suspender)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: (local.set $2
+;; CHECK-NEXT: (call $import$sleep_async
+;; CHECK-NEXT: (global.get $suspender)
+;; CHECK-NEXT: (local.get $0)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: )
+;; CHECK-NEXT: (global.set $suspender
+;; CHECK-NEXT: (local.get $1)
+;; CHECK-NEXT: )
+;; CHECK-NEXT: (local.get $2)
+;; CHECK-NEXT: )