1;;! component_model_threading = true 2 3(component definition $Tester 4 (core module $Memory 5 (table (export "t") 1 funcref) 6 ) 7 (core instance $memory (instantiate $Memory)) 8 9 (core type $ft (func (param i32))) 10 (core func $thread.new-indirect (canon thread.new-indirect $ft (table $memory "t"))) 11 (core func $thread.suspend-to-suspended (canon thread.suspend-to-suspended)) 12 (core func $thread.suspend (canon thread.suspend)) 13 (core func $thread.unsuspend (canon thread.unsuspend)) 14 (core func $thread.yield-to-suspended (canon thread.yield-to-suspended)) 15 16 (core module $DM 17 (import "" "thread.new-indirect" (func $thread.new-indirect (param i32 i32) (result i32))) 18 (import "" "thread.suspend-to-suspended" (func $thread.suspend-to-suspended (param i32) (result i32))) 19 (import "" "thread.suspend" (func $thread.suspend (result i32))) 20 (import "" "thread.unsuspend" (func $thread.unsuspend (param i32))) 21 (import "" "thread.yield-to-suspended" (func $thread.yield-to-suspended (param i32) (result i32))) 22 23 (func (export "noop")) 24 (func (export "trap-calling-thread-new-indirect") (call $thread.new-indirect (i32.const 0) (i32.const 0)) drop) 25 (func (export "trap-calling-thread-suspend-to-suspended") (call $thread.suspend-to-suspended (i32.const 0)) drop) 26 (func (export "trap-calling-thread-suspend") (call $thread.suspend) drop) 27 (func (export "trap-calling-thread-unsuspend") (call $thread.unsuspend (i32.const 0))) 28 (func (export "trap-calling-thread-yield-to-suspended") (call $thread.yield-to-suspended (i32.const 0)) drop) 29 ) 30 (core instance $dm (instantiate $DM (with "" (instance 31 (export "thread.new-indirect" (func $thread.new-indirect)) 32 (export "thread.suspend-to-suspended" (func $thread.suspend-to-suspended)) 33 (export "thread.suspend" (func $thread.suspend)) 34 (export "thread.unsuspend" (func $thread.unsuspend)) 35 (export "thread.yield-to-suspended" (func $thread.yield-to-suspended)) 36 )))) 37 (func (export "trap-calling-thread-new-indirect") 38 (canon lift (core func $dm "noop") 39 (post-return (func $dm "trap-calling-thread-new-indirect")))) 40 (func (export "trap-calling-thread-suspend-to-suspended") 41 (canon lift (core func $dm "noop") 42 (post-return (func $dm "trap-calling-thread-suspend-to-suspended")))) 43 (func (export "trap-calling-thread-suspend") 44 (canon lift (core func $dm "noop") 45 (post-return (func $dm "trap-calling-thread-suspend")))) 46 (func (export "trap-calling-thread-unsuspend") 47 (canon lift (core func $dm "noop") 48 (post-return (func $dm "trap-calling-thread-unsuspend")))) 49 (func (export "trap-calling-thread-yield-to-suspended") 50 (canon lift (core func $dm "noop") 51 (post-return (func $dm "trap-calling-thread-yield-to-suspended")))) 52) 53 54(component instance $i0 $Tester) 55(assert_trap (invoke "trap-calling-thread-new-indirect") "cannot leave component instance") 56(component instance $i1 $Tester) 57(assert_trap (invoke "trap-calling-thread-suspend-to-suspended") "cannot leave component instance") 58(component instance $i2 $Tester) 59(assert_trap (invoke "trap-calling-thread-suspend") "cannot leave component instance") 60(component instance $i3 $Tester) 61(assert_trap (invoke "trap-calling-thread-unsuspend") "cannot leave component instance") 62(component instance $i4 $Tester) 63(assert_trap (invoke "trap-calling-thread-yield-to-suspended") "cannot leave component instance") 64