diff options
author | Brendan Dahl <brendan.dahl@gmail.com> | 2022-11-08 12:24:15 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-08 12:24:15 -0800 |
commit | eb8481c6dc499a5b109f3ca60bd79f1803ee8ebe (patch) | |
tree | b6e25045b2f221d50c2f658f2c920d8f20ef3099 /test | |
parent | dcf19345b9825dc579334f27092aa0f7eff9b506 (diff) | |
download | binaryen-eb8481c6dc499a5b109f3ca60bd79f1803ee8ebe.tar.gz binaryen-eb8481c6dc499a5b109f3ca60bd79f1803ee8ebe.tar.bz2 binaryen-eb8481c6dc499a5b109f3ca60bd79f1803ee8ebe.zip |
Add arguments to control which imports/exports are JSPI'd. (#5217)
Instead of automatically determining which exports will be async they will
be explicitly set by the user. We'll rely on the runtime trapping if they
are incorrectly set.
Two new arguments that behave similar to asyncify-imports:
- jspi-imports
- jspi-exports
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/jspi-args.wast | 69 |
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: ) |