;;! component_model_threading = true
(component definition $Tester
(core module $Memory
(table (export "t") 1 funcref)
)
(core instance $memory (instantiate $Memory))
(core type $ft (func (param i32)))
(core func $thread.new-indirect (canon thread.new-indirect $ft (table $memory "t")))
(core func $thread.suspend-to-suspended (canon thread.suspend-to-suspended))
(core func $thread.suspend (canon thread.suspend))
(core func $thread.unsuspend (canon thread.unsuspend))
(core func $thread.yield-to-suspended (canon thread.yield-to-suspended))
(core module $DM
(import "" "thread.new-indirect" (func $thread.new-indirect (param i32 i32) (result i32)))
(import "" "thread.suspend-to-suspended" (func $thread.suspend-to-suspended (param i32) (result i32)))
(import "" "thread.suspend" (func $thread.suspend (result i32)))
(import "" "thread.unsuspend" (func $thread.unsuspend (param i32)))
(import "" "thread.yield-to-suspended" (func $thread.yield-to-suspended (param i32) (result i32)))
(func (export "noop"))
(func (export "trap-calling-thread-new-indirect") (call $thread.new-indirect (i32.const 0) (i32.const 0)) drop)
(func (export "trap-calling-thread-suspend-to-suspended") (call $thread.suspend-to-suspended (i32.const 0)) drop)
(func (export "trap-calling-thread-suspend") (call $thread.suspend) drop)
(func (export "trap-calling-thread-unsuspend") (call $thread.unsuspend (i32.const 0)))
(func (export "trap-calling-thread-yield-to-suspended") (call $thread.yield-to-suspended (i32.const 0)) drop)
)
(core instance $dm (instantiate $DM (with "" (instance
(export "thread.new-indirect" (func $thread.new-indirect))
(export "thread.suspend-to-suspended" (func $thread.suspend-to-suspended))
(export "thread.suspend" (func $thread.suspend))
(export "thread.unsuspend" (func $thread.unsuspend))
(export "thread.yield-to-suspended" (func $thread.yield-to-suspended))
))))
(func (export "trap-calling-thread-new-indirect")
(canon lift (core func $dm "noop")
(post-return (func $dm "trap-calling-thread-new-indirect"))))
(func (export "trap-calling-thread-suspend-to-suspended")
(canon lift (core func $dm "noop")
(post-return (func $dm "trap-calling-thread-suspend-to-suspended"))))
(func (export "trap-calling-thread-suspend")
(canon lift (core func $dm "noop")
(post-return (func $dm "trap-calling-thread-suspend"))))
(func (export "trap-calling-thread-unsuspend")
(canon lift (core func $dm "noop")
(post-return (func $dm "trap-calling-thread-unsuspend"))))
(func (export "trap-calling-thread-yield-to-suspended")
(canon lift (core func $dm "noop")
(post-return (func $dm "trap-calling-thread-yield-to-suspended"))))
)
(component instance $i0 $Tester)
(assert_trap (invoke "trap-calling-thread-new-indirect") "cannot leave component instance")
(component instance $i1 $Tester)
(assert_trap (invoke "trap-calling-thread-suspend-to-suspended") "cannot leave component instance")
(component instance $i2 $Tester)
(assert_trap (invoke "trap-calling-thread-suspend") "cannot leave component instance")
(component instance $i3 $Tester)
(assert_trap (invoke "trap-calling-thread-unsuspend") "cannot leave component instance")
(component instance $i4 $Tester)
(assert_trap (invoke "trap-calling-thread-yield-to-suspended") "cannot leave component instance")