blob: dca92283f808cc41c72375017e54248dafe1a5de [file] [log] [blame]
;; NOTE: Assertions have been generated by update_lit_checks.py --output=fuzz-exec and should not be edited.
;; RUN: foreach %s %t wasm-opt -all --fuzz-exec-before -q -o /dev/null 2>&1 | filecheck %s
;; $test will try to suspend through JS. That traps. If it threw a JS exception
;; instead, we would catch that exception and continue onwards, hitting an
;; invalid internal state.
(module
(type $f (func))
(type $k (cont $f))
(import "fuzzing-support" "call-export" (func $call-export (param i32 i32)))
(import "fuzzing-support" "call-export-catch" (func $call-export-catch (param i32) (result i32)))
(tag $e)
;; CHECK: [fuzz-exec] calling suspend
;; CHECK-NEXT: [exception thrown: unhandled suspend]
(func $suspend (export "suspend")
(suspend $e)
)
;; CHECK: [fuzz-exec] calling handle
;; CHECK-NEXT: [trap suspend through JS]
(func $handle (export "handle")
(drop
(block $block (result (ref $k))
(resume $k (on $e $block)
(cont.new $k
(ref.func $suspend-after-host-frame)
)
)
(return)
)
)
)
(func $suspend-after-host-frame (type $f)
(call $call-export
(i32.const 0) ;; "suspend"
(i32.const 0)
)
)
;; CHECK: [fuzz-exec] calling test
;; CHECK-NEXT: [trap suspend through JS]
(func $test (export "test")
(drop
(call $call-export-catch
(i32.const 1) ;; "handle"
)
)
(call $call-export
(i32.const 0) ;; "suspend"
(i32.const 1) ;; rethrow exceptions
)
)
)