|
| 1 | +;; NOTE: Assertions have been generated by update_lit_checks.py --output=fuzz-exec and should not be edited. |
| 2 | + |
| 3 | +;; RUN: foreach %s %t wasm-opt -all --fuzz-exec-before -q -o /dev/null 2>&1 | filecheck %s |
| 4 | + |
| 5 | +(module |
| 6 | + (type $none (func)) |
| 7 | + (type $cont (cont $none)) |
| 8 | + |
| 9 | + (import "fuzzing-support" "log" (func $log (param i32))) |
| 10 | + |
| 11 | + (import "fuzzing-support" "call-export" (func $call-export (param i32 i32))) |
| 12 | + |
| 13 | + (tag $tag (type $none)) |
| 14 | + |
| 15 | + ;; CHECK: [fuzz-exec] calling suspend |
| 16 | + ;; CHECK-NEXT: [LoggingExternalInterface logging 10] |
| 17 | + ;; CHECK-NEXT: [exception thrown: unhandled suspend] |
| 18 | + (func $suspend (export "suspend") |
| 19 | + ;; Helper for below. |
| 20 | + (call $log (i32.const 10)) |
| 21 | + (suspend $tag) |
| 22 | + (call $log (i32.const 20)) |
| 23 | + ) |
| 24 | + |
| 25 | + ;; CHECK: [fuzz-exec] calling call-call-export |
| 26 | + ;; CHECK-NEXT: [LoggingExternalInterface logging 10] |
| 27 | + ;; CHECK-NEXT: [exception thrown: __private externref] |
| 28 | + (func $call-call-export (export "call-call-export") |
| 29 | + ;; Call suspend as an export. We cannot suspend through JS, so we throw. |
| 30 | + (call $call-export |
| 31 | + (i32.const 0) |
| 32 | + (i32.const 0) |
| 33 | + ) |
| 34 | + ) |
| 35 | + |
| 36 | + ;; CHECK: [fuzz-exec] calling handled |
| 37 | + ;; CHECK-NEXT: [LoggingExternalInterface logging 10] |
| 38 | + ;; CHECK-NEXT: [exception thrown: __private externref] |
| 39 | + (func $handled (export "handled") |
| 40 | + ;; As above, but inside a continuation, so it would be handled - if we could |
| 41 | + ;; suspend though JS. But we can't, so we throw. |
| 42 | + (drop |
| 43 | + (block $inner (result (ref $cont)) |
| 44 | + (resume $cont (on $tag $inner) |
| 45 | + (cont.new $cont |
| 46 | + (ref.func $call-call-export) |
| 47 | + ) |
| 48 | + ) |
| 49 | + (unreachable) |
| 50 | + ) |
| 51 | + ) |
| 52 | + ) |
| 53 | +) |
0 commit comments